1 | # | |
---|
2 | # o---------------------------------------------------------------------o |
---|
3 | # | |
---|
4 | # | MAD makefile - config |
---|
5 | # | |
---|
6 | # o---------------------------------------------------------------------o |
---|
7 | # | |
---|
8 | # | Methodical Accelerator Design |
---|
9 | # | |
---|
10 | # | Copyright (c) 2011+ CERN, mad@cern.ch |
---|
11 | # | |
---|
12 | # | For more information, see http://cern.ch/mad |
---|
13 | # | |
---|
14 | # o---------------------------------------------------------------------o |
---|
15 | # | |
---|
16 | # | $Id$ |
---|
17 | # | |
---|
18 | |
---|
19 | # detect operating system |
---|
20 | # OSTYPE = Linux, Darwin, Cygwin, Windows (or empty) |
---|
21 | # OSARCH = i386, i686, x86, x86_64, amd64, ia64 (or empty) |
---|
22 | ifeq ($(windir),) |
---|
23 | OSTYPE := $(shell uname -s) |
---|
24 | OSARCH := $(shell uname -m) |
---|
25 | OSTYPE := $(patsubst CYGWIN%,Cygwin,$(OSTYPE)) |
---|
26 | else |
---|
27 | OSTYPE := $(findstring Windows,$(shell ver)) |
---|
28 | OSARCH := $(if $(PROCESSOR_ARCHITEW6432),$(PROCESSOR_ARCHITEW6432) \ |
---|
29 | ,$(PROCESSOR_ARCHITECTURE)) |
---|
30 | endif |
---|
31 | |
---|
32 | # some useful command and variables |
---|
33 | ifeq ($(OSTYPE),Windows) |
---|
34 | / := $(strip \ ) |
---|
35 | LS := dir /L /B |
---|
36 | CP := copy /Y |
---|
37 | MV := move |
---|
38 | RM := del /f |
---|
39 | RMDIR := rmdir /s /q |
---|
40 | FIND := find_cmd_not_found |
---|
41 | CAT := more |
---|
42 | HOME := $(HOMEDRIVE)$(HOMEPATH) |
---|
43 | else |
---|
44 | / := / |
---|
45 | LS := ls -1 |
---|
46 | CP := cp -f |
---|
47 | MV := mv -f |
---|
48 | RM := rm -f |
---|
49 | RMDIR := rm -fr |
---|
50 | FIND := find |
---|
51 | CAT := cat |
---|
52 | endif |
---|
53 | |
---|
54 | # set command echo (SHOW=yes -> trace commands & remove echo) |
---|
55 | ifneq ($(OSTYPE),Windows) |
---|
56 | _ := $(if $(call eq,$(SHOW),yes),,@) |
---|
57 | E := $(if $(call eq,$(SHOW),yes),@ \#,@ echo) |
---|
58 | else |
---|
59 | _ := $(if $(call eq,$(SHOW),yes),,@) |
---|
60 | E := $(if $(call eq,$(SHOW),yes),@ rem,@ echo) |
---|
61 | endif |
---|
62 | |
---|
63 | # backward slash manip |
---|
64 | ifeq ($(OSTYPE),Windows) |
---|
65 | / := \$(EMPTY) |
---|
66 | ; := & |
---|
67 | f1bs = $(subst /,\,$1) |
---|
68 | f2bs = $(subst /,\\,$1) |
---|
69 | s1bs = $(subst $(SPACE),\ ,$1) |
---|
70 | else |
---|
71 | / := / |
---|
72 | ; := ; |
---|
73 | f1bs = $1 |
---|
74 | f2bs = $1 |
---|
75 | s1bs = $(subst $(SPACE),\ ,$1) |
---|
76 | endif |
---|
77 | |
---|
78 | # detect ARCH if requested |
---|
79 | ifeq ($(ARCH),detect) |
---|
80 | ARCH := $(if $(findstring 64,$(OSARCH)),64,32) |
---|
81 | endif |
---|
82 | |
---|
83 | # detect TESTS if requested or provided |
---|
84 | ifeq ($(TESTS),detect) |
---|
85 | override TESTS := $(notdir $(wildcard tests/test-*)) |
---|
86 | endif |
---|
87 | |
---|
88 | # default optimization level |
---|
89 | ifeq ($(NOPT),) |
---|
90 | NOPT := 3 |
---|
91 | endif |
---|
92 | |
---|
93 | # destination directory |
---|
94 | ifeq ($(DESTDIR),) |
---|
95 | DESTDIR := build$/ |
---|
96 | else |
---|
97 | override DESTDIR := $(subst $/$/,$/,$(strip $(DESTDIR))$/) |
---|
98 | endif |
---|
99 | |
---|
100 | # build directory |
---|
101 | ifeq ($(APPENDLD),yes) |
---|
102 | OBJDIR = $(DESTDIR)$(OSTYPE)$(ARCH)_$(LDNAME) |
---|
103 | else |
---|
104 | OBJDIR := $(DESTDIR)$(OSTYPE)$(ARCH) |
---|
105 | endif |
---|
106 | |
---|
107 | # project's name |
---|
108 | PRJNAME := $(PROJECT)$(ARCH) |
---|
109 | |
---|
110 | # list of build targets |
---|
111 | BUILDGOALS := $(PROJECT) |
---|
112 | |
---|
113 | # default target (immediate!) |
---|
114 | .DEFAULT_GOAL := $(PROJECT) |
---|
115 | |
---|
116 | # add default target to make commands |
---|
117 | ifeq ($(MAKECMDGOALS),) |
---|
118 | MAKECMDGOALS := $(.DEFAULT_GOAL) |
---|
119 | endif |
---|
120 | |
---|
121 | # shortcut for Intel compilers familly |
---|
122 | ifeq ($(Intel),yes) |
---|
123 | ifeq ($(OSTYPE),Windows) |
---|
124 | CC := $(if $(CC),icl,) |
---|
125 | CXX := $(if $(CXX),icl,) |
---|
126 | else |
---|
127 | CC := $(if $(CC),icc,) |
---|
128 | CXX := $(if $(CXX),icc,) |
---|
129 | endif |
---|
130 | FC := $(if $(FC),ifort,) |
---|
131 | endif |
---|
132 | |
---|
133 | # shortcut for GNU compilers familly |
---|
134 | ifeq ($(GNU),yes) |
---|
135 | CC := $(if $(CC),gcc,) |
---|
136 | CXX := $(if $(CXX),g++,) |
---|
137 | FC := $(if $(FC),gfortran,) |
---|
138 | endif |
---|
139 | |
---|
140 | # cleanup default make settings |
---|
141 | ifeq ($(origin CC),default) |
---|
142 | CC := |
---|
143 | endif |
---|
144 | ifeq ($(origin CXX),default) |
---|
145 | CXX := |
---|
146 | endif |
---|
147 | ifeq ($(origin FC),default) |
---|
148 | FC := |
---|
149 | endif |
---|
150 | ifeq ($(origin LD),default) |
---|
151 | LD := |
---|
152 | endif |
---|
153 | ifeq ($(origin AR),default) |
---|
154 | AR := |
---|
155 | endif |
---|
156 | ifeq ($(origin ND),default) |
---|
157 | ND := |
---|
158 | endif |
---|
159 | |
---|
160 | # standard included settings |
---|
161 | ifndef CCNAME |
---|
162 | CCNAME := $(CC) |
---|
163 | endif |
---|
164 | ifndef CXXNAME |
---|
165 | CXXNAME := $(CXX) |
---|
166 | endif |
---|
167 | ifndef FCNAME |
---|
168 | FCNAME := $(FC) |
---|
169 | endif |
---|
170 | ifndef LDNAME |
---|
171 | LDNAME := $(LD) |
---|
172 | endif |
---|
173 | ifndef ARNAME |
---|
174 | ARNAME := $(AR) |
---|
175 | endif |
---|
176 | ifndef NDNAME |
---|
177 | NDNAME := $(ND) |
---|
178 | endif |
---|
179 | |
---|
180 | # standard included makefiles |
---|
181 | ifndef FILE_PRE |
---|
182 | FILE_PRE := Makefile_pre # user's preprocessing extra stuff |
---|
183 | endif |
---|
184 | ifndef FILE_VER |
---|
185 | FILE_VER := VERSION # setup project VERSION and VERSION_DATE |
---|
186 | endif |
---|
187 | ifndef FILE_CPP |
---|
188 | FILE_CPP := Makefile_cpp # setup project specific CPPFLAGS defines |
---|
189 | endif |
---|
190 | ifndef FILE_C |
---|
191 | FILE_C := Makefile_c # setup project CC_SRC and CC_HDR |
---|
192 | endif |
---|
193 | ifndef FILE_CXX |
---|
194 | FILE_CXX := Makefile_cxx # setup project CXX_SRC and CXX_HDR |
---|
195 | endif |
---|
196 | ifndef FILE_F90 |
---|
197 | FILE_F90 := Makefile_f90 # setup project FC_SRC |
---|
198 | endif |
---|
199 | ifndef FILE_LIB |
---|
200 | FILE_LIB := Makefile_lib # setup project LIBS paths and libs |
---|
201 | endif |
---|
202 | ifndef FILE_SYS |
---|
203 | FILE_SYS := Makefile_sys # setup project System specific stuffs |
---|
204 | endif |
---|
205 | ifndef FILE_TEST |
---|
206 | FILE_TEST := Makefile_test # setup project tests |
---|
207 | endif |
---|
208 | ifndef FILE_POST |
---|
209 | FILE_POST := Makefile_post # user's postprocessing extra stuff |
---|
210 | endif |
---|
211 | |
---|
212 | # standard translation settings |
---|
213 | CC_tr = $(strip $1) |
---|
214 | CXX_tr = $(strip $1) |
---|
215 | FC_tr = $(strip $1) |
---|
216 | LD_tr = $(strip $1) |
---|
217 | AR_tr = $(strip $1) |
---|
218 | ND_tr = $(strip $1) |
---|
219 | |
---|
220 | # standard build defines |
---|
221 | ifeq ($(origin CPPFLAGS),default) |
---|
222 | CPPFLAGS = |
---|
223 | endif |
---|
224 | |
---|
225 | ifeq ($(DEBUG),yes) |
---|
226 | CPPFLAGS += -D_DEBUG |
---|
227 | endif |
---|
228 | |
---|
229 | ifeq ($(PROFILE),yes) |
---|
230 | CPPFLAGS += -D_PROFILE |
---|
231 | endif |
---|
232 | |
---|
233 | ifeq ($(STATIC),yes) |
---|
234 | CPPFLAGS += -D_STATIC |
---|
235 | endif |
---|
236 | |
---|
237 | ifeq ($(SHARED),yes) |
---|
238 | CPPFLAGS += -D_SHARED |
---|
239 | endif |
---|
240 | |
---|
241 | ifeq ($(PLUGIN),yes) |
---|
242 | CPPFLAGS += -D_PLUGIN |
---|
243 | endif |
---|
244 | |
---|
245 | # gnu libs directory (if needed, lazy) |
---|
246 | GNULIBDIR = $(dir $(shell $(CC) $(CFLAGS) -print-file-name=libgcc.a)) |
---|
247 | |
---|
248 | # clear suffixes (avoid misbehavior) |
---|
249 | .SUFFIXES: |
---|
250 | |
---|
251 | # clear search path (avoid misbehavior) |
---|
252 | VPATH = |
---|
253 | vpath |
---|
254 | |
---|
255 | # end of makefile |
---|