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 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, 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 # The very first top-most make invocation we want to have install
65 # depend on internal-check-install-permissions and on all, and
66 # distclean depend on clean. We used to check MAKELEVEL=0 here to
67 # determine if this is the top-most invocation of make, but that does
68 # not work if the top-most invocation of make is done from within a
69 # (non-gnustep-make) makefile itself! So we use a marker variable.
70 # _GNUSTEP_TOP_INVOCATION_DONE is not set the very first / top-most
71 # make invocation , but we set it for all sub-invocations, so all
72 # subinvocations will have it set and we can distinguish them.
73 ifeq ($(_GNUSTEP_TOP_INVOCATION_DONE),)
74 # Top-most invocation of make
75 install:: internal-check-install-permissions all \
76 before-install internal-install after-install internal-after-install
78 distclean:: clean before-distclean internal-distclean after-distclean
80 # Further make invocations will have this variable set
81 export _GNUSTEP_TOP_INVOCATION_DONE = 1
83 # Sub-invocation of make
84 install:: before-install internal-install after-install internal-after-install
86 distclean:: before-distclean internal-distclean after-distclean
90 uninstall:: before-uninstall internal-uninstall after-uninstall
92 clean:: before-clean internal-clean after-clean
94 check:: before-check internal-check after-check
96 strings:: before-strings internal-strings after-strings
99 # Placeholders for internal targets
108 # In case of problems, we print a message trying to educate the user
109 # about how to install elsewhere, except if the installation dir is
110 # GNUSTEP_SYSTEM_ROOT, in that case we don't want to suggest to
111 # install the software elsewhere, because it is likely to be system
112 # software like the gnustep-base library. NB: the check of
113 # GNUSTEP_INSTALLATION_DIR against GNUSTEP_SYSTEM_ROOT is not perfect
114 # as /usr/GNUstep/System/ might not match /usr/GNUstep/System (note
115 # the missing '/' at the end) but what we really want to catch is the
116 # GNUSTEP_INSTALLATION_DIR = $(GNUSTEP_SYSTEM_ROOT) command in the
117 # makefiles, and the check of course works with it.
118 internal-check-install-permissions:
119 @if [ -d "$(GNUSTEP_INSTALLATION_DIR)" \
120 -a ! -w "$(GNUSTEP_INSTALLATION_DIR)" ]; then \
121 echo "*ERROR*: the software is configured to install itself into $(GNUSTEP_INSTALLATION_DIR)"; \
122 echo "but you do not have permissions to write in that directory:";\
123 echo "Aborting installation."; \
125 if [ "$(GNUSTEP_INSTALLATION_DIR)" != "$(GNUSTEP_SYSTEM_ROOT)" ]; then \
126 echo "Suggestion: if you can't get permissions to install there, you can try";\
127 echo "to install the software in a different directory by setting";\
128 echo "GNUSTEP_INSTALLATION_DIR. For example, to install into";\
129 echo "$(GNUSTEP_USER_ROOT), which is your own GNUstep directory, just type"; \
131 echo "make install GNUSTEP_INSTALLATION_DIR=\"$(GNUSTEP_USER_ROOT)\""; \
133 echo "You should always be able to install into $(GNUSTEP_USER_ROOT),";\
134 echo "so this might be a good option. The other meaningful values for";\
135 echo "GNUSTEP_INSTALLATION_DIR on your system are:";\
136 echo "$(GNUSTEP_SYSTEM_ROOT) (the System directory)";\
137 echo "$(GNUSTEP_LOCAL_ROOT) (the Local directory)";\
138 echo "$(GNUSTEP_NETWORK_ROOT) (the Network directory)";\
139 echo "but you might need special permissions to install in those directories.";\
150 # The following for exclusive use of packaging code
151 internal-after-install::
162 rm -rf $(GNUSTEP_BUILD_DIR)/*~ $(GNUSTEP_BUILD_DIR)/obj
169 rm -f $(GNUSTEP_BUILD_DIR)/core
185 # declare targets as PHONY
187 .PHONY: all before-all internal-all after-all \
188 install before-install internal-install after-install \
189 internal-after-install \
190 uninstall before-uninstall internal-uninstall after-uninstall \
191 clean before-clean internal-clean after-clean \
192 distclean before-distclean internal-distclean after-distclean \
193 check before-check internal-check after-check \
194 strings before-strings internal-strings after-strings
196 # Prevent make from trying to remove stuff like
197 # libcool.library.all.subprojects thinking that it is a temporary file
198 .PRECIOUS: %.variables %.subprojects
201 ## The magical %.variables rules, thank you GNU make!
204 # The %.variables target has to be called with the name of the actual
205 # instance, followed by the operation, then the makefile fragment to be
206 # called and then the variables word. Suppose for example we build the
207 # library libgmodel, the target should look like:
209 # libgmodel.all.library.variables
211 # when the rule is executed, $* is libgmodel.all.libray;
212 # instance will be libgmodel
213 # operation will be all
214 # type will be library
216 # this rule might be executed many times, for different targets to build.
218 # the rule then calls a submake, which runs the real code
220 # the following is the code used in %.variables and %.subprojects
221 # to extract the instance, operation and type from the $* (the stem) of the
222 # rule. with GNU make => 3.78, we could define the following as macros
223 # and use $(call ...) to call them; but because we have users who are using
224 # GNU make older than that, we have to manually `paste' this code
225 # wherever we need to access instance or type or operation.
227 # Anyway, the following table tells you what these commands do -
229 # instance=$(basename $(basename $(1)))
230 # operation=$(subst .,,$(suffix $(basename $(1))))
231 # type=$(subst -,_,$(subst .,,$(suffix $(1))))
233 # It's very important to notice that $(basename $(basename $*)) in
234 # these rules is simply the instance (such as libgmodel).
236 # NB: INTERNAL_$${type}_NAME and TARGET are deprecated - use
237 # GNUSTEP_INSTANCE instead.
239 # Before building the real thing, we must build the subprojects
241 # If we are at the very first make invocation, convert
242 # GNUSTEP_BUILD_DIR into an absolute path. All other make invocations
243 # can then assume it is already an absolute path form, and avoid the
244 # shell invocation to convert into absolute path. Let's avoid the
245 # shell invocation unless strictly necessary - it's slow.
246 ifeq ($(MAKELEVEL),0)
247 ifneq ($(GNUSTEP_BUILD_DIR),.)
249 # We can't use ':=' here (which we'd like, since it would guarantee
250 # that the shell command is executed only once) because ':=' would
251 # cause the shell command to be executed immediately, which is *now*
252 # during parsing, before any rule has been executed; in particular,
253 # before the rule which creates GNUSTEP_BUILD_DIR has been executed
254 # (if it had to be executed), and that might cause the 'cd' in the
255 # following shell command to fail. So what we do, is we define this
256 # as a simple variable with '=', which means it will be evaluated
257 # every time it is used, but not before, and then we make sure to
258 # use it as little as possible and only in rules which are executed
259 # after the rule to build GNUSTEP_BUILD_DIR. Please note that in
260 # this setup, *any* reference to this variable causes a slow
261 # subshell invocation. At the moment, it's used when running
262 # the subprojects/variables and when running the aggregate
265 # That makes 1 invocation per type of project per type of target
266 # used in the top-level makefile. For example, if the top-level
267 # makefile includes aggregate.make and documentation.make and does
268 # a make all, we evaluate this variable twice. If it does a make
269 # distclean (which automatically invokes make clean as well) we
270 # evaluate this variable 4 times. All non-top-level make code
271 # is free from overhead.
272 # In the rules which need the ABS_GNUSTEP_BUILD_DIR variable more
273 # than once we copy it into a shell variable and reuse the shell
274 # variable to avoid evaluating ABS_GNUSTEP_BUILD_DIR multiple
275 # times in the same rule.
276 # DO NOT EVER USE THIS VARIABLE UNLESS YOU FULLY UNDERSTAND THE
277 # PERFORMANCE IMPLICATIONS JUST DESCRIBED.
278 ABS_GNUSTEP_BUILD_DIR = $(shell (cd "$(GNUSTEP_BUILD_DIR)"; pwd))
280 ABS_GNUSTEP_BUILD_DIR = .
283 ABS_GNUSTEP_BUILD_DIR = $(strip $(GNUSTEP_BUILD_DIR))
286 # If you change the subprojects code here, make sure to update the
287 # %.subprojects rule below too! The code from the %.subprojects rule
288 # below is 'inlined' here for speed (so that we don't run a separate
289 # shell just to execute that code).
292 instance=$(basename $(basename $*)); \
293 operation=$(subst .,,$(suffix $(basename $*))); \
294 type=$(subst -,_,$(subst .,,$(suffix $*))); \
295 abs_build_dir="$(ABS_GNUSTEP_BUILD_DIR)"; \
296 if [ "$($(basename $(basename $*))_SUBPROJECTS)" != "" ]; then \
297 echo Making $$operation in subprojects of $$type $$instance...; \
298 for f in $($(basename $(basename $*))_SUBPROJECTS) __done; do \
299 if [ $$f != __done ]; then \
300 mf=$(MAKEFILE_NAME); \
301 if [ ! -f $$f/$$mf -a -f $$f/Makefile ]; then \
303 echo "WARNING: No $(MAKEFILE_NAME) found for subproject $$f; using 'Makefile'"; \
305 if [ "$${abs_build_dir}" = "." ]; then \
308 gsbuild="$${abs_build_dir}/$$f"; \
310 if [ "$(OWNING_PROJECT_HEADER_DIR_NAME)" = "" ]; then \
311 if [ "$$type" = "framework" ]; then \
312 if [ "$(FRAMEWORK_VERSION_SUPPORT)" = "yes" ]; then \
313 framework_version="$($(basename $(basename $*))_CURRENT_VERSION_NAME)"; \
314 if [ "$$framework_version" = "" ]; then framework_version="A"; fi; \
315 owning_project_header_dir="../$${instance}.framework/Versions/$${framework_version}/Headers"; \
317 owning_project_header_dir="../$${instance}.framework/Headers"; \
319 else owning_project_header_dir=""; \
322 owning_project_header_dir="../$(OWNING_PROJECT_HEADER_DIR_NAME)"; \
324 if $(MAKE) -C $$f -f $$mf --no-keep-going $$operation \
325 OWNING_PROJECT_HEADER_DIR_NAME="$${owning_project_header_dir}" \
326 DERIVED_SOURCES="../$(DERIVED_SOURCES)" \
327 GNUSTEP_BUILD_DIR="$$gsbuild" \
335 echo Making $$operation for $$type $$instance...; \
336 $(MAKE) -f $(MAKEFILE_NAME) --no-print-directory --no-keep-going \
337 internal-$${type}-$$operation \
338 GNUSTEP_TYPE=$$type \
339 GNUSTEP_INSTANCE=$$instance \
340 GNUSTEP_OPERATION=$$operation \
341 INTERNAL_$${type}_NAME=$$instance \
343 GNUSTEP_BUILD_DIR="$${abs_build_dir}"
346 # This rule provides exactly the same code as the %.variables one with
347 # respect to subprojects; it is available for clean targets when they
348 # want to run make clean in subprojects but do not need a full Instance
349 # invocation. In that case, they can depend on %.subprojects only.
351 # NB: The OWNING_PROJECT_HEADER_DIR_NAME hack in this rule is sort of
352 # horrible, because it pollutes this general rule with code specific
353 # to the framework implementation (eg, where the framework headers are
354 # located). Still, it's the least evil we could think of at the
355 # moment :-) The framework code is now completely confined into
356 # framework.make makefiles, except for this little hack in here. It
357 # would be nice to remove this hack without loosing functionality (or
358 # polluting other general-purpose makefiles).
361 instance=$(basename $(basename $*)); \
362 operation=$(subst .,,$(suffix $(basename $*))); \
363 type=$(subst -,_,$(subst .,,$(suffix $*))); \
364 abs_build_dir="$(ABS_GNUSTEP_BUILD_DIR)"; \
365 if [ "$($(basename $(basename $*))_SUBPROJECTS)" != "" ]; then \
366 echo Making $$operation in subprojects of $$type $$instance...; \
367 for f in $($(basename $(basename $*))_SUBPROJECTS) __done; do \
368 if [ $$f != __done ]; then \
369 mf=$(MAKEFILE_NAME); \
370 if [ ! -f $$f/$$mf -a -f $$f/Makefile ]; then \
372 echo "WARNING: No $(MAKEFILE_NAME) found for subproject $$f; using 'Makefile'"; \
374 if [ "$${abs_build_dir}" = "." ]; then \
377 gsbuild="$${abs_build_dir}/$$f"; \
379 if [ "$(OWNING_PROJECT_HEADER_DIR_NAME)" = "" ]; then \
380 if [ "$$type" = "framework" ]; then \
381 if [ "$(FRAMEWORK_VERSION_SUPPORT)" = "yes" ]; then \
382 framework_version="$($(basename $(basename $*))_CURRENT_VERSION_NAME)"; \
383 if [ "$$framework_version" = "" ]; then framework_version="A"; fi; \
384 owning_project_header_dir="../$${instance}.framework/Versions/$${framework_version}/Headers"; \
386 owning_project_header_dir="../$${instance}.framework/Headers"; \
388 else owning_project_header_dir=""; \
391 owning_project_header_dir="../$(OWNING_PROJECT_HEADER_DIR_NAME)"; \
393 if $(MAKE) -C $$f -f $$mf --no-keep-going $$operation \
394 OWNING_PROJECT_HEADER_DIR_NAME="$${owning_project_header_dir}" \
395 DERIVED_SOURCES="../$(DERIVED_SOURCES)" \
396 GNUSTEP_BUILD_DIR="$$gsbuild" \
406 # Now rules for packaging - all automatically included
409 PACKAGE_NAME := $(strip $(PACKAGE_NAME))
411 ifeq ($(PACKAGE_NAME),)
412 # Use a default of unnamed-package if nothing better is provided.
413 PACKAGE_NAME := unnamed-package
416 # For backwards compatibility, take value of PACKAGE_VERSION from
417 # VERSION. New GNUmakefiles should all use the PACKAGE_VERSION
418 # variable rather than the VERSION variable.
419 ifeq ($(PACKAGE_VERSION),)
421 PACKAGE_VERSION = $(VERSION)
423 # Use a default of 0.0.1 if nothing better is provided.
424 ifeq ($(PACKAGE_VERSION),)
425 PACKAGE_VERSION = 0.0.1
431 # Rules for building source distributions
433 include $(GNUSTEP_MAKEFILES)/Master/source-distribution.make
436 # Rules for building spec files/file lists for RPMs, and RPMs
438 include $(GNUSTEP_MAKEFILES)/Master/rpm.make
441 # Rules for building debian/* scripts for DEBs, and DEBs
443 #include $(GNUSTEP_MAKEFILES)/Master/deb.make <TODO>