1#   -*-makefile-*-
2#   Instance/tool.make
3#
4#   Instance Makefile rules to build GNUstep-based command line tools.
5#
6#   Copyright (C) 1997, 2001 Free Software Foundation, Inc.
7#
8#   Author:  Scott Christley <scottc@net-community.com>
9#   Author:  Nicola Pero <nicola@brainstorm.co.uk>
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
23# Tools don't link against gui by default
24ifeq ($(NEEDS_GUI),)
25  NEEDS_GUI = no
26endif
27
28#
29# The name of the tools is in the TOOL_NAME variable.
30#
31# xxx We need to prefix the target name when cross-compiling
32#
33
34ifeq ($(RULES_MAKE_LOADED),)
35include $(GNUSTEP_MAKEFILES)/rules.make
36endif
37
38.PHONY: internal-tool-all_       \
39        internal-tool-install_   \
40        internal-tool-uninstall_ \
41        internal-tool-copy_into_dir \
42	internal-tool-compile
43
44# This is the directory where the tools get installed. If you don't specify a
45# directory they will get installed in the GNUstep Local Root.
46ifneq ($($(GNUSTEP_INSTANCE)_INSTALL_DIR),)
47  TOOL_INSTALL_DIR = $($(GNUSTEP_INSTANCE)_INSTALL_DIR)
48endif
49
50ifeq ($(TOOL_INSTALL_DIR),)
51  TOOL_INSTALL_DIR = $(GNUSTEP_TOOLS)
52endif
53
54# This is the 'final' directory in which we copy the tool executable, including
55# the target and library-combo paths.  You can override it in special occasions
56# (eg, installing an executable into a web server's cgi dir).
57ifeq ($(FINAL_TOOL_INSTALL_DIR),)
58  FINAL_TOOL_INSTALL_DIR = $(TOOL_INSTALL_DIR)/$(GNUSTEP_TARGET_LDIR)
59endif
60
61#
62# Compilation targets
63#
64ifeq ($(GNUSTEP_MAKE_PARALLEL_BUILDING), no)
65# Standard building
66internal-tool-all_:: $(GNUSTEP_OBJ_INSTANCE_DIR) \
67                     $(OBJ_DIRS_TO_CREATE) \
68                     $(GNUSTEP_OBJ_DIR)/$(GNUSTEP_INSTANCE)$(EXEEXT)
69else
70# Parallel building.  The actual compilation is delegated to a
71# sub-make invocation where _GNUSTEP_MAKE_PARALLEL is set to yes.
72# That sub-make invocation will compile files in parallel.
73internal-tool-all_:: $(GNUSTEP_OBJ_INSTANCE_DIR) $(OBJ_DIRS_TO_CREATE)
74	$(ECHO_NOTHING_RECURSIVE_MAKE)$(MAKE) -f $(MAKEFILE_NAME) --no-print-directory --no-keep-going \
75	internal-tool-compile \
76	GNUSTEP_TYPE=$(GNUSTEP_TYPE) \
77	GNUSTEP_INSTANCE=$(GNUSTEP_INSTANCE) \
78	GNUSTEP_OPERATION=compile \
79	GNUSTEP_BUILD_DIR="$(GNUSTEP_BUILD_DIR)" \
80	_GNUSTEP_MAKE_PARALLEL=yes$(END_ECHO_RECURSIVE_MAKE)
81
82internal-tool-compile: $(GNUSTEP_OBJ_DIR)/$(GNUSTEP_INSTANCE)$(EXEEXT)
83endif
84
85$(GNUSTEP_OBJ_DIR)/$(GNUSTEP_INSTANCE)$(EXEEXT): $(OBJ_FILES_TO_LINK)
86ifeq ($(OBJ_FILES_TO_LINK),)
87	$(WARNING_EMPTY_LINKING)
88endif
89	$(ECHO_LINKING)$(LD) $(ALL_LDFLAGS) $(CC_LDFLAGS) -o $(LDOUT)$@ \
90		$(OBJ_FILES_TO_LINK) \
91		$(ALL_LIB_DIRS) $(ALL_LIBS)$(END_ECHO)
92
93internal-tool-copy_into_dir::
94	$(ECHO_COPYING_INTO_DIR)$(MKDIRS) $(COPY_INTO_DIR)/$(GNUSTEP_TARGET_LDIR);\
95	  $(INSTALL_PROGRAM) -m 0755 \
96	  $(GNUSTEP_OBJ_DIR)/$(GNUSTEP_INSTANCE)$(EXEEXT) \
97	  $(COPY_INTO_DIR)/$(GNUSTEP_TARGET_LDIR)$(END_ECHO)
98
99# This rule runs $(MKDIRS) only if needed
100$(FINAL_TOOL_INSTALL_DIR):
101	$(ECHO_CREATING)$(MKINSTALLDIRS) $@$(END_ECHO)
102
103internal-tool-install_:: $(FINAL_TOOL_INSTALL_DIR)
104	$(ECHO_INSTALLING)$(INSTALL_PROGRAM) -m 0755 \
105		$(GNUSTEP_OBJ_DIR)/$(GNUSTEP_INSTANCE)$(EXEEXT) \
106		$(FINAL_TOOL_INSTALL_DIR)$(END_ECHO)
107
108internal-tool-uninstall_::
109	rm -f $(FINAL_TOOL_INSTALL_DIR)/$(GNUSTEP_INSTANCE)$(EXEEXT)
110
111# NB: We don't have any cleaning targets for tools here, because we
112# clean during the Master make invocation.
113
114#
115# If the user makefile contains the command
116# xxx_HAS_RESOURCE_BUNDLE = yes
117# then we need to build a resource bundle for the tool, and install it.
118# You can then add resources to the tool, any sort of, with the usual
119# xxx_RESOURCE_FILES, xxx_LOCALIZED_RESOURCE_FILES, xxx_LANGUAGES, etc.
120# The tool resource bundle (and all resources inside it) can be
121# accessed at runtime very comfortably, by using gnustep-base's
122# [NSBundle +mainBundle] (exactly as you would do for an application).
123#
124ifeq ($($(GNUSTEP_INSTANCE)_HAS_RESOURCE_BUNDLE),yes)
125
126# Include the rules to build resource bundles
127GNUSTEP_SHARED_BUNDLE_RESOURCE_PATH = $(GNUSTEP_BUILD_DIR)/Resources/$(GNUSTEP_INSTANCE)
128
129GNUSTEP_SHARED_BUNDLE_INSTALL_NAME = $(GNUSTEP_INSTANCE)
130GNUSTEP_SHARED_BUNDLE_INSTALL_LOCAL_PATH = Resources
131GNUSTEP_SHARED_BUNDLE_INSTALL_PATH = $(GNUSTEP_LIBRARY)/Tools/Resources
132include $(GNUSTEP_MAKEFILES)/Instance/Shared/bundle.make
133
134internal-tool-all_:: shared-instance-bundle-all
135internal-tool-copy_into_dir:: shared-instance-bundle-copy_into_dir
136
137$(TOOL_INSTALL_DIR):
138	$(ECHO_CREATING)$(MKINSTALLDIRS) $@$(END_ECHO)
139
140$(GNUSTEP_LIBRARY)/Tools/Resources:
141	$(ECHO_CREATING)$(MKINSTALLDIRS) $@$(END_ECHO)
142
143internal-tool-install_:: $(GNUSTEP_LIBRARY)/Tools/Resources \
144                         shared-instance-bundle-install
145
146internal-tool-uninstall:: shared-instance-bundle-uninstall
147
148endif
149
150include $(GNUSTEP_MAKEFILES)/Instance/Shared/strings.make
151