Make.ase (5976B)
1 # Holds rules for ASE. 2 # 3 # 4 # This license is set out in https://raw.githubusercontent.com/Broadcom-Network-Switching-Software/OpenBCM/master/Legal/LICENSE file. 5 # 6 # Copyright 2007-2019 Broadcom Inc. All rights reserved. 7 8 ifeq (,$(findstring TCL,$(FEATURE_LIST))) 9 $(warning "features: $(FEATURE_LIST)") 10 $(error "Loading ASE without TCL defined") 11 endif 12 13 $(info "TCL/ASE bindings") 14 15 export CC 16 export PATH 17 18 # ASE Interrupt support issues warning because of setjmp/longjmp 19 # 20 ifneq (,$(findstring -DINCLUDE_ASE_INTERRUPT,$(CFGFLAGS))) 21 CFLAGS += -fno-strict-aliasing -Wno-uninitialized 22 # Option required for GCC version used in 'metrocore' build 23 ifneq (,$(findstring -DBCM_METROCORE_LOCAL_BUS,$(CFGFLAGS))) 24 CFLAGS += -Wno-pointer-sign 25 endif 26 endif 27 28 # Built by broadcom only because we need a specific version. 29 RUBY=/projects/ntsw-tools/bin/ruby 30 SWIG=/projects/ntsw-tools/bin/swig 31 32 # Here are the tools in the SDK tree that ASE requires. 33 MKBND=$(SDK)/tools/mkbinding 34 MKDSP=$(SDK)/tools/mkdispatch 35 36 ASE=$(MKBND)/ase 37 SOCGEN=$(MKBND)/socgen 38 39 # SWIG configuration 40 LOCALSWIGLIB=$(MKBND)/swig_lib 41 ASE_LANGUAGE=tcl 42 ASE_CFG=-fvirtual -tcl 43 44 # Extract just -D and -I from CFLAGS 45 ASE_CPPFLAGS := $(filter -D%, $(CFLAGS)) 46 47 # Some platforms need to define TRUE on the CC command line to work 48 # around problems with the target compiler headers. However, this 49 # causes the "TRUE" constant to not get defined in TCL, so filter out 50 # the definition here. 51 ASE_CPPFLAGS := $(filter-out -DTRUE=1,$(ASE_CPPFLAGS)) 52 53 ASE_CPPFLAGS += $(filter -I%, $(CFLAGS)) 54 ASE_CPPFLAGS += -I${MKBND}/include -I${XFLOW_MACSEC_HOME}/include 55 56 # SWIG TCL generation 57 SWIG_TCLOPT=-I- -Wall \ 58 -I${LOCALSWIGLIB} -I${LOCALSWIGLIB}/tcl \ 59 -outdir ${BLDDIR} ${ASE_CFG} 60 # SWIG XML header analysis 61 # analysis file must be a .c file that eventually includes sal/types.h 62 # some versions of gcc will object to doing this on a header file directly 63 64 SWIG_XMLOPT := -importall -ignoremissing -xml -o /dev/null 65 66 export SWIG 67 export SWIG_TCLOPT 68 export SWIG_XMLOPT 69 70 # SWIG Dependency generation 71 SWIG_DEPOPT=${SWIG_TCLOPT} -I${BLDDIR} ${ASE_CFG} -DSWIG_MAKEDEPEND -MM 72 73 # 74 # Build configuration file. 75 ASE_CONFIG= ${MKBND}/ase.conf 76 MKDSP_CONFIG= ${MKDSP}/mkdispatch.cf 77 PAPI_CONFIG= ${MKDSP}/bcmpapi.cf 78 PAPI_BCMX_CONFIG= ${MKDSP}/bcmxpapi.cf 79 80 # ASE configuration 81 ASE_TCLOPT=--swig --mkdispatch-config ${MKDSP_CONFIG} --mkdispatch-config ${PAPI_CONFIG} --mkdispatch-config ${PAPI_BCMX_CONFIG} 82 83 ASE_FILE=sdk_wrap 84 85 # This file is auto-generated. The rules required are following. 86 # We need this in order for clean and the final library link. 87 BOBJS += ${BLDDIR}/${ASE_FILE}.o 88 89 $(BLDDIR)/.tree: 90 @$(MKDIR) $(BLDDIR)/ 91 @/bin/touch $(BLDDIR)/.tree 92 93 # 94 # ASE Wrapper Build 95 # 96 97 # stage 1 - analyze headers 98 # input: sdk_h.i 99 # output: sdk_xml.xml 100 # deps: <ase -M> 101 # prog: swig 102 # 103 104 ${BLDDIR}/sdk_xml.xml: $(BLDDIR)/.tree ${MKBND}/swig_lib/sdk_h.i 105 @date 106 $Q$(RUBY) $(ASE) --swig-xml \ 107 $(ASE_CPPFLAGS) \ 108 --compiler-defs ${SDK}/include/sal/compiler.h \ 109 --compiler-includes ${SDK}/src/sal/core/libc.c \ 110 --output $@ sdk_h.i 111 @date 112 113 #${BLDDIR}/sdk_xml.d: ${MKBND}/swig_lib/sdk_h.i 114 @$(ECHO) Dependencies for $@ 115 # Keep swig dep action for debugging 116 # $Q${SWIG} ${SWIG_DEPOPT} -o $(*D)/$(*F).d ${MKBND}/swig_lib/sdk_h.i 117 # Postprocess the dependency file to add empty rules to prevent errors when a file is removed 118 $Q$(RUBY) $(ASE) ${ASE_CPPFLAGS} -M -n $@ -o $(@:%.xml=%.d) 119 $Qcp $(@:%.xml=%.d) $(@:%.xml=%.P) 120 $Qsed -e 's/\#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.xml=%.d) >> $(@:%.xml=%.P) 121 $Qrm $(@:%.xml=%.d) 122 123 # stage 2 - create public SDK SWIG interface sdk_gen.i 124 # input: sdk_xml.xml ase.conf mkdispatch.cf bcmpapi.cf bcmxpapi.cf 125 # output: sdk_gen.i 126 # deps: <input> + ase-typemap-template-files + ase-prog-files 127 # prog: ase 128 # 129 130 ${BLDDIR}/sdk_gen.i : ${BLDDIR}/sdk_xml.xml ${ASE_CONFIG} ${ASE} \ 131 ${MKDSP_CONFIG} ${PAPI_CONFIG} ${PAPI_BCMX_CONFIG} \ 132 ${MKBND}/lib/*.rb \ 133 ${MKBND}/lib/ase/*.rb \ 134 ${MKBND}/lib/tcl/*.ii 135 @date 136 $Q$(RUBY) $(ASE) ${ASE_TCLOPT} --config ${ASE_CONFIG} -o $@ $< 137 @date 138 139 # stage 3 - create SOC SWIG interface soc_gen.i 140 # input: <none> 141 # output: soc_gen.i 142 # deps: socgen-prog-files + socgen -M 143 # prog: socgen 144 # 145 146 ${BLDDIR}/soc_gen.i: ${SOCGEN} 147 rm -f ${@} 148 $Q$(RUBY) $(SOCGEN) -o $@ 149 @$(ECHO) Dependencies for $@ 150 $Q$(RUBY) $(SOCGEN) -M -n $@ -o $(@:%.i=%.d) 151 # Postprocess the dependency file to add empty rules to prevent errors when a file is removed 152 $Qcp $(@:%.i=%.d) $(@:%.i=%.P) 153 $Qsed -e 's/\#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.i=%.d) >> $(@:%.i=%.P) 154 $Qrm $(@:%.i=%.d) 155 156 # stage 4 - create sdk_wrap.c/sdk_wrap.o 157 # input: sdk.i 158 # output: sdk_wrap.c 159 # deps: <swig -MM sdk.i> sdk_gen.i sdk_soc.i swig_lib/tcl/swigtcl8.swg 160 # prog: swig 161 # 162 # Note:swig -MM does not include the generated swig interfaces 163 164 ${BLDROOT}/${lib}.${LIBSUFFIX}: ${BLDDIR}/${ASE_FILE}.o 165 166 ${BLDDIR}/${ASE_FILE}.o: ${BLDDIR}/${ASE_FILE}.c \ 167 ${MKBND}/include/*.h ${MKBND}/src/*/*.[ch] 168 169 ${BLDDIR}/${ASE_FILE}.c: ${BLDDIR}/soc_gen.i ${BLDDIR}/sdk_gen.i \ 170 ${MKBND}/swig_lib/tcl/swigtcl8.swg \ 171 ${MKBND}/src/tcl/*.c 172 @date 173 $Q$(SWIG) ${ASE_CPPFLAGS} ${SWIG_TCLOPT} -I${BLDDIR} -o $@ sdk.i 174 @date 175 @$(ECHO) Dependencies for $@ 176 @date 177 $Q$(SWIG) ${SWIG_DEPOPT} -o $@ ${MKBND}/swig_lib/sdk.i 178 @date 179 # Postprocess the dependency file to add empty rules to prevent errors when a file is removed 180 $Qcp $(@:%.c=%.d) $(@:%.c=%.P) 181 $Qsed -e 's/\#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' -e '/^$$/ d' -e 's/$$/ :/' < $(@:%.c=%.d) >> $(@:%.c=%.P) 182 $Qrm $(@:%.c=%.d) 183 184 # 185 # include generated dependencies 186 # 187 ifeq (,$(findstring clean,$(MAKECMDGOALS))) 188 -include ${BLDDIR}/sdk_xml.P 189 -include ${BLDDIR}/soc_gen.P 190 -include ${BLDDIR}/${ASE_FILE}.P 191 endif