1 |
#***********************************************************************************************# |
2 |
# |
3 |
# INITIALIZATION |
4 |
# |
5 |
|
6 |
VPATH = $(SRCDIR) |
7 |
STATIC = |
8 |
DBMS = POSTGRESQL |
9 |
CUSTOMSW = |
10 |
|
11 |
# Run a script to determine the machine on which make is being run. This |
12 |
# MAY return a machine type, if the host found falls into one of several |
13 |
# categories (like dbserver). |
14 |
MACHTYPE = $(shell hostname) |
15 |
|
16 |
# If MACH was set when the make command was issued (eg., make MACH='N02'), then |
17 |
# use its value for the output/obj directory and use the drmsparams.mk variables |
18 |
# relevant to its value. Otherwise, use $(JSOC_MACHINE). |
19 |
ifeq ($(MACH),) |
20 |
MACH = $(JSOC_MACHINE) |
21 |
endif |
22 |
|
23 |
#***********************************************************************************************# |
24 |
# |
25 |
# COMPILER SELECTION |
26 |
# |
27 |
COMPILER = icc |
28 |
FCOMPILER = ifort |
29 |
MPICOMPILER = $(MPI_PATH)/mpicc |
30 |
MPIFCOMPILER = $(MPI_PATH)/mpif90 |
31 |
|
32 |
# can set through drmsparams.mk or through environment |
33 |
ifneq ($(JSOC_COMPILER),) |
34 |
COMPILER = $(JSOC_COMPILER) |
35 |
endif |
36 |
|
37 |
ifneq ($(JSOC_FCOMPILER),) |
38 |
FCOMPILER = $(JSOC_FCOMPILER) |
39 |
endif |
40 |
#***********************************************************************************************# |
41 |
|
42 |
#***********************************************************************************************# |
43 |
# This optional file has custom definitions created by the configure script. |
44 |
# Do this after compiler selection since drmsparams.mk might use $COMPILER or $FCOMPILER. |
45 |
# drmsparams.mk might also set compiler (through moreconfigure.pl) |
46 |
-include $(SRCDIR)/$(LOCALIZATIONDIR)/drmsparams.mk |
47 |
#***********************************************************************************************# |
48 |
|
49 |
#***********************************************************************************************# |
50 |
# |
51 |
# DEBUGGING |
52 |
# |
53 |
# Check for debug vs. release build - release is default. |
54 |
# To do a debug build, either set the environment variable JSOC_DEBUG to 1, OR |
55 |
# modify the following line so that DEBUG = 1. The environment variable takes precedence. |
56 |
# |
57 |
DEBUG = 0 |
58 |
|
59 |
ifdef JSOC_DEBUG |
60 |
ifeq ($(JSOC_DEBUG), 1) |
61 |
DEBUG = 1 |
62 |
else |
63 |
DEBUG = 0 |
64 |
endif |
65 |
endif |
66 |
#***********************************************************************************************# |
67 |
|
68 |
|
69 |
#***********************************************************************************************# |
70 |
# |
71 |
# WARNINGS |
72 |
# |
73 |
# Warnings ARE displayed, by default, for a release build. |
74 |
# |
75 |
WARN = 1 |
76 |
|
77 |
# Builder can request warnings via environment variable (setenv JSOC_WARN 1). |
78 |
# The environment variable takes precedence. |
79 |
ifdef JSOC_WARN |
80 |
ifeq ($(JSOC_WARN), 1) |
81 |
WARN = 1 |
82 |
else |
83 |
WARN = 0 |
84 |
endif |
85 |
endif |
86 |
|
87 |
ICC_WARNMORE = |
88 |
ifdef JSOC_WARNICC |
89 |
ifeq ($(COMPILER), icc) |
90 |
ICC_WARNMORE = $(JSOC_WARNICC) |
91 |
endif |
92 |
endif |
93 |
|
94 |
#***********************************************************************************************# |
95 |
|
96 |
|
97 |
#***********************************************************************************************# |
98 |
# |
99 |
# THIRD-PARTY LIBRARIES |
100 |
# |
101 |
# This section contains make variables that hold the paths to and names of third-party libraries. |
102 |
# Variables that end in 'H' contain the -I link flags that contain the include paths |
103 |
# for the library headers, variables that end in 'L' contain the -L link flags that |
104 |
# contain the paths to the library binaries, and variables |
105 |
# that end in "LIBS" contain the full link cmd (the -L flag plus the -l flag) |
106 |
# |
107 |
|
108 |
# PostgreSQL |
109 |
PGH = -I$(POSTGRES_INCS) |
110 |
|
111 |
# For use of dynamic library |
112 |
PGLIBS = $(POSTGRES_LIBS)/lib$(POSTGRES_LIB).so |
113 |
|
114 |
# CFITSIO |
115 |
CFITSIOH = -I$(CFITSIO_INCS) |
116 |
CFITSIOL = -L$(CFITSIO_LIBS) |
117 |
CFITSIOLIBNAME = $(CFITSIO_LIB) |
118 |
CFITSIOLIBS = $(CFITSIOL) -l$(CFITSIOLIBNAME) |
119 |
|
120 |
# GSL |
121 |
GSLH = -I$(GSL_INCS) |
122 |
GSLL = -L$(GSL_LIBS) |
123 |
GSLLIBS = $(GSLL) -lgsl |
124 |
|
125 |
# FFTW |
126 |
FFTWH = -I$(FFTW_INCS) |
127 |
FFTWL = -L$(FFTW_LIBS) |
128 |
FFTW3LIBS = $(FFTWL) -lfftw3 |
129 |
FFTW3FLIBS = $(FFTWL) -lfftw3f |
130 |
|
131 |
# TAR |
132 |
LIBTARH = -I$(TAR_INCS) |
133 |
LIBTARL = -L$(TAR_LIBS) -ltar |
134 |
|
135 |
# Python |
136 |
LIBPYH = -I$(PY_INCS) |
137 |
LIBPYL = -L$(PY_LIBS) -l$(PY_LIB) |
138 |
PYTHONHOME = "\"$(PY_HOME)\"" |
139 |
|
140 |
#***********************************************************************************************# |
141 |
|
142 |
|
143 |
#***********************************************************************************************# |
144 |
# |
145 |
# CUSTOM BUILDS |
146 |
# |
147 |
# Compilation define customizations (eg., for remote DRMS builds) |
148 |
ifneq ($(DRMS_DEFAULT_RETENTION),) |
149 |
# CUSTOMSW = $(CUSTOMSW) -DDRMS_DEFAULT_RETENTION="\"$(DRMS_DEFAULT_RETENTION)\"" |
150 |
CUSTOMSW := $(CUSTOMSW) -DDRMS_DEFAULT_RETENTION=$(DRMS_DEFAULT_RETENTION) |
151 |
endif |
152 |
|
153 |
# Due to legacy code, the name __LOCALIZED_DEFS__ must be used for NetDRMS builds. |
154 |
# Despite the name, this macro has nothing to do with localized definitions. It means |
155 |
# "not Stanford JSOC-SDP" (it essentially means NetDRMS). So, if __LOCALIZED_DEFS__ is set, then |
156 |
# the binaries were built for use outside of Stanford. |
157 |
# For future use, we also define the NETDRMS_BUILD as a synonym, but with a more appropriate name. |
158 |
# __LOCALIZED_DEFS__ is deprecated and should not be used in new code. |
159 |
ifeq ($(BUILD_TYPE),NETDRMS) |
160 |
CUSTOMSW := $(CUSTOMSW) -DNETDRMS_BUILD -D__LOCALIZED_DEFS__ |
161 |
endif |
162 |
|
163 |
# Stanford builds are marked by the JSOC_SDP_BUILD macro. |
164 |
ifeq ($(BUILD_TYPE),JSOC_SDP) |
165 |
CUSTOMSW := $(CUSTOMSW) -DJSOC_SDP_BUILD |
166 |
endif |
167 |
|
168 |
# |
169 |
#***********************************************************************************************# |
170 |
|
171 |
#***********************************************************************************************# |
172 |
# |
173 |
# Global flags |
174 |
# |
175 |
# All modules must be able to find libdsds.so. The define DRMS_LIBDIR specifies the path to |
176 |
# all libraries. |
177 |
|
178 |
GLOBALSW = -DDRMS_ARCH="\"$(MACH)\"" |
179 |
# |
180 |
#***********************************************************************************************# |
181 |
|
182 |
#***********************************************************************************************# |
183 |
# |
184 |
# WARNINGS |
185 |
# |
186 |
# NO LONGER USED - Disable several warnings/remarks when compiling with icc - icc's Wall is a bit picky, it |
187 |
# complains about extern declarations in .c files. |
188 |
# 1418 (remark) - external function definition with no prior declaration |
189 |
# 1419 (warning) - external declaration in primary source file |
190 |
# 310 (remark) - old style function declaration (pre-ANSI) |
191 |
# 279 ? |
192 |
# 981 (remark) - operands are evaluted in unspecified order |
193 |
|
194 |
# list of warnings to turn into errors |
195 |
ICC_WARNTOERR = -we266 |
196 |
|
197 |
ifeq ($(WARN), 1) |
198 |
# Show warnings (always true for a debug build). |
199 |
ICC_WARN = $(ICC_WARNMORE) |
200 |
GCC_WARN = -Wno-comment |
201 |
FCOMPILER_WARN = |
202 |
else |
203 |
# Don't show warnings. |
204 |
ICC_WARN = -w0 -vec-report0 -Wno-comment $(ICC_WARNTOERR) |
205 |
GCC_WARN = -Wno-comment |
206 |
ifeq ($(FCOMPILER), ifort) |
207 |
FCOMPILER_WARN = -vec-report0 |
208 |
else |
209 |
FCOMPILER_WARN = |
210 |
endif |
211 |
endif |
212 |
|
213 |
#***********************************************************************************************# |
214 |
|
215 |
|
216 |
#***********************************************************************************************# |
217 |
# |
218 |
# GLOBAL LINK FLAGS |
219 |
# |
220 |
# Link flags for all targets |
221 |
# |
222 |
LL_ALL = $(SYSLIBS) -lcurl |
223 |
GCC_LF_ALL = $(STATIC) |
224 |
ICC_LF_ALL = -diag-disable 10237 $(STATIC) -openmp -static-intel -Wl,-export-dynamic |
225 |
|
226 |
# Fortran global LINK flags |
227 |
ifeq ($(FCOMPILER), ifort) |
228 |
F_LF_ALL = -diag-disable 10237 -nofor-main -openmp -static-intel -Wl,-export-dynamic |
229 |
endif |
230 |
#***********************************************************************************************# |
231 |
|
232 |
#***********************************************************************************************# |
233 |
# |
234 |
# GLOBAL COMPILE FLAGS |
235 |
# |
236 |
GCC_CF_GCCCOMP = -DGCCCOMP |
237 |
ICC_CF_ICCCOMP = -DICCCOMP -openmp |
238 |
|
239 |
# can't figure out how to get stupid make to do if/else if/else |
240 |
ifeq ($(DEBUG), 0) |
241 |
GCC_CF_ALL = -I$(SRCDIR)/base/include -std=gnu99 -O2 $(GCC_WARN) $(GCC_CF_GCCCOMP) $(CUSTOMSW) $(GLOBALSW) -DNDEBUG |
242 |
|
243 |
ifeq ($(JSOC_MACHINE), linux_x86_64) |
244 |
ICC_CF_ALL = -I$(SRCDIR)/base/include -std=c99 -D_GNU_SOURCE $(ICC_WARN) $(ICC_CF_ICCCOMP) $(CUSTOMSW) $(GLOBALSW) -DNDEBUG |
245 |
GCC_CF_ALL = -I$(SRCDIR)/base/include -std=gnu99 -O2 -march=opteron $(GCC_WARN) $(GCC_CF_GCCCOMP) $(CUSTOMSW) $(GLOBALSW) |
246 |
endif |
247 |
|
248 |
ifeq ($(JSOC_MACHINE), linux_avx) |
249 |
ICC_CF_ALL = -xavx -I$(SRCDIR)/base/include -std=c99 -D_GNU_SOURCE $(ICC_WARN) $(ICC_CF_ICCCOMP) $(CUSTOMSW) $(GLOBALSW) -DNDEBUG |
250 |
endif |
251 |
|
252 |
ifeq ($(JSOC_MACHINE), linux_ia64) |
253 |
ICC_CF_ALL = -I$(SRCDIR)/base/include -std=c99 -D_GNU_SOURCE $(ICC_WARN) $(ICC_CF_ICCCOMP) $(CUSTOMSW) $(GLOBALSW) -DNDEBUG |
254 |
endif |
255 |
|
256 |
ifeq ($(JSOC_MACHINE), linux_ia32) |
257 |
GCC_CF_ALL = -I$(SRCDIR)/base/include -std=gnu99 -O2 -march=i686 $(GCC_WARN) $(GCC_CF_GCCCOMP) $(CUSTOMSW) $(GLOBALSW) -DNDEBUG |
258 |
endif |
259 |
|
260 |
else |
261 |
# -g tells the icc and gcc compilers to generate full debugging information |
262 |
GCC_CF_ALL = -I$(SRCDIR)/base/include -std=gnu99 -g $(GCC_WARN) $(GCC_CF_GCCCOMP) $(CUSTOMSW) $(GLOBALSW) |
263 |
ICC_CF_ALL = -I$(SRCDIR)/base/include -std=c99 -D_GNU_SOURCE -g $(ICC_WARN) $(ICC_CF_ICCCOMP) $(CUSTOMSW) $(GLOBALSW) |
264 |
endif |
265 |
|
266 |
# Fortran global COMPILE flags |
267 |
ifeq ($(JSOC_MACHINE), linux_avx) |
268 |
ifeq ($(FCOMPILER), ifort) |
269 |
F_CF_ALL := -xavx -openmp |
270 |
endif |
271 |
endif |
272 |
|
273 |
ifeq ($(JSOC_MACHINE), linux_x86_64) |
274 |
ifeq ($(FCOMPILER), ifort) |
275 |
F_CF_ALL := -openmp |
276 |
endif |
277 |
endif |
278 |
|
279 |
# Other compiler-specific Fortran COMPILE flags |
280 |
ifeq ($(FCOMPILER), ifort) |
281 |
FCFLAGS_INIT := -ftrapuv |
282 |
else |
283 |
# must be gfortran |
284 |
FCFLAGS_INIT := |
285 |
endif |
286 |
|
287 |
ifeq ($(DEBUG), 0) |
288 |
# -xW optimizes ifort compilation for Pentium 4 |
289 |
# -ftrapuv initializes stack local variables to an unusual value to aid error detection. |
290 |
F_CF_ALL := $(F_CF_ALL) $(FCOMPILER_WARN) |
291 |
else |
292 |
F_CF_ALL := $(F_CF_ALL) -g $(FCFLAGS_INIT) $(FCOMPILER_WARN) |
293 |
endif |
294 |
#***********************************************************************************************# |
295 |
|
296 |
|
297 |
#***********************************************************************************************# |
298 |
# |
299 |
# BUILD TOOLS |
300 |
# |
301 |
# The C compiler named here must output full (header) dependencies in $(@).d. |
302 |
# It may be necessary to create a script similar to ccd-gcc for your compiler. |
303 |
# |
304 |
GCC_CMPLR = $(SRCDIR)/build/ccd-gcc |
305 |
ICC_CMPLR = $(SRCDIR)/build/ccd-icc |
306 |
ARCHIVE = ar crus $@ $^ |
307 |
|
308 |
ECPG = ecpg -o $@ -c $< |
309 |
SWIG = swig -perl5 -o $@ $< |
310 |
|
311 |
GCC_COMP = $(GCC_CMPLR) $(GCC_CF_ALL) $(CF_TGT) -o $@ -c $< |
312 |
ICC_COMP = $(ICC_CMPLR) $(ICC_CF_ALL) $(CF_TGT) -o $@ -c $< |
313 |
|
314 |
GCC_LINK = $(GCC_CMPLR) $(GCC_LF_ALL) $(LF_TGT) -o $@ $^ $(LL_TGT) $(LL_ALL) |
315 |
ICC_LINK = $(ICC_CMPLR) $(ICC_LF_ALL) $(LF_TGT) -o $@ $^ $(LL_TGT) $(LL_ALL) |
316 |
|
317 |
GCC_COMPLINK = $(GCC_CMPLR) $(GCC_CF_ALL) $(CF_TGT) $(GCC_LF_ALL) $(LF_TGT) -o $@ $< $(LL_TGT) $(LL_ALL) |
318 |
ICC_COMPLINK = $(ICC_CMPLR) $(GCC_CF_ALL) $(CF_TGT) $(ICC_LF_ALL) $(LF_TGT) -o $@ $< $(LL_TGT) $(LL_ALL) |
319 |
|
320 |
ifneq ($(COMPILER), icc) |
321 |
COMP = $(GCC_COMP) |
322 |
LINK = $(GCC_LINK) |
323 |
COMPLINK = $(GCC_COMPLINK) |
324 |
else |
325 |
COMP = $(ICC_COMP) |
326 |
LINK = $(ICC_LINK) |
327 |
COMPLINK = $(ICC_COMPLINK) |
328 |
endif |
329 |
|
330 |
FCOMP = $(FCOMPILER) $(F_CF_ALL) $(FF_TGT) -o $@ -c $< |
331 |
FLINK = $(FCOMPILER) $(F_LF_ALL) $(LF_TGT) -o $@ $^ $(LL_TGT) $(LL_ALL) |
332 |
|
333 |
SLBIN = ln -sf ../../_$(MACH)/$@ ../bin/$(MACH)/ |
334 |
SLLIB = ln -sf ../../_$(MACH)/$@ ../lib/$(MACH)/ |
335 |
#***********************************************************************************************# |
336 |
|
337 |
|
338 |
#***********************************************************************************************# |
339 |
# |
340 |
# LIBRARY COLLECTIONS |
341 |
# |
342 |
ALL_LIBS_FPIC = $(LIBDRMSCLIENT_FPIC) $(LIBDBCLIENT_FPIC) $(LIBCMDPARAMS_FPIC) $(LIBTHREADUTIL_FPIC) $(LIBRICECOMP_FPIC) $(LIBDEFS_FPIC) $(LIBMISC_FPIC) $(LIBDSTRUCT_FPIC) $(LIBTIMEIO_FPIC) $(LIBFITSRW_FPIC) |
343 |
|
344 |
### Standard parts |
345 |
# |
346 |
include $(SRCDIR)/Rules.mk |
347 |
|
348 |
# Libraries from src/util linked with all programs. |
349 |
ifneq ($(COMPILER), icc) |
350 |
SYSLIBS = -lz -ldl -lpthread -lm -lutil |
351 |
else |
352 |
SYSLIBS = -lz -ldl -lpthread -lutil |
353 |
endif |
354 |
SRCLIBS = $(LIBTHREADUTIL) $(LIBRICECOMP) $(LIBCMDPARAMS) $(LIBTIMEIO) $(LIBFITSRW) $(LIBERRLOG) $(LIBEXPDRMS) $(LIBEXPUTL) $(LIBMISC) $(LIBDSTRUCT) $(LIBSTATS) |
355 |
FSRCLIBS = $(LIBTHREADUTIL) $(LIBRICECOMP) $(LIBCMDPARAMSF) $(LIBTIMEIO) $(LIBFITSRW) $(LIBERRLOG) $(LIBEXPDRMS) $(LIBEXPUTL) $(LIBMISC) $(LIBDSTRUCT) $(LIBSTATS) |
356 |
|
357 |
########## Libraries to link for server executables, ############## |
358 |
########## standalone executables and pipeline modules. ############## |
359 |
|
360 |
# SERVERLIBS: Libraries linked with "server" programs that |
361 |
# need direct access to the DRMS databases. |
362 |
SERVERLIBS = $(LIBDRMS) $(LIBDEFSSERVER) $(LIBDB) $(LIBSUMSAPI) $(LIBCJSON) $(SRCLIBS) |
363 |
|
364 |
# EXELIBS: Libraries linked with standalone executables. |
365 |
EXELIBS = $(LIBDRMSCLIENT) $(LIBDEFSCLIENT) $(LIBDBCLIENT) $(SRCLIBS) |
366 |
|
367 |
# MODLIBS: Libraries linked with DRMS modules. |
368 |
MODLIBS = $(LIBJSOC_MAIN) $(SERVERLIBS) |
369 |
|
370 |
# MODLIBS_SOCK: Libraries linked with DRMS modules with socket connection to a drms_server |
371 |
MODLIBS_SOCK = $(LIBJSOC_MAIN_SOCK) $(LIBDRMSCLIENT) $(LIBDEFSCLIENT) $(LIBDBCLIENT) $(LIBSUMSAPI) $(LIBCJSON) $(SRCLIBS) |
372 |
|
373 |
# FMODLIBS: Libraries linked with DRMS Fortran modules |
374 |
FMODLIBS_SOCK = $(LIBJSOC_MAIN_SOCK_F) $(LIBINTHANDLESF) $(LIBDRMSCLIENT) $(LIBDEFSCLIENT) $(LIBDBCLIENT) $(FSRCLIBS) |
375 |
#***********************************************************************************************# |
376 |
|
377 |
|
378 |
#***********************************************************************************************# |
379 |
# |
380 |
# PROJECT MAKE RULES |
381 |
# |
382 |
# Make rules that apply to all projects outside of the base DRMS/SUMS system |
383 |
-include $(SRCDIR)/$(LOCALIZATIONDIR)/make_basic.mk |
384 |
#***********************************************************************************************# |
385 |
|
386 |
|
387 |
#***********************************************************************************************# |
388 |
# |
389 |
# MODULE TYPES |
390 |
# |
391 |
# Make rules that apply to all projects, inside and outside of the base DRMS/SUMS system |
392 |
$(CEXE): %: %.o $(EXELIBS) |
393 |
$(LINK) |
394 |
$(SLBIN) |
395 |
|
396 |
$(FEXE): %: %.o |
397 |
$(FLINK) |
398 |
$(SLBIN) |
399 |
|
400 |
$(SERVEREXE): LL_TGT := $(LL_TGT) $(PGLIBS) $(CFITSIOLIBS) |
401 |
$(SERVEREXE): %: %.o $(SERVERLIBS) |
402 |
$(LINK) |
403 |
$(SLBIN) |
404 |
|
405 |
$(MODEXE): LL_TGT := $(LL_TGT) $(PGLIBS) $(CFITSIOLIBS) |
406 |
$(MODEXE): %: %.o $(MODLIBS) |
407 |
$(LINK) |
408 |
$(SLBIN) |
409 |
|
410 |
$(MODEXE_SOCK): LL_TGT := $(LL_TGT) $(PGLIBS) $(CFITSIOLIBS) |
411 |
$(MODEXE_SOCK): %_sock: %.o $(MODLIBS_SOCK) |
412 |
$(LINK) |
413 |
$(SLBIN) |
414 |
# FMODEXE_SOCK contains all Fortran modules - the DoIt() function is defined inside a .f file. |
415 |
# These are socket-connect modules only. Assume they use third-party Fortran libraries |
416 |
# (although this may not be the case). |
417 |
$(FMODEXE_SOCK): LL_TGT := $(LL_TGT) $(PGLIBS) $(CFITSIOLIBS) |
418 |
$(FMODEXE_SOCK): %_sock: %.o $(FMODLIBS_SOCK) |
419 |
$(FLINK) |
420 |
$(SLBIN) |
421 |
|
422 |
# MODEXE_USEF contains all C direct-connect modules that use third-party Fortran libraries. |
423 |
$(MODEXE_USEF): LL_TGT := $(LL_TGT) $(PGLIBS) $(CFITSIOLIBS) |
424 |
$(MODEXE_USEF): %: %.o $(MODLIBS) |
425 |
$(FLINK) |
426 |
$(SLBIN) |
427 |
# MODEXE_USEF contains all C socket-connect modules that use third-party Fortran libraries. |
428 |
$(MODEXE_USEF_SOCK): LL_TGT := $(LL_TGT) $(PGLIBS) $(CFITSIOLIBS) |
429 |
$(MODEXE_USEF_SOCK): %_sock: %.o $(MODLIBS_SOCK) |
430 |
$(FLINK) |
431 |
$(SLBIN) |
432 |
#***********************************************************************************************# |