corba/make/common/Defs.gmk
changeset 3871 3d528461f61d
parent 4 02bb8761fcce
child 5555 b2b5ed3f0d0d
equal deleted inserted replaced
3665:c5d39b6be65c 3871:3d528461f61d
     1 #
     1 #
     2 # Copyright 1995-2007 Sun Microsystems, Inc.  All Rights Reserved.
     2 # Copyright 1995-2009 Sun Microsystems, Inc.  All Rights Reserved.
     3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4 #
     4 #
     5 # This code is free software; you can redistribute it and/or modify it
     5 # This code is free software; you can redistribute it and/or modify it
     6 # under the terms of the GNU General Public License version 2 only, as
     6 # under the terms of the GNU General Public License version 2 only, as
     7 # published by the Free Software Foundation.  Sun designates this
     7 # published by the Free Software Foundation.  Sun designates this
   308 
   308 
   309 # Default make settings for processing SUBDIRS with clobber or clean names
   309 # Default make settings for processing SUBDIRS with clobber or clean names
   310 SUBDIRS_MAKEFLAGS-clobber = INCREMENTAL_BUILD=false
   310 SUBDIRS_MAKEFLAGS-clobber = INCREMENTAL_BUILD=false
   311 SUBDIRS_MAKEFLAGS-clean   = INCREMENTAL_BUILD=false
   311 SUBDIRS_MAKEFLAGS-clean   = INCREMENTAL_BUILD=false
   312 
   312 
   313 # Current directory
       
   314 CURRENT_DIRECTORY := $(shell $(PWD))
       
   315 
       
   316 # If no timing wanted, we need to define these as empty
       
   317 ifdef NO_TIMING
       
   318 
       
   319 TIMING_ID:=NA
       
   320 
       
   321 define TIMING_start
       
   322 t=0:0:0:0
       
   323 endef
       
   324 
       
   325 define TIMING_end
       
   326 time_used=0
       
   327 endef
       
   328 
       
   329 else # NO_TIMING
       
   330 
       
   331 # Default timing id
       
   332 TIMING_ID:=$(shell $(BASENAME) $(CURRENT_DIRECTORY))
       
   333 
       
   334 # Timing start (must be used in same shell, e.g. same command line)
       
   335 #    Defines the shell variable $1 to have the start time.
       
   336 define TIMING_start
       
   337 $1=`$(DATE) +%j:%H:%M:%S`
       
   338 endef
       
   339 
       
   340 # Timing end (must be used in same shell, e.g. same command line)
       
   341 #    Expects shell variable $1 to have been defined as the start time.
       
   342 #    Expects shell variable $2 to have timing id string
       
   343 #    Sets total_seconds shell variable as the total seconds used.
       
   344 #    Sets time_used shell variable to contain format "%dh%dm%ds"
       
   345 define TIMING_end
       
   346 begTime="$${$1}"; \
       
   347 timing_id="$${$2}"; \
       
   348 endTime=`$(DATE) +%j:%H:%M:%S`; \
       
   349 d1=`$(ECHO) $${begTime} | $(CUT) -d':' -f1 | $(SED) -e 's@^0*@@'`; \
       
   350 if [ "$${d1}" = "" ] ; then d1=0; fi; \
       
   351 h1=`$(ECHO) $${begTime} | $(CUT) -d':' -f2 | $(SED) -e 's@^0*@@'`; \
       
   352 if [ "$${h1}" = "" ] ; then h1=0; fi; \
       
   353 m1=`$(ECHO) $${begTime} | $(CUT) -d':' -f3 | $(SED) -e 's@^0*@@'`; \
       
   354 if [ "$${m1}" = "" ] ; then m1=0; fi; \
       
   355 s1=`$(ECHO) $${begTime} | $(CUT) -d':' -f4 | $(SED) -e 's@^0*@@'`; \
       
   356 if [ "$${s1}" = "" ] ; then s1=0; fi; \
       
   357 d2=`$(ECHO) $${endTime} | $(CUT) -d':' -f1 | $(SED) -e 's@^0*@@'`; \
       
   358 if [ "$${d2}" = "" ] ; then d2=0; fi; \
       
   359 h2=`$(ECHO) $${endTime} | $(CUT) -d':' -f2 | $(SED) -e 's@^0*@@'`; \
       
   360 if [ "$${h2}" = "" ] ; then h2=0; fi; \
       
   361 m2=`$(ECHO) $${endTime} | $(CUT) -d':' -f3 | $(SED) -e 's@^0*@@'`; \
       
   362 if [ "$${m2}" = "" ] ; then m2=0; fi; \
       
   363 s2=`$(ECHO) $${endTime} | $(CUT) -d':' -f4 | $(SED) -e 's@^0*@@'`; \
       
   364 if [ "$${s2}" = "" ] ; then s2=0; fi; \
       
   365 t1_secs=`$(EXPR) $${d1} '*' 60 '*' 60 '*' 24 '+' $${h1} '*' 60 '*' 60 \
       
   366 		 '+' $${m1} '*' 60 '+' $${s1}`; \
       
   367 t2_secs=`$(EXPR) $${d2} '*' 60 '*' 60 '*' 24 '+' $${h2} '*' 60 '*' 60 \
       
   368 		 '+' $${m2} '*' 60 '+' $${s2}`; \
       
   369 total_seconds=`$(EXPR) $${t2_secs} '-' $${t1_secs}`; \
       
   370 if [ "$${total_seconds}" -lt 0 ] ; then total_seconds=0; fi; \
       
   371 t_hour=`$(EXPR) $${total_seconds} '/' '(' 60 '*' 60 ')'`h; \
       
   372 t_min=`$(EXPR) '(' $${total_seconds} '%' '(' 60 '*' 60 ')' ')' '/' 60`m; \
       
   373 t_sec=`$(EXPR) $${total_seconds} '%' 60`s; \
       
   374 time_used=$${t_sec}; \
       
   375 if [ "$${t_hour}" != "0h" ] ; then \
       
   376 time_used=$${t_hour}$${t_min}$${t_sec}; \
       
   377 elif [ "$${t_min}" != "0m" ] ; then \
       
   378 time_used=$${t_min}$${t_sec}; \
       
   379 else \
       
   380 time_used=$${t_sec}; \
       
   381 fi; \
       
   382 $(PRINTF) "  Timing: %05d seconds or %s for %s\n" \
       
   383     $${total_seconds} $${time_used} $${timing_id}
       
   384 endef
       
   385 
       
   386 endif # NO_TIMING
       
   387 
       
   388 # Given a SUBDIRS list, cd into them and make them
   313 # Given a SUBDIRS list, cd into them and make them
   389 #   SUBDIRS_MAKEFLAGS      Make settings for a subdir make
   314 #   SUBDIRS_MAKEFLAGS      Make settings for a subdir make
   390 #   SUBDIRS_MAKEFLAGS-$@   Make settings specific to this target
   315 #   SUBDIRS_MAKEFLAGS-$@   Make settings specific to this target
   391 define SUBDIRS-loop
   316 define SUBDIRS-loop
   392 @$(ECHO) "Begin Processing SUBDIRS: $(SUBDIRS)"
       
   393 @for i in DUMMY $(SUBDIRS) ; do \
   317 @for i in DUMMY $(SUBDIRS) ; do \
   394   if [ "$$i" != "DUMMY" ] ; then \
   318   if [ "$$i" != "DUMMY" ] ; then \
   395     $(ECHO) ">>>Recursively making "$$i" "$@" @ `$(DATE)` ..."; \
   319     $(MAKE) -C $${i} $@ \
   396     timing_id="$(TIMING_ID)-`$(BASENAME) $${i}`"; \
   320           $(SUBDIRS_MAKEFLAGS) \
   397     $(call TIMING_start,startTime); \
   321           $(SUBDIRS_MAKEFLAGS-$@) \
   398     curDir=$(CURRENT_DIRECTORY); \
   322           FULL_VERSION=$(FULL_VERSION) \
   399     $(CD) $$i; $(MAKE) $@ TIMING_ID=$${timing_id} \
   323           RELEASE=$(RELEASE) || exit 1; \
   400 			  $(SUBDIRS_MAKEFLAGS) \
       
   401 			  $(SUBDIRS_MAKEFLAGS-$@) \
       
   402 			  FULL_VERSION=$(FULL_VERSION) \
       
   403 			  RELEASE=$(RELEASE) || exit 1; \
       
   404 	       $(CD) $${curDir}; \
       
   405     $(call TIMING_end,startTime,timing_id); \
       
   406     $(ECHO) "<<<Finished Recursively making "$$i" "$@" @ `$(DATE)`." ; \
       
   407   fi ; \
   324   fi ; \
   408 done
   325 done
   409 @$(ECHO) "Done Processing SUBDIRS: $(SUBDIRS)"
       
   410 endef
   326 endef
   411 
   327 
   412 # Given a OTHERSUBDIRS list, cd into them and make them (extra loop define)
   328 # Given a OTHERSUBDIRS list, cd into them and make them (extra loop define)
   413 #   OTHERSUBDIRS_MAKEFLAGS      Make settings for a subdir make
   329 #   OTHERSUBDIRS_MAKEFLAGS      Make settings for a subdir make
   414 define OTHERSUBDIRS-loop
   330 define OTHERSUBDIRS-loop
   415 @$(ECHO) "Begin Processing OTHERSUBDIRS: $(OTHERSUBDIRS)"
       
   416 @for i in DUMMY $(OTHERSUBDIRS) ; do \
   331 @for i in DUMMY $(OTHERSUBDIRS) ; do \
   417   if [ "$$i" != "DUMMY" ] ; then \
   332   if [ "$$i" != "DUMMY" ] ; then \
   418     $(ECHO) ">>>Recursively making "$$i" "$@" @ `$(DATE)` ..."; \
   333     $(MAKE) -C $${i} $@ \
   419     timing_id="$(TIMING_ID)-`$(BASENAME) $${i}`"; \
   334           $(OTHERSUBDIRS_MAKEFLAGS) \
   420     $(call TIMING_start,startTime); \
   335           FULL_VERSION=$(FULL_VERSION) \
   421     curDir=$(CURRENT_DIRECTORY); \
   336           RELEASE=$(RELEASE) || exit 1; \
   422     $(CD) $$i; $(MAKE) $@ TIMING_ID=$${timing_id} \
       
   423 		          $(OTHERSUBDIRS_MAKEFLAGS) \
       
   424 			  FULL_VERSION=$(FULL_VERSION) \
       
   425 			  RELEASE=$(RELEASE) || exit 1; \
       
   426 	       $(CD) $${curDir}; \
       
   427     $(call TIMING_end,startTime,timing_id); \
       
   428     $(ECHO) "<<<Finished Recursively making "$$i" "$@" @ `$(DATE)`." ; \
       
   429   fi ; \
   337   fi ; \
   430 done
   338 done
   431 @$(ECHO) "Done Processing OTHERSUBDIRS: $(OTHERSUBDIRS)"
       
   432 endef
   339 endef
   433 
   340 
   434 #
   341 #
   435 # Create BYFILE OPT and DBG settings, if CFLAGS_OPT/foobar.o is set then it is
   342 # Create BYFILE OPT and DBG settings, if CFLAGS_OPT/foobar.o is set then it is
   436 #    used for this file, otherwise the default settings are used.
   343 #    used for this file, otherwise the default settings are used.
   458   VERSION_DEFINES = -DRELEASE="\"$(RELEASE)\""
   365   VERSION_DEFINES = -DRELEASE="\"$(RELEASE)\""
   459 else
   366 else
   460   VERSION_DEFINES = -DRELEASE='"$(RELEASE)"'
   367   VERSION_DEFINES = -DRELEASE='"$(RELEASE)"'
   461 endif
   368 endif
   462 
   369 
   463 # Note: As a rule, GNU Make rules should not appear in any of the 
   370 # Prevent the use of many default suffix rules we do not need
   464 # Defs*.gmk files. These were added for Kestrel-Solaris and do address
   371 .SUFFIXES:
   465 # a TeamWare bug. They should be moved elsewhere for Merlin.
   372 .SUFFIXES: .c .o .h .obj .cpp .hpp .java .class
   466 # 
   373 
   467 #  Override gnumake built-in rules which do sccs get operations badly.
   374 # Make sure we are all insane
   468 #  (They put the checked out code in the current directory, not in the
       
   469 #  directory of the original file.) 
       
   470 # Since this is a symptom of a teamware failure, complain and die on the spot.
       
   471 
       
   472 # This message immediately goes to stdout and the build terminates.
       
   473 define SCCS-trouble
       
   474 $(error  \
       
   475 "ERROR: File $@ referenced while building in $(CURRENT_DIRECTORY) \
       
   476  is out of date with respect to its SCCS file $<. \
       
   477  This can happen from an unresolved Teamware conflict, a file movement, or \
       
   478  a failure in which SCCS files are updated but the 'sccs get' was not done. \
       
   479  You should double check for other out of date files in your workspace. \
       
   480  Or run: cd $(TOPDIR) && $(MAKE) sccs_get")
       
   481 endef
       
   482 
       
   483 %:: s.%
       
   484 	@$(SCCS-trouble)
       
   485 %:: SCCS/s.%
       
   486 	@$(SCCS-trouble)
       
   487 	@$(ECHO) "         is out of date with respect to its SCCS file." >> $(WARNING_FILE)
       
   488 	@$(ECHO) "         This file may be from an unresolved Teamware conflict." >> $(WARNING_FILE)
       
   489 	@$(ECHO) "         This is also a symptom of a Teamware bringover/putback failure" >> $(WARNING_FILE)
       
   490 	@$(ECHO) "         in which SCCS files are updated but not checked out." >> $(WARNING_FILE)
       
   491 	@$(ECHO) "         Check for other out of date files in your workspace." >> $(WARNING_FILE)
       
   492 	@$(ECHO) "" >> $(WARNING_FILE)
       
   493 	@#exit 666
       
   494 
       
   495 ifdef INSANE
   375 ifdef INSANE
   496   export INSANE
   376   export INSANE
   497 endif
   377 endif
   498 
   378 
   499 ifdef ALT_COPYRIGHT_YEAR
   379 # Make sure we have the current year
   500   COPYRIGHT_YEAR = $(ALT_COPYRIGHT_YEAR)
   380 ifndef COPYRIGHT_YEAR
   501 else
   381   ifdef ALT_COPYRIGHT_YEAR
   502   COPYRIGHT_YEAR = $(shell $(DATE) '+%Y')
   382     COPYRIGHT_YEAR := $(ALT_COPYRIGHT_YEAR)
       
   383   else
       
   384     COPYRIGHT_YEAR := $(shell $(DATE) '+%Y')
       
   385   endif
       
   386   export COPYRIGHT_YEAR
   503 endif
   387 endif
   504 
   388 
   505 # Install of imported file (JDK_IMPORT_PATH, or some other external location)
   389 # Install of imported file (JDK_IMPORT_PATH, or some other external location)
   506 define install-import-file
   390 define install-import-file
   507 @$(ECHO) "ASSEMBLY_IMPORT: $@"
   391 @$(ECHO) "ASSEMBLY_IMPORT: $@"