--- makefile.orig 2019-08-29 18:03:23 UTC +++ makefile @@ -7,23 +7,32 @@ # # Constants -CXX=g++ +# Default to g++ if not set by make args or environment +CXX?=g++ #-O0 -g will turn on debugging #The rule of thumb: #When you need to debug, use -O0 (and -g to generate debugging symbols.) #When you are preparing to ship it, use -O2. #When you use gentoo, use -O3...! #When you need to put it on an embedded system, use -Os (optimize for size, not for efficiency.) -CXX_FLAGS=-Wall -g -stdlib=libstdc++ +# Use canonincal compiler variables, which may be provided by build env +CXXFLAGS?=-Wall -g -stdlib=libstdc++ SRC=src CONF=conf HMM_SRC=$(SRC)/hmm UTIL_SRC=$(SRC)/util -BOOST=/usr/local/boost_1_52_0 +BOOST?=/usr/local/boost_1_52_0 INCLUDES=-I./$(SRC) -I./$(HMM_SRC) -I./$(UTIL_SRC) -isystem$(BOOST) -LIBRARY_PATHS=-Llib/macosx +LIBRARY_PATHS?=-Llib/macosx LIBRARIES=-lm -lboost_program_options -lboost_system -lboost_filesystem -lboost_thread +# Installation target with destdir support +DESTDIR?=. +PREFIX?=/usr/local +MKDIR?=mkdir +INSTALL?=install +STRIP?= # empty, set to -s to install stripped binary + # Generated directories which are generated in this script and cleaned up with 'make clean' BUILD=build OBJ=$(BUILD)/obj @@ -35,18 +44,21 @@ directories: # Create object files into the OBJ directory from cpp files in the SRC directory. $(OBJ)/%.o: $(SRC)/%.cpp directories - $(CXX) $(CXX_FLAGS) $(INCLUDES) -c -o $@ $< + $(CXX) $(CXXFLAGS) $(INCLUDES) -c -o $@ $< $(OBJ)/%.o: $(HMM_SRC)/%.cpp directories - $(CXX) $(CXX_FLAGS) $(INCLUDES) -c -o $@ $< + $(CXX) $(CXXFLAGS) $(INCLUDES) -c -o $@ $< $(OBJ)/%.o: $(UTIL_SRC)/%.cpp directories - $(CXX) $(CXX_FLAGS) $(INCLUDES) -c -o $@ $< + $(CXX) $(CXXFLAGS) $(INCLUDES) -c -o $@ $< -all: clean haplohseq +all: haplohseq test haplohseq: $(OBJ)/Hmm.o $(OBJ)/DataStructures.o $(OBJ)/MathUtil.o $(OBJ)/StringUtil.o $(OBJ)/InputProcessor.o $(OBJ)/Reporter.o $(OBJ)/FreqPhase.o $(OBJ)/VcfUtil.o $(OBJ)/HaplohSeq.o - $(CXX) -o $(BIN)/$@ $(CXX_FLAGS) $(INCLUDES) $(OBJ)/Hmm.o $(OBJ)/DataStructures.o $(OBJ)/MathUtil.o $(OBJ)/StringUtil.o $(OBJ)/InputProcessor.o $(OBJ)/Reporter.o $(OBJ)/FreqPhase.o $(OBJ)/VcfUtil.o $(OBJ)/HaplohSeq.o $(LIBRARY_PATHS) $(LIBRARIES) - cp -r $(CONF) $(BIN)/. - + $(CXX) -o $(BIN)/$@ $(CXXFLAGS) $(INCLUDES) $(OBJ)/Hmm.o $(OBJ)/DataStructures.o $(OBJ)/MathUtil.o $(OBJ)/StringUtil.o $(OBJ)/InputProcessor.o $(OBJ)/Reporter.o $(OBJ)/FreqPhase.o $(OBJ)/VcfUtil.o $(OBJ)/HaplohSeq.o $(LIBRARY_PATHS) $(LIBRARIES) $(LDFLAGS) + +install: + $(MKDIR) -p $(DESTDIR)$(PREFIX)/bin + $(INSTALL) -c $(STRIP) $(BIN)/* $(DESTDIR)$(PREFIX)/bin + clean: rm -rf $(BUILD) @@ -74,28 +86,28 @@ test: FreqPhaseTest HaplohSeqTest HmmTest InputProcess # Create test object files into the OBJ directory from cpp files in the SRC directory. $(TEST_BIN)/%.o: $(TEST_SRC)/%.cpp directories test_directory - $(CXX) $(CXX_FLAGS) $(INCLUDES) $(TEST_INCLUDES) -c -o $@ $< + $(CXX) $(CXXFLAGS) $(INCLUDES) $(TEST_INCLUDES) -c -o $@ $< HaplohSeqTest: $(OBJ)/Hmm.o $(OBJ)/DataStructures.o $(OBJ)/MathUtil.o $(OBJ)/StringUtil.o $(OBJ)/InputProcessor.o $(TEST_BIN)/HaplohSeqTest.o - $(CXX) -o $(TEST_BIN)/$@ $(CXX_FLAGS) $(OBJ)/Hmm.o $(OBJ)/DataStructures.o $(OBJ)/MathUtil.o $(OBJ)/StringUtil.o $(OBJ)/InputProcessor.o $(TEST_BIN)/HaplohSeqTest.o $(LIBRARY_PATHS) $(LIBRARIES) + $(CXX) -o $(TEST_BIN)/$@ $(CXXFLAGS) $(OBJ)/Hmm.o $(OBJ)/DataStructures.o $(OBJ)/MathUtil.o $(OBJ)/StringUtil.o $(OBJ)/InputProcessor.o $(TEST_BIN)/HaplohSeqTest.o $(LIBRARY_PATHS) $(LIBRARIES) $(LDFLAGS) FreqPhaseTest: $(OBJ)/StringUtil.o $(OBJ)/InputProcessor.o $(OBJ)/FreqPhase.o $(TEST_BIN)/FreqPhaseTest.o - $(CXX) -o $(TEST_BIN)/$@ $(CXX_FLAGS) $(OBJ)/StringUtil.o $(OBJ)/InputProcessor.o $(OBJ)/FreqPhase.o $(TEST_BIN)/FreqPhaseTest.o $(LIBRARY_PATHS) $(LIBRARIES) + $(CXX) -o $(TEST_BIN)/$@ $(CXXFLAGS) $(OBJ)/StringUtil.o $(OBJ)/InputProcessor.o $(OBJ)/FreqPhase.o $(TEST_BIN)/FreqPhaseTest.o $(LIBRARY_PATHS) $(LIBRARIES) $(LDFLAGS) HmmTest: $(OBJ)/Hmm.o $(OBJ)/DataStructures.o $(OBJ)/MathUtil.o $(OBJ)/StringUtil.o $(TEST_BIN)/HmmTest.o - $(CXX) -o $(TEST_BIN)/$@ $(CXX_FLAGS) $(OBJ)/Hmm.o $(OBJ)/DataStructures.o $(OBJ)/MathUtil.o $(OBJ)/StringUtil.o $(TEST_BIN)/HmmTest.o $(LIBRARY_PATHS) $(LIBRARIES) + $(CXX) -o $(TEST_BIN)/$@ $(CXXFLAGS) $(OBJ)/Hmm.o $(OBJ)/DataStructures.o $(OBJ)/MathUtil.o $(OBJ)/StringUtil.o $(TEST_BIN)/HmmTest.o $(LIBRARY_PATHS) $(LIBRARIES) $(LDFLAGS) InputProcessorTest: $(OBJ)/Hmm.o $(OBJ)/DataStructures.o $(OBJ)/MathUtil.o $(OBJ)/StringUtil.o $(OBJ)/InputProcessor.o $(TEST_BIN)/InputProcessorTest.o - $(CXX) -o $(TEST_BIN)/$@ $(CXX_FLAGS) $(OBJ)/Hmm.o $(OBJ)/DataStructures.o $(OBJ)/MathUtil.o $(OBJ)/StringUtil.o $(OBJ)/InputProcessor.o $(TEST_BIN)/InputProcessorTest.o $(LIBRARY_PATHS) $(LIBRARIES) + $(CXX) -o $(TEST_BIN)/$@ $(CXXFLAGS) $(OBJ)/Hmm.o $(OBJ)/DataStructures.o $(OBJ)/MathUtil.o $(OBJ)/StringUtil.o $(OBJ)/InputProcessor.o $(TEST_BIN)/InputProcessorTest.o $(LIBRARY_PATHS) $(LIBRARIES) $(LDFLAGS) MathUtilTest: $(OBJ)/Hmm.o $(OBJ)/DataStructures.o $(OBJ)/MathUtil.o $(OBJ)/StringUtil.o $(TEST_BIN)/MathUtilTest.o - $(CXX) -o $(TEST_BIN)/$@ $(CXX_FLAGS) $(OBJ)/Hmm.o $(OBJ)/DataStructures.o $(OBJ)/MathUtil.o $(OBJ)/StringUtil.o $(TEST_BIN)/MathUtilTest.o $(LIBRARY_PATHS) $(LIBRARIES) + $(CXX) -o $(TEST_BIN)/$@ $(CXXFLAGS) $(OBJ)/Hmm.o $(OBJ)/DataStructures.o $(OBJ)/MathUtil.o $(OBJ)/StringUtil.o $(TEST_BIN)/MathUtilTest.o $(LIBRARY_PATHS) $(LIBRARIES) $(LDFLAGS) ReporterTest: $(OBJ)/Hmm.o $(OBJ)/DataStructures.o $(OBJ)/MathUtil.o $(OBJ)/StringUtil.o $(TEST_BIN)/ReporterTest.o - $(CXX) -o $(TEST_BIN)/$@ $(CXX_FLAGS) $(OBJ)/Hmm.o $(OBJ)/DataStructures.o $(OBJ)/MathUtil.o $(OBJ)/StringUtil.o $(TEST_BIN)/ReporterTest.o $(LIBRARY_PATHS) $(LIBRARIES) + $(CXX) -o $(TEST_BIN)/$@ $(CXXFLAGS) $(OBJ)/Hmm.o $(OBJ)/DataStructures.o $(OBJ)/MathUtil.o $(OBJ)/StringUtil.o $(TEST_BIN)/ReporterTest.o $(LIBRARY_PATHS) $(LIBRARIES) $(LDFLAGS) ThreadPoolTest: $(OBJ)/Hmm.o $(OBJ)/DataStructures.o $(OBJ)/MathUtil.o $(OBJ)/StringUtil.o $(OBJ)/ThreadPool.o $(TEST_BIN)/ThreadPoolTest.o - $(CXX) -o $(TEST_BIN)/$@ $(CXX_FLAGS) $(OBJ)/Hmm.o $(OBJ)/DataStructures.o $(OBJ)/MathUtil.o $(OBJ)/StringUtil.o $(OBJ)/ThreadPool.o $(TEST_BIN)/ThreadPoolTest.o $(LIBRARY_PATHS) $(LIBRARIES) + $(CXX) -o $(TEST_BIN)/$@ $(CXXFLAGS) $(OBJ)/Hmm.o $(OBJ)/DataStructures.o $(OBJ)/MathUtil.o $(OBJ)/StringUtil.o $(OBJ)/ThreadPool.o $(TEST_BIN)/ThreadPoolTest.o $(LIBRARY_PATHS) $(LIBRARIES) $(LDFLAGS) ############################## END TEST LOGIC ##############################