1#   -*-makefile-*-
2#   application.make
3#
4#   Master makefile rules to build GNUstep-based applications.
5#
6#   Copyright (C) 1997, 2001, 2002 Free Software Foundation, Inc.
7#
8#   Author:  Nicola Pero <nicola@brainstorm.co.uk>
9#   Author:  Ovidiu Predescu <ovidiu@net-community.com>
10#   Based on the original version by Scott Christley.
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 3
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.
21#   If not, write to the Free Software Foundation,
22#   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23
24ifeq ($(RULES_MAKE_LOADED),)
25include $(GNUSTEP_MAKEFILES)/rules.make
26endif
27
28APP_NAME := $(strip $(APP_NAME))
29
30ifeq ($(GNUSTEP_MAKE_PARALLEL_BUILDING), no)
31
32internal-all:: $(GNUSTEP_OBJ_DIR) $(APP_NAME:=.all.app.variables)
33
34else
35
36# See tool.make for an explanation of the parallel building.
37internal-all:: $(GNUSTEP_OBJ_DIR)
38	$(ECHO_NOTHING_RECURSIVE_MAKE)$(MAKE) -f $(MAKEFILE_NAME) --no-print-directory --no-keep-going \
39	internal-master-app-all \
40	GNUSTEP_BUILD_DIR="$(GNUSTEP_BUILD_DIR)" \
41	_GNUSTEP_MAKE_PARALLEL=yes$(END_ECHO_RECURSIVE_MAKE)
42
43.PHONY: internal-master-app-all
44
45internal-master-app-all: $(APP_NAME:=.all.app.variables)
46
47endif
48
49internal-install:: $(APP_NAME:=.install.app.variables)
50
51internal-uninstall:: $(APP_NAME:=.uninstall.app.variables)
52
53# Compute them manually to avoid having to do an Instance make
54# invocation just to remove them.
55_PSWRAP_C_FILES = $(foreach app,$(APP_NAME),$($(app)_PSWRAP_FILES:.psw=.c))
56_PSWRAP_H_FILES = $(foreach app,$(APP_NAME),$($(app)_PSWRAP_FILES:.psw=.h))
57# The following intricate code computes the list of xxxInfo.plist files
58# for all applications xxx which have xxx_PREPROCESS_INFO_PLIST=yes.
59_PLIST_INFO_FILES = $(addsuffix Info.plist,$(foreach app,$(APP_NAME),$(patsubst yes,$(app),$($(app)_PREPROCESS_INFO_PLIST))))
60
61internal-clean::
62ifeq ($(GNUSTEP_IS_FLATTENED), no)
63	(cd $(GNUSTEP_BUILD_DIR); \
64	rm -rf $(_PSWRAP_C_FILES) $(_PSWRAP_H_FILES) $(_PLIST_INFO_FILES) *.$(APP_EXTENSION)/$(GNUSTEP_TARGET_LDIR))
65else
66	(cd $(GNUSTEP_BUILD_DIR); \
67	rm -rf $(_PSWRAP_C_FILES) $(_PSWRAP_H_FILES) $(_PLIST_INFO_FILES) *.$(APP_EXTENSION))
68endif
69
70internal-distclean::
71ifeq ($(GNUSTEP_IS_FLATTENED), no)
72	(cd $(GNUSTEP_BUILD_DIR); rm -rf *.$(APP_EXTENSION))
73endif
74
75# The following make trick extracts all apps in APP_NAME for which
76# the xxx_SUBPROJECTS variable is set to something non-empty.
77# For those apps (and only for them), we need to run 'clean' and
78# 'distclean' in subprojects too.
79#
80# Please note that newer GNU make has a $(if condition,then,else)
81# function, which would be so handy here!  But unfortunately it's not
82# available in older GNU makes, so we must not use it.  This trick
83# works around this problem.
84
85APPS_WITH_SUBPROJECTS = $(strip $(foreach app,$(APP_NAME),$(patsubst %,$(app),$($(app)_SUBPROJECTS))))
86ifneq ($(APPS_WITH_SUBPROJECTS),)
87internal-clean:: $(APPS_WITH_SUBPROJECTS:=.clean.app.subprojects)
88internal-distclean:: $(APPS_WITH_SUBPROJECTS:=.distclean.app.subprojects)
89endif
90
91internal-strings:: $(APP_NAME:=.strings.app.variables)
92
93# FIXME - GNUSTEP_BUILD_DIR here.  Btw should we remove this or
94# provide a better more general way of doing it ?
95$(APP_NAME): $(GNUSTEP_OBJ_DIR)
96	$(ECHO_NOTHING_RECURSIVE_MAKE)$(MAKE) -f $(MAKEFILE_NAME) --no-print-directory $@.all.app.variables$(END_ECHO_RECURSIVE_MAKE)
97