Fix tabbing on everything
[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 $(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 PHONY += docs
41 docs: $(C_SOURCES) $(HEADERS)
42         doxygen
43
44 $(LIB_SO): $(OBJECTS)
45         $(CC) -g $(SHARED) -o ${OBJ_DIR}/$(LIB_SO) $+ $(LDFLAGS)
46
47 ${OBJ_DIR}/%.o: %.c
48         $(CC) -fPIC -c $< -o $@ $(CFLAGS) -Wno-unused-variable
49
50 -include $(OBJECTS:%=$OBJ_DIR/.%.d)
51
52 PHONY += clean
53 clean:
54         rm -f *.o *.so
55         rm -rf $(OBJ_DIR)
56
57 PHONY += mrclean
58 mrclean: clean
59         rm -rf ../docs
60
61 PHONY += tags
62 tags:
63         ctags -R
64
65 tabbing:
66         uncrustify -c C.cfg --no-backup *.c
67         uncrustify -c C.cfg --no-backup *.h */*.h
68
69 wc:
70         wc */*.c */*.h *.c *.h
71
72 .PHONY: $(PHONY)