4
# Makefile rules for the Master invocation.
6
# Copyright (C) 1997, 2001, 2002 Free Software Foundation, Inc.
8
# Author: Scott Christley <scottc@net-community.com>
9
# Author: Ovidiu Predescu <ovidiu@net-community.com>
10
# Author: Nicola Pero <nicola@brainstorm.co.uk>
12
# This file is part of the GNUstep Makefile Package.
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.
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.
27
# Say that you run `make all'. The rule for `all' is below here, and
28
# depends on internal-all. Rules for internal-all are found in
29
# tool.make, library.make etc; there, internal-all will depend on a
30
# list of appropriate %.variables targets, such as
31
# gsdoc.tool.all.variables <which means we need to make `all' for the
32
# `tool' called `gsdoc'> - to process these prerequisites, the
33
# %.variables rule below is used. this rule gets an appropriate make
34
# subprocess going, with the task of building that specific
35
# instance-type-operation prerequisite. The make subprocess will be run
36
# as in `make internal-tool-all INTERNAL_tool_NAME=gsdoc ...<and other
37
# variables>' and this make subprocess wil find the internal-tool-all
38
# rule in tool.make, and execute that, building the tool.
40
# Hint: run make with `make -n' to see the recursive method invocations
41
# with the parameters used
48
# The first time you invoke `make', if you have not given a target,
49
# `all' is executed as it is the first one. If a GNUSTEP_BUILD_DIR is
50
# specifed, make sure to create it before anything else is done.
51
ifeq ($(GNUSTEP_BUILD_DIR),.)
52
all:: before-all internal-all after-all
54
all:: $(GNUSTEP_BUILD_DIR) before-all internal-all after-all
57
# internal-after-install is used by packaging to get the list of files
58
# installed (see rpm.make); it must come after *all* the installation
59
# rules have been executed.
60
# internal-check-installation-permissions comes before everything so
61
# that we run any command if we aren't allowed to install
62
# install depends on all as per GNU/Unix habits, conventions and standards.
64
install:: internal-check-install-permissions all \
65
before-install internal-install after-install internal-after-install
67
install:: before-install internal-install after-install internal-after-install
70
uninstall:: before-uninstall internal-uninstall after-uninstall
72
clean:: before-clean internal-clean after-clean
75
distclean:: clean before-distclean internal-distclean after-distclean
77
distclean:: before-distclean internal-distclean after-distclean
80
check:: before-check internal-check after-check
82
strings:: before-strings internal-strings after-strings
85
# Placeholders for internal targets
94
# In case of problems, we print a message trying to educate the user
95
# about how to install elsewhere, except if the installation dir is
96
# GNUSTEP_SYSTEM_ROOT, in that case we don't want to suggest to
97
# install the software elsewhere, because it is likely to be system
98
# software like the gnustep-base library. NB: the check of
99
# GNUSTEP_INSTALLATION_DIR against GNUSTEP_SYSTEM_ROOT is not perfect
100
# as /usr/GNUstep/System/ might not match /usr/GNUstep/System (note
101
# the missing '/' at the end) but what we really want to catch is the
102
# GNUSTEP_INSTALLATION_DIR = $(GNUSTEP_SYSTEM_ROOT) command in the
103
# makefiles, and the check of course works with it.
104
internal-check-install-permissions:
105
@if [ -d "$(GNUSTEP_INSTALLATION_DIR)" \
106
-a ! -w "$(GNUSTEP_INSTALLATION_DIR)" ]; then \
107
echo "*ERROR*: the software is configured to install itself into $(GNUSTEP_INSTALLATION_DIR)"; \
108
echo "but you do not have permissions to write in that directory:";\
109
echo "Aborting installation."; \
111
if [ "$(GNUSTEP_INSTALLATION_DIR)" != "$(GNUSTEP_SYSTEM_ROOT)" ]; then \
112
echo "Suggestion: if you can't get permissions to install there, you can try";\
113
echo "to install the software in a different directory by setting";\
114
echo "GNUSTEP_INSTALLATION_DIR. For example, to install into";\
115
echo "$(GNUSTEP_USER_ROOT), which is your own GNUstep directory, just type"; \
117
echo "make install GNUSTEP_INSTALLATION_DIR=\"$(GNUSTEP_USER_ROOT)\""; \
119
echo "You should always be able to install into $(GNUSTEP_USER_ROOT),";\
120
echo "so this might be a good option. The other meaningful values for";\
121
echo "GNUSTEP_INSTALLATION_DIR on your system are:";\
122
echo "$(GNUSTEP_SYSTEM_ROOT) (the System directory)";\
123
echo "$(GNUSTEP_LOCAL_ROOT) (the Local directory)";\
124
echo "$(GNUSTEP_NETWORK_ROOT) (the Network directory)";\
125
echo "but you might need special permissions to install in those directories.";\
136
# The following for exclusive use of packaging code
137
internal-after-install::
148
rm -rf $(GNUSTEP_BUILD_DIR)/*~ $(GNUSTEP_BUILD_DIR)/obj
155
rm -f $(GNUSTEP_BUILD_DIR)/core
171
# declare targets as PHONY
173
.PHONY: all before-all internal-all after-all \
174
install before-install internal-install after-install \
175
internal-after-install \
176
uninstall before-uninstall internal-uninstall after-uninstall \
177
clean before-clean internal-clean after-clean \
178
distclean before-distclean internal-distclean after-distclean \
179
check before-check internal-check after-check \
180
strings before-strings internal-strings after-strings
182
# Prevent make from trying to remove stuff like
183
# libcool.library.all.subprojects thinking that it is a temporary file
184
.PRECIOUS: %.variables %.subprojects
187
## The magical %.variables rules, thank you GNU make!
190
# The %.variables target has to be called with the name of the actual
191
# instance, followed by the operation, then the makefile fragment to be
192
# called and then the variables word. Suppose for example we build the
193
# library libgmodel, the target should look like:
195
# libgmodel.all.library.variables
197
# when the rule is executed, $* is libgmodel.all.libray;
198
# instance will be libgmodel
199
# operation will be all
200
# type will be library
202
# this rule might be executed many times, for different targets to build.
204
# the rule then calls a submake, which runs the real code
206
# the following is the code used in %.variables and %.subprojects
207
# to extract the instance, operation and type from the $* (the stem) of the
208
# rule. with GNU make => 3.78, we could define the following as macros
209
# and use $(call ...) to call them; but because we have users who are using
210
# GNU make older than that, we have to manually `paste' this code
211
# wherever we need to access instance or type or operation.
213
# Anyway, the following table tells you what these commands do -
215
# instance=$(basename $(basename $(1)))
216
# operation=$(subst .,,$(suffix $(basename $(1))))
217
# type=$(subst -,_,$(subst .,,$(suffix $(1))))
219
# It's very important to notice that $(basename $(basename $*)) in
220
# these rules is simply the instance (such as libgmodel).
222
# NB: INTERNAL_$${type}_NAME and TARGET are deprecated - use
223
# GNUSTEP_INSTANCE instead.
225
# Before building the real thing, we must build the subprojects
227
# If we are at the very first make invocation, convert
228
# GNUSTEP_BUILD_DIR into an absolute path. All other make invocations
229
# can then assume it is already an absolute path form, and avoid the
230
# shell invocation to convert into absolute path. Let's avoid the
231
# shell invocation unless strictly necessary - it's slow.
232
ifeq ($(MAKELEVEL),0)
233
ifneq ($(GNUSTEP_BUILD_DIR),.)
235
# We can't use ':=' here (which we'd like, since it would guarantee
236
# that the shell command is executed only once) because ':=' would
237
# cause the shell command to be executed immediately, which is *now*
238
# during parsing, before any rule has been executed; in particular,
239
# before the rule which creates GNUSTEP_BUILD_DIR has been executed
240
# (if it had to be executed), and that might cause the 'cd' in the
241
# following shell command to fail. So what we do, is we define this
242
# as a simple variable with '=', which means it will be evaluated
243
# every time it is used, but not before, and then we make sure to
244
# use it as little as possible and only in rules which are executed
245
# after the rule to build GNUSTEP_BUILD_DIR. Please note that in
246
# this setup, *any* reference to this variable causes a slow
247
# subshell invocation. At the moment, it's used when running
248
# the subprojects/variables and when running the aggregate
251
# That makes 1 invocation per type of project per type of target
252
# used in the top-level makefile. For example, if the top-level
253
# makefile includes aggregate.make and documentation.make and does
254
# a make all, we evaluate this variable twice. If it does a make
255
# distclean (which automatically invokes make clean as well) we
256
# evaluate this variable 4 times. All non-top-level make code
257
# is free from overhead.
258
# In the rules which need the ABS_GNUSTEP_BUILD_DIR variable more
259
# than once we copy it into a shell variable and reuse the shell
260
# variable to avoid evaluating ABS_GNUSTEP_BUILD_DIR multiple
261
# times in the same rule.
262
# DO NOT EVER USE THIS VARIABLE UNLESS YOU FULLY UNDERSTAND THE
263
# PERFORMANCE IMPLICATIONS JUST DESCRIBED.
264
ABS_GNUSTEP_BUILD_DIR = $(shell (cd "$(GNUSTEP_BUILD_DIR)"; pwd))
266
ABS_GNUSTEP_BUILD_DIR = .
269
ABS_GNUSTEP_BUILD_DIR = $(strip $(GNUSTEP_BUILD_DIR))
272
# If you change the subprojects code here, make sure to update the
273
# %.subprojects rule below too! The code from the %.subprojects rule
274
# below is 'inlined' here for speed (so that we don't run a separate
275
# shell just to execute that code).
278
instance=$(basename $(basename $*)); \
279
operation=$(subst .,,$(suffix $(basename $*))); \
280
type=$(subst -,_,$(subst .,,$(suffix $*))); \
281
abs_build_dir="$(ABS_GNUSTEP_BUILD_DIR)"; \
282
if [ "$($(basename $(basename $*))_SUBPROJECTS)" != "" ]; then \
283
echo Making $$operation in subprojects of $$type $$instance...; \
284
for f in $($(basename $(basename $*))_SUBPROJECTS) __done; do \
285
if [ $$f != __done ]; then \
286
mf=$(MAKEFILE_NAME); \
287
if [ ! -f $$f/$$mf -a -f $$f/Makefile ]; then \
289
echo "WARNING: No $(MAKEFILE_NAME) found for subproject $$f; using 'Makefile'"; \
291
if [ "$${abs_build_dir}" = "." ]; then \
294
gsbuild="$${abs_build_dir}/$$f"; \
296
if [ "$(OWNING_PROJECT_HEADER_DIR_NAME)" = "" ]; then \
297
if [ "$$type" = "framework" ]; then \
298
framework_version="$($(basename $(basename $*))_CURRENT_VERSION_NAME)"; \
299
if [ "$$framework_version" = "" ]; then framework_version="A"; fi; \
300
owning_project_header_dir="../$${instance}.framework/Versions/$${framework_version}/Headers"; \
301
else owning_project_header_dir=""; \
304
owning_project_header_dir="../$(OWNING_PROJECT_HEADER_DIR_NAME)"; \
306
if $(MAKE) -C $$f -f $$mf --no-keep-going $$operation \
307
OWNING_PROJECT_HEADER_DIR_NAME="$${owning_project_header_dir}" \
308
DERIVED_SOURCES="../$(DERIVED_SOURCES)" \
309
GNUSTEP_BUILD_DIR="$$gsbuild" \
317
echo Making $$operation for $$type $$instance...; \
318
$(MAKE) -f $(MAKEFILE_NAME) --no-print-directory --no-keep-going \
319
internal-$${type}-$$operation \
320
GNUSTEP_TYPE=$$type \
321
GNUSTEP_INSTANCE=$$instance \
322
GNUSTEP_OPERATION=$$operation \
323
INTERNAL_$${type}_NAME=$$instance \
325
GNUSTEP_BUILD_DIR="$${abs_build_dir}"
328
# This rule provides exactly the same code as the %.variables one with
329
# respect to subprojects; it is available for clean targets when they
330
# want to run make clean in subprojects but do not need a full Instance
331
# invocation. In that case, they can depend on %.subprojects only.
333
# NB: The OWNING_PROJECT_HEADER_DIR_NAME hack in this rule is sort of
334
# horrible, because it pollutes this general rule with code specific
335
# to the framework implementation (eg, where the framework headers are
336
# located). Still, it's the least evil we could think of at the
337
# moment :-) The framework code is now completely confined into
338
# framework.make makefiles, except for this little hack in here. It
339
# would be nice to remove this hack without loosing functionality (or
340
# polluting other general-purpose makefiles).
343
instance=$(basename $(basename $*)); \
344
operation=$(subst .,,$(suffix $(basename $*))); \
345
type=$(subst -,_,$(subst .,,$(suffix $*))); \
346
abs_build_dir="$(ABS_GNUSTEP_BUILD_DIR)"; \
347
if [ "$($(basename $(basename $*))_SUBPROJECTS)" != "" ]; then \
348
echo Making $$operation in subprojects of $$type $$instance...; \
349
for f in $($(basename $(basename $*))_SUBPROJECTS) __done; do \
350
if [ $$f != __done ]; then \
351
mf=$(MAKEFILE_NAME); \
352
if [ ! -f $$f/$$mf -a -f $$f/Makefile ]; then \
354
echo "WARNING: No $(MAKEFILE_NAME) found for subproject $$f; using 'Makefile'"; \
356
if [ "$${abs_build_dir}" = "." ]; then \
359
gsbuild="$${abs_build_dir}/$$f"; \
361
if [ "$(OWNING_PROJECT_HEADER_DIR_NAME)" = "" ]; then \
362
if [ "$$type" = "framework" ]; then \
363
framework_version="$($(basename $(basename $*))_CURRENT_VERSION_NAME)"; \
364
if [ "$$framework_version" = "" ]; then framework_version="A"; fi; \
365
owning_project_header_dir="../$${instance}.framework/Versions/$${framework_version}/Headers"; \
366
else owning_project_header_dir=""; \
369
owning_project_header_dir="../$(OWNING_PROJECT_HEADER_DIR_NAME)"; \
371
if $(MAKE) -C $$f -f $$mf --no-keep-going $$operation \
372
OWNING_PROJECT_HEADER_DIR_NAME="$${owning_project_header_dir}" \
373
DERIVED_SOURCES="../$(DERIVED_SOURCES)" \
374
GNUSTEP_BUILD_DIR="$$gsbuild" \
384
# Now rules for packaging - all automatically included
387
PACKAGE_NAME := $(strip $(PACKAGE_NAME))
389
ifeq ($(PACKAGE_NAME),)
390
# Use a default of unnamed-package if nothing better is provided.
391
PACKAGE_NAME := unnamed-package
394
# For backwards compatibility, take value of PACKAGE_VERSION from
395
# VERSION. New GNUmakefiles should all use the PACKAGE_VERSION
396
# variable rather than the VERSION variable.
397
ifeq ($(PACKAGE_VERSION),)
399
PACKAGE_VERSION = $(VERSION)
401
# Use a default of 0.0.1 if nothing better is provided.
402
ifeq ($(PACKAGE_VERSION),)
403
PACKAGE_VERSION = 0.0.1
409
# Rules for building source distributions
411
include $(GNUSTEP_MAKEFILES)/Master/source-distribution.make
414
# Rules for building spec files/file lists for RPMs, and RPMs
416
include $(GNUSTEP_MAKEFILES)/Master/rpm.make
419
# Rules for building debian/* scripts for DEBs, and DEBs
421
#include $(GNUSTEP_MAKEFILES)/Master/deb.make <TODO>