aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
blob: 31de296b9dd530798dc5ac9d0564b719f886eef8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
TEST     = teststore test_mmap ftrunctest testbuddy testalloc
SONAME   = libobjstore.so.0
VERSION  = 0.0.1
OBJSTORE = libobjstore.so libobjstore.a

OSOBJ	 = objstore.o alloc.o
OSPICOBJ = $(patsubst %.o,%.pic.o,$(OSOBJ))

CC	 = gcc
# This is a reasonable set of flags for production
# CFLAGS	 = -Wall -O3 -fomit-frame-pointer -DNDEBUG -D_FILE_OFFSET_BITS=64
# This is for debugging
CFLAGS	 = -Wall -O -g -D_FILE_OFFSET_BITS=64
PICFLAGS = $(CFLAGS) -fPIC
SOFLAGS	 = -shared

AR	 = ar cq
RANLIB	 = ranlib

all: $(OBJSTORE) $(TEST)

clean:
	rm -f *.o *~ core *.dat *.log $(OBJSTORE) $(TEST)
	rm -f libobjstore.so.*

%.o: %.c
	$(CC) $(CFLAGS) -o $@ -c $<

%.pic.o: %.c
	$(CC) $(PICFLAGS) -o $@ -c $<

libobjstore.so: $(OSPICOBJ)
	$(CC) $(SOFLAGS) -Wl,-soname,$(SONAME) -o libobjstore.so.$(VERSION) $(OSPICOBJ)
	ln -sf libobjstore.so.$(VERSION) $(SONAME)
	ln -sf libobjstore.so.$(VERSION) libobjstore.so

libobjstore.a: $(OSOBJ)
	rm -f libobjstore.a
	$(AR) libobjstore.a $(OSOBJ)
	$(RANLIB) libobjstore.a

teststore: teststore.o libobjstore.a
	$(CC) $(LDFLAGS) -o $@ $< libobjstore.a

testbuddy: testbuddy.o libobjstore.a
	$(CC) $(LDFLAGS) -o $@ $< libobjstore.a

testalloc: testalloc.o libobjstore.a
	$(CC) $(LDFLAGS) -o $@ $< libobjstore.a

test_mmap: test_mmap.o
	$(CC) $(LDFLAGS) -o $@ $<

ftrunctest: ftrunctest.o
	$(CC) $(LDFLAGS) -o $@ $<