From 4673d82793f918eece864c9f612d88c508ec3bc1 Mon Sep 17 00:00:00 2001 From: Steffen Jaeckel Date: Mon, 13 Oct 2014 16:44:58 +0200 Subject: [PATCH] improve makefiles shared makefile now uses libtool update gitignore according remove 'timing' target in shared makefile add dependency of HEADERS to OBJECTS for both makefiles --- .gitignore | 2 ++ makefile | 2 ++ makefile.shared | 18 ++++++++++-------- 3 files changed, 14 insertions(+), 8 deletions(-) diff --git a/.gitignore b/.gitignore index 75fac9d..b5c7d99 100644 --- a/.gitignore +++ b/.gitignore @@ -8,6 +8,8 @@ *.log *.toc *.out +*.l[ao] +/.libs test test.exe diff --git a/makefile b/makefile index 5c6a6c3..44aa0cc 100644 --- a/makefile +++ b/makefile @@ -89,6 +89,8 @@ endif default: $(LIBNAME) +$(OBJECTS): $(HEADERS) + $(LIBNAME): $(OBJECTS) $(AR) $(ARFLAGS) $@ $(OBJECTS) $(RANLIB) $@ diff --git a/makefile.shared b/makefile.shared index efc9771..dc118d7 100644 --- a/makefile.shared +++ b/makefile.shared @@ -3,7 +3,8 @@ # VERSION=0:12 -CC=libtool --mode=compile --tag=CC gcc +LT ?= libtool +LTCOMPILE = $(LT) --mode=compile --tag=CC $(CC) CFLAGS += -Wall -W -Wshadow -Isrc/headers @@ -80,7 +81,10 @@ endif default: $(LIBNAME) -objs: $(OBJECTS) +$(OBJECTS): $(HEADERS) + +.c.o: + $(LTCOMPILE) $(CFLAGS) $(LDFLAGS) -o $@ -c $< $(LIBNAME): $(OBJECTS) libtool --silent --mode=link gcc $(CFLAGS) `find . -type f | grep "[.]lo" | xargs` -o $(LIBNAME) -rpath $(LIBPATH) -version-info $(VERSION) @@ -94,14 +98,12 @@ install: $(LIBNAME) mtest/mtest: mtest/mtest.c cd mtest ; make mtest -test: $(LIBNAME) demo/test.o mtest/mtest - $(CC) $(CFLAGS) demo/test.o $(LIBNAME_S) $(PROF) -o test +.PHONY: test +test: $(LIBNAME) demo/test.o + $(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o test demo/test.o $(LIBNAME) -timing: $(LIBNAME) demo/test.o - $(CC) $(CFLAGS) demo/test.o $(LIBNAME_S) $(PROF) -o test - stest: $(LIBNAME) demo/stest.o - $(CC) $(CFLAGS) demo/stest.o $(LIBNAME_S) -o stest + $(LT) --mode=link --tag=CC $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS) -o stest demo/stest.o $(LIBNAME) # $Source$ # $Revision$