scratch of (de)serializing
[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 Tuner/*.cc) $(wildcard Collections/*.cc) $(wildcard Backend/*.cc) $(wildcard Encoders/*.cc) $(wildcard Serialize/*.cc)
8
9 C_SOURCES := $(wildcard *.c) $(wildcard AST/*.c) $(wildcard ASTTransform/*.c) $(wildcard Translator/*.c) $(wildcard ASTAnalyses/*.c) $(wildcard Tuner/*.c) $(wildcard Collections/*.c) $(wildcard Backend/*.c) $(wildcard Encoders/*.c) $(wildcard Serialize/*.c)
10
11 HEADERS := $(wildcard *.h) $(wildcard AST/*.h) $(wildcard ASTTransform/*.h) $(wildcard Translator/*.h) $(wildcard ASTAnalyses/*.h) $(wildcard Tuner/*.h) $(wildcard Collections/*.h) $(wildcard Backend/*.h) $(wildcard Encoders/*.h) $(wildcard Serialize/*.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 -ITranslator -ICollections -IBackend -I. -IEncoders -ITuner -ISerialize
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}/ASTTransform
37         ${MKDIR_P} ${OBJ_DIR}/Translator
38         ${MKDIR_P} ${OBJ_DIR}/Tuner
39         ${MKDIR_P} ${OBJ_DIR}/Collections
40         ${MKDIR_P} ${OBJ_DIR}/Backend
41         ${MKDIR_P} ${OBJ_DIR}/Encoders
42         ${MKDIR_P} ${OBJ_DIR}/Serialize
43
44 debug: CFLAGS += -DCONFIG_DEBUG
45 debug: all
46
47 test: all
48         make -C Test
49
50 PHONY += docs
51 docs: $(C_SOURCES) $(HEADERS)
52         doxygen
53
54 ${OBJ_DIR}/$(LIB_SO): $(OBJECTS)
55         $(CXX) -g $(SHARED) -o ${OBJ_DIR}/$(LIB_SO) $+ $(LDFLAGS)
56
57 ${OBJ_DIR}/%.o: %.cc
58         $(CXX) -fPIC -c $< -o $@ $(CFLAGS) -Wno-unused-variable
59
60 ${OBJ_DIR}/%.o: %.c
61         $(CC) -fPIC -c $< -o $@ $(CFLAGS) -Wno-unused-variable
62
63 -include $(OBJECTS:%=$OBJ_DIR/.%.d)
64
65 PHONY += clean
66 clean:
67         rm -f *.o *.so
68         rm -rf $(OBJ_DIR)
69
70 PHONY += mrclean
71 mrclean: clean
72         rm -rf ../docs
73
74 PHONY += tags
75 tags:
76         ctags -R
77
78 tabbing:
79         uncrustify -c C.cfg --no-backup *.cc */*.cc
80         uncrustify -c C.cfg --no-backup *.h */*.h
81
82 wc:
83         wc */*.cc */*.h *.cc *.h
84
85 .PHONY: $(PHONY)