SLAC PEP-II
BABAR
SLAC<->RAL
Babar logo
Workbook HEPIC Databases PDG HEP preprints
Organization Detector Computing Physics Documentation
Personnel Glossary Sitemap Search Hypernews
Unwrap page!
Wkbk. Search
Wkbk. Sitemap
Introduction
Non SLAC
HOWTO's
Introduction
Logging In
QuickTour
Detector
Info Resources
Software Infrastructure
CM2 Introduction
Unix
OO
SRT
Objectivity
Event Store
Framework
Beta
Modifying Code
Writing and Editing
Compiling
Debugging
Analysis
Framework II
Analysis
Find Data
Batch Processing
PAW
PAW II
ROOT I
ROOT II
ROOT III
Advanced Infrastructure
New Releases
Workdir
Main Packages
Event Displays
Gen/Sim/Reco
Contributing Software
SRT and CVS
Coding
Advanced Topics
Make CM2 Ntuples
New Packages
New Packages 2
Persistent Classes
Java
Site Installation
Check this page for HTML 4.01 Transitional compliance with the
W3C Validator
(More checks...)

Top-level GNUmakefile from analysis-26 release directory

# top level GNUmakefile for a release
# $Id: GNUmakefile.main,v 1.534 2004/09/29 00:00:34 terryh Exp $
#
# Note: See standard.mk for more variable definition/descriptions.
#
#___________________________________________________________________________
#++ Major Targets:
#
#    all	equivalent to 'lib', followed by 'bin'
#    bin        build binaries and scripts defined in BINS and BINSCRIPTS.  
#    bootstrap  build basic packages that need to be built in special order.
#    clean	delete files in working directories for all architectures.
#    cold      used when making a production release; bootstrap + all.
#    installdirs   create needed directories.
#    lib        build library.
#    libext     build library that can be loaded independantly of build.
#
#++ Minor targets:
#
#    allbin     build executables defined in BINS + EXTRABINS + BINSCRIPTS +EXTRABINSCRIPTS.
#    binscripts build scripts defined in BINSCRIPTS.
#    cleanarch	delete files in working directories for current $BFARCH.
#    cleanbin   clean binary only.
#    cleanlib   clean library only.
#    extrabin   build extra binaries defined in EXTRABINS.
#    extrabinscripts   build extra scripts defined in EXTRABINSCRIPTS.
#    pkg.  build individual binary with 'gmake pkg.foo'.
#          'gmake ' in all subdirectories.  not containing a .)
#    siteinstall install scripts for remote site. Normally run binscript.
#
# 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
#
#___________________________________________________________________________
#++ Options that can be set in BFARCH or ROPT. e.g. "gmake ROPT=-Time-Optimize"
#   Use 'no' to turn off an option; e.g. ROPT=-noDebug.
#
#++ Major ROPT options:
#    -Debug	turn on debug option. e.g. add '-g' to CXXFLAGS.
#    -NOBIN	do not build binary except in bootstrap
#    -Optimize  turn on optimization. e.g. add '-O' to CXXFLAGS.
#    -Production  production release. Same as PRODUCTION_RELEASE=1.
#    -Prunebin    prune binary based on keep_xxx list.
#    -Shared    build shared library. =-Shared-Lshared-Lstatic.
#    -Verbose   Verbose mode, same as VERBOSE=1.
#
#++ Minor ROPT options:
#    -Fastbuild collect .o to libfoo.a at end of lib target to save I/O.
#    -Ldlink    uses ldlink to find shared SYSLIB, turn off "-rpath/-R".
#    -Lshared   put shared library in link library search path.
#    -Lstatic   put static library in link library search path, default.
#    -native	use native compiler.
#    -NOInstalldirs  skip installdirs
#    -Objy	use Objectivity.
#    -Profile	profile build. Add -pg to CXXFLAGS etc.
#    -Showdir   show detail directory level information "-> pkg.dir.target"
#    -Skipdfile skip 'include .d files'
#    -Skiplib   skip 'lib' step. Use production library.
#    -SkipSlaclog skip 'slaclog' when it hangs.
#    -Static    build static library, default. Exclusive with -Shared.
#    -Time	display CPU timing information.
#
#___________________________________________________________________________
#++ Options used in 'gmake clean' and 'gmake cleanarch'
#
#    CLEANLIST  full path of directories to be cleaned.
#		e.g CLEANLIST='lib tmp/SunOS5'  
#    NOCLEAN    top directories not to be cleaned. e.g. NOCLEAN='lib results'
#
# Note:
#    CLEANLIST must be the full path while NOCLEAN is the top-level directory. 
#
#___________________________________________________________________________
#++ Variables used to define general directores.
#
#    TOPDIR	top level directory of this production/test release.
#    srcdir	current directory in packages/sub-directories.
#    PACKAGE    name of package
#
#___________________________________________________________________________
#++ Centrally controlled list (Major)
#
# These lists are now contained in the babar_specials.mk file in SRT
#
# *) build list:
#    binonly_sunos5	build 'bin' for this package on SunOS5 only.
#    nodebug_pkg	packages to be built with -noDebug
#    debug_pkg		packages to be built with -Debug
#    noautomatic_pkg	packages to be built with -fno-automatic
#    only_sunos5 build 'all' for this package on SunOS5 only. For online build.
#    skip_optimize	do not optimize these packages in -Optimize build.
#
# *) keep/nokeep list:
#    keep_bin		binaries to be kept in a -Prunebin build	
#    keep_bin_opt	binaries to be kept in a -Prunebin-Optimize build
#    keep_pkg		packages to be kept in a -Prunebin build	
#    keep_pkg_opt	packages to be kept in a -Prunebin-Optimize build
#    nokeep_bin		binaries that should be pruned in all cases
#    nokeep_bin_opt	binaries that should be pruned in an -Optimize build
#    nokeep_bin_noopt	binaries that should be pruned in an -noOptimize build
#
#   Centrally controlled list (Minor)
#    protect_dbdir	database directory to be protected	
#    skip_bin		skip bin stage
#    skip_fastbuild	ignore -Fastbuild option for these packages
#    skip_include	skip include stage
#    skip_include_d	skip include *.d files. e.g. bootstrap, clean 
#    skip_lib		skip lib stage
#    skip_nonstd	do not use -fnonstd flag to dump upon FPE.
#    skip_test		skip test stage
# 
#___________________________________________________________________________
#   

