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

Make.depend (2933B)


      1 #
      2 #  Copyright 2017 Broadcom
      3 #  
      4 #  This program is free software; you can redistribute it and/or modify
      5 #  it under the terms of the GNU General Public License, version 2, as
      6 #  published by the Free Software Foundation (the "GPL").
      7 #  
      8 #  This program is distributed in the hope that it will be useful, but
      9 #  WITHOUT ANY WARRANTY; without even the implied warranty of
     10 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
     11 #  General Public License version 2 (GPLv2) for more details.
     12 #  
     13 #  You should have received a copy of the GNU General Public License
     14 #  version 2 (GPLv2) along with this source code.
     15 #
     16 # $Id: Make.depend,v 1.14 Broadcom SDK $
     17 # $Copyright: (c) 2005 Broadcom Corp.
     18 # All Rights Reserved.$
     19 #
     20 # Default rule to build dependencies.  This builds a x.d file for each
     21 # x.c file that describes the dependencies.  We then conditionally include 
     22 # the generated .d files.
     23 #
     24 
     25 #
     26 # If making 'clean', do not include any .d files.  If they are included,
     27 # gmake intrinsically tries to remake them all.
     28 #
     29 ifeq (,$(findstring clean,$(MAKECMDGOALS)))
     30 
     31 ZFS      :=$(wildcard *.zf)
     32 ZFC := $(ZFS:.zf=.c)
     33 
     34 ifdef GENERATE_C_FILES
     35 ifndef GEN_INCS
     36 $(error "GEN_INCS was not defined")
     37 endif
     38 
     39 ZF_GEN   = ${SDK}/tools/zFrameCodeGen.pl
     40 
     41 # 1=.zf
     42 define ZFS_RULE
     43 $(1:.zf=Console.c) : $(1:.zf=.c)
     44 	@echo updated $$@ from $$?
     45 
     46 $(1:.zf=.c) : $(1) $(ZF_GEN)
     47 	@$(PERL) $(ZF_GEN) -s -z . -p . -g $1 -t c
     48 	@echo generated ${LOCALDIR}/$$@ from $(1)
     49 	@mv $$(*F).cx $$@
     50 	@if [ -e $$(*F)Console.cx ] ; then \
     51 	   mv $$(*F)Console.cx $$(*F)Console.c; \
     52 	    echo Created $$(*F)Console.c ;\
     53 	fi
     54 	@if [ -e $$(*F)Console.hx ] ; then \
     55 	   echo Created $(GEN_INCS)/$$(*F)Console.hx ;\
     56 	   mv $$(*F)Console.hx $(GEN_INCS)/ ; \
     57 	fi
     58 	@mv $$(*F).hx $(GEN_INCS)/
     59 endef
     60 
     61 $(foreach zf,$(ZFS),$(eval $(call ZFS_RULE,$(zf))))
     62 
     63 ${BLDDIR}/%.P : ${BLDDIR}/.tree %.c
     64 
     65 .PHONY: GENFILES
     66 GENFILES: $(ZFC)
     67 
     68 $(BOBJS) : $(ZFC)
     69 
     70 else
     71 #
     72 # Attempt to build the depend files.  If it fails, the depend file is
     73 # removed so that it is not included in later builds.
     74 #
     75 ${BLDDIR}/%.P : %.c ${BLDDIR}/.tree
     76 	@$(ECHO) Dependencies for ${LOCALDIR}/$<
     77 
     78 ${BLDDIR}/%.P : %.cc ${BLDDIR}/.tree
     79 	@$(ECHO) Dependencies for ${LOCALDIR}/$<
     80 
     81 endif
     82 
     83 #
     84 # If there are C or C++ files in this directory, include the 
     85 # depend files for them.
     86 #
     87 
     88 ifeq ($(findstring _COMPILER,$(MAKECMDGOALS))$(findstring variable,$(MAKECMDGOALS)),)
     89 ifneq ($(strip ${LSRCS}),)
     90 ifneq (,$(findstring .o,$(MAKECMDGOALS)))
     91 -include $(addprefix ${BLDDIR}/,$(MAKECMDGOALS:.o=.P)) $(addprefix ${BLDDIR}/,$(MAKECMDGOALS:.o=.sig))
     92 else
     93 -include $(addprefix ${BLDDIR}/,$(addsuffix .P,$(basename $(LSRCS)))) $(addprefix ${BLDDIR}/,$(addsuffix .sig,$(basename $(LSRCS))))
     94 endif
     95 endif
     96 endif
     97 
     98 endif	# !CLEANING
     99 
    100 clean_d::
    101 ifdef QUIET
    102 	@$(ECHO) Cleaning dependencies for ${LOCALDIR}
    103 endif
    104 ifdef GENERATE_C_FILES
    105 	$Q$(RM) $(ZFC:%=$(SDK)/$(LOCALDIR)/%) $(ZFC:%.c=$(SDK)/$(LOCALDIR)/%Console.c)
    106 endif
    107 
    108 clean:: clean_d