Make.depend (2400B)
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-2019 Broadcom Inc. All rights reserved. 5 # 6 # Default rule to build dependencies. This builds a x.d file for each 7 # x.c file that describes the dependencies. We then conditionally include 8 # the generated .d files. 9 # 10 11 # 12 # If making 'clean', do not include any .d files. If they are included, 13 # gmake intrinsically tries to remake them all. 14 # 15 ifeq (,$(findstring clean,$(MAKECMDGOALS))) 16 17 ZFS :=$(wildcard *.zf) 18 ZFC := $(ZFS:.zf=.c) 19 20 ifdef GENERATE_C_FILES 21 ifndef GEN_INCS 22 $(error "GEN_INCS was not defined") 23 endif 24 25 ZF_GEN = ${SDK}/tools/zFrameCodeGen.pl 26 27 # 1=.zf 28 define ZFS_RULE 29 $(1:.zf=Console.c) : $(1:.zf=.c) 30 @echo updated $$@ from $$? 31 32 $(1:.zf=.c) : $(1) $(ZF_GEN) 33 @$(PERL) $(ZF_GEN) -s -z . -p . -g $1 -t c 34 @echo generated ${LOCALDIR}/$$@ from $(1) 35 @mv $$(*F).cx $$@ 36 @if [ -e $$(*F)Console.cx ] ; then \ 37 mv $$(*F)Console.cx $$(*F)Console.c; \ 38 echo Created $$(*F)Console.c ;\ 39 fi 40 @if [ -e $$(*F)Console.hx ] ; then \ 41 echo Created $(GEN_INCS)/$$(*F)Console.hx ;\ 42 mv $$(*F)Console.hx $(GEN_INCS)/ ; \ 43 fi 44 @mv $$(*F).hx $(GEN_INCS)/ 45 endef 46 47 $(foreach zf,$(ZFS),$(eval $(call ZFS_RULE,$(zf)))) 48 49 ${BLDDIR}/%.P : ${BLDDIR}/.tree %.c 50 51 .PHONY: GENFILES 52 GENFILES: $(ZFC) 53 54 $(BOBJS) : $(ZFC) 55 56 else 57 # 58 # Attempt to build the depend files. If it fails, the depend file is 59 # removed so that it is not included in later builds. 60 # 61 ${BLDDIR}/%.P : %.c ${BLDDIR}/.tree 62 @$(ECHO) Dependencies for ${LOCALDIR}/$< 63 64 ${BLDDIR}/%.P : %.cc ${BLDDIR}/.tree 65 @$(ECHO) Dependencies for ${LOCALDIR}/$< 66 67 endif 68 69 # 70 # If there are C or C++ files in this directory, include the 71 # depend files for them. 72 # 73 74 ifeq ($(findstring _COMPILER,$(MAKECMDGOALS))$(findstring variable,$(MAKECMDGOALS)),) 75 ifneq ($(strip ${LSRCS}),) 76 ifneq (,$(findstring .o,$(MAKECMDGOALS))) 77 -include $(addprefix ${BLDDIR}/,$(MAKECMDGOALS:.o=.P)) $(addprefix ${BLDDIR}/,$(MAKECMDGOALS:.o=.sig)) 78 else 79 -include $(addprefix ${BLDDIR}/,$(addsuffix .P,$(basename $(LSRCS)))) $(addprefix ${BLDDIR}/,$(addsuffix .sig,$(basename $(LSRCS)))) 80 endif 81 endif 82 endif 83 84 endif # !CLEANING 85 86 clean_d:: 87 ifdef QUIET 88 @$(ECHO) Cleaning dependencies for ${LOCALDIR} 89 endif 90 ifdef GENERATE_C_FILES 91 $Q$(RM) $(ZFC:%=$(SDK)/$(LOCALDIR)/%) $(ZFC:%.c=$(SDK)/$(LOCALDIR)/%Console.c) 92 endif 93 94 clean:: clean_d