summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile13
1 files changed, 11 insertions, 2 deletions
diff --git a/Makefile b/Makefile
index 3f7db7f..867b86c 100644
--- a/Makefile
+++ b/Makefile
@@ -6,9 +6,10 @@ OBJDIR=obj
SRCDIR=src
INCDIR=include
TESTDIR=test
-CFLAGS=-I$(INCDIR) -Wall -Wextra -Wpedantic -g
+CFLAGS=-I$(INCDIR) -Wall -Wextra -Wpedantic -g -fPIC
OBJECTS=$(OBJDIR)/mapalloc.o
+WRAPOBJECTS=$(OBJECTS) $(OBJDIR)/wrap.o
TESTS=$(BINDIR)/overflow \
$(BINDIR)/underflow \
$(BINDIR)/zero \
@@ -16,7 +17,7 @@ TESTS=$(BINDIR)/overflow \
$(BINDIR)/use-after-free \
$(BINDIR)/double-free
-all: $(LIBDIR)/libmapalloc.a
+all: $(LIBDIR)/libmapalloc.a $(LIBDIR)/libwrapalloc.so
#$(LIBDIR)/libmapalloc.so
@@ -26,6 +27,10 @@ $(OBJDIR)/mapalloc.o: $(SRCDIR)/mapalloc.c $(INCDIR)/mapalloc.h
@mkdir -p $(@D)
$(CC) -c -o $@ $(CFLAGS) $(SRCDIR)/$(*F).c
+$(OBJDIR)/wrap.o: $(SRCDIR)/wrap.c $(INCDIR)/mapalloc.h
+ @mkdir -p $(@D)
+ $(CC) -c -o $@ $(CFLAGS) $(SRCDIR)/$(*F).c
+
$(LIBDIR)/libmapalloc.a: $(OBJECTS)
@mkdir -p $(@D)
$(AR) $(ARFLAGS) $@ $<
@@ -34,6 +39,10 @@ $(LIBDIR)/libmapalloc.so: $(OBJECTS)
@mkdir -p $(@D)
$(CC) -o $@ -shared $(OBJECTS)
+$(LIBDIR)/libwrapalloc.so: $(WRAPOBJECTS)
+ @mkdir -p $(@D)
+ $(CC) -o $@ -shared $(WRAPOBJECTS)
+
$(TESTS): $(LIBDIR)/libmapalloc.a
$(BINDIR)/overflow: $(TESTDIR)/overflow.c
$(BINDIR)/underflow: $(TESTDIR)/underflow.c