#___________________________________________________________________________
# Debugging Options:
#
# VERBOSE=yes or 1  Dump of the rules and other verbose output.
# DEBUG=1 : debug ROPT, OPTIONS.
# DEBUG02=1 : debug schema information.
# DEBUG03=1 : debug subdirectory level, turn on 'set -x'. 
# DEBUG04=1 : debug sub-make, MAKEOVERRIDES. See standard.mk.
# DEBUG05=1 : debug shared library. See standard.mk.
# DEBUG06=1 : debug ALLLIB of shared library, careful! long! See standard.mk.
# DEBUG07=1 : debug ROPT=-Prunebin option.
# DEBUG08=1 : debug SRCDIR, etc
# DEBUG10=1 : debug include .d files. See standard.mk.
# DEBUG11=1 : debug speed by monitoring PACKAGES, etc.
# DEBUG12=1 : debug checking links during installdirs
# DEBUG13=1 : debug display BIN1, LIBCCFILE1, etc. See standard.mk.
# DEBUG14=1 : debug corba.
# DEBUG15=1 : debug 'clean'.
# DEBUG16=1 : debug slaclog. Won't call slaclog. Use 'logopt=-debug' to debug.
# DEBUG17=1 : debug binonly-sunos5.
# DEBUG18=1 : debug nodebug_pkg and debug_pkg
# DEBUG19=1 : test nodebug_pkg, define this list for test release
# DEBUG20=1 : test clean target's NOCLEAN and CLEANLIST option
# DEBUG21=1 : debug BIN targets, display BINNAME and MAKEGOAL.
# DEBUG23=1 : debug message of installdirs
# DEBUG24=1 : debug compiler checking.
# DEBUG25=1 : debug checking of main().
# DEBUG26=1 : debug ldlink, major messages only.
# DEBUG27=1 : debug ldlink, detail messages.
# DEBUG28=1 : run ldlink by running ".ldlink" for each package.
# DEBUG29=1 : trace entrance to GNUmakefile, arch_spec.mk, and standard.mk.
# DEBUG30=1 : turn on informational messages for ldlink, normally suppressed.
# DEBUG31=1 : debug message for srtbinlist.
# DEBUG32=1 : debug message for rootlib (multi-package ROOT library) 
# DEBUG33=1 : debug variables for arch_spec_flex.mk.
# DEBUG34=1 : debug mkdir tmp and shtmp

