gator: Version 5.21.1
[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 CPPFLAGS += -O3 -Wall -fno-exceptions -pthread -MMD -DETCDIR=\"/etc\" -Ilibsensors
9 CXXFLAGS += -fno-rtti -Wextra -Wshadow # -Weffc++
10 ifeq ($(WERROR),1)
11         CPPFLAGS += -Werror
12 endif
13 # -s strips the binary of debug info
14 LDFLAGS += -s
15 LDLIBS += -lrt -lm -pthread
16 TARGET = gatord
17 C_SRC = $(wildcard mxml/*.c) $(wildcard libsensors/*.c)
18 CXX_SRC = $(wildcard *.cpp)
19
20 all: $(TARGET)
21
22 events.xml: events_header.xml $(wildcard events-*.xml) events_footer.xml
23         cat $^ > $@
24
25 include $(wildcard *.d)
26 include $(wildcard mxml/*.d)
27
28 EventsXML.cpp: events_xml.h
29 ConfigurationXML.cpp: defaults_xml.h
30
31 # Don't regenerate conf-lex.c or conf-parse.c
32 libsensors/conf-lex.c: ;
33 libsensors/conf-parse.c: ;
34
35 %_xml.h: %.xml escape
36         ./escape $< > $@
37
38 %.o: %.c
39         $(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
40
41 %.o: %.cpp
42         $(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -o $@ $<
43
44 SrcMd5.cpp: $(wildcard *.cpp *.h mxml/*.c mxml/*.h libsensors/*.c libsensors/*.h)
45         echo 'extern const char *const gSrcMd5 = "'`ls $^ | grep -Ev '^(.*_xml\.h|$@)$$' | LC_ALL=C sort | xargs cat | md5sum | cut -b 1-32`'";' > $@
46
47 $(TARGET): $(CXX_SRC:%.cpp=%.o) $(C_SRC:%.c=%.o) SrcMd5.o
48         $(CC) $(LDFLAGS) $^ $(LDLIBS) -o $@
49
50 # Intentionally ignore CC as a native binary is required
51 escape: escape.c
52         gcc $^ -o $@
53
54 clean:
55         rm -f *.d *.o mxml/*.d mxml/*.o libsensors/*.d libsensors/*.o $(TARGET) escape events.xml events_xml.h defaults_xml.h SrcMd5.cpp