summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Duncan <pabs@pablotron.org>2016-08-27 01:56:00 -0400
committerPaul Duncan <pabs@pablotron.org>2016-08-27 01:56:00 -0400
commitf51c619c81a8a3b623f13484ea57c9533677d532 (patch)
treee94421c858f90931aa14092a188613744955edac
parent7a4a5e6f117e2768e7ececc7cf62a2941203adf4 (diff)
downloadlibfhp-f51c619c81a8a3b623f13484ea57c9533677d532.tar.bz2
libfhp-f51c619c81a8a3b623f13484ea57c9533677d532.zip
clean up makefile
-rw-r--r--Makefile30
1 files 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) $<