-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
68 lines (53 loc) · 1.66 KB
/
Makefile
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
56
57
58
59
60
61
62
63
64
65
66
67
68
EXTRAS = Makefile LICENSE README.md .travis.yml saw/bitvector.saw \
saw/llvm.saw test/test.c
HEADERS = include/bitvector.h
SOURCES = src/bitvector.c
OBJECTS = $(SOURCES:src/%.c=obj/%.o)
BCOBJECTS = $(SOURCES:src/%.c=obj/%.bc)
BITVECTORLIB = bitvector
CC = gcc
DBG = -g -Wall -fstack-protector-all -pedantic -Wconversion
#OPT = -march=native -O3 -DNDEBUG -ffast-math -fomit-frame-pointer -finline-functions
VERIFY = -O1 -g
INCLUDES = -Iinclude
LIBS = -l$(BITVECTORLIB)
LDFLAGS = -Llib
CFLAGS = -std=gnu99 $(DBG) $(OPT) $(INCLUDES)
AR = ar r
RANLIB = ranlib
all: depend lib/lib$(BITVECTORLIB).a
depend: .depend
.depend: $(SOURCES)
@echo "Building dependencies"
ifneq ($(wildcard ./.depend),)
@rm -f "./.depend"
endif
@$(CC) $(CFLAGS) -MM $^ > .depend
# Make .depend use the 'obj' directory
@sed -i.bak -e :a -e '/\\$$/N; s/\\\n//; ta' .depend
@sed -i.bak 's/^/obj\//' .depend
@rm -f .depend.bak
-include .depend
$(OBJECTS): obj/%.o : src/%.c Makefile
@echo "Compiling "$<""
@[ -d obj ] || mkdir -p obj
@$(CC) $(CFLAGS) -c $< -o $@
lib/lib$(BITVECTORLIB).a: $(OBJECTS) Makefile
@echo "Creating "$@""
@[ -d lib ] || mkdir -p lib
@rm -f $@
@$(AR) $@ $(OBJECTS)
@$(RANLIB) $@
$(BCOBJECTS): obj/%.bc : src/%.c Makefile
@echo "Compiling "$<""
@[ -d obj ] || mkdir -p obj
@clang -emit-llvm -std=gnu99 $(VERIFY) $(INCLUDES) -c $< -o $@
test/test: test/test.c lib/lib$(BITVECTORLIB).a
$(CC) $(CFLAGS) $(LDFLAGS) test/test.c -o test/test $(LIBS)
saw: saw/bitvector.saw $(BCOBJECTS) FORCE
saw $<
clean: FORCE
rm -rf *~ */*~ $(OBJECTS) $(BCOBJECTS) ./.depend test/test *.dSYM test/test.dSYM lib/lib$(BITVECTORLIB).a
edit: FORCE
emacs -nw $(EXTRAS) $(HEADERS) $(SOURCES)
FORCE: