-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
183 lines (142 loc) · 4.41 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
180
181
182
183
SUBNAME = grid-files
LIB = smartmet-$(SUBNAME)
SPEC = smartmet-library-$(SUBNAME)
INCDIR = smartmet/$(SUBNAME)
REQUIRES = geos gdal webp filesystem
include $(shell echo $${PREFIX-/usr})/share/smartmet/devel/makefile.inc
DEFINES = -DUNIX -D_REENTRANT -DUSE_UNSTABLE_GEOS_CPP_API
CFLAGS += $(shell pkg-config --cflags libopenjp2)
OPENJPEG2_LIBS += $(shell pkg-config --libs libopenjp2)
LIBS += \
$(PREFIX_LDFLAGS) \
$(REQUIRED_LIBS) \
-lsmartmet-newbase \
-lsmartmet-spine \
-lsmartmet-macgyver \
-lsmartmet-trax \
-lboost_iostreams \
-lboost_thread \
-lpng \
-ljpeg \
$(OPENJPEG2_LIBS) \
-laec \
-lz
# What to install
LIBFILE = libsmartmet-$(SUBNAME).so
# Compilation directories
vpath %.cpp src \
src/common \
src/grid \
src/grib1 \
src/grib1/definition \
src/grib1/implementation \
src/grib2 \
src/grib2/definition \
src/grib2/implementation \
src/identification \
src/netcdf \
src/querydata
vpath %.h src \
src/common \
src/grid \
src/grib1 \
src/grib1/definition \
src/grib1/implementation \
src/grib2 \
src/grib2/definition \
src/grib2/implementation \
src/identification \
src/netcdf \
src/querydata
vpath %.o obj
# The files to be compiled
SRCS = $(patsubst src/%,%,$(wildcard src/*.cpp src/*/*.cpp src/*/definition/*.cpp src/*/implementation/*.cpp))
OBJS = $(SRCS:%.cpp=%.o)
OBJFILES = $(OBJS:%.o=obj/%.o)
DEPFILES = $(OBJFILES:%.o=%.d)
INCLUDES := -Isrc $(INCLUDES)
.PHONY: test rpm
# The rules
all: objdir $(LIBFILE)
#debug:
# make create_def;
# make obj_and_lib;
debug: all
release: all
profile: all
#obj_and_lib: objdir $(LIBFILE)
$(LIBFILE): $(OBJFILES)
$(CXX) $(LDFLAGS) -shared -rdynamic -o $(LIBFILE) $(OBJFILES) $(LIBS)
@echo Checking $(LIBFILE) for unresolved references
@if ldd -r $(LIBFILE) 2>&1 | c++filt | grep ^undefined\ symbol |\
grep -Pv ':\ __(?:(?:a|t|ub)san_|sanitizer_)'; \
then \
rm -v $(LIBFILE); \
exit 1; \
fi
clean:
rm -f src/*~ src/*/*~ src/*/*/*~
rm -rf obj
rm -rf $(LIBFILE)
clean-install:
rm -rf $(includedir)/$(INCDIR)/*
rm -f $(libdir)/$(LIBFILE)
format:
clang-format -i -style=file $(SUBNAME)/*.h $(SUBNAME)/*.cpp test/*.cpp
install:
@mkdir -p $(includedir)/$(INCDIR)
@mkdir -p $(includedir)/$(INCDIR)/common
@mkdir -p $(includedir)/$(INCDIR)/grid
@mkdir -p $(includedir)/$(INCDIR)/grib1
@mkdir -p $(includedir)/$(INCDIR)/grib1/definition
@mkdir -p $(includedir)/$(INCDIR)/grib1/implementation
@mkdir -p $(includedir)/$(INCDIR)/grib2
@mkdir -p $(includedir)/$(INCDIR)/grib2/definition
@mkdir -p $(includedir)/$(INCDIR)/grib2/implementation
@mkdir -p $(includedir)/$(INCDIR)/identification
@mkdir -p $(includedir)/$(INCDIR)/netcdf
@mkdir -p $(includedir)/$(INCDIR)/querydata
@cp src/common/*.h $(includedir)/$(INCDIR)/common
@cp src/grid/*.h $(includedir)/$(INCDIR)/grid
@cp src/grib1/*.h $(includedir)/$(INCDIR)/grib1
@cp src/grib1/definition/*.h $(includedir)/$(INCDIR)/grib1/definition
@cp src/grib1/implementation/*.h $(includedir)/$(INCDIR)/grib1/implementation
@cp src/grib2/*.h $(includedir)/$(INCDIR)/grib2
@cp src/grib2/definition/*.h $(includedir)/$(INCDIR)/grib2/definition
@cp src/grib2/implementation/*.h $(includedir)/$(INCDIR)/grib2/implementation
@cp src/identification/*.h $(includedir)/$(INCDIR)/identification
@cp src/netcdf/*.h $(includedir)/$(INCDIR)/netcdf
@cp src/querydata/*.h $(includedir)/$(INCDIR)/querydata
@mkdir -p $(libdir)
$(INSTALL_PROG) $(LIBFILE) $(libdir)/$(LIBFILE)
test:
+cd test && make test
objdir:
@mkdir -p obj \
obj/common \
obj/grid \
obj/grib1 \
obj/grib1/definition \
obj/grib1/implementation \
obj/grib2 \
obj/grib2/definition \
obj/grib2/implementation \
obj/identification \
obj/netcdf \
obj/querydata
create_def:
cd src/grib1/definition; $(MAKE) definitions;
cd src/grib2/definition; $(MAKE) definitions;
delete_def:
cd src/grib1/definition; $(MAKE) clean;
cd src/grib2/definition; $(MAKE) clean;
rpm: clean $(SPEC).spec
rm -f $(SPEC).tar.gz # Clean a possible leftover from previous attempt
tar -czvf $(SPEC).tar.gz --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 $@ $<
obj/common/GeneralFunctions.o: CFLAGS += -Wno-deprecated-declarations
-include $(DEPFILES)