1 ############################################################################
3 # Author: Artur Szostak
4 # Email: artur@alice.phy.uct.ac.za | artursz@iafrica.com
6 ############################################################################
8 # Implementation of make rules that are common to all modules.
10 .PHONY : all depend create-distrib symlink
12 all : $(TARGET_NAME) symlink $(addprefix $(INCLUDE_DIR)/,$(INCLUDE_HEADERS))
15 @mkdir -p $(DISTRIBUTION_TARGET_DIR)
16 $(VERBOSE) cp $(TARGET_NAME) $(DISTRIBUTION_TARGET_DIR)/
20 symlink : $(SYMLINK_NAME)
22 ############################################################################
24 $(TARGET_NAME) : $(OBJECTS)
25 # Create the output directory if it is missing
28 @echo -------------------------------------------------------------------------------
30 @echo "linking $(^F) => $(@F)"
32 $(VERBOSE) $(CXX) $(LINKFLAGS) $^ -o $@
35 ############################################################################
39 # The following file must be generated for rootcint. Refer to the comment
40 # where the command is used.
41 $(OUTPUT_TARGET_DIR)/dummy.h :
45 # Note the -p, +P, -P options makes rootcint use the real C++ preprocessor
46 # to preprocess the headers.
47 $(OUTPUT_TARGET_DIR)/$(DICTIONARY) : $(DICTIONARY_HEADERS) $(STUB_HEADERS) $(LINKDEF) $(OUTPUT_TARGET_DIR)/dummy.h
48 # Create the output directory if it is missing
51 @echo "generating $(@F)"
53 # $(VERBOSE) rootcint -f $@ -c $(INCLUDES) $(MACROS) -p +STUB $(STUB_HEADERS) -STUB $(DICTIONARY_HEADERS) $(LINKDEF)
54 # Since rootcint contains a bug and does not allow one to use -p with the
55 # (+/-)STUB option but does allow (+/-)P combinations we need to run the
56 # command as given bellow. Note the dummy file is there since rootcint
57 # requires at least one file before the +P or +STUB options.
58 $(VERBOSE) rootcint -f $@ -c $(INCLUDES) $(MACROS) $(OUTPUT_TARGET_DIR)/dummy.h +P +STUB $(STUB_HEADERS) -STUB $(DICTIONARY_HEADERS) -P $(LINKDEF)
63 ############################################################################
65 $(OUTPUT_TARGET_DIR)/%.d : %.cxx
66 # Create the output directory if it is missing
69 @echo "making dependancies $(<F) => $(@F)"
71 # Note the sed command replaces the target xx.o with xx.o xx.d
72 $(VERBOSE) $(CXX) $(CXXFLAGS) -MM $< | \
73 sed "s/\(.*\)\.o/$(subst /,\/,$(@D)/)\1\.o $(subst /,\/,$(@D)/)\1\.d/g" > $@
75 ############################################################################
77 $(OUTPUT_TARGET_DIR)/%.o : %.cxx
78 # Create the output directory if it is missing
81 @echo "compiling $(<F) => $(@F)"
83 $(VERBOSE) $(CXX) $(CXXFLAGS) -c $< -o $@
85 ############################################################################
87 $(INCLUDE_DIR)/%.hpp : %.hpp
88 # Create the output directory if it is missing
91 @echo "copying header $(@F) to include directory."
95 ############################################################################
97 $(SYMLINK_NAME) : $(TARGET_NAME)
98 # Create the output directory if it is missing
101 @echo "creating symbolic link to $<"
104 $(VERBOSE) ln -s $< $@
106 ############################################################################
108 incbuild : $(OUTPUT_TARGET_DIR)/build.number
110 @echo Incrementing build version number for $(TARGET_NAME).
112 $(VERBOSE) let NUM=`cat $<`+1 && echo $$NUM > $<
114 $(OUTPUT_TARGET_DIR)/build.number :
118 ############################################################################
120 $(SRC_DIR)/Version/Version.cxx : $(OUTPUT_TARGET_DIR)/VersionNumbers.hpp
122 $(OUTPUT_TARGET_DIR)/VersionNumbers.hpp : major.number minor.number $(OUTPUT_TARGET_DIR)/build.number
124 @echo Generating $(@F)
126 $(VERBOSE) echo // This file was generated with \"rules.mk\". Do not modify. > $@
127 $(VERBOSE) echo \#define MAJOR_VERSION `cat $(word 1,$^)` >> $@
128 $(VERBOSE) echo \#define MINOR_VERSION `cat $(word 2,$^)` >> $@
129 $(VERBOSE) echo \#define BUILD_NUMBER `cat $(word 3,$^)` >> $@
131 ############################################################################
133 ifneq ($(findstring clean, $(MAKECMDGOALS)), clean)