openbcm

Git mirror of https://github.com/Broadcom-Network-Switching-Software/OpenBCM
git clone git://git.finwo.net/mirror/broadcom/openbcm
Log | Files | Refs | README

Makefile (7132B)


      1 # 
      2 # This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file.
      3 # 
      4 # Copyright 2007-2020 Broadcom Inc. All rights reserved.
      5 #
      6 
      7 SDK :=$(shell if [ -n "$$SDK" ] ; then\
      8 	echo $$SDK;\
      9 	else\
     10 	cd $(dir $(lastword $(MAKEFILE_LIST))); while /usr/bin/test ! -e RELEASE ; do \
     11 	dir=`cd ../;pwd`;			\
     12 	if [ "$$dir" = "/" ] ; then		\
     13 	   echo Cannot find SDK in $(lastword $(MAKEFILE_LIST)) 1>&2;		\
     14 	   exit 1;				\
     15 	fi ;					\
     16 	cd $$dir;				\
     17 	done ;					\
     18 	pwd;					\
     19 	fi)
     20 
     21 ifeq ($(SDK),)					
     22 $(error Please run this in a tree)		
     23 endif 				
     24 
     25 export SDK
     26 
     27 LOCALDIR=systems/sim
     28 
     29 uname := $(shell uname -s)
     30 ifeq ($(uname),Linux)
     31  ifeq ($(shell uname -m),x86_64)
     32   override-target=unix-linux-64
     33  else
     34   override-target=unix-linux
     35  endif
     36 endif
     37 ifeq ($(uname),SunOS)
     38  override-target=unix-solaris
     39 endif
     40 ifeq ($(uname),NetBSD)
     41  override-target=unix-netbsd
     42 endif
     43 
     44 ifdef NO_SAL_APPL
     45 export NO_SAL_APPL
     46 ifndef BLDCONFIG
     47 BLDCONFIG=nsa
     48 endif
     49 export BLDCONFIG
     50 endif
     51 
     52 MFLAGS = 
     53 
     54 export PCID_BUILD=1
     55 export IPROC_NO_ATL = 1
     56 CFGFLAGS += -DIPROC_NO_ATL
     57 
     58 # Turn on direct schan to accelerate simulation in
     59 # BCMSIM and AV environments.
     60 CFGFLAGS += -DPLISIM_DIRECT_SCHAN
     61 
     62 export CFGFLAGS
     63 
     64 include ${SDK}/make/Make.config
     65 
     66 #
     67 # To use Purify, add a line here similar to the following:
     68 #
     69 #CC=/net/igor/export/home/pure/purify-4.2-solaris2/purify gcc
     70 
     71 #
     72 # Define all targets to build
     73 # pcid is built first so you can start it before bcm links :-)
     74 #
     75 ifeq ($(DEST_DIR),)
     76 DEST_DIR=${BLDDIR}
     77 endif
     78 
     79 PCID_LOCAL :=pcid.sim${all_suffix}
     80 PCID = ${DEST_DIR}/pcid.${targetplat}${all_suffix}
     81 L2SWITCH = ${DEST_DIR}/l2switch.${targetplat}${all_suffix}
     82 
     83 # This defines where main is found
     84 BCM_LOCAL = bcm.sim${all_suffix}
     85 ifdef NO_SAL_APPL
     86 MAIN_LIB=${BLDDIR}/socdiag-nsa.o
     87 NSA=.nsa
     88 BCM = ${DEST_DIR}/bcm.${targetplat}${all_suffix}${NSA}
     89 all_targets := ${BCM}
     90 ifeq ($(NO_LOCAL_TARGETS),)
     91 all_targets += $(BCM_LOCAL)
     92 endif
     93 else
     94 MAIN_LIB=${BLDDIR}/socdiag.o
     95 BCM = ${DEST_DIR}/bcm.${targetplat}${all_suffix}${NSA}
     96 all_targets := ${BCM} ${PCID}
     97 ifeq ($(NO_LOCAL_TARGETS),)
     98 all_targets += $(BCM_LOCAL) $(PCID_LOCAL)
     99 endif
    100 endif
    101 
    102 
    103 
    104 # MAIN_LIB=${LIBDIR}/libdisctest.a
    105 
    106 ifdef DPP_CHIPS
    107   subdirs = dpp/ChipSim
    108   include ${SDK}/make/Make.subdirs
    109 endif
    110 
    111 #
    112 # Define targets to be built by default.
    113 #
    114 build_targets = ${all_targets}
    115 
    116 #
    117 # Libraries
    118 #
    119 
    120 BCM_LIBS = ${APPL_LIBS} ${DIAG_LIBS} ${DRV_LIBS}
    121 BCM_LIBS_BLD = $(addprefix ${LIBDIR}/,${BCM_LIBS})
    122 
    123 ifdef BUILD_XFLOW_MACSEC
    124 BCM_LIBS_BLD += ${BCM_LIB_XFLOW_MACSEC}
    125 else
    126 ifdef BUILD_MACSEC
    127 BCM_LIBS_BLD += ${BCM_LIB_MACSEC}
    128 endif
    129 endif
    130 
    131 ifdef DPP_CHIPS
    132 BCM_LIB_CHIPSIM = ${LIBDIR}/libchipsim_sim.${libext}
    133 BCM_LIBS_BLD += ${BCM_LIB_CHIPSIM}
    134 endif
    135 
    136 PCID_LIBS = ${DRV_LIBS}
    137 PCID_LIBS_BLD = $(addprefix ${LIBDIR}/,${PCID_LIBS})
    138 
    139 L2SWITCH_LIBS = ${DRV_LIBS}
    140 L2SWITCH_LIBS_BLD = $(addprefix ${LIBDIR}/,${L2SWITCH_LIBS})
    141 
    142 ifeq (,$(findstring DELIVER,$(MAKECMDGOALS)))
    143 all:: ${BLDDIR}/.tree ${build_targets} 
    144 
    145 #
    146 # Simplified targets to build a target for current platform
    147 #
    148 .PHONY:	bcm pcid l2switch
    149 
    150 bcm.${override-target} bcm.${targetplat}${all_suffix}: ${BCM}
    151 
    152 pcid.${override-target} pcid.${targetplat}${all_suffix}: ${PCID}
    153 
    154 l2switch l2switch.${targetplat}${all_suffix}: ${L2SWITCH}
    155 
    156 
    157 $(BCM_LOCAL) : $(BCM)
    158 	cp $? $@
    159 
    160 
    161 $(PCID_LOCAL) : $(PCID)
    162 	cp $? $@
    163 
    164 # Libraries
    165 
    166 .PHONY: _bcm_libraries
    167 
    168 _bcm_libraries:
    169 ifndef NO_BCM
    170 ifdef BUILD_PHYMOD
    171 	$(MAKE) -C ${SDK}/libs/phymod
    172 endif
    173 	$(MAKE) -C ${SDK}
    174 endif
    175 
    176 ifdef BUILD_XFLOW_MACSEC
    177 	$Q$(ECHO) "Building XFLOW_MACSEC libraries ...."
    178 	$Q$(ECHO) "${targetbase}, $(targetplat), ${platform}"
    179 	$(MAKE) -C ${XFLOW_MACSEC_HOME} XFLOW_MACSEC_CC="${CC}" XFLOW_MACSEC_LD="${LD}" XFLOW_MACSEC_CFLAGS="${XFLOW_MACSEC_BUILD_FLAG}" XFLOW_MACSEC_TARGET="${targetbase}/$(targetplat)/${platform}"
    180 else
    181 ifdef BUILD_MACSEC
    182 	$Q$(ECHO) "Building MACSEC libraries ...."
    183 	$(MAKE) -C ${MACSEC_HOME} MACSEC_CC="${CC}" MACSEC_LD="${LD}" MACSEC_CFLAGS="${MACSEC_BUILD_FLAG}" MACSEC_TARGET="${targetbase}/$(targetplat)/${platform}"
    184 endif
    185 endif
    186 
    187 
    188 
    189 # Broadcom Command Monitor
    190 
    191 # Build platform_defines.c to compile in config.bcm
    192 #
    193 ifndef NO_SAL_APPL
    194 PLATFORM_DEFINES_OBJ=${BLDDIR}/platform_defines.o
    195 
    196 ${BLDDIR}/platform_defines.c: $(BLDDIR)/.tree ${SDK}/rc/config.bcm
    197 	+$(PERL) ${SDK}/tools/bcm2c_linux.pl ${SDK}/rc/config.bcm >$@
    198 
    199 ${BLDDIR}/platform_defines.o: ${BLDDIR}/platform_defines.c
    200 	+${CC} ${CFLAGS} -c $< -o $@
    201 ifndef NO_VERSION
    202 	touch ${SDK}/rc/config.bcm
    203 endif
    204 else
    205 PLATFORM_DEFINES_OBJ=
    206 endif
    207 
    208 ${BCM}: ${MAIN_LIB} _bde _bcm_libraries ${BLDDIR}/version.o \
    209         ${PLATFORM_DEFINES_OBJ}
    210 	mkdir -p $(@D)
    211 	@rm -f $@	# Prevent core dump if currently running
    212 	${CC} -o $@ ${MAIN_LIB} ${BLDDIR}/version.o \
    213         ${PLATFORM_DEFINES_OBJ} ${LDFLAGS} \
    214         -Wl,--start-group ${BCM_LIBS_BLD} -Wl,--end-group
    215 
    216 # PCI Daemon (chip simulator)
    217 
    218 pcid.${override-target}.sim: ${PCID}
    219 	${RM} -f pcid.sim
    220 	${LN} -s ${PCID} pcid.sim
    221 
    222 ${PCID}: _bcm_libraries _bde
    223 	mkdir -p $(@D)
    224 	$(MAKE) -C ${SDK}/systems/sim/pcid \
    225 		PCID=${PCID}
    226 
    227 # Example L2 Switch Application
    228 
    229 ${L2SWITCH}: _bcm_libraries _bde
    230 	mkdir -p $(@D)
    231 	$(MAKE) -C ${SDK}/systems/sim/l2switch \
    232 		INSTALL_DIR=$(DEST_DIR) ${L2SWITCH}
    233 
    234 
    235 
    236 
    237 
    238 #
    239 # Build version generator.  If NO_VERSION=1 is specified in Make.local
    240 # or on command line, then use the existing version.c.  If that doesn't
    241 # exist, copy the default one from config.
    242 #
    243 # Otherwise, force the generation of a new version.c using the perl script.
    244 #
    245 ifdef NO_VERSION
    246 ${BLDDIR}/version.c: ${BLDDIR}/.tree
    247 	$(CP) ${SDK}/make/version.c $@
    248 else
    249 .PHONY: _force
    250 ${BLDDIR}/version.c: ${MAIN_LIB} _bde _bcm_libraries
    251 	$(MKVERS) > $@
    252 endif
    253 ${BLDDIR}/version.o: ${BLDDIR}/version.c
    254 	${CC} ${CFLAGS} -c $< -o $@
    255 
    256 # Make.depend is before clean:: so that Make.depend's clean:: runs first.
    257 
    258 include ${SDK}/make/Make.depend
    259 
    260 else
    261 ifndef DELIVERY
    262 $(error DELIVERY required)
    263 endif
    264 
    265 DELIVERABLES := ${all_targets}
    266 
    267 # 1= source
    268 define DELIVERY_RULE
    269 _DEL_TARG += $(DELIVERY)/$(firstword $(subst -, ,$(notdir $(1))))
    270 $(DELIVERY)/$(firstword $(subst -, ,$(notdir $(1)))) : $(1)
    271 	@mkdir -p $(DELIVERY)
    272 	\cp $$< $$@
    273 endef
    274 
    275 $(foreach f,$(DELIVERABLES),$(eval $(call DELIVERY_RULE,$(f))))
    276 
    277 DELIVER: $(_DEL_TARG)
    278 endif
    279 
    280 # Clean
    281 clean:: ${BLDDIR}/.tree
    282 	$(RM) $(BLDDIR)/version.c $(BLDDIR)/version.o
    283 	$(RM) $(BLDDIR)/platform_defines.c $(BLDDIR)/platform_defines.o
    284 	$(RM) ${all_targets}
    285 	$(RM) ${BOBJS}
    286 	# Cleaning in PCID cleans BCM libs, BDE, etc.
    287 ifdef BUILD_PHYMOD
    288 	$(MAKE) -C ${SDK}/libs/phymod clean
    289 endif
    290 	$(MAKE) -C ${SDK}/systems/sim/pcid \
    291 		INSTALL_DIR=$(BLDDIR) clean
    292 	$(MAKE) -C ${SDK}/systems/sim/l2switch \
    293 		INSTALL_DIR=$(BLDDIR) clean
    294 ifdef BUILD_XFLOW_MACSEC
    295 	$(MAKE) -C ${XFLOW_MACSEC_HOME} XFLOW_MACSEC_CC="${CC}" XFLOW_MACSEC_LD="${LD}" \
    296 		XFLOW_MACSEC_TARGET="${targetbase}/$(targetplat)/${platform}" clean
    297 endif
    298 
    299 distclean::
    300 	$(RM) $(BLDROOT)
    301 	$(RM) $(DEST_DIR)
    302 
    303 .PHONY: _bde
    304 _bde:
    305 	$(MAKE) -C ${SDK}/systems/bde/pli
    306 
    307 # two libraries this binary needs
    308 # point to them to allow parallel make processes
    309 $(SDK)/build/%/libdiscover.a:
    310 	$(MAKE) -C $(SDK)/src/appl/discover
    311 
    312 $(SDK)/build/%/libstktask.a:
    313 	$(MAKE) -C $(SDK)/src/appl/stktask
    314 
    315 
    316