# #! # @file support/MakeRules # # @brief Rules for building targets # # @see @link ./Makefile ./Makefile@endlink # # @see @link support/MakeSetup support/MakeSetup@endlink # # # @section Control # # \$URL$ # # \$Id$ # # Copyright 2005 The Apache Software Foundation # or its licensors, as applicable. # # Licensed under the Apache License, Version 2.0 ("the License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, # either express or implied. # # See the License for the specific language governing permissions # and limitations under the License. # # @version \$LastChangedRevision$ # # @date \$LastChangedDate$ # # @author \$LastChangedBy$ # # @section Reference # #/ /* # (Use #! and #/ with dox-filter.sh to fool Doxygen into # parsing this non-source text file for the documentation set. # Use the above open comment to force termination of parsing # since it is not a Doxygen-style 'C' comment.) # # ################################################################### # # Makefile sources, objects, and targets # # Generic copyright message reference (C pgms use 'jvm/include/arch.h') ARCH_COPYRIGHT_TEXT_APACHE=\ "Copyright 2005 The Apache Software Foundation or its licensors, as applicable." ######################## # # File extensions # C_SOURCE=c C_OBJECT=o AR_ARCHIVE=a # (Only needed for MS binaries, namely '.exe') DOT_BIN_EXTENSION= JAVA_SOURCE=java JAVA_CLASS=class JAVA_ARCHIVE=jar ######################## # # Rule verbosity # # Permit C compilation to be silent except errors with '@' CC_SILENT=@ #CC_SILENT= # Permit Java compilation to be silent except errors with '@' JAVAC_SILENT=@ #JAVAC_SILENT= # Permit 'clean' rules to be silent except errors with '@' CLEAN_SILENT=@ #CLEAN_SILENT= ######################## # # Select C compiler based on configuration, defaulting # to CONFIG_CCOMPILER_OTHER # ifdef CONFIG_CCOMPILER_GCC ######################## # # Configured to use GNU 'C' compiler and 'bintools' # CC=gcc AR=ar CFLAGS:=-m$(CONFIG_WORDWIDTH) -O0 -g3 -Wall -fmessage-length=0 -ansi LFLAGS=-m$(CONFIG_WORDWIDTH) -lpthread -lm -L$(TOPDIR)/libjvm/lib ARCMD=r else ######################## # # Default to GNU 'C' compiler and 'bintools' # CC=gcc AR=ar CFLAGS:=-m$(CONFIG_WORDWIDTH) -O0 -g3 -Wall -fmessage-length=0 -ansi LFLAGS=-m$(CONFIG_WORDWIDTH) -lpthread -lm -L$(TOPDIR)/libjvm/lib ARCMD=r endif ######################## # # Java compiler and archiver # JAVAC=$(JAVA_HOME)/bin/javac JAR=$(JAVA_HOME)/bin/jar JFLAGS=-g -sourcepath .:$(TOPDIR) -d $(CLSDIR) # No compression so archive is readable by 'getsvndata.sh' JARFLAGS=0 JARCMD=-cf$(JARFLAGS) ######################## # # Compendium of all include paths # STD_INCLUDE_PATHS= -I../include -I$(TOPDIR)/config \ -I$(TOPDIR)/jvm/include \ $(JAVA_INCLUDE_PATHS) INCLUDES:= \ $(PRE_INCLUDE_PATHS) \ $(STD_INCLUDE_PATHS) \ $(POST_INCLUDE_PATHS) ################################################################### # # Utility rules # ######################## # # Start 'C' utility rules with empty rule. # Do nothing for these rules unless 'C' sources are defined. # If defined, additional actions are also defined. # # If 'makedepend' is in the $PATH, then HAVE_MAKEDEPEND will be 1. # If 'ctags' is in the $PATH, then HAVE_CTAGS will be 1. # If either of these utilities is missing, then invocation of # these rules will produce no actions. # depend:: nodepend:: tags:: ######################## # # Create header file dependency list. # Notice that the $(DEPEND_FILE) file cannot # reside in $(BINDIR) or $(LIBDIR) since # some directories have targets in both, # thus making this file's proper location # ambiguous. Therefore, leave it in the # _same_ directory as its invoking Makefile. # DEPEND_FILE=.depend ifneq (,$(BIN_TARGET)) DEPDIR=$(BINDIR) endif ifneq (,$(LIB_TARGET)) DEPDIR=$(LIBDIR) endif TOUCHDEPEND=touch $(DEPEND_FILE) MAKEDEPEND:=makedepend -f$(DEPEND_FILE) $(INCLUDES) -p$(DEPDIR)/ \ $(C_SOURCES) ######################## # # Build 'C' source and header file tags for 'vi'. # Other editor utilties are welcome here, but # please _add_ to this function, do not replace it. # # Note: 'tags' is the default tag file name for 'ctags' # CTAGS=ctags CTAGS_FILE=tags ######################## # # Start of additional definitions when 'C' sources are defined # There will be a corresponding end of block later. # ifneq (,$(C_SOURCES)) ######################## # # Unconditionally build dependencies for directories with 'C' sources. # Ignore request for other directory types. Also ignore request when # 'makedepend' is not found in $PATH. # ifeq (1,$(HAVE_MAKEDEPEND)) depend:: $(CC_SILENT)$(TOUCHDEPEND) $(CC_SILENT)-$(MAKEDEPEND) endif # Permit removal of dependency file regardless of whether or not # 'makedepend' is found in $PATH. Some versions generate a '.bak; # also, so get rid of it, too. nodepend:: $(CC_SILENT)rm -f $(DEPEND_FILE) $(DEPEND_FILE).bak # If a dependency file exists anyway, reference it -include $(DEPEND_FILE) ######################## # # Unconditionally build editor tag file $(CTAGS_FILE). # Do not build it if 'ctags' is not found in $PATH. # ifeq (1,$(HAVE_CTAGS)) tags:: $(CC_SILENT)-$(CTAGS) -f $(CTAGS_FILE) $(C_SOURCES) $(C_HEADERS) endif ######################## # # Automatically build dependencies if not present # all:: ifeq (,$(wildcard $(DEPEND_FILE))) ifeq (1,$(HAVE_MAKEDEPEND)) $(CC_SILENT)@$(TOUCHDEPEND) $(CC_SILENT)@-$(MAKEDEPEND) endif # HAVE_MAKEDEPEND endif # DEPEND_FILE ######################## # # End of additional definitions when 'C' sources are defined. # endif # C_SOURCES clean veryclean:: $(CLEAN_SILENT)rm -f core \ $(DEPEND_FILE) $(DEPEND_FILE).bak core \ $(CTAGS_FILE) ################################################################### # # Compilation rules # ######################## # # Compile classes for a Java archive-- yes, I know about 'ant'. # # Send classes to a lib sub-directory, while result # goes to bin directory. # # Put these rules ahead of 'lib' rules so 'clean' operates # on $(CLSDIR) ahead of 'lib' rules, being a 'lib' subdirectory. # ifneq (,$(JAR_TARGET)) ifneq (,$(JAVA_SOURCES)) JAVA_CLASSES:=$(patsubst %.$(JAVA_SOURCE),%.$(JAVA_CLASS),$(JAVA_SOURCES)) JAVA_CLASSES:=$(patsubst %,$(CLSDIR)/%,$(JAVA_CLASSES)) # Java archive target depends on Java sources $(JAR_TARGET):: $(JAVA_SOURCES) # # Compile Java source into Java classes, then on into a Java archive. # For incremental compile, let Java compiler decide which class files # are up to date or not. # $(JAR_TARGET):: $(JAVA_SOURCES) #ifeq (,$(wildcard $(LIBDIR))) @if test ! -d $(LIBDIR); then mkdir $(LIBDIR); fi #endif #ifeq (,$(wildcard $(CLSDIR))) @if test ! -d $(CLSDIR); then mkdir $(CLSDIR); fi #endif $(JAVAC_SILENT)$(JAVAC) $(JFLAGS) $(JJFLAGS) $^ #ifeq (,$(wildcard $(BINDIR))) @if test ! -d $(BINDIR); then mkdir $(BINDIR); fi #endif $(JAVAC_SILENT)$(JAR) $(JARCMD) $@ -C $(CLSDIR) . # Assume that 'rmdir' works on an empty directory-- there should # _never_ be anything there that 'make' did not put there. # Remove $(CLSDIR) subdirectories by deepest first. # (Be just a _bit_ lazy and not recursively 'rmdir' up to the # top, but do 'rm -rf' of any leftover intermediate directories.) clean:: $(CLEAN_SILENT)rm -f $(JAVA_CLASSES) $(JAR_TARGET) @-rmdir `(for d in $(sort $(dir $(JAVA_CLASSES))); do \ echo $$d; done) | sort -ru` $(CLEAN_SILENT)rm -rf $(CLSDIR)/* $(CLEAN_SILENT)-rmdir $(CLSDIR) $(CLEAN_SILENT)-rmdir $(LIBDIR) $(CLEAN_SILENT)-rmdir $(BINDIR) veryclean:: $(CLEAN_SILENT)for d in $(CLSDIR) $(LIBDIR) $(BINDIR); \ do if test -d $$d/.; then chmod -R +w $$d; fi; done $(CLEAN_SILENT)-rm -rf $(CLSDIR) $(LIBDIR) $(BINDIR) endif # JAVA_SOURCES endif # JAR_TARGET ######################## # # Enable 'bin' rules when BIN_TARGET specified # ifneq (,$(BIN_TARGET)) ifneq (,$(C_SOURCES)) BIN_OBJECTS:=$(patsubst %.$(C_SOURCE),$(BINDIR)/%.$(C_OBJECT),$(C_SOURCES)) ifneq (,$(wildcard main.$(C_SOURCE))) BIN_OBJECTS+=$(BINDIR)/main.$(C_OBJECT) endif # # Compile sources into linkable objects # $(BINDIR)/%.$(C_OBJECT):: %.$(C_SOURCE) #ifeq (,$(wildcard $(BINDIR))) @if test ! -d $(BINDIR); then mkdir $(BINDIR); fi #endif $(CC_SILENT)$(CC) $(CFLAGS) $(INCLUDES) -o $@ -c $< # # Link objects into executable binary # $(BIN_TARGET):: $(BIN_OBJECTS) $(CC_SILENT)$(CC) $^ -o $@ $(LFLAGS) $(LLFLAGS) endif # C_SOURCES # Assume that 'rmdir' works on an empty directory-- there should # _never_ be anything there that 'make' did not put there. clean:: ifneq (,$(wildcard main.$(C_SOURCE))) $(CLEAN_SILENT)rm -f $(BINDIR)/main.$(C_OBJECT) endif $(CLEAN_SILENT)rm -f $(BIN_OBJECTS) $(BIN_TARGET) @rm -rf $(ECLIPSE_BINDIR) $(CLEAN_SILENT)-rmdir $(BINDIR) veryclean:: $(CLEAN_SILENT)if test -d $(BINDIR); then chmod -R +w $(BINDIR); fi $(CLEAN_SILENT)-rm -rf $(BINDIR) endif # BIN_TARGET ######################## # # Enable 'lib' rules when LIB_TARGET specified # ifneq (,$(LIB_TARGET)) LIB_OBJECTS=$(patsubst %.$(C_SOURCE),$(LIBDIR)/%.$(C_OBJECT),$(C_SOURCES)) # # Compile sources into archivable objects # $(LIBDIR)/%.$(C_OBJECT): %.$(C_SOURCE) #ifeq (,$(wildcard $(LIBDIR))) @if test ! -d $(LIBDIR); then mkdir $(LIBDIR); fi #endif $(CC_SILENT)$(CC) $(CFLAGS) $(INCLUDES) -o $@ -c $< # # Archive objects into linkable static library archive # $(LIB_TARGET): $(LIB_OBJECTS) $(CC_SILENT)$(AR) $(ARCMD) $@ $^ # Assume that 'rmdir' works on an empty directory-- there should # _never_ be anything there that 'make' did not put there. clean:: $(CLEAN_SILENT)rm -f $(LIB_OBJECTS) $(LIB_TARGET) @rm -rf $(ECLIPSE_LIBDIR) $(CLEAN_SILENT)-rmdir $(LIBDIR) veryclean:: $(CLEAN_SILENT)if test -d $(LIBDIR); then chmod -R +w $(LIBDIR); fi $(CLEAN_SILENT)-rm -rf $(LIBDIR) endif # LIB_TARGET ######################## # # Rules that really only operate at the top level, # placed at other levels for convenience. # roster doc dox undox:: $(MAKE) -C $(TOPDIR) $@ ################################################################### # # EOF