1#   -*-makefile-*-
2#   Instance/subproject.make
3#
4#   Instance Makefile rules to build subprojects in GNUstep projects.
5#
6#   Copyright (C) 1998, 2001, 2010 Free Software Foundation, Inc.
7#
8#   Author:  Jonathan Gapen <jagapen@whitewater.chem.wisc.edu>
9#   Author:  Nicola Pero <nicola.pero@meta-innovation.com>
10#
11#   This file is part of the GNUstep Makefile Package.
12#
13#   This library is free software; you can redistribute it and/or
14#   modify it under the terms of the GNU General Public License
15#   as published by the Free Software Foundation; either version 3
16#   of the License, or (at your option) any later version.
17#
18#   You should have received a copy of the GNU General Public
19#   License along with this library; see the file COPYING.
20#   If not, write to the Free Software Foundation,
21#   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22
23ifeq ($(RULES_MAKE_LOADED),)
24include $(GNUSTEP_MAKEFILES)/rules.make
25endif
26
27.PHONY: internal-subproject-all_       \
28        internal-subproject-install_   \
29        internal-subproject-uninstall_ \
30	internal-subproject-compile
31
32#
33# Compilation targets
34#
35ifeq ($(GNUSTEP_MAKE_PARALLEL_BUILDING), no)
36# Standard building
37internal-subproject-all_:: $(GNUSTEP_OBJ_INSTANCE_DIR) \
38                           $(OBJ_DIRS_TO_CREATE) \
39                           $(GNUSTEP_OBJ_DIR)/$(SUBPROJECT_PRODUCT)
40else
41# Parallel building.  The actual compilation is delegated to a
42# sub-make invocation where _GNUSTEP_MAKE_PARALLEL is set to yet.
43# That sub-make invocation will compile files in parallel.
44internal-subproject-all_:: $(GNUSTEP_OBJ_INSTANCE_DIR) $(OBJ_DIRS_TO_CREATE)
45	$(ECHO_NOTHING_RECURSIVE_MAKE)$(MAKE) -f $(MAKEFILE_NAME) --no-print-directory --no-keep-going \
46	internal-subproject-compile \
47	GNUSTEP_TYPE=$(GNUSTEP_TYPE) \
48	GNUSTEP_INSTANCE=$(GNUSTEP_INSTANCE) \
49	GNUSTEP_OPERATION=compile \
50	GNUSTEP_BUILD_DIR="$(GNUSTEP_BUILD_DIR)" \
51	_GNUSTEP_MAKE_PARALLEL=yes$(END_ECHO_RECURSIVE_MAKE)
52
53internal-subproject-compile: $(GNUSTEP_OBJ_DIR)/$(SUBPROJECT_PRODUCT)
54endif
55
56# We need to depend on SUBPROJECT_OBJ_FILES to account for sub-subprojects.
57$(GNUSTEP_OBJ_DIR)/$(SUBPROJECT_PRODUCT): $(OBJ_FILES_TO_LINK)
58ifeq ($(OBJ_FILES_TO_LINK),)
59	$(WARNING_EMPTY_LINKING)
60endif
61	$(ECHO_LINKING)$(OBJ_MERGE_CMD)$(END_ECHO)
62
63#
64# Build-header target for framework subprojects
65#
66# If we are called with OWNING_PROJECT_HEADER_DIR_NAME which is not empty,
67# we need to copy our headers into that directory during the
68# build-headers stage, and to disable installation/uninstallation of
69# headers.
70#
71ifneq ($(OWNING_PROJECT_HEADER_DIR_NAME),)
72.PHONY: internal-subproject-build-headers
73
74# NB: See headers.make for an explanation of how HEADER_SUBDIRS is
75# computed.
76OWNING_PROJECT_HEADER_DIR = $(GNUSTEP_BUILD_DIR)/$(OWNING_PROJECT_HEADER_DIR_NAME)
77HEADER_FILES   = $($(GNUSTEP_INSTANCE)_HEADER_FILES)
78HEADER_SUBDIRS = $(strip $(filter-out ./,$(sort $(dir $(HEADER_FILES)))))
79HEADER_FILES_DIR = $($(GNUSTEP_INSTANCE)_HEADER_FILES_DIR)
80ifeq ($(HEADER_FILES_DIR),)
81  HEADER_FILES_DIR = .
82endif
83OWNING_PROJECT_HEADER_FILES   = $(addprefix $(OWNING_PROJECT_HEADER_DIR)/,$(HEADER_FILES))
84OWNING_PROJECT_HEADER_SUBDIRS = $(addprefix $(OWNING_PROJECT_HEADER_DIR)/,$(HEADER_SUBDIRS))
85
86# We need to build the OWNING_PROJECT_HEADER_DIR directory here
87# because this rule could be executed before the top-level framework
88# has built his dirs
89internal-subproject-build-headers:: $(OWNING_PROJECT_HEADER_DIR) \
90                                    $(OWNING_PROJECT_HEADER_SUBDIRS) \
91                                    $(OWNING_PROJECT_HEADER_FILES)
92
93$(OWNING_PROJECT_HEADER_DIR):
94	$(ECHO_CREATING)$(MKDIRS) $@$(END_ECHO)
95
96$(OWNING_PROJECT_HEADER_SUBDIRS):
97	$(ECHO_CREATING)$(MKDIRS) $@$(END_ECHO)
98
99$(OWNING_PROJECT_HEADER_DIR)/%.h: $(HEADER_FILES_DIR)/%.h
100	$(ECHO_CREATING)$(INSTALL_DATA) $< $@$(END_ECHO)
101
102# End FRAMEWORK code
103else
104# Start no FRAMEWORK code
105
106#
107# Installation targets - we only need to install headers and only
108# if this is not in a framework
109#
110
111include $(GNUSTEP_MAKEFILES)/Instance/Shared/headers.make
112
113internal-subproject-install_:: shared-instance-headers-install
114
115internal-subproject-uninstall_:: shared-instance-headers-uninstall
116
117endif # no FRAMEWORK
118
119
120#
121# A subproject can have resources, which it stores into the
122# Resources/Subproject directory.  If you want your subproject
123# to have resources, you need to put
124# xxx_HAS_RESOURCE_BUNDLE = yes
125# in your GNUmakefile.  The project which owns us can then
126# copy recursively this directory into its own Resources directory
127# (that is done automatically if the project uses
128# Instance/Shared/bundle.make to manage its own resource bundle)
129#
130ifeq ($($(GNUSTEP_INSTANCE)_HAS_RESOURCE_BUNDLE), yes)
131
132GNUSTEP_SHARED_BUNDLE_RESOURCE_PATH = $(GNUSTEP_BUILD_DIR)/Resources/Subproject
133include $(GNUSTEP_MAKEFILES)/Instance/Shared/bundle.make
134
135# Only build, not install
136internal-subproject-all_:: shared-instance-bundle-all
137
138endif
139
140include $(GNUSTEP_MAKEFILES)/Instance/Shared/strings.make
141