Fixing more bugs
[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)
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)
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)
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
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
43 debug: CFLAGS += -DCONFIG_DEBUG
44 debug: all
45
46 test: all
47         make -C Test
48
49 PHONY += docs
50 docs: $(C_SOURCES) $(HEADERS)
51         doxygen
52
53 ${OBJ_DIR}/$(LIB_SO): $(OBJECTS)
54         $(CXX) -g $(SHARED) -o ${OBJ_DIR}/$(LIB_SO) $+ $(LDFLAGS)
55
56 ${OBJ_DIR}/%.o: %.cc
57         $(CXX) -fPIC -c $< -o $@ $(CFLAGS) -Wno-unused-variable
58
59 ${OBJ_DIR}/%.o: %.c
60         $(CC) -fPIC -c $< -o $@ $(CFLAGS) -Wno-unused-variable
61
62 -include $(OBJECTS:%=$OBJ_DIR/.%.d)
63
64 PHONY += clean
65 clean:
66         rm -f *.o *.so
67         rm -rf $(OBJ_DIR)
68
69 PHONY += mrclean
70 mrclean: clean
71         rm -rf ../docs
72
73 PHONY += tags
74 tags:
75         ctags -R
76
77 tabbing:
78         uncrustify -c C.cfg --no-backup *.cc */*.cc
79         uncrustify -c C.cfg --no-backup *.h */*.h
80
81 wc:
82         wc */*.cc */*.h *.cc *.h
83
84 .PHONY: $(PHONY)