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