From 8781ea55a0aecc715e3955028457eedeaae79eeb Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Wed, 23 Apr 2014 17:59:34 +0200 Subject: improve makefile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- Makefile | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index c9afc10..f854536 100644 --- a/Makefile +++ b/Makefile @@ -57,11 +57,9 @@ STD = gnu99 # C preprocessor flags CPPFLAGS_ = $(foreach D, $(OPTIONS), -D'$(D)=1') $(CPPFLAGS) # C compiling flags -_fPIC = -fPIC -CFLAGS_ = -std=$(STD) $(WARN) $(_fPIC) $(CFLAGS) +CFLAGS_ = -std=$(STD) $(WARN) $(CFLAGS) # Linking flags -_shared = -shared -LDFLAGS_ = $(_shared) $(LDFLAGS) +LDFLAGS_ = $(LDFLAGS) # Flags to use when compiling and assembling CC_FLAGS = $(CPPFLAGS_) $(CFLAGS_) $(OPTIMISE) @@ -87,13 +85,16 @@ test: bin/test bin/libpassphrase.so: obj/passphrase.o @mkdir -p bin - $(CC) $(LD_FLAGS) -o "$@" $^ + $(CC) $(LD_FLAGS) -shared -o "$@" $^ -bin/test: obj/passphrase.o obj/test.o - @mkdir -p bin - $(CC) $(LD_FLAGS) -o "$@" $^ +bin/test: bin/libpassphrase.so obj/test.o + $(CC) $(LD_FLAGS) -L bin -lpassphrase -o "$@" obj/test.o + +obj/passphrase.o: src/passphrase.c src/passphrase.h + @mkdir -p "$(shell dirname "$@")" + $(CC) $(CC_FLAGS) -fPIC -o "$@" -c "$<" -obj/%.o: src/%.c src/%.h +obj/test.o: src/test.c src/test.h @mkdir -p "$(shell dirname "$@")" $(CC) $(CC_FLAGS) -o "$@" -c "$<" -- cgit v1.2.3-70-g09d2