# $Id: globlib.gmk,v 1.2 2010/06/11 10:12:34 arce Exp $ # -------------------------------------------------------------- # Script for compound libraries. Gabriele Cosmo, 25/6/98. # -------------------------------------------------------------- include $(GAMOSINSTALL)/config/architecture.gmk G4LIBDIR := $(GAMOSINSTALL)/lib/$(G4SYSTEM) G4BINDIR := $(GAMOSINSTALL)/bin/$(G4SYSTEM) #G4LIBDIR = $(G4LIB)/$(G4SYSTEM) .PHONY : all glob global objs includes clean clean_libs wipe_libs all: makesub makesub: @for dir in $(SUBDIRS); do (cd $$dir && $(MAKE)); done g4libraries_to_build:= ifeq ($(G4LIB_NO_SHARED),) ifneq ($(G4LIB_BUILD_SHARED),) SHARED_LIB=$(G4LIBDIR)/lib$(name).$(SHEXT) g4libraries_to_build += $(SHARED_LIB) else SHARED_LIB= endif endif ifneq ($(G4LIB_BUILD_STATIC),) g4libraries_to_build += $(G4LIBDIR)/lib$(name).a endif glob global: objs wipe_libs $(g4libraries_to_build) ## ## make static libraries ## ifneq ($(G4LIB_BUILD_STATIC),) $(G4LIBDIR)/lib$(name).a: \ $(foreach dir,$(SUBLIBS),$(G4TMP)/$(G4SYSTEM)/$(dir)/obj.last) @if [ ! -d $(G4LIBDIR) ] ; then mkdir $(G4LIBDIR) ; fi @echo Merging object files in $(G4LIBDIR)/lib$(name).a ... @$(RM) $(G4LIBDIR)/lib$(name).a # # # @if [ X$(G4SYSTEM) = XWIN32-VC ] ; \ then \ i=NO; \ (( for lib in $(SUBLIBS); \ do ( if [ $$i = NO ]; \ then \ $(AR) $(OUT_LIB)$(G4LIBDIR)/lib$(name).lib \ $(G4TMP)/$(G4SYSTEM)/$$lib/*.o ; \ else \ $(AR) $(G4LIBDIR)/lib$(name).lib $(G4TMP)/$(G4SYSTEM)/$$lib/*.o; \ fi ); \ i=YES; \ done ) ; \ mv $(G4LIBDIR)/lib$(name).lib $(G4LIBDIR)/lib$(name).a); \ else \ (for lib in $(SUBLIBS); \ do ($(AR) $(OUT_LIB)$(G4LIBDIR)/lib$(name).a \ $(G4TMP)/$(G4SYSTEM)/$$lib/*.o); \ done);\ fi # # # @if [ X$(G4SYSTEM) != XWIN32-VC ] ; then \ if [ -f /usr/bin/ranlib -o -f /bin/ranlib ] ; then \ ranlib $(G4LIBDIR)/lib$(name).a ; fi ; fi endif ## ## make shared libraries ## ifeq ($(G4LIB_NO_SHARED),) ifneq ($(G4LIB_BUILD_SHARED),) $(SHARED_LIB): $(foreach dir,$(SUBLIBS),$(G4TMP)/$(G4SYSTEM)/$(dir)/obj.last) @if [ ! -d $(G4LIBDIR) ] ; then mkdir $(G4LIBDIR) ; fi @echo Creating global shared library $@ ... @$(RM) $@ # use system specific commands to build the library $(build-global-shared-lib) endif endif objs: @for dir in $(SUBDIRS); \ do (cd $$dir; $(MAKE) -q obj && ok=yes; \ if [ $$ok ]; \ then echo Nothing to be done for lib$(name) in $$dir/.; \ else $(MAKE) clean_libs; $(MAKE) obj; \ fi; ) \ done includes:: @for dir in $(SUBDIRS); do (cd $$dir && $(MAKE) $@ ); done wipe_libs: @for lib in $(SUBLIBS); do (rm -f $(G4LIBDIR)/lib$$lib.a); done @for lib in $(SUBLIBS); do (rm -f $(G4LIBDIR)/lib$$lib.$(SHEXT)); done clean: # @echo Cleaning up (SUBLIBS) ... @echo Cleaning up $(SUBDIRS) ... #??GAMOS @for lib in $(SUBLIBS); do # @for dir in $(SUBDIRS); do ( \ # rm -rf $(G4TMP)/$(G4SYSTEM)/$$lib;\ # rm -f $(G4BINDIR)/*;\ # rm -f $(G4LIBDIR)/*$$lib.a;\ # rm -f $(G4LIBDIR)/*$$lib.lib;\ # rm -f $(G4LIBDIR)/*$$lib.exp;\ # rm -f $(G4LIBDIR)/*$$lib.$(SHEXT) );\ # done ## this is better but regenerate dependencies and take more time @for dir in $(SUBDIRS); do (cd $$dir && $(MAKE) clean ); done # @rm -f $(G4LIBDIR)/*$(name).a # @rm -f $(G4LIBDIR)/*$(name).lib # @rm -f $(G4LIBDIR)/*$(name).exp # @rm -f $(G4LIBDIR)/*$(name).$(SHEXT) clean_libs:: @echo Removing lib$(name).a/.$(SHEXT) and sub-libraries ... @for lib in $(SUBLIBS); do ( \ rm -f $(G4LIBDIR)/*$$lib.a;\ rm -f $(G4LIBDIR)/*$$lib.lib;\ rm -f $(G4LIBDIR)/*$$lib.exp;\ rm -f $(G4LIBDIR)/*$$lib.$(SHEXT) );\ done @rm -f $(G4LIBDIR)/*$(name).a @rm -f $(G4LIBDIR)/*$(name).lib @rm -f $(G4LIBDIR)/*$(name).exp @rm -f $(G4LIBDIR)/*$(name).$(SHEXT)