From bee24cadd868ec5931a527dd3938171c936b7add Mon Sep 17 00:00:00 2001 From: "Janet B. Anderson" Date: Wed, 25 Jul 2001 14:40:18 +0000 Subject: [PATCH] Changes to automatically generate header dependancy files. --- configure/CONFIG.gnuCommon | 2 +- configure/CONFIG_COMMON | 23 ++++++---- configure/CONFIG_SITE | 9 ++++ configure/RULES.Db | 10 ++++- configure/RULES_ARCHS | 1 - configure/RULES_BUILD | 45 +++++++++++++------ configure/RULES_DIRS | 2 +- configure/RULES_TOP | 2 - configure/Sample.Makefile | 24 +++++----- configure/os/CONFIG.Common.vxWorksCommon | 3 +- configure/os/CONFIG.hpux-parisc.hpux-parisc | 2 +- configure/os/CONFIG.osf-alpha.osf-alpha | 2 +- .../os/CONFIG.solaris-sparc.solaris-sparc | 5 ++- configure/os/CONFIG.solaris-x86.solaris-x86 | 4 +- configure/os/CONFIG.sun4-68k.sun4-68k | 2 +- configure/os/CONFIG.win32-x86.win32-x86 | 8 ++-- configure/tools/makeMakefileInclude.pl | 2 - 17 files changed, 92 insertions(+), 54 deletions(-) diff --git a/configure/CONFIG.gnuCommon b/configure/CONFIG.gnuCommon index 84891ab59..f21bcc3df 100644 --- a/configure/CONFIG.gnuCommon +++ b/configure/CONFIG.gnuCommon @@ -42,5 +42,5 @@ STATIC_LDFLAGS_NO = SHRLIB_LDFLAGS_YES = -shared SHRLIB_LDFLAGS_NO = -DEPENDS_FLAG = -MM +HDEPENDS_FLAGS = -MM diff --git a/configure/CONFIG_COMMON b/configure/CONFIG_COMMON index 8b31f4511..6df78f84f 100644 --- a/configure/CONFIG_COMMON +++ b/configure/CONFIG_COMMON @@ -29,7 +29,8 @@ CONFIG_INSTALLS += ../RULES_BUILD BUILD_CLASS = HOST #------------------------------------------------------- -# Divider and suffix +# Prefix and suffix +DEP=.depends DIVIDER = . OBJ = . RES = . @@ -163,6 +164,7 @@ TARGET_LDFLAGS = $($(basename $@)_LDFLAGS_$(OS_CLASS)) $($(basename $@)_LDFLAGS) TARGET_CPPFLAGS = $($(basename $@)_CPPFLAGS_$(OS_CLASS)) $($(basename $@)_CPPFLAGS) # Level of ansi conformance flags +CONFORM_CPPFLAGS = $(CONFORM_CPPFLAGS_$(CMPLR)) CONFORM_CFLAGS = $(CONFORM_CFLAGS_$(CMPLR)) CONFORM_CXXFLAGS = $(CONFORM_CXXFLAGS_$(CMPLR)) @@ -210,8 +212,8 @@ LDFLAGS = $(OPT_LDFLAGS) $(TARGET_LDFLAGS) $(USR_LDFLAGS) $(DEPLIB_LDFLAGS)\ LDLIBS = $(DEPLIB_LDLIBS) $(STATIC_LDLIBS)\ $(POSIX_LDLIBS) $(ARCH_DEP_LDLIBS) $(OP_SYS_LDLIBS) -CPPFLAGS += $(CROSS_CPPFLAGS) $(POSIX_CPPFLAGS) $(EPICS_BASE_CPPFLAGS)\ - $(TARGET_CPPFLAGS) $(USR_CPPFLAGS) $(ARCH_DEP_CPPFLAGS)\ +CPPFLAGS += $(CONFORM_CPPFLAGS) $(CROSS_CPPFLAGS) $(POSIX_CPPFLAGS)\ + $(EPICS_BASE_CPPFLAGS) $(TARGET_CPPFLAGS) $(USR_CPPFLAGS) $(ARCH_DEP_CPPFLAGS)\ $(OP_SYS_CPPFLAGS) $(OP_SYS_INCLUDE_CPPFLAGS) $(CODE_CPPFLAGS) #-------------------------------------------------- @@ -232,16 +234,19 @@ COMPILE.cpp = $(CCC) -c $(CPPFLAGS) $(CXXFLAGS) $(INCLUDES) $(SOURCE_CXXFLAG) #-------------------------------------------------- # Build depends command here -DEPENDS.cpp = $(CCC) -DEPENDSFLAGS += $(CPPFLAGS) $(INCLUDES) $(DEPENDS_FLAG) -DEPENDS_CMD.cpp = -$(DEPENDS.cpp) $(DEPENDSFLAGS) $(DEPENDS_SRC_FILES) > DEPENDS +HDEPENDS.c = $(CC) +HDEPENDS.cpp = $(CCC) +HDEPENDS_CMD.c = -$(HDEPENDS.c) $(HDEPENDS_CFLAGS) $(HDEPENDSFLAGS) $< > $*$(DEP) +HDEPENDS_CMD.cpp = -$(HDEPENDS.cpp) $(HDEPENDS_CXXFLAGS) $(HDEPENDSFLAGS) $< > $*$(DEP) +HDEPENDS_TARGETS_CMD = @$(PERL) $(TOOLS)/makeDependsTargets.pl $*$(DEP) +HDEPENDSFLAGS += $(CPPFLAGS) $(INCLUDES) $(HDEPENDS_FLAGS) #-------------------------------------------------- # depends definition + TARGET_SRCS = $(foreach name, $(TESTPROD) $(PROD) $(LIBRARY), $($(name)_SRCS)) -SRC_FILES = $(foreach src, $(LIB_SRCS) $(LIBSRCS) $(SRCS) $(PROD_SRCS) $(TARGET_SRCS) , \ - $(firstword $(wildcard $(addsuffix /$(src),$(ALL_SRC_DIRS))) $(src))) -DEPENDS_SRC_FILES = $(SRC_FILES) +SRC_FILES = $(LIB_SRCS) $(LIBSRCS) $(SRCS) $(PROD_SRCS) $(TARGET_SRCS) +HDEPENDS_FILES = $(addsuffix $(DEP),$(notdir $(basename $(SRC_FILES)))) #--------------------------------------------------------------- # Names of installed items diff --git a/configure/CONFIG_SITE b/configure/CONFIG_SITE index 46e6c328f..b95ae1e34 100644 --- a/configure/CONFIG_SITE +++ b/configure/CONFIG_SITE @@ -88,6 +88,15 @@ SHARED_LIBRARIES=NO # must be either YES or NO STATIC_BUILD=NO +# Should header dependancy files be automatically generated +# for each C/C++ source code file? +# must be either YES or NO +# +# Note: On solaris and WIN32 hosts, the gnu compilers gcc and g++ are +# used to generate the dependancy files, and they must be in +# your path. +HDEPENDS=YES + # Host build optimization # must be either YES or NO HOST_OPT=YES diff --git a/configure/RULES.Db b/configure/RULES.Db index cdcfdc348..77f8e7f8e 100644 --- a/configure/RULES.Db +++ b/configure/RULES.Db @@ -61,7 +61,7 @@ install: buildInstall rebuild: clean install -.PHONY: all inc depends build install clean rebuild buildInstall +.PHONY: all inc build install clean rebuild buildInstall endif # T_A defined @@ -146,6 +146,14 @@ $(COMMON_DIR)/menu%.h: ../menu%.dbd @$(RM) $@ $(DBTOMENUH) $< $@ +$(COMMON_DIR)/%Record.h: %Record.dbd + @$(RM) $@ + $(DBTORECORDTYPEH) $(DBDFLAGS) $< $@ + +$(COMMON_DIR)/menu%.h: menu%.dbd + @$(RM) $@ + $(DBTOMENUH) $< $@ + ##################################################### DBD files $(COMMON_DIR)/bpt%.dbd: ../bpt%.data diff --git a/configure/RULES_ARCHS b/configure/RULES_ARCHS index ba47b86d8..2a760da46 100644 --- a/configure/RULES_ARCHS +++ b/configure/RULES_ARCHS @@ -10,7 +10,6 @@ ACTIONS = inc ACTIONS += build ACTIONS += install ACTIONS += buildInstall -ACTIONS += depends ACTIONS += browse actionPart = $(word 1, $(subst $(DIVIDER), ,$@)) diff --git a/configure/RULES_BUILD b/configure/RULES_BUILD index 945e2e1db..c9a3b1e00 100644 --- a/configure/RULES_BUILD +++ b/configure/RULES_BUILD @@ -72,6 +72,14 @@ endif all: install +-include $(CONFIG)/RULES.Db + +ifeq ($(HDEPENDS),YES) +ifneq (,$(strip $(HDEPENDS_FILES))) +-include $(HDEPENDS_FILES) +endif +endif + #--------------------------------------------------------------- # Create included Makefile for prod,testprod, and library targets @@ -142,7 +150,7 @@ clean:: @$(RM) *.i *$(OBJ) *.a $(PRODNAME) $(TESTPRODNAME) $(LIBNAME) $(SHRLIBNAME)\ $(INC) *$(RES) $(TARGETS) \ *.out MakefileInclude \ - $(COMMON_INC) + $(COMMON_INC) $(HDEPENDS_FILES) ifdef MUNCHNAME @$(RM) $(MUNCHNAME) $(CTDT_SRCS) $(CTDT_OBJS) $(NMS) endif @@ -174,13 +182,6 @@ $(DIRECTORY_TARGETS) : # The order of the following rules is # VERY IMPORTANT !!!! -depends: inc $(DEPENDS_SRC_FILES) - @$(RM) DEPENDS - @touch DEPENDS -ifneq (,$(strip $(DEPENDS_SRC_FILES))) - $(DEPENDS_CMD.cpp) -endif - $(TESTPRODNAME) $(PRODNAME):%$(EXE): $(PRODUCT_OBJS) $(PROD_RESS) $(PROD_DEPLIBS) @$(RM) $@ $(LINK.cpp) @@ -195,18 +196,38 @@ $(OBJLIBNAME):%$(OBJ): $(OBJLIB_LD_OBJS) $(COMPILE.c) -traditional $< %$(OBJ): %.c +ifeq ($(HDEPENDS),YES) + @$(RM) $*$(DEP) + @$(HDEPENDS_CMD.c) + @$(HDEPENDS_TARGETS_CMD) $*$(DEP) +endif @$(RM) $@ $(COMPILE.c) $< %$(OBJ): %.cc +ifeq ($(HDEPENDS),YES) + @$(RM) $*$(DEP) + @$(HDEPENDS_CMD.cpp) + @$(HDEPENDS_TARGETS_CMD) $*$(DEP) +endif @$(RM) $@ $(COMPILE.cpp) $< %$(OBJ): %.cpp +ifeq ($(HDEPENDS),YES) + @$(RM) $*$(DEP) + @$(HDEPENDS_CMD.cpp) + @$(HDEPENDS_TARGETS_CMD) $*$(DEP) +endif @$(RM) $@ $(COMPILE.cpp) $< %$(OBJ): %.C +ifeq ($(HDEPENDS),YES) + @$(RM) $*$(DEP) + @$(HDEPENDS_CMD.cpp) + @$(HDEPENDS_TARGETS_CMD) $*$(DEP) +endif @$(RM) $@ $(COMPILE.cpp) $< @@ -407,14 +428,10 @@ $(INSTALL_TEMPLATES_SUBDIR)/%: % @echo "Installing $@" @$(INSTALL) -d -m 644 $< $(@D) -.PRECIOUS: %.i %.o %.c %.nm %.cpp +.PRECIOUS: %.i %.o %.c %.nm %.cpp %.cc .PRECIOUS: $(COMMON_INC) --include $(CONFIG)/RULES.Db - --include DEPENDS - -.PHONY: all inc depends build install clean rebuild buildInstall binInstalls +.PHONY: all inc build install clean rebuild buildInstall binInstalls # EOF RULES_BUILD diff --git a/configure/RULES_DIRS b/configure/RULES_DIRS index fa0f3ce6d..8a9205dfb 100644 --- a/configure/RULES_DIRS +++ b/configure/RULES_DIRS @@ -4,7 +4,7 @@ ARCHS += $(BUILD_ARCHS) -ACTIONS += inc build install buildInstall depends clean +ACTIONS += inc build install buildInstall clean dirPart = $(word 1, $(subst $(DIVIDER), ,$@)) actionArchPart = $(join $(word 2, $(subst $(DIVIDER), ,$@)), \ diff --git a/configure/RULES_TOP b/configure/RULES_TOP index b036f06c5..35e08a79f 100644 --- a/configure/RULES_TOP +++ b/configure/RULES_TOP @@ -68,14 +68,12 @@ help: @echo " in all except the O. level Makefile" @echo " rebuild - Same as clean install" @echo " inc - Installs header files" - @echo " depends - Generates include header file dependencies" @echo " build - Builds all targets" @echo "\"Partial\" build targets supported by Makefiles:" @echo " inc. - Installs only header files." @echo " install. - Builds and installs only." @echo " clean. - Cleans binaries in O. dirs only." @echo " build. - Builds only." - @echo " depends. - Generates dependencies only." @echo "Targets supported by top level Makefile:" @echo " uninstall - Cleans directories created by the install." @echo " distclean - Same as clean uninstall." diff --git a/configure/Sample.Makefile b/configure/Sample.Makefile index 280d962e2..309422faa 100755 --- a/configure/Sample.Makefile +++ b/configure/Sample.Makefile @@ -8,33 +8,35 @@ TOP = ../../.. include $(TOP)/configure/CONFIG -# Add-on CFLAGS that are needed by this Makefile. +# Add-on CPPFLAGS that are needed by this Makefile. # (If possible, all system specific flags should be # defined in configure/os/CONFIG.. # -# These CFLAGS rules also apply to these Makefile-variables: +# These CPPFLAGS rules also apply to these Makefile-variables: +# CPPFLAGS C preprocessor flags +# CFLAGS C flags # CXXFLAGS C++ flags # LDFLAGS link flags # # This is used on all systems: -USR_CFLAGS = -DVAR=value -Ddefine_for_all_systems +USR_CPPFLAGS = -DVAR=value -Ddefine_for_all_systems # ..only for WIN32: -USR_CFLAGS_WIN32 = -DVERSION='WIN32 port' +USR_CPPFLAGS_WIN32 = -DVERSION='WIN32 port' # # -nil- is special: -# if USR_CFLAGS_WIN32 was undefined or empty, .._DEFAULT would have +# if USR_CPPFLAGS_WIN32 was undefined or empty, .._DEFAULT would have # been used. # To indicate -# "yes, there is a special USR_CFLAGS for WIN32, but it's empty" +# "yes, there is a special USR_CPPFLAGS for WIN32, but it's empty" # you have to set it to -nil-: -USR_CFLAGS_WIN32 = -nil- +USR_CPPFLAGS_WIN32 = -nil- # .. for all other arch classes: -USR_CFLAGS_DEFAULT = -DVERSION='generic Unix' +USR_CPPFLAGS_DEFAULT = -DVERSION='generic Unix' -# CFLAGS that are only used to compile a_file.c or a_file.cpp: +# CPPFLAGS that are only used to compile a_file.c or a_file.cpp: # -a_file_CFLAGS = -DIN_A_FILE -a_file_CFLAGS_WIN32 = -DVERSION='WIN32 port' +a_file_CPPFLAGS = -DIN_A_FILE +a_file_CPPFLAGS_WIN32 = -DVERSION='WIN32 port' # --------------------------------------------------------- # general rule for all .c .cpp .h .hh files and scripts: diff --git a/configure/os/CONFIG.Common.vxWorksCommon b/configure/os/CONFIG.Common.vxWorksCommon index eaa62c3a2..f7b66f527 100644 --- a/configure/os/CONFIG.Common.vxWorksCommon +++ b/configure/os/CONFIG.Common.vxWorksCommon @@ -62,7 +62,8 @@ CTDT_SRCS += $(OBJLIBNAME:%$(OBJ)=%_ctdt.c) CTDT_OBJS += $(OBJLIBNAME:%$(OBJ)=%_ctdt$(OBJ)) NMS += $(OBJLIBNAME:%$(OBJ)=%.nm) OBJLIB_LINK.cpp = $(LD) -o $@ $(OBJLIB_LD_OBJS) - +TARGET_SRCS += $(foreach name, $(OBJLIB), $($(name)_SRCS)) +SRC_FILES += $(OBJLIB_SRCS) #-------------------------------------------------- # vxWorks directory definitions diff --git a/configure/os/CONFIG.hpux-parisc.hpux-parisc b/configure/os/CONFIG.hpux-parisc.hpux-parisc index 40ca72192..ffd070bc6 100644 --- a/configure/os/CONFIG.hpux-parisc.hpux-parisc +++ b/configure/os/CONFIG.hpux-parisc.hpux-parisc @@ -53,5 +53,5 @@ STATIC_LDLIBS_NO= SHRLIB_LDFLAGS_YES = -G -h $@ -DEPENDS_FLAG = +m +HDEPENDS_FLAGS = +m diff --git a/configure/os/CONFIG.osf-alpha.osf-alpha b/configure/os/CONFIG.osf-alpha.osf-alpha index fe970668e..04361771a 100644 --- a/configure/os/CONFIG.osf-alpha.osf-alpha +++ b/configure/os/CONFIG.osf-alpha.osf-alpha @@ -43,7 +43,7 @@ STATIC_LDLIBS_NO= SHRLIB_LDFLAGS_YES = -shared -DEPENDS_FLAG = +HDEPENDS_FLAGS = ############# ??????????? #####ACC_SFLAGS_YES= -non_shared diff --git a/configure/os/CONFIG.solaris-sparc.solaris-sparc b/configure/os/CONFIG.solaris-sparc.solaris-sparc index dddc9b220..0ad06ab81 100644 --- a/configure/os/CONFIG.solaris-sparc.solaris-sparc +++ b/configure/os/CONFIG.solaris-sparc.solaris-sparc @@ -57,6 +57,7 @@ SHRLIB_LDFLAGS_YES = -G -h $@ # gnu compiler used because Sun compiler output # includes headers from /opt/SUNWspro and does # not work for c++ headers without .h suffix. -DEPENDS_FLAG = -MM -DEPENDS.cpp = g++ +HDEPENDS_FLAGS = -MM +HDEPENDS.c = gcc +HDEPENDS.cpp = g++ diff --git a/configure/os/CONFIG.solaris-x86.solaris-x86 b/configure/os/CONFIG.solaris-x86.solaris-x86 index 7eebbf593..9c30e8fd3 100644 --- a/configure/os/CONFIG.solaris-x86.solaris-x86 +++ b/configure/os/CONFIG.solaris-x86.solaris-x86 @@ -57,6 +57,6 @@ SHRLIB_LDFLAGS_YES = -G -h $@ # gnu compiler used because Sun compiler output # includes headers from /opt/SUNWspro and does # not work for c++ headers without .h suffix. -DEPENDS_FLAG = -MM -DEPENDS.cpp = g++ +HDEPENDS_FLAGS = -MM +HDEPENDS.cpp = g++ diff --git a/configure/os/CONFIG.sun4-68k.sun4-68k b/configure/os/CONFIG.sun4-68k.sun4-68k index 51d1f378d..965c1b3ae 100644 --- a/configure/os/CONFIG.sun4-68k.sun4-68k +++ b/configure/os/CONFIG.sun4-68k.sun4-68k @@ -46,5 +46,5 @@ STATIC_LDLIBS_NO= SHRLIB_LDFLAGS_YES = -assert pure-text -h $@ -DEPENDS_FLAG = -xM1 +HDEPENDS_FLAGS = -xM1 diff --git a/configure/os/CONFIG.win32-x86.win32-x86 b/configure/os/CONFIG.win32-x86.win32-x86 index 4d136632d..30a1af90c 100644 --- a/configure/os/CONFIG.win32-x86.win32-x86 +++ b/configure/os/CONFIG.win32-x86.win32-x86 @@ -29,10 +29,10 @@ ARCMD = lib /nologo /verbose /out:$@ $(LIBRARY_LD_OBJS) BAFCMD = bscmake /nologo /o $@ -#DEPENDS_RULE = @echo depends target not supported -#GNU depends flag -DEPENDS.cpp = g++ -DEPENDS_FLAG = -MM +# gnu compiler used to create depends files (not available in Visual C++) +HDEPENDS_FLAGS = -MM $(addprefix -I,$(subst ;, ,$(INCLUDE))) +HDEPENDS.c = gcc +HDEPENDS.cpp = g++ # # Configure OS vendor C compiler diff --git a/configure/tools/makeMakefileInclude.pl b/configure/tools/makeMakefileInclude.pl index 765a34a8f..d80f9ccfc 100755 --- a/configure/tools/makeMakefileInclude.pl +++ b/configure/tools/makeMakefileInclude.pl @@ -69,8 +69,6 @@ foreach $name ( @nameList ) { print OUT "endif\n"; print OUT "${name}_OBJS+=\$(addsuffix \$(OBJ),\$(basename \$(${name}_SRCS)))\n"; print OUT "\n"; - print OUT "depends: \$(${name}_SRCS)\n"; - print OUT "\n"; print OUT "ifeq (\$(filter ${name},\$(TESTPROD)),${name})\n"; print OUT "ifeq (,\$(strip \$(${name}_OBJS) \$(PRODUCT_OBJS)))\n"; print OUT "${name}_OBJS+=${name}\$(OBJ)\n";