From 7ea5b3766509d0ea0e2374f82f4f419782860e69 Mon Sep 17 00:00:00 2001 From: Justin Lecher Date: Sat, 4 Mar 2017 19:13:09 +0000 Subject: [PATCH] Update buildsystem for better downstream packaging Properly use CXXFLAGS, CFLAGS, CPPFLAGS and CC. Signed-off-by: Justin Lecher --- Makefile | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/Makefile b/Makefile index 44fa872..3e1b7a5 100644 --- a/Makefile +++ b/Makefile @@ -10,24 +10,28 @@ SDIR := src ODIR := obj BDIR := bin +CC ?= gcc +CXX ?= g++ +CFLAGS ?= -Wall -O3 +CXXFLAGS ?= -Wall -O3 +CPPFLAGS ?= +LDFLAGS ?= + +CFLAGS += -MMD -MP -std=gnu99 +CXXFLAGS += -MMD -MP +LDFLAGS += -pthread + # Set up flags depending on mode ifdef USERMODE PROG := yaha -CCFLAGS := -Wall -O3 -D COMPILE_USER_MODE -D BUILDNUM=$(BUILDNUM) +CPPFLAGS += -D COMPILE_USER_MODE -D BUILDNUM=$(BUILDNUM) else PROG := yaha$(BUILDNUM) -CCFLAGS := -Wall -Winline -O3 -g -D BUILDNUM=$(BUILDNUM) +CPPFLAGS += -D BUILDNUM=$(BUILDNUM) +CFLAGS += -g +CXXFLAGS += -g endif -# Auto build dependency files. -CCFLAGS += -MMD -MP - -CC := gcc -CPP := g++ -CFLAGS := $(CCFLAGS) -std=gnu99 -CPPFLAGS := $(CCFLAGS) -LDFLAGS := -pthread - # The list of object files. OBJfiles := Main.o AlignArgs.o AlignHelpers.o AlignExtFrag.o AlignOutput.o BaseSeq.o Compress.o \ FileHelpers.o GraphPath.o Index.o Query.o QueryMatch.o QueryState.o SW.o Math.o @@ -45,7 +49,7 @@ $(BDIR): # Link the program $(BDIR)/$(PROG): $(OBJS) - $(CPP) $(LDFLAGS) -o $@ $(OBJS) + $(CXX) $(CXXFLAGS) $(LDFLAGS) -o $@ $(OBJS) # Include the dependencies. # The actual objects will be built by the below generic rules based on these dependencies. @@ -53,15 +57,14 @@ $(BDIR)/$(PROG): $(OBJS) -include $(OBJS:.o=.d) # Make the object files. -# The built in rules will miss the subdirectories. +# The built in rules will miss the subdirectories. $(ODIR)/%.o: $(SDIR)/%.c - $(CC) $(CFLAGS) -c $< -o $@ + $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@ $(ODIR)/%.o: $(SDIR)/%.cpp - $(CPP) $(CPPFLAGS) -c $< -o $@ + $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $< -o $@ .PHONY: clean clean: rm -Rf $(ODIR) rm -Rf $(BDIR) -