1#   -*-makefile-*-
2#   Instance/palette.make
3#
4#   Instance Makefile rules to build GNUstep-based palettes.
5#
6#   Copyright (C) 1999 Free Software Foundation, Inc.
7#
8#   Author:  Scott Christley <scottc@net-community.com>
9#   Author:  Ovidiu Predescu <ovidiu@net-community.com>
10#   Author:  Richard Frith-Macdonald <richard@brainstorm.co.uk>
11#   Author:  Nicola Pero <nicola@brainstorm.co.uk>
12#
13#   This file is part of the GNUstep Makefile Package.
14#
15#   This library is free software; you can redistribute it and/or
16#   modify it under the terms of the GNU General Public License
17#   as published by the Free Software Foundation; either version 3
18#   of the License, or (at your option) any later version.
19#
20#   You should have received a copy of the GNU General Public
21#   License along with this library; see the file COPYING.
22#   If not, write to the Free Software Foundation,
23#   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
24
25# Palettes usually link against a gui library (if available).
26ifeq ($(NEEDS_GUI),)
27  NEEDS_GUI = yes
28endif
29
30ifeq ($(RULES_MAKE_LOADED),)
31include $(GNUSTEP_MAKEFILES)/rules.make
32endif
33
34# The name of the palette is in the PALETTE_NAME variable.
35# The list of palette resource file are in xxx_RESOURCE_FILES
36# The list of palette resource directories are in xxx_RESOURCE_DIRS
37# The name of the palette class is xxx_PRINCIPAL_CLASS
38# The name of the palette nib is xxx_MAIN_MODEL_FILE
39# The name of the palette icon is xxx_PALETTE_ICON
40# The name of a file containing info.plist entries to be inserted into
41# Info-gnustep.plist (if any) is xxxInfo.plist where xxx is the palette name
42# The name of a file containing palette.table entries to be inserted into
43# palette.table (if any) is xxxpalette.table where xxx is the palette name
44#
45
46.PHONY: internal-palette-all_ \
47        internal-palette-install_ \
48        internal-palette-uninstall_ \
49        internal-palette-copy_into_dir \
50        internal-palette-run-compile-submake \
51        internal-palette-compile
52
53# On windows, this is unfortunately required.
54ifeq ($(BUILD_DLL), yes)
55  LINK_PALETTE_AGAINST_ALL_LIBS = yes
56endif
57
58# On Apple, two-level namespaces require all symbols in bundles
59# to be resolved at link time. Also on gnu/darwin
60ifeq ($(CC_BUNDLE), yes)
61  LINK_PALETTE_AGAINST_ALL_LIBS = yes
62endif
63
64ifeq ($(LINK_PALETTE_AGAINST_ALL_LIBS), yes)
65  PALETTE_LIBS += $(ALL_LIBS)
66endif
67
68ifeq ($(BUILD_DLL),yes)
69PALETTE_OBJ_EXT = $(DLL_LIBEXT)
70endif
71
72PALETTE_DIR_NAME = $(GNUSTEP_INSTANCE).palette
73PALETTE_DIR = $(GNUSTEP_BUILD_DIR)/$(PALETTE_DIR_NAME)
74PALETTE_FILE_NAME = $(PALETTE_DIR_NAME)/$(GNUSTEP_TARGET_LDIR)/$(PALETTE_NAME)$(PALETTE_OBJ_EXT)
75PALETTE_FILE = $(GNUSTEP_BUILD_DIR)/$(PALETTE_FILE_NAME)
76
77ifneq ($($(GNUSTEP_INSTANCE)_INSTALL_DIR),)
78  PALETTE_INSTALL_DIR = $($(GNUSTEP_INSTANCE)_INSTALL_DIR)
79endif
80
81ifeq ($(PALETTE_INSTALL_DIR),)
82  PALETTE_INSTALL_DIR = $(GNUSTEP_PALETTES)
83endif
84
85GNUSTEP_SHARED_BUNDLE_RESOURCE_PATH = $(PALETTE_DIR)/Resources
86
87GNUSTEP_SHARED_BUNDLE_INSTALL_NAME = $(PALETTE_DIR_NAME)
88GNUSTEP_SHARED_BUNDLE_INSTALL_LOCAL_PATH = .
89GNUSTEP_SHARED_BUNDLE_INSTALL_PATH = $(PALETTE_INSTALL_DIR)
90include $(GNUSTEP_MAKEFILES)/Instance/Shared/bundle.make
91
92internal-palette-all_:: $(GNUSTEP_OBJ_INSTANCE_DIR) \
93                        $(OBJ_DIRS_TO_CREATE) \
94                        $(PALETTE_DIR)/Resources \
95                        $(PALETTE_DIR)/$(GNUSTEP_TARGET_LDIR) \
96                        internal-palette-run-compile-submake \
97                        $(PALETTE_DIR)/Resources/Info-gnustep.plist \
98                        $(PALETTE_DIR)/Resources/palette.table \
99                        shared-instance-bundle-all
100# If they specified Info-gnustep.plist in the xxx_RESOURCE_FILES,
101# print a warning. They are supposed to provide a xxxInfo.plist which
102# gets merged with the automatically generated entries to generate
103# Info-gnustep.plist.
104ifneq ($(FOUNDATION_LIB), apple)
105  ifneq ($(filter Info-gnustep.plist,$($(GNUSTEP_INSTANCE)_RESOURCE_FILES)),)
106	$(WARNING_INFO_GNUSTEP_PLIST)
107  endif
108else
109  ifneq ($(filter Info.plist,$($(GNUSTEP_INSTANCE)_RESOURCE_FILES)),)
110	$(WARNING_INFO_PLIST)
111  endif
112endif
113
114$(PALETTE_DIR)/$(GNUSTEP_TARGET_LDIR):
115	$(ECHO_CREATING)$(MKDIRS) $(PALETTE_DIR)/$(GNUSTEP_TARGET_LDIR)$(END_ECHO)
116
117ifeq ($(GNUSTEP_MAKE_PARALLEL_BUILDING), no)
118# Standard building
119internal-palette-run-compile-submake: $(PALETTE_FILE)
120else
121# Parallel building.  The actual compilation is delegated to a
122# sub-make invocation where _GNUSTEP_MAKE_PARALLEL is set to yet.
123# That sub-make invocation will compile files in parallel.
124internal-palette-run-compile-submake:
125	$(ECHO_NOTHING_RECURSIVE_MAKE)$(MAKE) -f $(MAKEFILE_NAME) --no-print-directory --no-keep-going \
126	internal-palette-compile \
127	GNUSTEP_TYPE=$(GNUSTEP_TYPE) \
128	GNUSTEP_INSTANCE=$(GNUSTEP_INSTANCE) \
129	GNUSTEP_OPERATION=compile \
130	GNUSTEP_BUILD_DIR="$(GNUSTEP_BUILD_DIR)" \
131	_GNUSTEP_MAKE_PARALLEL=yes$(END_ECHO_RECURSIVE_MAKE)
132
133internal-palette-compile: $(PALETTE_FILE)
134endif
135
136# Standard bundle build using the rules for this target
137$(PALETTE_FILE): $(OBJ_FILES_TO_LINK)
138ifeq ($(OBJ_FILES_TO_LINK),)
139	$(WARNING_EMPTY_LINKING)
140endif
141	$(ECHO_LINKING)$(BUNDLE_LD) $(BUNDLE_LDFLAGS) \
142	  -o $(LDOUT)$(PALETTE_FILE) \
143	  $(OBJ_FILES_TO_LINK) $(ALL_LDFLAGS) \
144	  $(BUNDLE_LIBFLAGS) $(ALL_LIB_DIRS) $(PALETTE_LIBS)$(END_ECHO)
145
146PRINCIPAL_CLASS = $(strip $($(GNUSTEP_INSTANCE)_PRINCIPAL_CLASS))
147
148ifeq ($(PRINCIPAL_CLASS),)
149  PRINCIPAL_CLASS = $(GNUSTEP_INSTANCE)
150endif
151
152PALETTE_ICON = $($(GNUSTEP_INSTANCE)_PALETTE_ICON)
153
154ifeq ($(PALETTE_ICON),)
155  PALETTE_ICON = $(GNUSTEP_INSTANCE)
156endif
157
158# FIXME - xxxInfo.plist in this case is not really a plist!
159
160$(PALETTE_DIR)/Resources/Info-gnustep.plist: $(PALETTE_DIR)/Resources $(GNUSTEP_PLIST_DEPEND)
161	$(ECHO_CREATING)(echo "{"; echo '  NOTE = "Automatically generated, do not edit!";'; \
162	  echo "  NSExecutable = \"$(PALETTE_NAME)$(PALETTE_OBJ_EXT)\";"; \
163	  if [ -r "$(GNUSTEP_PLIST_DEPEND)" ]; then \
164	    cat $(GNUSTEP_PLIST_DEPEND); \
165	  fi; \
166	  echo "}") >$@$(END_ECHO)
167
168MAIN_MODEL_FILE = $(strip $(subst .gmodel,,$(subst .gorm,,$(subst .nib,,$($(GNUSTEP_INSTANCE)_MAIN_MODEL_FILE)))))
169
170# Depend on xxxpalette.table but only if it exists.
171PALETTE_TABLE_DEPEND = $(wildcard $(GNUSTEP_INSTANCE)palette.table)
172
173# FIXME - use stamp.make to depend on the value of the variables
174# MAIN_MODEL_FILE, PRINCIPAL_CLASS and PALETTE_ICON
175$(PALETTE_DIR)/Resources/palette.table: $(PALETTE_DIR)/Resources $(PALETTE_TABLE_DEPEND)
176	$(ECHO_CREATING)(echo "{";\
177	  echo '  NOTE = "Automatically generated, do not edit!";'; \
178	  echo "  NibFile = \"$(MAIN_MODEL_FILE)\";"; \
179	  echo "  Class = \"$(PRINCIPAL_CLASS)\";"; \
180	  echo "  Icon = \"$(PALETTE_ICON)\";"; \
181	  echo "}"; \
182	  if [ -r "$(GNUSTEP_INSTANCE)palette.table" ]; then \
183	    cat $(GNUSTEP_INSTANCE)palette.table; \
184	  fi; \
185	  ) >$@$(END_ECHO)
186
187internal-palette-copy_into_dir:: shared-instance-bundle-copy_into_dir
188
189#
190# Install targets
191#
192$(PALETTE_INSTALL_DIR):
193	$(ECHO_CREATING)$(MKINSTALLDIRS) $@$(END_ECHO)
194
195internal-palette-install_:: shared-instance-bundle-install
196ifeq ($(strip),yes)
197	$(ECHO_STRIPPING)$(STRIP) $(PALETTE_INSTALL_DIR)/$(PALETTE_FILE_NAME)$(END_ECHO)
198endif
199
200internal-palette-uninstall_:: shared-instance-bundle-uninstall
201
202
203include $(GNUSTEP_MAKEFILES)/Instance/Shared/strings.make
204