]> WPIA git - cassiopeia.git/blob - lib/collissiondetect/Makefile
Merge remote-tracking branch 'origin/libs/detectcoll/local'
[cassiopeia.git] / lib / collissiondetect / Makefile
1 LT_CC=libtool --mode=compile gcc
2 LT_CC_DEP=gcc
3 LT_LD=libtool --mode=link gcc
4
5 MKDIR=mkdir -p
6
7 CC=${LT_CC}
8 CC_DEP=${LT_CC_DEP}
9 LD=${LT_LD}
10
11 CFLAGS=-O3 -g -flto -Wall -Werror -Wextra -pedantic -std=c11 -Ilib
12 LDFLAGS=-O3 -g -flto
13
14 LIB_DIR=lib
15 SRC_DIR=src
16 OBJ_DIR=obj
17 DEP_DIR=dep
18
19 FS_LIB=$(wildcard ${LIB_DIR}/*.c)
20 FS_SRC=$(wildcard ${SRC_DIR}/*.c)
21 FS_OBJ_LIB=$(FS_LIB:${LIB_DIR}/%.c=${OBJ_DIR}/%.lo)
22 FS_OBJ_SRC=$(FS_SRC:${SRC_DIR}/%.c=${OBJ_DIR}/%.lo)
23 FS_OBJ=$(FS_OBJ_SRC) $(FS_OBJ_LIB)
24 FS_DEP_LIB=$(FS_LIB:${LIB_DIR}/%.c=${DEP_DIR}/%.d)
25 FS_DEP_SRC=$(FS_SRC:${SRC_DIR}/%.c=${DEP_DIR}/%.d)
26 FS_DEP=$(FS_DEP_SRC) $(FS_DEP_LIB)
27
28 .SUFFIXES: .c .d
29
30 .PHONY: all
31 all: library tools test
32
33 .PHONY: clean
34 clean::
35         -find . -type f -name '*.a' -print -delete
36         -find . -type f -name '*.d' -print -delete
37         -find . -type f -name '*.o' -print -delete
38         -find . -type f -name '*.la' -print -delete
39         -find . -type f -name '*.lo' -print -delete
40         -find . -type f -name '*.so' -print -delete
41         -find . -type d -name '.libs' -print | xargs rm -rv
42         -rm -rf bin/*
43
44 .PHONY: test
45 test: tools
46         bin/detectcoll_verbose tests/*
47
48 .PHONY: tools
49 tools: detectcoll detectcoll_verbose detectcoll_reducedsha
50
51 .PHONY: detectcoll_verbose
52 detectcoll_verbose: bin/detectcoll_verbose
53
54 .PHONY: detectcoll
55 detectcoll: bin/detectcoll
56
57 .PHONY: detectcoll_reducedsha
58 detectcoll_reducedsha: bin/detectcoll_reducedsha
59
60 .PHONY: library
61 library: bin/libdetectcoll.la
62
63 bin/libdetectcoll.la: $(FS_OBJ_LIB)
64         ${LD} ${CFLAGS} $(FS_OBJ_LIB) -o bin/libdetectcoll.la
65
66 bin/detectcoll: $(FS_SRC) $(FS_LIB)
67         ${LD} ${CFLAGS} $(FS_SRC) $(FS_LIB) -o bin/detectcoll
68
69 bin/detectcoll_verbose: $(FS_SRC) $(FS_LIB)
70         ${LD} ${CFLAGS} -DVERBOSE_COLLDETECT $(FS_SRC) $(FS_LIB) -o bin/detectcoll_verbose
71
72 bin/detectcoll_reducedsha: $(FS_SRC) $(FS_LIB)
73         ${LD} ${CFLAGS} -DVERBOSE_COLLDETECT -DDETECT_REDUCED_SHA_COLLISION $(FS_SRC) $(FS_LIB) -o bin/detectcoll_reducedsha
74
75 ${DEP_DIR}/%.d: ${LIB_DIR}/%.c
76         ${MKDIR} $(shell dirname $@) && $(CC_DEP) $(CFLAGS) -M -MF $@ $<
77
78 ${OBJ_DIR}/%.lo ${OBJ_DIR}/%.o: ${LIB_DIR}/%.c ${DEP_DIR}/%.d
79         ${MKDIR} $(shell dirname $@) && $(CC) $(CFLAGS) -o $@ -c $<
80
81 -include $(FS_DEP)