-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
179 lines (134 loc) · 3.54 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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
SUBNAME = grid
LIB = smartmet-$(SUBNAME)
SPEC = smartmet-tools-$(SUBNAME)
INCDIR = smartmet/$(SUBNAME)
# Enabling / disabling CORBA usage.
CORBA = enabled
REQUIRES = libpq gdal icu-i18n
include $(shell echo $${PREFIX-/usr})/share/smartmet/devel/makefile.inc
ifeq ($(CORBA), disabled)
CORBA_FLAGS = -DCORBA_DISABLED
else
CORBA_INCLUDE = -I/usr/include/smartmet/grid-content/contentServer/corba/stubs \
-I/usr/include/smartmet/grid-content/dataServer/corba/stubs \
-I/usr/include/smartmet/grid-content/queryServer/corba/stubs
CORBA_LIBS = -lomniORB4 -lomnithread
endif
DEFINES = -DUNIX -D_REENTRANT
INCLUDES += \
-I$(includedir)/smartmet \
`pkg-config --cflags freetype2` \
`pkg-config --cflags icu-i18n` \
$(CORBA_INCLUDE)
# Compile options in detault, debug and profile modes
LIBS += $(PREFIX_LDFLAGS) \
-lsmartmet-spine \
-lsmartmet-macgyver \
-lsmartmet-newbase \
-lsmartmet-gis \
-lsmartmet-grid-files \
-lsmartmet-grid-content \
-lboost_program_options \
-lboost_regex \
-lboost_thread \
-lboost_system \
-lboost_iostreams \
-lpthread \
-ljpeg \
-lpng \
-lhiredis \
-lmicrohttpd \
-lcurl \
$(CORBA_LIBS) \
$(REQUIRED_LIBS) \
-lssl -lcrypto \
-lstdc++ -lm \
-L /usr/lib/x86_64-linux-gnu -lpq \
`pkg-config --libs-only-l freetype2`
# What to install
LIBFILE = libsmartmet-$(SUBNAME).so
# Compile option overrides
ifneq (,$(findstring debug,$(MAKECMDGOALS)))
CFLAGS = $(CFLAGS_DEBUG)
endif
ifneq (,$(findstring profile,$(MAKECMDGOALS)))
CFLAGS = $(CFLAGS_PROFILE)
endif
# Compilation directories
vpath %.cpp src \
src/clients \
src/files \
src/fmi \
src/servers \
src/utils
vpath %.h src \
src/clients \
src/files \
src/fmi \
src/servers \
src/utils
vpath %.o obj
# The files to be compiled
SRCS = $(patsubst src/%,%,$(wildcard src/*.cpp src/*/*.cpp))
PROGS = $(SRCS:%.cpp=bin/%)
OBJS = $(SRCS:%.cpp=obj/bin/%.o)
INCLUDES := -Isrc $(INCLUDES)
.PHONY: test rpm
# The rules
all: objdir $(PROGS)
debug: objdir $(OBJS) $(PROGS)
#debug: all
release: all
profile: all
src_debug: objdir $(LIBFILE)
$(PROGS): % : obj/%.o
$(CXX) $(LDFLAGS) $(LDFLAGS) $(INCLUDES) -o $@ obj/[email protected] $(LIBS)
clean:
rm -f src/*~ src/*/*~ src/*/*/*~
rm -rf obj
rm -rf bin/*
clean-install:
rm -rf $(bindir)/fmi
rm -rf $(bindir)/servers
rm -rf $(bindir)/utils
rm -rf $(bindir)/files
rm -rf $(bindir)/clients
format:
clang-format -i -style=file $(SUBNAME)/*.h $(SUBNAME)/*.cpp test/*.cpp
install:
mkdir -p $(bindir)/fmi
mkdir -p $(bindir)/servers
mkdir -p $(bindir)/utils
mkdir -p $(bindir)/files
mkdir -p $(bindir)/clients
mkdir -p $(bindir)/clients/python
@list='$(PROGS)'; \
for prog in $$list; do \
echo $(INSTALL_PROG) $$prog $(bindir)/../$$prog; \
$(INSTALL_PROG) $$prog $(bindir)/../$$prog; \
done
cp src/python/*.py $(bindir)/clients/python/
mkdir -p $(libdir)/../lib/systemd/system
$(INSTALL_DATA) systemd/radon2smartmet.service $(libdir)/../lib/systemd/system
test:
+cd test && make test
objdir:
@mkdir -p obj/bin/clients
@mkdir -p obj/bin/files
@mkdir -p obj/bin/fmi
@mkdir -p obj/bin/servers
@mkdir -p obj/bin/utils
@mkdir -p bin/clients
@mkdir -p bin/files
@mkdir -p bin/fmi
@mkdir -p bin/servers
@mkdir -p bin/utils
rpm: $(SPEC).spec
rm -f $(SPEC).tar.gz # Clean a possible leftover from previous attempt
tar -czvf $(SPEC).tar.gz --exclude bin --exclude-vcs --transform "s,^,$(SPEC)/," *
rpmbuild -tb $(SPEC).tar.gz
rm -f $(SPEC).tar.gz
.SUFFIXES: $(SUFFIXES) .cpp
obj/bin/%.o: %.cpp
$(CXX) $(CFLAGS) $(INCLUDES) -c $< -o $@
-include obj/*/*.d