]> err.no Git - sope/blob - common.make
bebff12a9e089e3ed262772a96868184cff7bd91
[sope] / common.make
1 #   -*-makefile-*-
2 #   common.make
3 #
4 #   Set all of the common environment variables.
5 #
6 #   Copyright (C) 1997, 2001 Free Software Foundation, Inc.
7 #
8 #   Author:  Scott Christley <scottc@net-community.com>
9 #   Author:  Ovidiu Predescu <ovidiu@net-community.com>
10 #   Author:  Nicola Pero <n.pero@mi.flashnet.it>
11 #
12 #   This file is part of the GNUstep Makefile Package.
13 #
14 #   This library is free software; you can redistribute it and/or
15 #   modify it under the terms of the GNU General Public License
16 #   as published by the Free Software Foundation; either version 2
17 #   of the License, or (at your option) any later version.
18 #   
19 #   You should have received a copy of the GNU General Public
20 #   License along with this library; see the file COPYING.LIB.
21 #   If not, write to the Free Software Foundation,
22 #   59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23
24 ifeq ($(COMMON_MAKE_LOADED),)
25 COMMON_MAKE_LOADED = yes
26
27 SHELL = /bin/sh
28
29 # GNUSTEP_BASE_INSTALL by default is `' - this is correct
30
31 # GNUSTEP_BUILD_DIR is the directory in which anything generated
32 # during the build will be placed.  '.' means it's the same as the
33 # source directory; this case is the default/common and we optimize
34 # for it whenever possible.
35 ifeq ($(GNUSTEP_BUILD_DIR),)
36   GNUSTEP_BUILD_DIR = .
37 endif
38
39 #
40 # Scripts to run for parsing canonical names
41 #
42 CONFIG_GUESS_SCRIPT    = $(GNUSTEP_MAKEFILES)/config.guess
43 CONFIG_SUB_SCRIPT      = $(GNUSTEP_MAKEFILES)/config.sub
44 CONFIG_CPU_SCRIPT      = $(GNUSTEP_MAKEFILES)/cpu.sh
45 CONFIG_VENDOR_SCRIPT   = $(GNUSTEP_MAKEFILES)/vendor.sh
46 CONFIG_OS_SCRIPT       = $(GNUSTEP_MAKEFILES)/os.sh
47 CLEAN_CPU_SCRIPT       = $(GNUSTEP_MAKEFILES)/clean_cpu.sh
48 CLEAN_VENDOR_SCRIPT    = $(GNUSTEP_MAKEFILES)/clean_vendor.sh
49 CLEAN_OS_SCRIPT        = $(GNUSTEP_MAKEFILES)/clean_os.sh
50 ifeq ($(GNUSTEP_FLATTENED),)
51   WHICH_LIB_SCRIPT \
52         = $(GNUSTEP_MAKEFILES)/$(GNUSTEP_HOST_CPU)/$(GNUSTEP_HOST_OS)/which_lib
53 else
54   WHICH_LIB_SCRIPT = $(GNUSTEP_MAKEFILES)/which_lib
55 endif
56 LD_LIB_PATH_SCRIPT     = $(GNUSTEP_MAKEFILES)/ld_lib_path.sh
57 TRANSFORM_PATHS_SCRIPT = $(GNUSTEP_MAKEFILES)/transform_paths.sh
58 REL_PATH_SCRIPT        = $(GNUSTEP_MAKEFILES)/relative_path.sh
59
60 # Take the makefiles from the system root
61 ifeq ($(GNUSTEP_MAKEFILES),)
62   GNUSTEP_MAKEFILES = $(GNUSTEP_SYSTEM_ROOT)/Library/Makefiles
63 endif
64
65 #
66 # Determine the compilation host and target
67 #
68 include $(GNUSTEP_MAKEFILES)/names.make
69
70 ifeq ($(GNUSTEP_FLATTENED),)
71   GNUSTEP_HOST_DIR = $(GNUSTEP_HOST_CPU)/$(GNUSTEP_HOST_OS)
72   GNUSTEP_TARGET_DIR = $(GNUSTEP_TARGET_CPU)/$(GNUSTEP_TARGET_OS)
73   GNUSTEP_HOST_LDIR = $(GNUSTEP_HOST_DIR)/$(LIBRARY_COMBO)
74   GNUSTEP_TARGET_LDIR = $(GNUSTEP_TARGET_DIR)/$(LIBRARY_COMBO)
75 else
76   GNUSTEP_HOST_DIR = .
77   GNUSTEP_TARGET_DIR = .
78   GNUSTEP_HOST_LDIR = .
79   GNUSTEP_TARGET_LDIR = .
80 endif
81
82 #
83 # Get the config information
84 #
85 include $(GNUSTEP_MAKEFILES)/$(GNUSTEP_TARGET_DIR)/config.make
86
87 #
88 # Sanity checks - only performed at the first make invocation
89 #
90 ifeq ($(MAKELEVEL),0)
91
92 # Sanity check on GNUSTEP_*_ROOT.  We want them all to be non-empty.
93 GNUSTEP_ERROR = 
94
95 ifeq ($(GNUSTEP_USER_ROOT),)
96   GNUSTEP_ERROR=GNUSTEP_USER_ROOT
97 endif
98 ifeq ($(GNUSTEP_LOCAL_ROOT),)
99   GNUSTEP_ERROR=GNUSTEP_LOCAL_ROOT
100 endif
101 ifeq ($(GNUSTEP_NETWORK_ROOT),)
102   GNUSTEP_ERROR=GNUSTEP_NETWORK_ROOT
103 endif
104 ifeq ($(GNUSTEP_SYSTEM_ROOT),)
105   GNUSTEP_ERROR=GNUSTEP_SYSTEM_ROOT
106 endif
107
108 ifneq ($(GNUSTEP_ERROR),)
109   $(warning ERROR: Your $(GNUSTEP_ERROR) environment variable is empty !)
110   $(error Please try again after running ". $(GNUSTEP_MAKEFILES)/GNUstep.sh")
111 endif
112
113 # Sanity check on $PATH - NB: if PATH is wrong, we can't do certain things
114 # because we can't run the tools (not even using opentool as we can't even
115 # run opentool if PATH is wrong) - this is particularly bad for gui stuff
116
117 # Skip the check if we are on an Apple system.  I was told that you can't
118 # source GNUstep.sh before running Apple's PB and that the only
119 # friendly solution is to disable the check.
120 ifneq ($(FOUNDATION_LIB), apple)
121
122 # NB - we can't trust PATH here because it's what we are trying to
123 # check ... but hopefully if we (common.make) have been found, we
124 # can trust that at least $(GNUSTEP_MAKEFILES) is set up correctly :-)
125
126 # We want to check that this path is in the PATH
127 SYS_TOOLS_PATH = $(GNUSTEP_SYSTEM_ROOT)/Tools
128
129 # But on cygwin we might need to first fix it up ...
130 ifeq ($(findstring cygwin, $(GNUSTEP_HOST_OS)), cygwin)
131   ifeq ($(shell echo "$(SYS_TOOLS_PATH)" | sed 's/^\([a-zA-Z]:.*\)//'),)
132     SYS_TOOLS_PATH := $(shell $(GNUSTEP_MAKEFILES)/fixpath.sh -u $(SYS_TOOLS_PATH))
133   endif
134 endif
135
136 # Under mingw paths are so confused this warning is not worthwhile
137 ifneq ($(findstring mingw, $(GNUSTEP_HOST_OS)), mingw)
138   ifeq ($(findstring $(SYS_TOOLS_PATH),$(PATH)),)
139     $(warning WARNING: Your PATH may not be set up correctly !)
140     $(warning Please try again after running ". $(GNUSTEP_MAKEFILES)/GNUstep.sh")
141   endif
142 endif
143
144 endif # code used when FOUNDATION_LIB != apple
145
146 endif # End of sanity checks run only at makelevel 0
147
148 #
149 # Get standard messages
150 #
151 include $(GNUSTEP_MAKEFILES)/messages.make
152
153 #
154 # Get flags/config options for core libraries
155 #
156
157 # First, work out precisely library combos etc
158 include $(GNUSTEP_MAKEFILES)/library-combo.make
159 # Then include custom makefiles with flags/config options
160 # This is meant to be used by the core libraries to override loading
161 # of the system makefiles from $(GNUSTEP_MAKEFILES)/Additional/*.make
162 # with their local copy (presumably more up-to-date)
163 ifneq ($(GNUSTEP_LOCAL_ADDITIONAL_MAKEFILES),)
164 include $(GNUSTEP_LOCAL_ADDITIONAL_MAKEFILES)
165 endif
166 # Then include makefiles with flags/config options installed by the 
167 # libraries themselves
168 -include $(GNUSTEP_MAKEFILES)/Additional/*.make
169
170 #
171 # Determine target specific settings
172 #
173 include $(GNUSTEP_MAKEFILES)/target.make
174
175 #
176 # GNUSTEP_INSTALLATION_DIR is the directory where all the things go. If you
177 # don't specify it defaults to GNUSTEP_LOCAL_ROOT.
178 #
179 ifeq ($(GNUSTEP_INSTALLATION_DIR),)
180   GNUSTEP_INSTALLATION_DIR = $(GNUSTEP_LOCAL_ROOT)
181 endif
182
183 # Make it public and available to all submakes invocations
184 export GNUSTEP_INSTALLATION_DIR
185
186 #
187 # Variables specifying the installation directory paths
188 #
189 GNUSTEP_APPS                 = $(GNUSTEP_INSTALLATION_DIR)/Applications
190 GNUSTEP_TOOLS                = $(GNUSTEP_INSTALLATION_DIR)/Tools
191 GNUSTEP_LIBRARY              = $(GNUSTEP_INSTALLATION_DIR)/Library
192 GNUSTEP_SERVICES             = $(GNUSTEP_LIBRARY)/Services
193 ifeq ($(GNUSTEP_FLATTENED),yes)
194   GNUSTEP_HEADERS              = $(GNUSTEP_INSTALLATION_DIR)/Library/Headers
195 else
196   GNUSTEP_HEADERS              = $(GNUSTEP_INSTALLATION_DIR)/Library/Headers/$(LIBRARY_COMBO)
197 endif
198 GNUSTEP_APPLICATION_SUPPORT  = $(GNUSTEP_LIBRARY)/ApplicationSupport
199 GNUSTEP_BUNDLES              = $(GNUSTEP_LIBRARY)/Bundles
200 GNUSTEP_FRAMEWORKS           = $(GNUSTEP_LIBRARY)/Frameworks
201 GNUSTEP_PALETTES             = $(GNUSTEP_LIBRARY)/ApplicationSupport/Palettes
202 GNUSTEP_LIBRARIES            = $(GNUSTEP_INSTALLATION_DIR)/Library/Libraries
203 GNUSTEP_RESOURCES            = $(GNUSTEP_LIBRARY)/Libraries/Resources
204 GNUSTEP_JAVA                 = $(GNUSTEP_LIBRARY)/Libraries/Java
205 GNUSTEP_DOCUMENTATION        = $(GNUSTEP_LIBRARY)/Documentation
206 GNUSTEP_DOCUMENTATION_MAN    = $(GNUSTEP_DOCUMENTATION)/man
207 GNUSTEP_DOCUMENTATION_INFO   = $(GNUSTEP_DOCUMENTATION)/info
208
209 # The default name of the makefile to be used in recursive invocations of make
210 ifeq ($(MAKEFILE_NAME),)
211 MAKEFILE_NAME = GNUmakefile
212 endif
213
214 # Now prepare the library and header flags - we first prepare the list
215 # of directories (trying to avoid duplicates in the list), then
216 # optionally remove the empty ones, then prepend -I / -L to them.
217 ifeq ($(GNUSTEP_FLATTENED),)
218
219 # The following variables have to be evaluated after setting dir to
220 # something, such as GNUSTEP_USER_ROOT.  When you evaluate them in
221 # that situation, they will generate paths according to the following
222 # definition.  Later, we'll systematically replace dir with
223 # GNUSTEP_USER_ROOT, the GNUSTEP_LOCAL_ROOT, then
224 # GNUSTEP_NETWORK_ROOT, then GNUSTEP_SYSTEM_ROOT.
225 GS_HEADER_PATH = \
226  $(dir)/Library/Headers/$(LIBRARY_COMBO)/$(GNUSTEP_TARGET_DIR) \
227  $(dir)/Library/Headers/$(LIBRARY_COMBO)
228
229 GS_LIBRARY_PATH = \
230  $(dir)/Library/Libraries/$(GNUSTEP_TARGET_LDIR) \
231  $(dir)/Library/Libraries/$(GNUSTEP_TARGET_DIR)
232
233 else
234
235 # In the flattened case, the paths to generate are considerably simpler.
236
237 GS_HEADER_PATH = $(dir)/Library/Headers
238 GS_LIBRARY_PATH = $(dir)/Library/Libraries
239
240 endif
241
242 ifeq ($(FOUNDATION_LIB), apple)
243 GS_FRAMEWORK_PATH = $(dir)/Library/Frameworks
244 else
245 GS_FRAMEWORK_PATH =
246 endif
247
248 # First, we add paths based on GNUSTEP_USER_ROOT.
249
250 # Please note that the following causes GS_HEADER_PATH to be evaluated
251 # with the variable dir equal $(GNUSTEP_USER_ROOT), which gives the
252 # effect we wanted.
253 GNUSTEP_HEADERS_DIRS = $(foreach dir,$(GNUSTEP_USER_ROOT),$(GS_HEADER_PATH))
254 GNUSTEP_LIBRARIES_DIRS = $(foreach dir,$(GNUSTEP_USER_ROOT),$(GS_LIBRARY_PATH))
255 GNUSTEP_FRAMEWORKS_DIRS = $(foreach dir,$(GNUSTEP_USER_ROOT),$(GS_FRAMEWORK_PATH))
256
257 # Second, if GNUSTEP_LOCAL_ROOT is different from GNUSTEP_USER_ROOT
258 # (which has already been added), we add the paths based on
259 # GNUSTEP_LOCAL_ROOT too.
260 ifneq ($(GNUSTEP_LOCAL_ROOT), $(GNUSTEP_USER_ROOT))
261 GNUSTEP_HEADERS_DIRS += $(foreach dir,$(GNUSTEP_LOCAL_ROOT),$(GS_HEADER_PATH))
262 GNUSTEP_LIBRARIES_DIRS += $(foreach dir,$(GNUSTEP_LOCAL_ROOT),$(GS_LIBRARY_PATH))
263 GNUSTEP_FRAMEWORKS_DIRS += $(foreach dir,$(GNUSTEP_LOCAL_ROOT),$(GS_FRAMEWORK_PATH))
264 endif
265
266 # Third, if GNUSTEP_NETWORK_ROOT is different from GNUSTEP_USER_ROOT and
267 # GNUSTEP_LOCAL_ROOT (which have already been added), we add the paths
268 # based on GNUSTEP_NETWORK_ROOT too.
269 ifneq ($(GNUSTEP_NETWORK_ROOT), $(GNUSTEP_USER_ROOT))
270 ifneq ($(GNUSTEP_NETWORK_ROOT), $(GNUSTEP_LOCAL_ROOT))
271 GNUSTEP_HEADERS_DIRS += $(foreach dir,$(GNUSTEP_NETWORK_ROOT),$(GS_HEADER_PATH))
272 GNUSTEP_LIBRARIES_DIRS += $(foreach dir,$(GNUSTEP_NETWORK_ROOT),$(GS_LIBRARY_PATH))
273 GNUSTEP_FRAMEWORKS_DIRS += $(foreach dir,$(GNUSTEP_NETWORK_ROOT),$(GS_FRAMEWORK_PATH))
274 endif
275 endif
276
277 # Last, if GNUSTEP_SYSTEM_ROOT is different from GNUSTEP_USER_ROOT,
278 # GNUSTEP_LOCAL_ROOT and GNUSTEP_NETWORK_ROOT (which have already been
279 # added), we add the pathe paths based on GNUSTEP_SYSTEM_ROOT too.
280 ifneq ($(GNUSTEP_SYSTEM_ROOT), $(GNUSTEP_USER_ROOT))
281 ifneq ($(GNUSTEP_SYSTEM_ROOT), $(GNUSTEP_LOCAL_ROOT))
282 ifneq ($(GNUSTEP_SYSTEM_ROOT), $(GNUSTEP_NETWORK_ROOT))
283 GNUSTEP_HEADERS_DIRS += $(foreach dir,$(GNUSTEP_SYSTEM_ROOT),$(GS_HEADER_PATH))
284 GNUSTEP_LIBRARIES_DIRS += $(foreach dir,$(GNUSTEP_SYSTEM_ROOT),$(GS_LIBRARY_PATH))
285 GNUSTEP_FRAMEWORKS_DIRS += $(foreach dir,$(GNUSTEP_SYSTEM_ROOT),$(GS_FRAMEWORK_PATH))
286 endif
287 endif
288 endif
289
290 ifeq ($(REMOVE_EMPTY_DIRS),yes)
291  # This variable, when evaluated, gives $(dir) if dir is non-empty, and
292  # nothing if dir is empty.
293  remove_if_empty = $(dir $(word 1,$(wildcard $(dir)/*)))
294
295  # Build the GNUSTEP_HEADER_FLAGS by removing the empty dirs from
296  # GNUSTEP_HEADER_DIRS, then prepending -I to each of them
297  #
298  # Important - because this variable is defined with = and not :=, it
299  # is only evaluated when it is used.  Which is good - it means we don't 
300  # scan the directories and try to remove the empty one on each make 
301  # invocation (eg, on 'make clean') - we only scan the dirs when we are using
302  # GNUSTEP_HEADERS_FLAGS to compile.  Please make sure to keep this
303  # behaviour otherwise scanning the directories each time a makefile is
304  # read might slow down the package unnecessarily for operations like
305  # make clean, make distclean etc.
306  #
307  # Doing this filtering still gives a 5% to 10% slowdown in compilation times
308  # due to directory scanning, which is why is normally turned off by
309  # default - by default we put all directories in compilation commands.
310  GNUSTEP_HEADERS_FLAGS = \
311    $(addprefix -I,$(foreach dir,$(GNUSTEP_HEADERS_DIRS),$(remove_if_empty)))
312  GNUSTEP_LIBRARIES_FLAGS = \
313    $(addprefix -L,$(foreach dir,$(GNUSTEP_LIBRARIES_DIRS),$(remove_if_empty)))
314  GNUSTEP_FRAMEWORKS_FLAGS = \
315    $(addprefix -F,$(foreach dir,$(GNUSTEP_FRAMEWORKS_DIRS),$(remove_if_empty)))
316 else
317  # Default case, just add -I / -L
318  GNUSTEP_HEADERS_FLAGS = $(addprefix -I,$(GNUSTEP_HEADERS_DIRS))
319  GNUSTEP_LIBRARIES_FLAGS = $(addprefix -L,$(GNUSTEP_LIBRARIES_DIRS))
320  GNUSTEP_FRAMEWORKS_FLAGS = $(addprefix -F,$(GNUSTEP_FRAMEWORKS_DIRS))
321 endif
322
323 ifeq ($(FOUNDATION_LIB), fd)
324
325 # Map OBJC_RUNTIME_LIB values to OBJC_RUNTIME values as used by
326 # libFoundation.  TODO/FIXME: Drop all this stuff and have
327 # libFoundation use OBJC_RUNTIME_LIB directly.
328
329 # TODO: Remove all this cruft.  Standardize.
330 ifeq ($(OBJC_RUNTIME_LIB), nx)
331   OBJC_RUNTIME = NeXT
332 endif
333 ifeq ($(OBJC_RUNTIME_LIB), sun)
334   OBJC_RUNTIME = Sun
335 endif
336 ifeq ($(OBJC_RUNTIME_LIB), apple)
337   OBJC_RUNTIME = apple
338 endif
339 ifeq ($(OBJC_RUNTIME_LIB), gnu)
340   OBJC_RUNTIME = GNU
341 endif
342 ifeq ($(OBJC_RUNTIME_LIB), gnugc)
343   OBJC_RUNTIME = GNU
344 endif
345
346 # If all of the following really needed ?  If the system is not
347 # flattened, multiple Foundation libraries are not permitted anyway,
348 # so libFoundation could just put his headers in Foundation/.  If
349 # library combos are used, all headers are in a library-combo
350 # directory, so libFoundation could still put his headers in
351 # Foundation/ and no conflict should arise.  As for the
352 # GNUSTEP_TARGET_DIR, maybe we should key all of our headers in a
353 # GNUSTEP_TARGET_LDIR directory (rather than just a LIBRARY_COMBO
354 # directory).  But does it really matter in practice anyway ?
355 ifeq ($(GNUSTEP_FLATTENED),yes)
356 GNUSTEP_HEADERS_FND_DIRS = \
357   $(GNUSTEP_USER_ROOT)/Library/Headers/libFoundation \
358   $(GNUSTEP_LOCAL_ROOT)/Library/Headers/libFoundation \
359   $(GNUSTEP_NETWORK_ROOT)/Library/Headers/libFoundation \
360   $(GNUSTEP_SYSTEM_ROOT)/Library/Headers/libFoundation \
361   $(GNUSTEP_USER_ROOT)/Library/Headers/libFoundation/$(GNUSTEP_TARGET_DIR)/$(OBJC_RUNTIME) \
362   $(GNUSTEP_LOCAL_ROOT)/Library/Headers/libFoundation/$(GNUSTEP_TARGET_DIR)/$(OBJC_RUNTIME) \
363   $(GNUSTEP_NETWORK_ROOT)/Library/Headers/libFoundation/$(GNUSTEP_TARGET_DIR)/$(OBJC_RUNTIME) \
364   $(GNUSTEP_SYSTEM_ROOT)/Library/Headers/libFoundation/$(GNUSTEP_TARGET_DIR)/$(OBJC_RUNTIME)
365 else
366 GNUSTEP_HEADERS_FND_DIRS = \
367   $(GNUSTEP_USER_ROOT)/Library/Headers/$(LIBRARY_COMBO)/libFoundation \
368   $(GNUSTEP_LOCAL_ROOT)/Library/Headers/$(LIBRARY_COMBO)/libFoundation \
369   $(GNUSTEP_NETWORK_ROOT)/Library/Headers/$(LIBRARY_COMBO)/libFoundation \
370   $(GNUSTEP_SYSTEM_ROOT)/Library/Headers/$(LIBRARY_COMBO)/libFoundation \
371   $(GNUSTEP_USER_ROOT)/Library/Headers/$(LIBRARY_COMBO)/libFoundation/$(GNUSTEP_TARGET_DIR)/$(OBJC_RUNTIME) \
372   $(GNUSTEP_LOCAL_ROOT)/Library/Headers/$(LIBRARY_COMBO)/libFoundation/$(GNUSTEP_TARGET_DIR)/$(OBJC_RUNTIME) \
373   $(GNUSTEP_NETWORK_ROOT)/Library/Headers/$(LIBRARY_COMBO)/libFoundation/$(GNUSTEP_TARGET_DIR)/$(OBJC_RUNTIME) \
374   $(GNUSTEP_SYSTEM_ROOT)/Library/Headers/$(LIBRARY_COMBO)/libFoundation/$(GNUSTEP_TARGET_DIR)/$(OBJC_RUNTIME)
375 endif
376
377 ifeq ($(REMOVE_EMPTY_DIRS), yes)
378  # Build the GNUSTEP_HEADERS_FND_FLAG by removing the empty dirs
379  # from GNUSTEP_HEADERS_FND_DIRS, then prepending -I to each of them
380  GNUSTEP_HEADERS_FND_FLAG = \
381   $(addprefix -I,$(foreach dir,$(GNUSTEP_HEADERS_FND_DIRS),$(remove_if_empty)))
382 else
383  # default case - simply prepend -I
384  GNUSTEP_HEADERS_FND_FLAG = $(addprefix -I,$(GNUSTEP_HEADERS_FND_DIRS))
385 endif
386
387 # Just add the result of all this to the standard header flags.
388 GNUSTEP_HEADERS_FLAGS += $(GNUSTEP_HEADERS_FND_FLAG)
389
390 endif
391
392
393 #
394 # Overridable compilation flags
395 #
396 # FIXME: We use -fno-strict-aliasing to prevent annoying gcc3.3
397 # compiler warnings.  But we really need to investigate why the
398 # warning appear in the first place, if they are serious or not, and
399 # what can be done about it.
400 OBJCFLAGS = -fno-strict-aliasing
401 CFLAGS =
402 OBJ_DIR_PREFIX =
403
404 # If the compiler supports native ObjC exceptions and the user wants us to
405 # use them, turn them on!
406 ifeq ($(USE_OBJC_EXCEPTIONS), yes)
407   OBJCFLAGS += -fobjc-exceptions
408 endif
409
410 #
411 # Now decide whether to build shared objects or not.  Nothing depending
412 # on the value of the shared variable is allowed before this point!
413 #
414
415 #
416 # Fixup bundles to be always built as shared even when shared=no is given
417 #
418 ifeq ($(shared), no)
419   ifeq ($(GNUSTEP_TYPE), bundle)
420     $(warning "Static bundles are meaningless!  I am using shared=yes!")
421     override shared = yes
422     export shared
423   endif
424   ifeq ($(GNUSTEP_TYPE), framework)
425     $(warning "Static frameworks are meaningless!  I am using shared=yes!")
426     override shared = yes
427     export shared
428   endif
429 endif
430
431 # Enable building shared libraries by default. If the user wants to build a
432 # static library, he/she has to specify shared=no explicitly.
433 ifeq ($(HAVE_SHARED_LIBS), yes)
434   # Unless shared=no has been purposedly set ...
435   ifneq ($(shared), no)
436     # ... set shared = yes
437     shared = yes
438   endif
439 endif
440
441 ifeq ($(shared), yes)
442   LIB_LINK_CMD              =  $(SHARED_LIB_LINK_CMD)
443   OBJ_DIR_PREFIX            += shared_
444   INTERNAL_OBJCFLAGS        += $(SHARED_CFLAGS)
445   INTERNAL_CFLAGS           += $(SHARED_CFLAGS)
446   AFTER_INSTALL_LIBRARY_CMD =  $(AFTER_INSTALL_SHARED_LIB_CMD)
447 else
448   LIB_LINK_CMD              =  $(STATIC_LIB_LINK_CMD)
449   OBJ_DIR_PREFIX            += static_
450   AFTER_INSTALL_LIBRARY_CMD =  $(AFTER_INSTALL_STATIC_LIB_CMD)
451   LIBRARY_NAME_SUFFIX       := s$(LIBRARY_NAME_SUFFIX)
452 endif
453
454 ifeq ($(profile), yes)
455   ADDITIONAL_FLAGS += -pg
456   ifeq ($(LD), $(CC))
457     INTERNAL_LDFLAGS += -pg
458   endif
459   OBJ_DIR_PREFIX += profile_
460   LIBRARY_NAME_SUFFIX := p$(LIBRARY_NAME_SUFFIX)
461 endif
462
463 ifeq ($(debug), yes)
464   OPTFLAG := $(filter-out -O%, $(OPTFLAG))
465   ADDITIONAL_FLAGS += -g -Wall -DDEBUG -fno-omit-frame-pointer
466   INTERNAL_JAVACFLAGS += -g -deprecation
467   OBJ_DIR_PREFIX += debug_
468   LIBRARY_NAME_SUFFIX := d$(LIBRARY_NAME_SUFFIX)
469 else
470   INTERNAL_JAVACFLAGS += -O
471 endif
472
473 OBJ_DIR_PREFIX += obj
474
475 ifeq ($(warn), no)
476   ADDITIONAL_FLAGS += -UGSWARN
477 else
478   ADDITIONAL_FLAGS += -DGSWARN
479 endif
480
481 ifeq ($(diagnose), no)
482   ADDITIONAL_FLAGS += -UGSDIAGNOSE
483 else
484   ADDITIONAL_FLAGS += -DGSDIAGNOSE
485 endif
486
487 ifneq ($(LIBRARY_NAME_SUFFIX),)
488   LIBRARY_NAME_SUFFIX := _$(LIBRARY_NAME_SUFFIX)
489 endif
490
491 AUXILIARY_CPPFLAGS += $(GNUSTEP_DEFINE) \
492                 $(FND_DEFINE) $(GUI_DEFINE) $(BACKEND_DEFINE) \
493                 $(RUNTIME_DEFINE) $(FOUNDATION_LIBRARY_DEFINE)
494
495 INTERNAL_OBJCFLAGS += $(ADDITIONAL_FLAGS) $(OPTFLAG) $(OBJCFLAGS) \
496                         $(RUNTIME_FLAG)
497 INTERNAL_CFLAGS += $(ADDITIONAL_FLAGS) $(OPTFLAG)
498
499 # trick needed to replace a space with nothing
500 empty:=
501 space:= $(empty) $(empty)
502 GNUSTEP_OBJ_PREFIX = $(subst $(space),,$(OBJ_DIR_PREFIX))
503
504 #
505 # Support building of Multiple Architecture Binaries (MAB). The object files
506 # directory will be something like shared_obj/ix86_m68k_sun/
507 #
508 ifeq ($(arch),)
509   ARCH_OBJ_DIR = $(GNUSTEP_TARGET_DIR)
510 else
511   ARCH_OBJ_DIR = \
512       $(shell echo $(CLEANED_ARCH) | sed -e 's/ /_/g')/$(GNUSTEP_TARGET_OS)
513 endif
514
515 ifeq ($(GNUSTEP_FLATTENED),)
516   GNUSTEP_OBJ_DIR_NAME = $(GNUSTEP_OBJ_PREFIX)/$(ARCH_OBJ_DIR)/$(LIBRARY_COMBO)
517 else
518   GNUSTEP_OBJ_DIR_NAME = $(GNUSTEP_OBJ_PREFIX)
519 endif
520
521 GNUSTEP_OBJ_DIR = $(GNUSTEP_BUILD_DIR)/$(GNUSTEP_OBJ_DIR_NAME)
522
523 #
524 # Common variables for subprojects
525 #
526 SUBPROJECT_PRODUCT = subproject$(OEXT)
527
528 #
529 # Set JAVA_HOME if not set.
530 #
531 ifeq ($(JAVA_HOME),)
532   # Else, try JDK_HOME
533   ifeq ($(JDK_HOME),)
534     # Else, try by finding the path of javac and removing 'bin/javac' from it
535     ifeq ($(JAVAC),)
536       JAVA_HOME = $(shell which javac | sed "s/bin\/javac//g")
537     else # $(JAVAC) != "" 
538       JAVA_HOME = $(shell which $(JAVAC) | sed "s/bin\/javac//g")
539     endif  
540   else # $(JDK_HOME) != ""
541     JAVA_HOME = $(JDK_HOME) 
542   endif
543 endif
544
545 #
546 # The java compiler.
547 #
548 ifeq ($(JAVAC),)
549   JAVAC = $(JAVA_HOME)/bin/javac
550 endif
551
552 #
553 # The java header compiler.
554 #
555 ifeq ($(JAVAH),)
556   JAVAH = $(JAVA_HOME)/bin/javah
557 endif
558
559 #
560 # Common variables - default values
561 #
562 # Because this file is included at the beginning of the user's
563 # GNUmakefile, the user can override these variables by setting them
564 # in the GNUmakefile.
565 BUNDLE_EXTENSION = .bundle
566 ifeq ($(profile), yes)
567   APP_EXTENSION = profile
568 else
569   ifeq ($(debug), yes)
570     APP_EXTENSION = debug
571   else
572     APP_EXTENSION = app
573   endif
574 endif
575
576
577
578 # We want total control over GNUSTEP_INSTANCE.
579 # GNUSTEP_INSTANCE determines wheter it's a Master or an Instance
580 # invocation.  Whenever we run a submake, we want it to be a Master
581 # invocation, unless we specifically set it to run as an Instance
582 # invocation by adding the GNUSTEP_INSTANCE=xxx flag.  Tell make not
583 # to mess with our games by passing this variable to submakes himself
584 unexport GNUSTEP_INSTANCE
585 unexport GNUSTEP_TYPE
586
587 endif # COMMON_MAKE_LOADED