From f51c619c81a8a3b623f13484ea57c9533677d532 Mon Sep 17 00:00:00 2001 From: Paul Duncan Date: Sat, 27 Aug 2016 01:56:00 -0400 Subject: clean up makefile --- Makefile | 30 ++++++++++++++++++++---------- 1 file changed, 20 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 1bf4c11..e80b70a 100644 --- a/Makefile +++ b/Makefile @@ -1,16 +1,26 @@ CC ?= cc -CFLAGS=-std=c99 -W -Wall -pedantic -O2 -Iinclude -OBJS=fhp.o test.o -APP=./fhp-test +CFLAGS=-std=c99 -W -Wall -pedantic -O2 -Iinclude -fPIC +OBJS=fhp.o +SONAME=libfhp.so +LIB=libfhp.so -all: $(OBJS) - $(CC) -o $(APP) $(OBJS) +TEST_OBJS=test.o +TEST_APP=./fhp-test +TEST_LDFLAGS=-lfhp -L. -test: all - $(APP) +all: $(LIB) -%.o: %.c include/fhp/fhp.h - $(CC) -c $(CFLAGS) $< +test: $(TEST_APP) + LD_LIBRARY_PATH=. $(TEST_APP) clean: - rm -f $(APP) $(OBJS) + rm -f $(LIB) $(OBJS) $(TEST_APP) $(TEST_OBJS) + +$(LIB): $(OBJS) + $(CC) -o $(LIB) -shared -Wl,-soname,$(SONAME) $(OBJS) + +$(TEST_APP): $(LIB) $(TEST_OBJS) + $(CC) -o $(TEST_APP) $(TEST_OBJS) $(TEST_LDFLAGS) + +%.o: %.c include/fhp/fhp.h + $(CC) -c $(CFLAGS) $< -- cgit v1.2.3