# 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. # VDIR =yes Have GMake print entering/leaving directory messages # useful to allow emacs compilation mode to find sources # # 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 # # A. Jonckheere 1/22/99 Change all references to $(PWD) to $(SRT_TOP), defined # the same way. PWD is changed by some shells, so isn't safe to use as it # was being used here, as the top level release directory. # P. Russo 09-Dec-1998 Defined SRT_TOP automatically for builds from # the top of the release tree. # J. Amundson 22-Oct-1998 Added USE_SUBPACKAGES variable. Defaults to # false for D0, true everywhere else. # J. Amundson 12-Oct-1998 Added installation of temporary directories for # subpackages. # G. Cooper 25-Feb-1998 Remove duplicate lines so that GNUmakefile.main can # now be included by GNUmakefile.top # R. Harris 18-Feb-1998 Add tbin target # G. Cooper 16-Feb-1998 (CDF only) Drop extra include of arch_spec.mk # R. Harris 3-Feb-1998 Removed $(libder)/APPMain.o target and rule. # R. Harris 22-Dec-1997 Added $(libdir)/APPMain.o target if EXPERIMENT=CDF # G. Cooper 12-Dec-1997 Change "CPPFLAGS +=" to "override CPPFLAGS +=" # 8-Dec-1997 jonckheere@fnal.gov # Added code to handle ide directories on NT only. This is where the # Microsoft Visual C++ ide (project) files go. # 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 1-Oct-1997 Removed HepTuple from CDF skip_bin list so we get bin. # 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 # A.M.Jonckheere 10/29/98 # add BFPREFIX variable, used to filter out informational messages for D0's # error reporter. When prefixed to printed output, the output will be # ignored when looking for errors. export BFPREFIX BFPREFIX := --> # A.M.Jonckheere 10/29/98 export SRT_TOP := $(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 ifneq ($(VDIR),) MAKEFLAGS = --print-directory -s else MAKEFLAGS = --no-print-directory -s endif endif # are we in cdf? User must decide. -LSK EXPERIMENT := $(shell if [ -f .experiment ]; \ then cat .experiment; else echo NO_EXPER; \ echo "Warning: .experiment not found, EXPERIMENT not set">&2; \ 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 (CDF,$(EXPERIMENT)) skip_include:= skip_lib:= SoftRelTools skip_bin:= CLHEP BaBar Framework endif ifeq (CDF1,$(EXPERIMENT)) skip_include:= SoftRelTools skip_lib:= SoftRelTools skip_bin:= endif skip_tbin:= # jfa 10/21/98: The variable USE_SUBPACKAGES can be set to false in order # to inhibit the installtmpdirs target. # The default value is "true", unless overriden below USE_SUBPACKAGES=true # jfa 10/21/98: Override the default value of USE_SUBPACKAGES for D0. ifeq (D0,$(EXPERIMENT)) USE_SUBPACKAGES=false endif # patch for problems linking Tcl Main on HP #ifneq (,$(findstring HP-UX,$(BFARCH))) # skip_bin += FrameExample #endif # add experiment define -LSK override CPPFLAGS += -D$(EXPERIMENT) # set up search order - first the tmp local tree, tmp current, etc # FNAL-amj: 5/11/98 change from += to := adding $(CPPFLAGS) substiution # this is needed to get the order of includes correct since include/ # directory is added in GNUmakefile.top. include/ needs to be # *after* tmp/ ifdef BFCURRENT override CPPFLAGS := -I$(BFDIST)/releases/$(BFCURRENT)/tmp/$(BFARCH) $(CPPFLAGS) endif override CPPFLAGS := -I. -I$(SRT_TOP)/tmp/$(BFARCH) $(CPPFLAGS) ifndef BFOVERRIDE BFOVERRIDE = . endif # the following assignments are overrides because they matter so much, # yet users might want to include various options override LDFLAGS += -L$(SRT_TOP)/lib/$(BFARCH) ifdef BFCURRENT override LDFLAGS += -L$(BFDIST)/releases/$(BFCURRENT)/lib/$(BFARCH) endif libdir = $(SRT_TOP)/lib/$(BFARCH)/ bindir = $(SRT_TOP)/bin/$(BFARCH)/ includedir = $(SRT_TOP)/include/ workdir=$(SRT_TOP)/tmp/$(BFARCH)/ mandir = $(SRT_TOP)/man/ docdir = $(SRT_TOP)/doc/ #FNAL/D0:GTW 11/13/97 ifneq (,$(findstring NT4,$(BFARCH))) idedir=$(SRT_TOP)/ide/$(BFARCH)/ endif # these two are D0 specific, but won't be created for others # so it doesn't hurt to define them. ctbdir = $(SRT_TOP)/cttop/$(BFARCH)/ rcpdir = $(SRT_TOP)/rcpdb/ # force local executables onto end of PATH export PATH := $(SRT_TOP)/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 tbin clean depend dbx: ifeq (CDF,$(EXPERIMENT)) if [ -f .dbxinit ] ; then \ echo "<**dbx**>"; \ verb=Updating; else verb=Creating; fi; \ echo $$verb source file listing for dbx debugger; \ echo use $(addprefix $(SRT_TOP)/tmp/$(BFARCH)/,$(PACKAGES)) > .dbxinit else if [ -w ./ ] ; then \ if [ -w gnbase/ ] ; then \ if [ -f .dbxinit ] ; then \ echo "<**dbx**>"; \ verb=Updating; else verb=Creating; fi; \ echo $$verb source file listing for dbx debugger; \ echo use $(addprefix $(SRT_TOP)/tmp/$(BFARCH)/,$(PACKAGES)) > .dbxinit ; \ cd gnbase; rm -f .dbxinit; ln -s ../.dbxinit .; fi ; fi endif bin: @echo "<**bin**>" @(true; $(strip $(foreach var,$(filter-out $(skip_$@),$(PACKAGES)), \ echo "<**$@**> $(var)"; $(MAKE) $(var).$@;))) tbin: @echo "<**tbin**>" @(true; $(strip $(foreach var,$(filter-out $(skip_$@),$(PACKAGES)), \ echo "<**$@**> $(var)"; $(MAKE) $(var).$@;))) lib: @echo "<**lib**>" @(true; $(strip $(foreach var,$(filter-out $(skip_$@),$(PACKAGES)), \ echo "<**$@**> $(var)"; $(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. #amj-FNAL-1/27/99: added cleanup of idedir, ctbdir and rcpdir. # idedir isn't always defined so need to test. clean: $(RM) -rf $(bindir) $(RM) -rf $(libdir) $(RM) -rf $(workdir) ifneq (,$(idedir)) # needed because idedir isn't always defined. if [ -d $(idedir) ]; then $(RM) -rf $(idedir); fi endif if [ -d $(ctbdir) ]; then $(RM) -rf $(ctbdir); fi if [ -d $(rcpdir) ]; then $(RM) -rf $(rcpdir); fi # 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. # jfa 10/13/98: also deletes subpackage .d files depend: @echo "<**depend**>" $(foreach lib,tmp/$(BFARCH)/*,$(RM) $(lib)/*.d; $(RM) $(lib)/*/*.d) # include is routinely done for only those packages known to require it include: @echo "<**include**>" @(true; $(strip $(foreach var,$(filter-out $(skip_$@),$(PACKAGES)), \ echo "<**$@**> $(var)"; $(MAKE) $(var).$@;))) # all does not explicitly include check... #FNAL/D0: GTW 11/13/97 add idedir #jfa 10/98: added installtmpdir for subpackages #jfa 10/21/98: made this a little more robust, added check for USE_SUBPACKAGES directories_to_install = $(bindir) $(libdir) $(workdir) $(idedir) results \ $(foreach var,$(PACKAGES),$(workdir)$(var)) ifeq (D0,$(EXPERIMENT)) directories_to_install += $(rcpdir) endif ifneq (,$(findstring NT4,$(BFARCH))) directories_to_install += $(foreach var,$(PACKAGES),$(idedir)$(var)) endif ifneq ("$(USE_SUBPACKAGES)","false") search_subpackage_dirs = \ $(foreach var,$(PACKAGES),$(var).installtmpdir) endif installdirs: installtopdirs installsubpackagedirs installtopdirs: $(directories_to_install) installsubpackagedirs: $(search_subpackage_dirs) $(rcpdir): if [ ! -d $(rcpdir) ]; then mkdir $(rcpdir) ; fi results: if [ ! -d results ] ; then mkdir results ; fi .PHONY: installdirs installtopdirs installsubpackagedirs $(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 $@ #FNAL/D0:GTW 11/13/97 create idedir ifneq (,$(findstring NT4,$(BFARCH))) $(idedir): if [ ! -d ide ] ; then mkdir ide ; fi - mkdir $(idedir) $(foreach var,$(PACKAGES),$(idedir)$(var)): - mkdir $@ endif .SUFFIXES = VAR_OVERRIDES = libdir=$(libdir) bindir=$(bindir) mandir=$(mandir) docdir=$(docdir) rcpdir=$(rcpdir) EXPERIMENT="$(EXPERIMENT)" INC_OVERRIDES = -I$(BFOVERRIDE) -I. -I$(SRT_TOP)/include -I$(SRT_TOP) -I$(BFDIST)/releases/$(BFCURRENT)/include -I$(BFDIST)/releases/$(BFCURRENT) FLAG_OVERRIDES = LDFLAGS="$(LDFLAGS)" CPPFLAGS="$(CPPFLAGS)" QUOTED_FLAG_OVERRIDES = LDFLAGS="\"$(LDFLAGS)\"" CPPFLAGS="\"$(CPPFLAGS)\"" OVERRIDES = workdir=$(workdir)$(basename $@)/ $(FLAG_OVERRIDES) $(VAR_OVERRIDES) $(INC_OVERRIDES) MAKE_FLAGS_OVERRIDES = workdir=$(workdir)$(SRT_PACKAGE)/ $(QUOTED_FLAG_OVERRIDES) $(VAR_OVERRIDES) $(INC_OVERRIDES) # 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 $@)) PNAME=$(basename $@) $(OVERRIDES) $(subst .,,$(suffix $@)) %.installtmpdir : @if [ -r $(@:.installtmpdir=)/GNUmakefile ]; then \ $(MAKE) -k -C $(notdir $(basename $@)) CURPKG=$(notdir $(basename $@)) PNAME=$(basename $@) $(OVERRIDES) MAKING_TMP_DIRECTORIES=true $(subst .,,$(suffix $@)); \ fi # 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 $@)) PNAME=$(basename $@) $(OVERRIDES) $(subst .,,$(suffix $@)) # This is for support of make in subdirectories. The alias sets the variable # SRT_CURDIR. The string-processing business below defines SRT_PACKAGE to # be the first directory below SRT_TOP. ifdef SRT_CURDIR SRT_PACKAGE=$(word 1,$(subst /, ,$(subst $(SRT_TOP)/,,$(SRT_CURDIR)))) endif # the make_flags target simply spits out flags for make in subdirectories. make_flags : @echo -s CURPKG=$(SRT_PACKAGE) $(MAKE_FLAGS_OVERRIDES) # 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).$@;)))