-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
122 lines (93 loc) · 3.04 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
SUBNAME = observation
SPEC = smartmet-engine-$(SUBNAME)
INCDIR = smartmet//engines/$(SUBNAME)
REQUIRES = gdal configpp sqlite3 spatialite
include $(shell echo $${PREFIX-/usr})/share/smartmet/devel/makefile.inc
ifeq ($(origin localstatedir), undefined)
vardir = /var/smartmet/observation
else
vardir = $(localstatedir)/smartmet/observation
endif
# Compiler options
DEFINES = -DUNIX -D_REENTRANT
# TODO: Should remove -Wno-sign-conversion, FlashTools.cpp warns a lot
CFLAGS += -Wno-pedantic
INCLUDES += -isystem $(includedir)/mysql
LIBS += $(PREFIX_LDFLAGS) \
$(REQUIRED_LIBS) \
-lsmartmet-timeseries \
-lsmartmet-spine \
-lsmartmet-macgyver \
-lsmartmet-locus \
-lsmartmet-gis \
-lboost_thread \
-lboost_iostreams \
-lboost_locale \
-lboost_system \
-lboost_serialization \
-latomic \
-lbz2 -lz \
-lpthread
# What to install
LIBFILE = $(SUBNAME).so
# Compilation directories
vpath %.cpp $(SUBNAME)
vpath %.h $(SUBNAME)
# The files to be compiled
SRCS = $(wildcard $(SUBNAME)/*.cpp)
HDRS = $(wildcard $(SUBNAME)/*.h) $(wildcard $(SUBNAME)/*.ipp)
OBJS = $(patsubst %.cpp, obj/%.o, $(notdir $(SRCS)))
.PHONY: test rpm
# The rules
all: objdir $(LIBFILE)
debug: all
release: all
profile: all
$(LIBFILE): $(OBJS)
$(CXX) $(CFLAGS) -shared -rdynamic -o $(LIBFILE) $(OBJS) $(LIBS)
@echo Checking $(LIBFILE) for unresolved references
@if ldd -r $(LIBFILE) 2>&1 | c++filt | grep "^undefined symbol" | grep -v SmartMet::Engine::Geonames |\
grep -Pv ':\ __(?:(?:a|t|ub)san_|sanitizer_)'; \
then rm -v $(LIBFILE); \
exit 1; \
fi
clean:
rm -f $(LIBFILE) *~ $(SUBNAME)/*~
rm -rf obj
$(MAKE) -C test $@
format:
clang-format -i -style=file $(SUBNAME)/*.h $(SUBNAME)/*.cpp
install:
@mkdir -p $(includedir)/$(INCDIR)
@list='$(HDRS)'; \
for hdr in $$list; do \
HDR=$$(basename $$hdr); \
echo $(INSTALL_DATA) $$hdr $(includedir)/$(INCDIR)/$$HDR; \
$(INSTALL_DATA) $$hdr $(includedir)/$(INCDIR)/$$HDR; \
done
mkdir -p $(enginedir)
$(INSTALL_PROG) $(LIBFILE) $(enginedir)/$(LIBFILE)
mkdir -p $(vardir)
if [[ ! -e $(vardir)/stations.txt ]]; then $(INSTALL_DATA) cnf/stations.txt $(vardir)/; fi
if [[ ! -e $(vardir)/stations.sqlite ]]; then $(INSTALL_DATA) cnf/stations.sqlite $(vardir)/; fi
test:
@test -d test || echo "No test subdirectory, no tests defined"
@test ! -d test || ( $(MAKE) -C test test )
objdir:
@mkdir -p $(objdir)
rpm: clean $(SPEC).spec
rm -f $(SPEC).tar.gz # Clean a possible leftover from previous attempt
tar -czvf $(SPEC).tar.gz --exclude test --exclude-vcs --transform "s,^,$(SPEC)/," *
rpmbuild -tb $(SPEC).tar.gz
rm -f $(SPEC).tar.gz
test-headers:
ok=true; OPTIMIZE=-O0; for header in $(SUBNAME)/*.h ; do \
echo Testing $$header; \
echo "#include \"$$header\"" | $(CXX) -S -x c++ $(CFLAGS) $(INCLUDES) - -o /dev/null || ok=false; \
done; $$ok
.SUFFIXES: $(SUFFIXES) .cpp
obj/%.o: %.cpp
$(CXX) $(CFLAGS) $(INCLUDES) -c -MD -MF $(patsubst obj/%.o, obj/%.d, $@) -MT $@ -o $@ $<
ifneq ($(wildcard obj/*.d),)
-include $(wildcard obj/*.d)
endif