summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-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) $<