# BobJ Oct 94 - debugging version
# BobJ Mar 95 - reworked to add general target passdown to subdirs
# BobJ June 95 - removed FrameExample default link step (see TODO)
# BobJ Dec 95 - 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 Nov 95 - rule printing and 'entering dir' printing turned off
#	 by default. Can be activated via VERBOSE=yes
# B. Lockman Mar 96 - don't do dbx if gnbase is r/o
# M.Ronan  July 96 - Add commissioning detectors to include and bin lists.
# B. Lockman Sep 96 - replaced dbx target in all with debugger which now
#	builds .dbxinit and .gdbinit directory files for dbx and gdb 
#	debuggers, respectively.
# H. Park  Jan 97 - Add printing lines in log files  for automations
# M. Kelsey  May 98 -- Replace use of shell to get file lists with use of
#	GMake's own $(wildcard).
# M.Kunze July 98 - Add support for shared libs
# S. Metzler July 98 - add DhpTuple DistObjTree to bootstrap
# S. Metzler April 99 - add HepScaler to bootstrap
# gpdf June 99 - add decodeOdfTime to keep_bin
# A. Samuel September 99 - add OepFastMonRemoteApp to keep_bins
# G. Zioulas September 99 - add OdcNtupleMaker to keep_bin
# E. Chen October 99 - add DhpMonControl to SunOS5 only
# S. Gowdy Novemver 99 - Add oocheckdbexist to keep_bin
# J. Becla November 99 - Add oodeletecont BdbBrowseFullDbs BdbConvertDbIdToName
#	to keep_bin
#

#==========================================================================
#++ SRT Initialization for each invocation of gmake, sub-gmake 

ifdef DEBUG29
   ERROR := $(shell echo "-> GNUmakefile $(MAKECMDGOALS)" >&2)
endif

SHELL = /bin/sh

ifeq (,$(TOPDIR))
ifeq ($(BFSITE),slac)
    export TOPDIR := $(shell a2nfs -noe -t `/bin/pwd` 2>/dev/null)
endif
ifeq (,$(TOPDIR))
    export TOPDIR := $(shell /bin/pwd)
endif
endif

export PWD := $(TOPDIR)
export MAKEBASE := $(TOPDIR)

# which SoftRelTools add-on is being used?
ifneq (,$(wildcard $(TOPDIR)/SoftRelTools))
  SRTPATH = $(TOPDIR)/SoftRelTools
else
ifneq (,$(wildcard $(BFOVERRIDE)/$(BFCURRENT)/SoftRelTools))
  SRTPATH = $(BFOVERRIDE)/$(BFCURRENT)/SoftRelTools
else
  SRTPATH = $(BFDIST)/releases/$(BFCURRENT)/SoftRelTools
endif
endif
export SRTPATH

# which full SoftRelTools is being used?
ifneq (,$(wildcard $(TOPDIR)/SoftRelTools))
  SRTPATH2 = $(TOPDIR)/SoftRelTools
else
  SRTPATH2 = $(BFDIST)/releases/$(BFCURRENT)/SoftRelTools
endif
export SRTPATH2


ifneq (,$(findstring Verbose,$(ROPT)))
  VERBOSE=1
endif
ifneq ($(VERBOSE),)
  MAKEFLAGS =
else
  MAKEFLAGS = --no-print-directory -s
endif

ifeq (,$(findstring SunOS,$(BFARCH)))
  ETIME=/usr/bin/time
else
  ETIME=/bin/time
endif

#__________________________________________________________________________
#++ findmk: subroutine to search for a mk/mk+ file
#   please provide 2 gmake macros: PKG: package MK: files to be included

