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