031d169068817e3182ec3c3dd5e16487bb7da16f
[firefly-linux-kernel-4.4.55.git] / tools / gator / daemon / common.mk
1 # -g produces debugging information
2 # -O3 maximum optimization
3 # -O0 no optimization, used for debugging
4 # -Wall enables most warnings
5 # -Werror treats warnings as errors
6 # -std=c++0x is the planned new c++ standard
7 # -std=c++98 is the 1998 c++ standard
8 CFLAGS += -O3 -Wall -fno-exceptions -pthread -MMD -DETCDIR=\"/etc\" -Ilibsensors
9 CXXFLAGS += -fno-rtti -Wextra # -Weffc++
10 ifeq ($(WERROR),1)
11         CFLAGS += -Werror
12 endif
13 # -s strips the binary of debug info
14 LDFLAGS += -s
15 TARGET = gatord
16 C_SRC = $(wildcard mxml/*.c) $(wildcard libsensors/*.c)
17 CPP_SRC = $(wildcard *.cpp)
18
19 all: $(TARGET)
20
21 events.xml: events_header.xml $(wildcard events-*.xml) events_footer.xml
22         cat $^ > $@
23
24 include $(wildcard *.d)
25 include $(wildcard mxml/*.d)
26
27 EventsXML.cpp: events_xml.h
28 ConfigurationXML.cpp: configuration_xml.h
29
30 # Don't regenerate conf-lex.c or conf-parse.c
31 libsensors/conf-lex.c: ;
32 libsensors/conf-parse.c: ;
33
34 %_xml.h: %.xml escape
35         ./escape $< > $@
36
37 %.o: %.c
38         $(GCC) -c $(CFLAGS) -o $@ $<
39
40 %.o: %.cpp
41         $(CPP) -c $(CFLAGS) $(CXXFLAGS) -o $@ $<
42
43 $(TARGET): $(CPP_SRC:%.cpp=%.o) $(C_SRC:%.c=%.o)
44         $(CPP) $(LDFLAGS) -o $@ $^ -lrt -pthread
45
46 escape: escape.c
47         gcc $^ -o $@
48
49 clean:
50         rm -f *.d *.o mxml/*.d mxml/*.o libsensors/*.d libsensors/*.o $(TARGET) escape events.xml events_xml.h configuration_xml.h