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