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