Merge branch 'brian' of ssh://demsky.eecs.uci.edu/home/git/constraint_compiler into...
[satune.git] / src / Makefile
1 include common.mk
2
3 PHONY += directories
4 MKDIR_P = mkdir -p
5 OBJ_DIR = bin
6
7 C_SOURCES := $(wildcard *.c) $(wildcard AST/*.c) $(wildcard Collections/*.c) $(wildcard Backend/*.c) $(wildcard Encoders/*.c)
8
9 HEADERS := $(wildcard *.h) $(wildcard AST/*.h) $(wildcard Collections/*.h) $(wildcard Backend/*.h) $(wildcard Encoders/*.h)
10
11 OBJECTS := $(CPP_SOURCES:%.cc=$(OBJ_DIR)/%.o) $(C_SOURCES:%.c=$(OBJ_DIR)/%.o)
12
13 CFLAGS := -Wall -g -O0
14 CFLAGS += -IAST -ICollections -IBackend -I. -IEncoders
15 LDFLAGS := -ldl -lrt -rdynamic
16 SHARED := -shared
17
18 # Mac OSX options
19 ifeq ($(UNAME), Darwin)
20 LDFLAGS := -ldl
21 SHARED := -Wl,-undefined,dynamic_lookup -dynamiclib
22 endif
23
24 MARKDOWN := ../docs/Markdown/Markdown.pl
25
26 all: directories ${OBJ_DIR}/$(LIB_SO)
27
28 directories: ${OBJ_DIR}
29
30 ${OBJ_DIR}:
31         ${MKDIR_P} ${OBJ_DIR}
32         ${MKDIR_P} ${OBJ_DIR}/AST
33         ${MKDIR_P} ${OBJ_DIR}/Collections
34         ${MKDIR_P} ${OBJ_DIR}/Backend
35         ${MKDIR_P} ${OBJ_DIR}/Encoders
36
37 debug: CFLAGS += -DCONFIG_DEBUG
38 debug: all
39
40 test: all
41         make -C Test
42
43 PHONY += docs
44 docs: $(C_SOURCES) $(HEADERS)
45         doxygen
46
47 ${OBJ_DIR}/$(LIB_SO): $(OBJECTS)
48         $(CC) -g $(SHARED) -o ${OBJ_DIR}/$(LIB_SO) $+ $(LDFLAGS)
49
50 ${OBJ_DIR}/%.o: %.c
51         $(CC) -fPIC -c $< -o $@ $(CFLAGS) -Wno-unused-variable
52
53 -include $(OBJECTS:%=$OBJ_DIR/.%.d)
54
55 PHONY += clean
56 clean:
57         rm -f *.o *.so
58         rm -rf $(OBJ_DIR)
59
60 PHONY += mrclean
61 mrclean: clean
62         rm -rf ../docs
63
64 PHONY += tags
65 tags:
66         ctags -R
67
68 tabbing:
69         uncrustify -c C.cfg --no-backup *.c */*.c
70         uncrustify -c C.cfg --no-backup *.h */*.h
71
72 wc:
73         wc */*.c */*.h *.c *.h
74
75 .PHONY: $(PHONY)