-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
127 lines (94 loc) · 2.83 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
123
124
125
126
127
SUBNAME = wms
SPEC = smartmet-plugin-$(SUBNAME)
INCDIR = smartmet/plugins/$(SUBNAME)
REQUIRES = gdal jsoncpp cairo fmt librsvg ctpp2 configpp
include $(shell echo $${PREFIX-/usr})/share/smartmet/devel/makefile.inc
sysconfdir ?= /etc
# Compiler options
FLAGS += -Wno-maybe-uninitialized -Wno-variadic-macros -Wno-deprecated-declarations
DEFINES = -DUNIX -D_REENTRANT
LIBS += $(PREFIX_LDFLAGS) \
-lsmartmet-grid-content \
-lsmartmet-timeseries \
-lsmartmet-spine \
-lsmartmet-newbase \
-lsmartmet-macgyver \
-lsmartmet-gis \
-lsmartmet-giza \
-lsmartmet-locus \
$(REQUIRED_LIBS) \
-lboost_thread \
-lboost_regex \
-lboost_iostreams \
-lboost_system \
-lbz2 -lz \
-lheatmap
# Templates
TEMPLATES = $(wildcard tmpl/*.tmpl)
BYTECODES = $(TEMPLATES:%.tmpl=%.c2t)
# 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)
OBJS = $(patsubst %.cpp, obj/%.o, $(notdir $(SRCS)))
INCLUDES := -I$(SUBNAME) $(INCLUDES)
.PHONY: test rpm
# The rules
all: objdir $(LIBFILE) templates
debug: all
release: all
profile: all
$(LIBFILE): $(OBJS)
$(CXX) $(LDFLAGS) -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:: ; \
then rm -v $(LIBFILE); \
exit 1; \
fi
configtest:
@if [ -x "$$(command -v cfgvalidate)" ]; then cfgvalidate -v test/cnf/wms.conf; fi
jsontest:
@if [ -e /usr/bin/json_verify ]; then \
echo Validating json files ; \
for json in $$(find test/dali -name '*.json'); do \
echo " -> $$json"; \
cat $$json | json_verify -c | grep -v "JSON is valid"; \
done; \
fi
clean:
rm -f $(LIBFILE)
rm -rf $(objdir)
find . -name '*~' -exec rm -f {} ';'
find . -name '*.c2t' -exec rm -f {} ';'
find . -name '*.d' -exec rm -f {} ';'
find . -name '.#*' -exec rm -f {} ';'
$(MAKE) -C test $@
format:
clang-format -i -style=file $(SUBNAME)/*.h $(SUBNAME)/*.cpp test/*.cpp
install:
@mkdir -p $(plugindir)
$(INSTALL_PROG) $(LIBFILE) $(plugindir)/$(LIBFILE)
@mkdir -p $(datadir)/smartmet/wms
@list=`ls -1 tmpl/*.c2t`; \
echo $(INSTALL_DATA) $$list "$(datadir)/smartmet/wms"; \
$(INSTALL_DATA) $$list "$(datadir)/smartmet/wms";
test: configtest
cd test && make 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
.SUFFIXES: $(SUFFIXES) .cpp
obj/%.o: %.cpp
$(CXX) $(CFLAGS) $(INCLUDES) -c -MD -MF $(patsubst obj/%.o, obj/%.d, $@) -MT $@ -o $@ $<
templates: $(BYTECODES)
%.c2t: %.tmpl
ctpp2c $< $@
-include $(wildcard obj/*.d)