define findmk
	if  [ -f $(BFOVERRIDE)/$(BFCURRENT)/$(PKG)/$(MK) ]; then \
	   echo $(BFOVERRIDE)/$(BFCURRENT)/$(PKG)/$(MK) ; \
	elif [ -f $(TOPDIR)/SiteConfig/$(BFSITE)/$(PKG)/$(MK) ]; then \
	   echo $(TOPDIR)/SiteConfig/$(BFSITE)/$(PKG)/$(MK) ; \
	elif [ -f $(BFDIST)/releases/$(BFCURRENT)/SiteConfig/$(BFSITE)/$(PKG)/$(MK) ]; then \
	   echo $(BFDIST)/releases/$(BFCURRENT)/SiteConfig/$(BFSITE)/$(PKG)/$(MK); \
	elif [ -f $(TOPDIR)/$(PKG)/$(MK) ]; then \
	   echo $(TOPDIR)/$(PKG)/$(MK); \
	elif [ -f $(BFDIST)/releases/$(BFCURRENT)/include/$(PKG)/$(MK) ]; then \
	   echo $(BFDIST)/releases/$(BFCURRENT)/include/$(PKG)/$(MK); \
	else \
	   echo "$(MK)"; \
	fi;
endef

#__________________________________________________________________________
#++ function to log monitoring information via slaclog
#   syntax: "slaclog bfbuild     "
#   slaclog1: start record
#   slaclog2: end record

ifneq (,$(findstring noSkipSlaclog,$(ROPT)))
ifeq (,$(NOTFIRST))
override debug=
logopt=
ifdef DEBUG16
    override debug=echo
endif

#++ [slaclog1]: start record
define slaclog1
	if [ -r /usr/local/bin/slaclog ]; then \
	    $(debug) /usr/local/bin/slaclog $(logopt) bfbuild "start `cat .current` $(buildtype) $@ $(TOPDIR) $(MAKEOVERRIDES)"; \
	fi
endef

#++ [slaclog2]: end record
define slaclog2
	if [ -r /usr/local/bin/slaclog ]; then \
	    $(debug) /usr/local/bin/slaclog $(logopt) bfbuild "end `cat .current` $(buildtype) $@ $(TOPDIR)"; \
	fi
endef
endif   ## ~NOTFIRST
endif   ## ~SkipSlaclog

#==========================================================================
#++ Process build options. One time only section. This section is processed
#   only once for test release, twice for production/nightly release.

ifeq (,$(NOTFIRST))
    PKG = SoftRelTools
    MK=OS_check.mk
    include $(shell $(findmk))

     export BFARCHBASE := $(firstword $(subst -, ,$(BFARCH)))

#__________________________________________________________________________
#++ setting DEFOPT, default for all users

    override DEFOPT := -Debug-native-Objy-Optimize-Fastbuild-Ldlink2-SkipSlaclog

# Check ldlink2 in production  and give warning   (will be obsolete)
#ifeq (,$(PRODUCTION_RELEASE)$(PRODUCTION_TEST))
#  ifeq (,$(findstring ldlink,$(MAKECMDGOALS)))
#  ifeq (1,$(shell if [ "`ls ./shlib/$(BFARCH)/ldlink/*_pkg* $(BFDIST)/releases/$(BFCURRENT)/shlib/$(BFARCH)/ldlink/*_pkgid_* $(BFDIST)/releases/$(BFCURRENT)/BASE/shlib/$(BFARCH)/ldlink/*_pkgid_* 2>/dev/null`" = "" ]; then echo 1; fi))
#      error := $(shell echo "** Warning: no ldlink2 in production, please run 'gmake ldlink'." >&2)
#  endif   # no ldlink2
#  endif   # not ldlink
#endif     # not production

ifneq (,$(PRODUCTION_RELEASE)$(PRODUCTION_TEST))
    override buildtype := production
    override DEBUG30 := 1
else
    override buildtype := test
endif

#__________________________________________________________________________
#++ platform specific section, for all users

ifneq (,$(findstring AIX,$(BFARCH)))
else
ifneq (,$(findstring HP-UX,$(BFARCH)))
##   override DEFOPT += -noObjy-aCC
	# Overridden by gg 25/03/98
