Flattened Makefile 1: Difference between revisions
Line 2: | Line 2: | ||
Using a pile of copy/paste, let's try to build a flat makefile from the many levels of other files including other files. This isn't just a simple copy/paste operation, because we also have to expand all the variable references for paths, but some variables are re-used. In doing this we have to realize that Make acts like a two-pass assembler, first building the symbol table (so forward reference is technically legal), then doing all the expansion of the symbols and handling the rules that have been invoked by the user. When invoking make you can supply a list of rules (actions) at the command line and make will dig through the makefiles to find the matching segments of actions corresponding to each rule. Nice idea but hard to work with if that means significant amounts of the code are never used because all the user ever does is say 'make' with no arguments. | Using a pile of copy/paste, let's try to build a flat makefile from the many levels of other files including other files. This isn't just a simple copy/paste operation, because we also have to expand all the variable references for paths, but some variables are re-used. In doing this we have to realize that Make acts like a two-pass assembler, first building the symbol table (so forward reference is technically legal), then doing all the expansion of the symbols and handling the rules that have been invoked by the user. When invoking make you can supply a list of rules (actions) at the command line and make will dig through the makefiles to find the matching segments of actions corresponding to each rule. Nice idea but hard to work with if that means significant amounts of the code are never used because all the user ever does is say 'make' with no arguments. | ||
'''1 Begin copying code from /global/devel/gretTop/9-22/dgsDrivers/Makefile.==''' | |||
<nowiki> | <nowiki> | ||
#Makefile at top of application tree | #Makefile at top of application tree | ||
TOP = . | TOP = . | ||
include $(TOP)/configure/CONFIG | |||
</nowiki> | </nowiki> | ||
Manual expansion of line | '''1.1 Manual expansion of line include $(TOP)/configure/CONFIG is below.''' | ||
include $(TOP)/configure/CONFIG | |||
is below. | |||
<nowiki> | <nowiki> | ||
#CONFIG | #CONFIG | ||
include $(TOP)/configure/CONFIG_APP | include $(TOP)/configure/CONFIG_APP | ||
</nowiki> | |||
'''1.1.1 Manual expansion of line include $(TOP)/configure/CONFIG_APP is below.''' | |||
</nowiki> | </nowiki> | ||
Revision as of 20:01, May 22, 2018
Flattened Makefile 1
Using a pile of copy/paste, let's try to build a flat makefile from the many levels of other files including other files. This isn't just a simple copy/paste operation, because we also have to expand all the variable references for paths, but some variables are re-used. In doing this we have to realize that Make acts like a two-pass assembler, first building the symbol table (so forward reference is technically legal), then doing all the expansion of the symbols and handling the rules that have been invoked by the user. When invoking make you can supply a list of rules (actions) at the command line and make will dig through the makefiles to find the matching segments of actions corresponding to each rule. Nice idea but hard to work with if that means significant amounts of the code are never used because all the user ever does is say 'make' with no arguments.
1 Begin copying code from /global/devel/gretTop/9-22/dgsDrivers/Makefile.==
#Makefile at top of application tree TOP = . include $(TOP)/configure/CONFIG
1.1 Manual expansion of line include $(TOP)/configure/CONFIG is below.
#CONFIG include $(TOP)/configure/CONFIG_APP
1.1.1 Manual expansion of line include $(TOP)/configure/CONFIG_APP is below.
</nowiki>
- CONFIG_APP
- RELEASE Location of external products
- Run "gnumake clean uninstall install" in the application
- top directory each time this file is changed.
- NOTE: The build does not check dependancies on files
- external to this application. Thus you should run
- "gnumake clean uninstall install" in the top directory
- each time EPICS_BASE, SNCSEQ, or any other external
- module defined in the RELEASE file is rebuilt.
TEMPLATE_TOP=$(EPICS_BASE)/templates/makeBaseApp/top
GRETVME=./../gretVME DATASERVER=./../gretClust
- If using the sequencer, point SNCSEQ at its top directory:
SNCSEQ=/global/develbuild/supTop/31410/sncseq-2.0.12
ASYN=/global/develbuild/synApps/asyn/asyn4-17
- EPICS_BASE usually appears last so other apps can override stuff:
- EPICS_BASE=/global/develbuild/base/R3.14.10
EPICS_BASE=/global/develbuild/base/base-3.14.12.1
- Capfast users may need the following definitions
- CAPFAST_TEMPLATES=
- SCH2EDIF_PATH=
-include ./configure/RELEASE.$(EPICS_HOST_ARCH) ##jta: forward definition -include ./configure/RELEASE.Common.$(T_A) ##jta: forward definition -include ./configure/RELEASE.$(EPICS_HOST_ARCH).$(T_A) ##jta: forward definition
CONFIG=/global/develbuild/base/base-3.14.12.1/configure
- assume T_A is the host arch if not specified
- Common build definitions
</nowiki>
The following snippet likely never gets used by us...
ifneq ($(wildcard ./configure/CONFIG_BASE_VERSION),) EPICS_BASE = $(INSTALL_LOCATION) CONFIG = ./configure BASE_TOP=YES else CONFIG ?= $(EPICS_BASE)/configure endif # Provide a default if the user hasn't set EPICS_HOST_ARCH ifeq ($(origin EPICS_HOST_ARCH), undefined) # NB: Must use a simply expanded variable here for performance: EPICS_HOST_ARCH := $(shell $(CONFIG)/../startup/EpicsHostArch.pl) endif # -include $(CONFIG)/os/CONFIG_COMPAT -include $(CONFIG)/RELEASE -include $(CONFIG)/RELEASE.$(EPICS_HOST_ARCH) -include $(CONFIG)/RELEASE.$(EPICS_HOST_ARCH).Common ifdef T_A -include $(CONFIG)/RELEASE.Common.$(T_A) -include $(CONFIG)/RELEASE.$(EPICS_HOST_ARCH).$(T_A) endif
But at this point we get back to yet more includes... CONFIG_COMMON
include /global/develbuild/base/base-3.14.12.1/configure/CONFIG_COMMON
CONFIG_FILE_TYPE
include /global/develbuild/base/base-3.14.12.1/configure/CONFIG_FILE_TYPE
CONFIG_BASE
# Base-specific build options # include /global/develbuild/base/base-3.14.12.1/configure/CONFIG_BASE
CONFIG_SITE
# Site-specific build options # include /global/develbuild/base/base-3.14.12.1/configure/CONFIG_SITE
CONFIG_BASE_VERSION
# Version numbering # include /global/develbuild/base/base-3.14.12.1/configure/CONFIG_BASE_VERSION
- Host architecture specific definitions
include $(CONFIG)/os/CONFIG.$(EPICS_HOST_ARCH).Common <nowiki> yet another include... <nowiki> -include $(CONFIG)/os/CONFIG_SITE.$(EPICS_HOST_ARCH).Common ifdef T_A # Cross compile specific definitions # ifneq ($(EPICS_HOST_ARCH),$(T_A)) include $(CONFIG)/CONFIG.CrossCommon endif # Target architecture specific definitions # -include $(CONFIG)/os/CONFIG.Common.$(T_A) # Host-Target architecture specific definitions # -include $(CONFIG)/os/CONFIG.$(EPICS_HOST_ARCH).$(T_A) # RELEASE file specific definitions # ifneq ($(CONFIG),./configure) -include $(CONFIG)/CONFIG_APP_INCLUDE endif # Site specific target and host-target definitions # -include $(CONFIG)/os/CONFIG_SITE.Common.$(T_A) -include $(CONFIG)/os/CONFIG_SITE.$(EPICS_HOST_ARCH).$(T_A) endif # Include <top>/cfg/CONFIG* definitions from tops defined in RELEASE* files # ifneq ($(CONFIG),./configure) RELEASE_TOPS := $(shell $(CONVERTRELEASE) -T . releaseTops) RELEASE_CFG_CONFIGS = $(foreach top, $(RELEASE_TOPS), $(wildcard $(.)/cfg/CONFIG*)) ifneq ($(RELEASE_CFG_CONFIGS),) include $(RELEASE_CFG_CONFIGS) endif endif # Include $(INSTALL_CFG)/CONFIG* definitions # ifndef T_A TOP_CFG_CONFIGS = $(wildcard $(INSTALL_CFG)/CONFIG*) ifneq ($(TOP_CFG_CONFIGS),) include $(TOP_CFG_CONFIGS) endif endif # User specific definitions # -include $(HOME)/configure/CONFIG_USER -include $(HOME)/configure/CONFIG_USER.$(EPICS_HOST_ARCH) ifdef T_A -include $(HOME)/configure/CONFIG_USER.Common.$(T_A) -include $(HOME)/configure/CONFIG_USER.$(EPICS_HOST_ARCH).$(T_A) endif # All options # may be overridden here. # # EXAMPLES # -------- # Build client objects statically ? must be either YES or NO #STATIC_BUILD=NO # Host build optimization, must be either YES or NO #HOST_OPT=YES # Cross build optimization, must be either YES or NO #CROSS_OPT=YES # Generate Verbose Compiler Warnings for host build, must be either YES or NO #HOST_WARN=YES # Generate Verbose Compiler Warnings for cross compile builds, must be either YES or NO #CROSS_WARN=YES #etc. #CROSS_COMPILER_TARGET_ARCHS=vxWorks-68040 INSTALL_LOCATION = . ifdef INSTALL_LOCATION_APP INSTALL_LOCATION = $(INSTALL_LOCATION_APP) endif ifdef T_A -include ./configure/O.$(T_A)/CONFIG_APP_INCLUDE endif # dbst based database optimization (default: NO) DB_OPT = NO # Add any changes to make definitions here #CROSS_COMPILER_TARGET_ARCHS = vxWorks-68040 # Use this when your IOC and the host use different paths # to access the application. Typically this will be # used with the Microsoft FTP server or with NFS mounts. Use # is indicated by failure of the cdCommands script on # vxWorks. You must rebuild in the iocBoot directory # before this takes effect. #IOCS_APPL_TOP = <the top of the application as seen by the IOC> DIRS := $(DIRS) $(filter-out $(DIRS), configure) DIRS := $(DIRS) $(filter-out $(DIRS), $(wildcard *App)) DIRS := $(DIRS) $(filter-out $(DIRS), $(wildcard *app)) DIRS := $(DIRS) $(filter-out $(DIRS), $(wildcard iocBoot)) DIRS := $(DIRS) $(filter-out $(DIRS), $(wildcard iocboot)) include ./configure/RULES_TOP