-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.clang
152 lines (112 loc) · 3.05 KB
/
Makefile.clang
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
SUBNAME = gis
LIB = brainstorm-$(SUBNAME)
INCDIR = smartmet/brainstorm/engines/$(SUBNAME)
# Installation directories
processor := $(shell uname -p)
ifeq ($(origin PREFIX), undefined)
PREFIX = /usr
else
PREFIX = $(PREFIX)
endif
ifeq ($(processor), x86_64)
libdir = $(PREFIX)/lib64
else
libdir = $(PREFIX)/lib
endif
bindir = $(PREFIX)/bin
includedir = $(PREFIX)/include
datadir = $(PREFIX)/share
enginedir = $(datadir)/brainstorm/engines
objdir = obj
# Compiler options
DEFINES = -DUNIX -D_REENTRANT
FLAGS = -std=c++11 -fPIC -MD \
-Weverything \
-Wno-c++98-compat \
-Wno-float-equal \
-Wno-padded \
-Wno-missing-prototypes
CC = clang++
# Compile options in detault, debug and profile modes
CFLAGS = $(DEFINES) $(FLAGS) -DNDEBUG -O2
CFLAGS_DEBUG = $(DEFINES) $(FLAGS) -Werror -O0 -g
CFLAGS_PROFILE = $(DEFINES) $(FLAGS) -DNDEBUG -O2 -g -pg
INCLUDES = -isystem $(includedir) \
-isystem $(includedir)/smartmet \
-isystem $(includedir)/mysql
LIBS = -L$(libdir) \
-lsmartmet-brainstorm-spine \
-lsmartmet-newbase \
-lsmartmet-macgyver \
-lgeos \
-lgdal \
-lboost_thread-mt \
-lboost_filesystem-mt \
-lboost_iostreams-mt \
-lboost_regex-mt \
-lboost_system-mt \
-lbz2 -lz
# rpm variables
rpmsourcedir = /tmp/$(shell whoami)/rpmbuild
rpmerr = "There's no spec file ($(LIB).spec). RPM wasn't created. Please make a spec file or copy and rename it into $(LIB).spec"
# What to install
LIBFILE = $(SUBNAME).so
# How to install
INSTALL_PROG = install -p -m 775
INSTALL_DATA = install -p -m 664
# Compile option overrides
ifneq (,$(findstring debug,$(MAKECMDGOALS)))
CFLAGS = $(CFLAGS_DEBUG)
endif
ifneq (,$(findstring profile,$(MAKECMDGOALS)))
CFLAGS = $(CFLAGS_PROFILE)
endif
# Compilation directories
vpath %.cpp source
vpath %.h include
# The files to be compiled
SRCS = $(wildcard source/*.cpp)
HDRS = $(wildcard include/*.h)
OBJS = $(patsubst %.cpp, obj/%.o, $(notdir $(SRCS)))
INCLUDES := -Iinclude $(INCLUDES)
.PHONY: test rpm
# The rules
all: configtest objdir $(LIBFILE)
debug: all
release: all
profile: all
$(LIBFILE): $(OBJS)
$(CC) $(CFLAGS) -shared -rdynamic -o $(LIBFILE) $(OBJS) $(LIBS)
clean:
rm -f $(LIBFILE) $(OBJS) *~ source/*~ include/*~
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_DATA) $(LIBFILE) $(enginedir)/$(LIBFILE)
test:
cd test && make test
objdir:
@mkdir -p $(objdir)
rpm: clean
if [ -e $(LIB).spec ]; \
then \
mkdir -p $(rpmsourcedir) ; \
tar -C ../ -cf $(rpmsourcedir)/smartmet-$(LIB).tar $(SUBNAME) ; \
gzip -f $(rpmsourcedir)/smartmet-$(LIB).tar ; \
TAR_OPTIONS=--wildcards rpmbuild -v -ta $(rpmsourcedir)/smartmet-$(LIB).tar.gz ; \
rm -f $(rpmsourcedir)/smartmet-$(LIB).tar.gz ; \
else \
echo $(rpmerr); \
fi;
.SUFFIXES: $(SUFFIXES) .cpp
obj/%.o: %.cpp
$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $<
ifneq ($(wildcard obj/*.d),)
-include $(wildcard obj/*.d)
endif