##   override DEFOPT += -Objy-aCC-noOptimize
	## Tuned by gg 14/12/98
	override DEFOPT := $(subst native,aCC,$(DEFOPT))
	ifeq (,$(findstring aCC,$(DEFOPT)))
		DEFOPT += -aCC
	endif
else
ifneq (,$(findstring IRIX,$(BFARCH)))
else
ifneq (,$(findstring OSFV,$(BFARCH)))
else
ifneq (,$(findstring SunOS,$(BFARCH)))

endif   # AIX
endif   # HP-UX
endif   # IRIX
endif   # OSFV
endif   # SunOS

#__________________________________________________________________________
#++ arrange switches for shared and static libraries.

    # set -Lstatic as default
    override DEFOPT += -Lstatic

    #-> correct common typo such as -LShared
    ifneq (,$(findstring -LShared,$(ROPT)))
	override ROPT += -noLShared-Lshared
    endif
    ifneq (,$(findstring -LStatic,$(ROPT)))
	override ROPT += -noLStatic-Lstatic
    endif

    #-> Static and Shared are exclusive	
    ifneq (,$(findstring -Static,$(ROPT)))
	ifneq (,$(findstring -Shared,$(ROPT)))
	    ERROR:=$(shell echo Error: use either -Shared or -Static >& 2)
	    abort
	endif
    endif

    # set default for ROPT= or ROPT=-Static or ROPT=-Shared
    ifeq (,$(findstring Lstatic,$(ROPT)))
	ifeq (,$(findstring Lshared,$(ROPT)))
	    ifeq (,$(findstring Static,$(ROPT)))
		ifneq (,$(findstring Shared,$(ROPT)))
		    override ROPT += -Shared-Lstatic-Lshared
		else
		    override ROPT += -Static-Lstatic
		endif
	    else
		ifeq (,$(findstring -Shared,$(ROPT)))
		    override ROPT += -Static-Lstatic
		endif
	    endif	
	endif
    endif

#__________________________________________________________________________
#++ setting PROPT, default of production release

ifneq (,$(findstring Production,$(ROPT)))
    export PRODUCTION_RELEASE := 1
endif

ifneq (,$(PRODUCTION_RELEASE))
   override PROPT := -noDebug-Prunebin-Time-Fastbuild
ifneq (,$(findstring AIX,$(BFARCH)))
else
ifneq (,$(findstring HP-UX,$(BFARCH)))
else
ifneq (,$(findstring IRIX,$(BFARCH)))
else
ifneq (,$(findstring OSFV,$(BFARCH)))
else
ifneq (,$(findstring SunOS,$(BFARCH)))
endif
endif
endif
endif
endif
endif  # PRODUCTION_RELEASE

#__________________________________________________________________________
#++ OPTIONS = DEFOPT + BFARCH + PROPT + ROPT [1,2,3]
#   [1]. DEFOPT is default for all users.
#        PROPT is default for production release.
#	 ROPT is command-line options, normally for Release Coordinator. 
#   [2]. Put double word architecture (e.g. HP-UX) into 'longarch'.
#   [3]. This section will keep only on-switch in OPTIONS.
export DEFOPT PROPT OPTIONS
longarch := HP ADDMORE
override arch := $(shell perl -e '$$arch=$$ARGV[0]; shift; $$longarch=join(" ",@ARGV); split(/\-/, $$arch); if ($$longarch=~/.*$$_[0].*/) {print "$$_[0]-$$_[1]"} else {print "$$_[0]"}' $(BFARCH) $(longarch))
override suffix := $(subst $(arch),,$(BFARCH))
override OPTIONS :="$(DEFOPT) $(PROPT) $(suffix) $(ROPT)"

ifdef ROPT
    ifneq (-,$(shell echo $(shell echo $(ROPT) | cut -c1)))
	ERROR := $(shell echo "error: First letter in ROPT should be '-'" >&2) 
	exit 1
    endif
endif

#__________________________________________________________________________
#++ function to clean up the OPTIONS. It will be called twice, the first
#   pass filter out all the no