1 ################################################################################
3 # Author: Artur Szostak
4 # Email: artur@alice.phy.uct.ac.za | artursz@iafrica.com
6 ################################################################################
8 # Set the platform variable if not yet set.
10 PLATFORM = $(shell uname)
13 # Get verison numbers.
14 MAJOR_VERSION = $(shell cat $(SRC_DIR)/Version/major.number)
15 MINOR_VERSION = $(shell cat $(SRC_DIR)/Version/minor.number)
18 .SUFFIXES: .cxx .hpp .h .o .d
20 # Set the module name, i.e. the name of the executable / library.
22 MODULE_NAME = $(BINARY)
26 MODULE_NAME = $(LIBRARY)
29 ################################################################################
32 TOP_DIR = $(shell pwd)
33 BIN_DIR = $(TOP_DIR)/bin
34 LIB_DIR = $(TOP_DIR)/lib
35 INCLUDE_DIR = $(TOP_DIR)/include
36 OUTPUT_DIR = $(TOP_DIR)/output
37 BUILD_DIR = $(TOP_DIR)/build
38 MACRO_DIR = $(TOP_DIR)/macros
39 SRC_DIR = $(TOP_DIR)/src
41 # The base target directories.
42 BIN_TARGET_DIR = $(BIN_DIR)/$(PLATFORM)
43 LIB_TARGET_DIR = $(LIB_DIR)/$(PLATFORM)
44 OUTPUT_TARGET_DIR = $(OUTPUT_DIR)/$(MODULE_NAME)/$(PLATFORM)
46 # The list of source code sub directory names.
47 SRC_SUBDIR_NAMES = AliRoot Buffers Clustering Control Decision PubSub PipeIO \
48 Tracking Version System System/Linux System/Win32 Debug Framework DDL \
51 # Create full source and target directory names.
52 SRC_SUBDIRS = $(addprefix $(SRC_DIR)/,$(SRC_SUBDIR_NAMES))
53 OUTPUT_TARGET_SUBDIRS = $(addprefix $(OUTPUT_TARGET_DIR)/,$(SRC_SUBDIR_NAMES))
55 # Setup the distribution file name and directory structure.
56 DISTRIBUTION_DIRNAME = dHLT_v$(MAJOR_VERSION)-$(MINOR_VERSION)
57 DISTRIBUTION_DIR = $(OUTPUT_DIR)/distrib/$(PLATFORM)
58 DISTRIBUTION_SUBDIR = $(DISTRIBUTION_DIR)/$(DISTRIBUTION_DIRNAME)
60 ################################################################################
62 # Set the target name, symbolic link and full distribution directory paths.
64 TARGET_NAME = $(BIN_TARGET_DIR)/$(BINARY)$(BIN_EXT)
65 SYMLINK_NAME = $(BIN_DIR)/$(BINARY)$(BIN_EXT)
66 DISTRIBUTION_TARGET_DIR = $(DISTRIBUTION_SUBDIR)/bin
70 TARGET_NAME = $(LIB_TARGET_DIR)/$(LIB_PREFIX)$(LIBRARY)$(LIB_EXT)
71 SYMLINK_NAME = $(LIB_DIR)/$(LIB_PREFIX)$(LIBRARY)$(LIB_EXT)
72 DISTRIBUTION_TARGET_DIR = $(DISTRIBUTION_SUBDIR)/lib
75 ################################################################################
77 include $(BUILD_DIR)/$(PLATFORM).platform.mk
79 ################################################################################
81 # If we want a verbose build then all the actuall commands that are executed
82 # are printed to screen.
89 ################################################################################
90 # Setup the CXXFLAGS compiler flags and LINKFLAGS for the linker.
93 CXXFLAGS = $(INCLUDES) $(MACROS) $(BINARY_CXXFLAGS)
94 LINKFLAGS = $(BINARY_CXXFLAGS) $(LIBRARY_PATHS) $(LIBRARIES)
98 CXXFLAGS = $(INCLUDES) $(MACROS) $(LIBRARY_CXXFLAGS)
99 LINKFLAGS = $(LIBRARY_CXXFLAGS) $(LIBRARY_PATHS) $(LIBRARIES)
104 CXXFLAGS += $(CXX_DEBUG)
105 LINKFLAGS += $(CXX_DEBUG)
106 BIN_TARGET_DIR := $(BIN_TARGET_DIR)-debug
107 LIB_TARGET_DIR := $(LIB_TARGET_DIR)-debug
108 OUTPUT_TARGET_DIR := $(OUTPUT_TARGET_DIR)-debug
109 DISTRIBUTION_FILE = dHLT_$(PLATFORM)-debug_v$(MAJOR_VERSION)-$(MINOR_VERSION).tar.gz
111 CXXFLAGS += $(OPTIMIZATION)
112 LINKFLAGS += $(OPTIMIZATION)
113 DISTRIBUTION_FILE = dHLT_$(PLATFORM)_v$(MAJOR_VERSION)-$(MINOR_VERSION).tar.gz
116 ################################################################################
118 # Create a list of headers from the source file list.
119 HEADERS := $(SOURCES:.cxx=.hpp)
121 ifndef DICTIONARY_HEADERS
122 DICTIONARY_HEADERS = $(HEADERS)
125 # Add the dictionary file without adding its header to the HEADERS list.
127 SOURCES += $(DICTIONARY)
130 # Create a list of object .o and dependancy .d files from the list of source files.
131 OBJECTS = $(addprefix $(OUTPUT_TARGET_DIR)/,$(SOURCES:.cxx=.o))
132 DEPENDS = $(addprefix $(OUTPUT_TARGET_DIR)/,$(SOURCES:.cxx=.d))
134 # Make the includes search paths from the source directory and the output
136 INCLUDES += $(SRC_DIR) $(OUTPUT_TARGET_DIR)
138 # The library path should also contain the lib sub directory.
139 LIBRARY_PATHS += $(LIB_TARGET_DIR)
141 # Add compiler specific flag prefices:
142 INCLUDES := $(addprefix $(INCLUDE_PREFIX),$(INCLUDES))
143 MACROS := $(addprefix $(MACRO_PREFIX),$(MACROS))
144 LIBRARIES := $(addprefix $(LIBRARY_PREFIX),$(LIBRARIES))
145 LIBRARY_PATHS := $(addprefix $(LIBPATH_PREFIX),$(LIBRARY_PATHS))
147 ################################################################################
148 # Tell make where to find source files.
149 # Note: this must come after the OUTPUT_TARGET_DIR is appended with -debug
150 vpath %.cxx $(SRC_DIR) $(SRC_SUBDIRS) $(OUTPUT_TARGET_DIR) $(OUTPUT_TARGET_SUBDIRS)
151 vpath %.hpp $(SRC_DIR) $(SRC_SUBDIRS) $(OUTPUT_TARGET_DIR) $(OUTPUT_TARGET_SUBDIRS)
152 vpath %.h $(SRC_DIR) $(SRC_SUBDIRS) $(OUTPUT_TARGET_DIR) $(OUTPUT_TARGET_SUBDIRS)
153 vpath %.number $(SRC_DIR)/Version $(OUTPUT_TARGET_DIR)