summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorH. Peter Anvin <hpa@zytor.com>2012-03-11 00:54:59 (GMT)
committerH. Peter Anvin <hpa@zytor.com>2012-03-11 00:54:59 (GMT)
commit87798a1fba0d80e4ae002785dd5fda2b02c82d50 (patch)
tree72796ab0a816083a369666ae4ba0d0825aa79b31
parentf25af41829e85c68d70184008ba1921077b01e07 (diff)
downloadpbn-87798a1fba0d80e4ae002785dd5fda2b02c82d50.zip
pbn-87798a1fba0d80e4ae002785dd5fda2b02c82d50.tar.gz
pbn-87798a1fba0d80e4ae002785dd5fda2b02c82d50.tar.bz2
pbn-87798a1fba0d80e4ae002785dd5fda2b02c82d50.tar.xz
Makefile: build a library (.a file)
-rw-r--r--Makefile17
1 files changed, 13 insertions, 4 deletions
diff --git a/Makefile b/Makefile
index 9171300..57c06ba 100644
--- a/Makefile
+++ b/Makefile
@@ -1,20 +1,29 @@
CC = gcc
-CFLAGS = -O2 -g -D_FORTIFY_SOURCE=2 -W -Wall
+CFLAGS = -O3 -g -D_FORTIFY_SOURCE=2 -W -Wall
LDFLAGS =
+AR = ar
+RANLIB = ranlib
LIBOBJ = pbn_add.o pbn_cmp.o pbn_dump.o pbn_init.o pbn_mul.o pbn_shift.o \
pbn_and.o pbn_or.o pbn_xor.o pbn_bit.o \
pbn_abs.o pbn_div.o pbn_divs.o
+LIB = pbn.a
+
TESTS = test
.c.o:
$(CC) $(CFLAGS) -c -o $@ $<
-all: $(TESTS)
+all: $(TESTS) $(LIB)
+
+$(LIB): $(LIBOBJ)
+ rm -f $@
+ $(AR) cq $@ $^
+ $(RANLIB) $@
-test: test.o $(LIBOBJ)
+test: test.o $(LIB)
$(CC) $(LDFLAGS) -o $@ $^
clean:
- rm -f $(TESTS) *.o
+ rm -f $(TESTS) $(LIB) *.o