From f5c0fbf56bc150ef666fc596b46d2217e2be1c9c Mon Sep 17 00:00:00 2001 From: Daniel Fiser Date: Thu, 22 Nov 2007 14:27:26 +0100 Subject: [PATCH] Improved Makefiles. --- Makefile | 62 +++++++++++++++++++++++++++++----------------------------- src/Makefile | 27 ++++++------------------- tests/Makefile | 17 +++------------- 3 files changed, 40 insertions(+), 66 deletions(-) rewrite Makefile (85%) diff --git a/Makefile b/Makefile dissimilarity index 85% index 214c53a..2a6d984 100644 --- a/Makefile +++ b/Makefile @@ -1,31 +1,31 @@ -CC = g++ -CXXFLAGS = -Wall -Wno-long-long -pedantic -DEBUGFLAGS = -g -QT_INCLUDE = -DQT_SHARED -I/opt/qt4/include -I/opt/qt4/include/QtCore \ - -I/opt/qt4/include/QtGui -QT_LIBS = -lQtCore -lQtGui -L/opt/qt4/lib/ -lz -lm -pthread -lgthread-2.0 \ - -lrt -lglib-2.0 -lpthread -ldl - -ALL_FLAGS = $(CXXFLAGS) $(DEBUGFLAGS) $(QT_INCLUDE) -ALL_LD_FLAGS = $(QT_LIBS) - -SUBDIRS = src - -# export variables for sub-makes -export CC -export ALL_FLAGS -export ALL_LD_FLAGS - -all: - $(foreach dir, $(SUBDIRS), cd $(dir) && $(MAKE) $(MFLAGS) all) - -clean: - rm -f *.o - $(foreach dir, $(SUBDIRS), cd $(dir) && $(MAKE) $(MFLAGS) clean) - cd tests && $(MAKE) $(MFLAGS) clean - -test: - cd tests && $(MAKE) $(MFLAGS) - -.PHONY: all test clean - +CC = g++ +MOC = moc + +DEBUGFLAGS = -g +CXXFLAGS_OPTIM = -march=k8 -mtune=k8 -msse2 -O2 -pipe +CXXFLAGS = -Wall -Wno-long-long -pedantic $(DEBUGFLAGS) $(CXXFLAGS_OPTIM) + +QT_CFLAGS = $(shell pkg-config QtCore QtGui --cflags) +QT_LIBS = $(shell pkg-config QtCore QtGui --libs) + +# export variables for sub-makes +export CC +export MOC +export CXXFLAGS +export QT_CFLAGS +export QT_LIBS + +all: + cd src && $(MAKE) all + cd tests && $(MAKE) all + +clean: + rm -f *.o + cd src && $(MAKE) clean + cd tests && $(MAKE) clean + +check: + cd tests && $(MAKE) + +.PHONY: all check clean + diff --git a/src/Makefile b/src/Makefile index 3ad4dd3..bf28409 100644 --- a/src/Makefile +++ b/src/Makefile @@ -1,21 +1,6 @@ -CC = g++ -MOC = /opt/qt4/bin/moc - -CXXFLAGS = -Wall -Wno-long-long -pedantic \ - -march=k8 -mtune=k8 -msse2 -O2 -pipe -DEBUGFLAGS = -g -QT_INCLUDE = -DQT_SHARED -I/opt/qt4/include -I/opt/qt4/include/QtCore \ - -I/opt/qt4/include/QtGui -QT_LIBS = -lQtCore -lQtGui -L/opt/qt4/lib/ -lz -lm -pthread -lgthread-2.0 \ - -lrt -lglib-2.0 -lpthread -ldl -QT_LIBS = -lQtGui -L/opt/qt4-debug/lib -L/usr/X11R6/lib \ - -laudio -lXt -lpng -lSM -lICE -lQtCore -lz -pthread \ - -lgthread-2.0 -lrt -lglib-2.0 -lpthread -lXi -lXrender -lXrandr -lXfixes \ - -lXcursor -lXinerama -lfreetype -lfontconfig -lXext -lX11 -lm -ldl - -ALL_FLAGS = $(CXXFLAGS) $(DEBUGFLAGS) $(QT_INCLUDE) -Lobjs -ALL_LD_FLAGS = $(QT_LIBS) - +CXXFLAGS += $(QT_CFLAGS) +CXXFLAGS += -Lobjs +LDFLAGS += $(QT_LIBS) VPATH = diff qt parser @@ -33,13 +18,13 @@ OBJS = $(foreach file, $(OBJS_TMP), objs/$(file)) all: $(TARGETS) qshowdiff: $(OBJS) - $(CC) $(ALL_FLAGS) -o $@ $(OBJS) $(ALL_LD_FLAGS) + $(CC) $(CXXFLAGS) -o $@ $(OBJS) $(LDFLAGS) objs/%.o: %.cpp %.h - $(CC) $(ALL_FLAGS) -c -o $@ $< + $(CC) $(CXXFLAGS) -c -o $@ $< objs/%.o: %.cpp - $(CC) $(ALL_FLAGS) -c -o $@ $< + $(CC) $(CXXFLAGS) -c -o $@ $< qt/diff_view.cpp: qt/diff_view.moc qt/diff_view.moc: qt/diff_view.h diff --git a/tests/Makefile b/tests/Makefile index 43507d7..f9ebb86 100644 --- a/tests/Makefile +++ b/tests/Makefile @@ -1,16 +1,5 @@ -CC = g++ -CXXFLAGS = -Wall -Wno-long-long -pedantic -DEBUGFLAGS = -g -QT_INCLUDE = -DQT_SHARED -I/opt/qt4/include -I/opt/qt4/include/QtCore \ - -I/opt/qt4/include/QtGui -QT_LIBS = -lQtCore -lQtGui -L/opt/qt4/lib/ -lz -lm -pthread -lgthread-2.0 \ - -lrt -lglib-2.0 -lpthread -ldl - -ALL_FLAGS = $(CXXFLAGS) $(DEBUGFLAGS) $(QT_INCLUDE) -ALL_LD_FLAGS = $(QT_LIBS) - -ALL_FLAGS += -I../src/diff -ALL_LD_FLAGS += -lcppu +CXXFLAGS += $(QT_CFLAGS) +LDFLAGS += $(QT_LIBS) -lcppu TEST_SUITES = text.cpp snippet.cpp hunk.cpp diff.cpp levenshtein.cpp OBJS_LIST = snippet.o settings.o text.o hunk.o diff.o file.o levenshtein.o @@ -25,7 +14,7 @@ run_tests: test -valgrind --leak-check=full --show-reachable=yes ./test test: main.cpp $(TEST_SUITES) - pwd && $(CC) $(ALL_FLAGS) -o $@ $< $(OBJS) $(ALL_LD_FLAGS) + pwd && $(CC) $(CXXFLAGS) -o $@ $< $(OBJS) $(LDFLAGS) clean: rm -f test -- 2.11.4.GIT