# This make file is designed primarily to assist in the building of the target, # EpsgToAsc.exe in this case, from scratch in an "installation" environment. # The secondary objective of the design is to minimize the maintenance # requirements of achieving the primary objective. Thus, coding of a # comprehensive map of interdependencies between files is deliberately # avoided. # # Thus, one should _NOT_ expect this make file to compile only the # specific modules you might have changed in a development/debug # environment. Such may happen, and you may be thankful; but do _NOT_ # rely on this. Fortunately, build times on current Linux systems are # so small I suspect you will probably never consider the build to # be overly inefficient. # # Note that by simply adding files with the appropriate extensions to # the appropriate directories, automatically includes them in the # make process. Removing files from specific directories has the same # affect. To achieve this objective, certain files in particular are # specifically noted and referenced in this make file and removed from the # construction of the library. Your maintenance/development activities may # require you to add a module name to these lists. # # This make file was been written with the EXPRESS requirement that it # exists in the "CsMapDev/EspgToAsc/Source" directory and that directory is the # current working directory of the make executable which is processing it; with # the original intent being that this makefile would be invoked by a higher # level make file which executes something like the following: # # $(MAKE) -C./Source -fEpsgToAscLib.mak # # Set up the environment in which we will build, before we define any targets. # PRJ_NAME = EpsgToAsc TRG_BASE = EpsgToAsc TRG_EXT = .a TRG_NAME = $(TRG_BASE)$(TRG_EXT) # # Set the following default values using the ?= assignment operator. This # operator causes an assignment only if the variable is not already defined. # My current gcc compiler is version 4.7.4, so I set the VERSION argument # to 47. # VERSION ?= 47 CONFIGURATION ?= Linux PROCESSOR ?= x64 # # CSMAP_MAINS is set to a list of source modules known to contain "main" # functions, and therefore are inappropriate for inclusion in the library. # These names are filtered out before the make process starts. # CSMAP_MAINS = EpsgToAsc.cpp # # CSMAP_STDHDRS is set to a list of source modules which exist primarily for # generation of pre-compiled headers when using the Microsoft Visual Studio # IDE. We do not need to consider them for this Linux/Unix/Mac library. # CSMAP_STDHDRS = stubs.cpp # # The following definitions are instituted to facilitate building multiple # versions of the Library. The variables referenced by these definitions # are expected to be passed from a parent makefile. # OUT_DIR ?= ../../lib$(VERSION)/$(CONFIGURATION) INT_DIR ?= ../../obj$(VERSION)/$(PRJ_NAME)/$(CONFIGURATION) SRC_DIR ?= $(MAKEDIR) C_FLG ?= -c -w -O2 -I ../Include CXX_FLG ?= -c -w -O2 -I ../Include LCL_C_FLG = $(C_FLG) -I ../../Include LCL_CXX_FLG = $(CXX_FLG) -I ../../Include ifeq ($(PROCESSOR),x64) OUT_DIR := $(OUT_DIR)64 INT_DIR := $(INT_DIR)64 LCL_C_FLG += -m64 -fPIC LCL_CXX_FLG += -m64 -fPIC endif ifeq ($(PROCESSOR),x86) OUT_DIR := $(OUT_DIR)32 INT_DIR := $(INT_DIR)32 endif # # The -o option on the compiler is used to get the objects written to the # directory specified by the INT_DIR variable. Doing so enables building # libraries for different configurations without an implied clean of # configuration(s) already built. I suspect that it also means that the # compilations will not be batched and a new instance of the compiler is # invoked for each module. Slows us down a bit, but overall helps preserve # sanity when trying to build multiple configurations of the library from a # single set of source files, which is a major objective of this make file. # # Rule to compile the individual .c and .cpp modules. The individual object # file end up in the $(INT_DIR) directory, which is distinct for each of the # $(VERSION), $(CONFIGURATION), and $(PROCESSOR) specifications. $(INT_DIR)/%.o:$(SRC_DIR)%.cpp $(CXX) $(LCL_CXX_FLG) -o$(INT_DIR)/$(<:.cpp=.o) $< # Note that the following causes all .c and .cpp files in the Source # directory to be included in the EpsgToAsc.lib target. This is often helpful, # sometimes painful. In some cases, the features used may not be available # in your make implementation. So, in case this is undesirable or does not # work, a variable which lists all current distribution sources is coded # below, with a different name. OsGeo contributors must make sure this # listing remains current even though it may not be used in your # environment. Note that object modules not intended for the basic library # are filtered out. # CSMAP_CPP_SRC := $(wildcard *.cpp) CSMAP_CPP_SRC := $(filter-out $(CSMAP_MAINS),$(CSMAP_CPP_SRC)) CSMAP_CPP_SRC := $(filter-out $(CSMAP_STDHDRS),$(CSMAP_CPP_SRC)) # List of source module whose object code is to be added to the EpsgToAsc.a library CSMAP_SRC_CPP = crsDefToAsc.cpp \ csEpsgToAsc.cpp \ csToNmMap.cpp \ dtmDefToAsc.cpp \ dtToNmMap.cpp \ elpDefToAsc.cpp \ elToNmMap.cpp \ gxfDefToAsc.cpp # The following two assignments, one of which MUST BE commented out, essentially # select the mode of operation for this make file. CSMAP_LIB_SRC += $(CSMAP_CPP_SRC) #CSMAP_LIB_SRC = $(CSMAP_SRC_CPP) # From the source list, generate an equivalent list of objects with the # desired intermediate directory prefix. This directs the object to distinct # directories based on version, configuration, and processor; thus leaving # the SOURCE directory clean. CSMAP_LIB_OBJ := $(patsubst %.cpp,%.o,$(CSMAP_LIB_SRC)) CSMAP_LIB_OBJ := $(addprefix $(INT_DIR)/,$(CSMAP_LIB_OBJ)) # OK, we should now be able to do some real work. This is rather simple now. # Rule to actually generate the EpsgToAsc.a library in the $(OUT_DIR) directory # which should cause the "compile source to object" rkle defined above to # generate all the objects referenced in $(CSMAP_LIB_OBJ). $(OUT_DIR)/$(TRG_NAME) : $(CSMAP_LIB_OBJ) ar rv $(OUT_DIR)/$(TRG_NAME) $? .PHONY : clean clean : rm -f $(INT_DIR)/*.o rm -f $(OUT_DIR)/$(TRG_NAME) .PHONY : rebuild rebuild: clean $(OUT_DIR)/$(TRG_NAME) # # The following rules create the directories in which the results are to be # written if they don't already exist. The -p option on the 'mkdir' # command creates all intermediate directories as well; and also inhibits # an error condition of they already exist. # $(CSMAP_LIB_OBJ) : | $(INT_DIR) $(OUT_DIR)/$(TRG_NAME) : | $(OUT_DIR) $(INT_DIR) : mkdir -p $(INT_DIR) $(OUT_DIR) : mkdir -p $(OUT_DIR)