# top level GNUmakefile for a release # # debugging version, Bob Jacobsen, Oct 1994 # reworked to add general target passdown to subdirs, Mar 95 # removed FrameExample default link step (see TODO) BobJ June 95 # don't do dbx if gnbase is r/o Bill Lockman Mar 1996 # M.Ronan July 96 Add commissioning detectors to include and bin lists. # # targets defined: # # installdirs create needed directories # # all equivalent to 'lib', followed by 'bin' # lib & bin are expected to do the usual things in # all the subdirectories, so this is the usual build command # # cold used when making a production release; builds the # needed binary executables first # # foo.bar gmake the 'bar' target in the 'foo' subdirectory # bar 'gmake bar' in all subdirectories # (where foo and bar are arbitrary strings not containing a .) # # VERBOSE=yes Dump of the rules and other verbose output. # # Typically, a newly created release within the BaBar system # needs a gmake installdirs, followed by one or more gmakes. # # One can also do particular directories, like 'gmake stdhep.lib' # or 'gmake HepTuple.bin', or a complete phase like 'gmake lib' # # The include path now starts with tmp/$BFARCH, then <>/$BFCURRENT/tmp # so that locally created include files will be found # preferentially # # G. Cooper 19-Nov-1997 Get hardcoded include of arch_spec.mk (for CDF code) # from local SoftRelTools/ area, if it exists; if not, then look in $BFDIST. # R. Harris 14-Aug-1997 Slayed Hydra process by testing for arch_spec.mk # before including it. Added EXPERIMENT value CDF1 = run 1 (CDF = run 2) # R. Harris 3-Jan-1997; fixed argument list length problem for tmp/*/*/* area. # On 2nd gmake clean it reports unimportant error, because of no arguments. # L. Sexton-Kennedy Sep 27, 1996; added code to determine experiment # B. Jacobsen Dec 11, 1995; changed logic for finding $PACKAGES # to take (any and only) subdirectories containing a GNUmakefile # instead of explicit exception list. Removed the explicit # FrameExample.bin defeat, which should have been limited to # LLNL only (other HP sites have bothered to install Tcl) # # T. Wenaus 11/11/95 # - rule printing and 'entering dir' printing turned off by default. # Can be activated via VERBOSE=yes # SHELL = /bin/sh export PWD := $(shell /bin/pwd) # translation code: regenerate BFARCH if it is AIX1/2 or HP-UXA. ifeq (AIX1,$(BFARCH)) oldbfarch=1 endif ifeq (AIX2,$(BFARCH)) oldbfarch=1 endif ifeq (HP-UXA,$(BFARCH)) oldbfarch=1 endif ifdef oldbfarch uname=$(shell echo `uname`) BFARCH=$(uname)$(shell echo `uname -r | cut -c1`) ifeq (AIX,$(uname)) BFARCH=$(uname)$(shell echo `uname -v | cut -c1`) endif ifeq (HP-UX,$(uname)) ifeq ($(shell echo `uname -r | cut -c3`),0) BFARCH=$(uname)$(shell echo `uname -r | cut -c4`) else BFARCH=$(uname)$(shell echo `uname -r | cut -c3`) endif endif ifeq (OSF1,$(uname)) BFARCH=$(uname)$(shell echo `uname -r | cut -c1-2`) endif endif # translation code: - end ifneq ($(VERBOSE),) MAKEFLAGS = else MAKEFLAGS = --no-print-directory -s endif # are we in cdf? User must decide. -LSK EXPERIMENT := $(shell if [ -f .experiment ]; then cat .experiment; else echo BABAR; fi) # lists of phases to do or skip - these are not strictly # required (although they should be right), but speed up # makes of large projects...these are experiment specific ifeq (BABAR,$(EXPERIMENT)) skip_include:= gweed \ geane unt gnutil gnmisc gnfttk gnbbg \ gnaero gnbpip gnssvd gndcha gndirc gnmuon gnemca gntrol \ farfalla CLHEP colias stdhep beget \ BaBar FrameExample Framework HepTuple SoftRelTools \ dbin euclid \ SvtData AtcData IfrData EmcData DrcData DchData \ AbsEvent AbsEnv AbsTrack BbrGeom skip_include+= gntpcf gnstcd skip_lib:= SoftRelTools CERNLIB geant jetset skip_bin:= geant gweed \ geane unt gnutil gnmisc gnfttk gnbbg \ gnaero gnbpip gndcha gndirc gnmuon gnemca gntrol \ farfalla CLHEP stdhep beget BaBar \ Framework HepTuple skip_bin+= gntpcf gnstcd endif ifeq (CDF,$(EXPERIMENT)) skip_include:= CLHEP BaBar FrameExample Framework SoftRelTools AbsEnv \ HepTuple trybos Examples skip_lib:= SoftRelTools skip_bin:= CLHEP BaBar Framework endif ifeq (CDF1,$(EXPERIMENT)) skip_include:= SoftRelTools skip_lib:= SoftRelTools skip_bin:= endif # patch for problems linking Tcl Main on HP #ifneq (,$(findstring HP-UX,$(BFARCH))) # skip_bin += FrameExample #endif # make the correct BFCURRENT value newCURRENT := $(shell touch .current; cat .current) ifneq ($(newCURRENT),) # if the .current file exists in the release directory, use it ifneq ($(BFCURRENT),$(newCURRENT)) ERROR := $(shell echo This release based on $(shell cat .current), overriding BFCURRENT value of $(BFCURRENT) >& 2) endif override BFCURRENT := $(newCURRENT) export BFCURRENT endif # add experiment define -LSK override CPPFLAGS += -D$(EXPERIMENT) # Determine if the experiment is either CDF (CDF Run 2) or CDF1 (CDF Run 1) ifneq (,$(findstring CDF,$(EXPERIMENT))) # Get arch_spec.mk, but only if it exists. # Checking is necessary or gmake will spawn another gmake to try and make it, # ad infinitum. The Hydra process. # Look in local SoftRelTools area first, then try $BFDIST ARCH_EXIST = $(shell if [ -f SoftRelTools/arch_spec.mk ]; then echo YES; else echo NO; fi) ifeq (YES,$(ARCH_EXIST)) include SoftRelTools/arch_spec.mk override CPPFLAGS += $(DEFINES) else ARCH_EXIST = $(shell if [ -f $(BFDIST)/releases/$(BFCURRENT)/SoftRelTools/arch_spec.mk ]; then echo YES; else echo NO; fi) ifeq (YES,$(ARCH_EXIST)) include $(BFDIST)/releases/$(BFCURRENT)/SoftRelTools/arch_spec.mk override CPPFLAGS += $(DEFINES) else ERROR := $(shell echo This release does not have $(BFDIST)/releases/$(BFCURRENT)/SoftRelTools/arch_spec.mk >& 2) endif endif endif # set up search order - first the tmp local tree, tmp current, etc override CPPFLAGS += -I. -I$(PWD)/tmp/$(BFARCH) ifdef BFCURRENT override CPPFLAGS += -I$(BFDIST)/releases/$(BFCURRENT)/tmp/$(BFARCH) endif ifndef BFOVERRIDE BFOVERRIDE = . endif # the following four assignments are overrides because they matter so much, # yet users might want to include various options override CPPFLAGS += -I$(PWD)/include override LDFLAGS += -L$(PWD)/lib/$(BFARCH) ifdef BFCURRENT override CPPFLAGS += -I$(BFDIST)/releases/$(BFCURRENT)/include override LDFLAGS += -L$(BFDIST)/releases/$(BFCURRENT)/lib/$(BFARCH) endif libdir = $(PWD)/lib/$(BFARCH)/ bindir = $(PWD)/bin/$(BFARCH)/ includedir = $(PWD)/include/ workdir=$(PWD)/tmp/$(BFARCH)/ mandir = $(PWD)/man/ docdir = $(PWD)/doc/ # force local executables onto end of PATH export PATH := $(PWD)/bin/$(BFARCH):$(PATH) # You might want to override the following lines # with an explicit list in your own, private makefiles PACKAGES := $(shell /bin/sh -c "for v in *[!~]; do if test -r \$$v/GNUmakefile; then echo \$$v; fi; done") # This is the default target #because lib and bin are directories, simple rules do not work? all: @$(MAKE) installdirs @$(MAKE) include @$(MAKE) dbx @$(MAKE) lib @$(MAKE) bin cold: @$(MAKE) installdirs @if test -d SoftRelTools; then $(MAKE) SoftRelTools.all; fi; @if test -d dbin; then $(MAKE) dbin.all; fi; @if test -d dbio; then $(MAKE) dbio.all; fi; @if test -d dbinPlain; then $(MAKE) dbinPlain.all; fi; @if test -d CERNLIB; then $(MAKE) CERNLIB.include; fi; @if test -d geant; then $(MAKE) geant.include; fi; @if test -d jetset; then $(MAKE) jetset.include; fi; @if test -d gnbase; then $(MAKE) gnbase.include; fi; @if test -d DbiEvent; then $(MAKE) DbiEvent.include; fi; @$(MAKE) all @if test -d gnbase; then $(MAKE) gnbase.bin MODE=INTERACTIVE; fi; # the following two rules are needed because the existing directories # confuse the more general rule .PHONY: include lib bin dbx: ifeq (CDF,$(EXPERIMENT)) if [ -f .dbxinit ] ; then \ verb=Updating; else verb=Creating; fi; \ echo $$verb source file listing for dbx debugger; \ echo use $(addprefix $(PWD)/tmp/$(BFARCH)/,$(PACKAGES)) > .dbxinit else if [ -w ./ ] ; then \ if [ -w gnbase/ ] ; then \ if [ -f .dbxinit ] ; then \ verb=Updating; else verb=Creating; fi; \ echo $$verb source file listing for dbx debugger; \ echo use $(addprefix $(PWD)/tmp/$(BFARCH)/,$(PACKAGES)) > .dbxinit ; \ cd gnbase; rm -f .dbxinit; ln -s ../.dbxinit .; fi ; fi endif bin: @(true; $(strip $(foreach var,$(filter-out $(skip_bin),$(PACKAGES)),$(MAKE) $(var).$@;))) lib: @(true; $(strip $(foreach var,$(filter-out $(skip_lib),$(PACKAGES)),$(MAKE) $(var).$@;))) # clean is done locally by emptying directories # the tmp/*/*/* area has too long an argument list, so xargs is used. R. Harris #amj-FNAL-9/5/97: do only one Architecture at a time #amj-FNAL-9/5/97: must be able to handle subdirectories if present for the Kai # C++ compiler. clean: $(RM) -rf bin/$(BFARCH)/* $(RM) -rf lib/$(BFARCH)/* $(foreach lib,tmp/$(BFARCH)/*,$(RM) -rf $(lib)) # depend is done locally by explicit delete # note this does not actually remake the .d files - that's # done at the beginning of the next make #amj-FNAL-9/5/97: do only one Architecture at a time #amj-FNAL-9/5/97: must be able to handle subdirectories if present for the Kai # C++ compiler. depend: $(foreach lib,tmp/$(BFARCH)/*,$(RM) $(lib)/*.d) # include is routinely done for only those packages known to require it include: @(true; $(strip $(foreach var,$(filter-out $(skip_include),$(PACKAGES)),$(MAKE) $(var).$@;))) # all does not explicitly include check... installdirs: $(bindir) $(libdir) $(workdir) results \ $(foreach var,$(PACKAGES),$(workdir)$(var)) results: if [ ! -d results ] ; then mkdir results ; fi .PHONY: installdirs $(bindir): if [ ! -d bin ] ; then mkdir bin ; fi - mkdir $(bindir) $(libdir): if [ ! -d lib ] ; then mkdir lib ; fi - mkdir $(libdir) $(workdir): if [ ! -d tmp ] ; then mkdir tmp ; fi - mkdir $(workdir) $(foreach var,$(PACKAGES),$(workdir)$(var)): - mkdir $@ .SUFFIXES = OVERRIDES = libdir=$(libdir) bindir=$(bindir) LDFLAGS="$(LDFLAGS)" workdir=$(workdir)/$(basename $@)/ -I$(BFOVERRIDE) -I. -I$(PWD)/include -I$(BFDIST)/releases/$(BFCURRENT)/include -I$(BFDIST)/releases/$(BFCURRENT) mandir=$(mandir) docdir=$(docdir) CPPFLAGS="$(CPPFLAGS)" EXPERIMENT="$(EXPERIMENT)" # this null item is needed to avoid passing it down each time GNUmakefile: # anything of the form @ means to do a gmake item # in the package directory - this is a newer form, allowing periods in # and more than one in the target $(foreach var,$(PACKAGES),$(var)@%) : echo $@ Not yet functional # @$(MAKE) -C $(notdir $(basename $@)) CURPKG=$(notdir $(basename $@)) $(OVERRIDES) $(subst .,,$(suffix $@)) # anything of the form . means to do a gmake item # in the package directory - this older form is for compatibility $(foreach var,$(PACKAGES),$(var).%) : @$(MAKE) -C $(notdir $(basename $@)) CURPKG=$(notdir $(basename $@)) $(OVERRIDES) $(subst .,,$(suffix $@)) # any target not recognized gets passed to all subdirectories # i.e. gmake foo means do "gmake foo" in all subdirectories % : @($(strip $(foreach var, $(PACKAGES),$(MAKE) $(var).$@;)))