-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
56 lines (45 loc) · 1.49 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
EXTRAS = Makefile LICENSE.md README.md LICENSE.xxHash test/test.c
HEADERS = lib/c_list_types/include/c_list_types.h \
include/mphf_hashes.h include/mphf_serial.h include/mphf.h
SOURCES = src/mphf_hashes.c src/mphf_build.c src/mphf_query.c \
src/mphf_serial.c src/external_solve.c
OBJECTS = $(SOURCES:src/%.c=obj/%.o)
MPHFSATLIB = mphfsat
CC = gcc
#DBG = -g -Wall -fstack-protector-all -pedantic
OPT = -march=native -O3 -DNDEBUG -ffast-math -fomit-frame-pointer -finline-functions
INCLUDES = -Iinclude
LIBS = -l$(MPHFSATLIB) -lm
LDFLAGS = -Llib
CFLAGS = -std=gnu99 $(DBG) $(OPT) $(INCLUDES)
AR = ar r
RANLIB = ranlib
all: depend lib/lib$(MPHFSATLIB).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$(MPHFSATLIB).a: $(OBJECTS) Makefile
@echo "Creating "$@""
@[ -d lib ] || mkdir -p lib
@rm -f $@
@$(AR) $@ $(OBJECTS)
@$(RANLIB) $@
test/test: test/test.c lib/lib$(MPHFSATLIB).a
$(CC) $(CFLAGS) $(LDFLAGS) test/test.c -o test/test $(LIBS)
clean:
rm -rf *~ */*~ $(OBJECTS) ./.depend test/test *.dSYM test/test.dSYM mphf.out lib/lib$(MPHFSATLIB).a obj
edit:
emacs -nw $(SOURCES) $(HEADERS) $(EXTRAS)