File: bundle.make

package info (click to toggle)
gnustep-make 1.3.0-3
  • links: PTS
  • area: main
  • in suites: woody
  • size: 1,568 kB
  • ctags: 44
  • sloc: sh: 3,432; ansic: 852; makefile: 80; csh: 77; objc: 11
file content (252 lines) | stat: -rw-r--r-- 9,444 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
#
#   Instace/bundle.make
#
#   Instance makefile rules to build GNUstep-based bundles.
#
#   Copyright (C) 1997, 2001 Free Software Foundation, Inc.
#
#   Author:  Scott Christley <scottc@net-community.com>
#   Author:  Ovidiu Predescu <ovidiu@net-community.com>
#   Author:  Nicola Pero <nicola@brainstorm.co.uk>
#
#   This file is part of the GNUstep Makefile Package.
#
#   This library is free software; you can redistribute it and/or
#   modify it under the terms of the GNU General Public License
#   as published by the Free Software Foundation; either version 2
#   of the License, or (at your option) any later version.
#   
#   You should have received a copy of the GNU General Public
#   License along with this library; see the file COPYING.LIB.
#   If not, write to the Free Software Foundation,
#   59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.

ifeq ($(RULES_MAKE_LOADED),)
include $(GNUSTEP_MAKEFILES)/rules.make
endif

include $(GNUSTEP_MAKEFILES)/Instance/Shared/headers.make

# The name of the bundle is in the BUNDLE_NAME variable.
# The list of bundle resource file are in xxx_RESOURCE_FILES
# The list of localized bundle resource files is in 
#                               xxx_LOCALIZED_RESOURCE_FILES
# The list of languages the bundle supports is in xxx_LANGUAGES
# The list of bundle resource directories are in xxx_RESOURCE_DIRS
# The name of the principal class is xxx_PRINCIPAL_CLASS
# The header files are in xxx_HEADER_FILES
# The directory where the header files are located is xxx_HEADER_FILES_DIR
# The directory where to install the header files inside the library
# installation directory is xxx_HEADER_FILES_INSTALL_DIR
# where xxx is the bundle name
#

.PHONY: internal-bundle-all_ \
        internal-bundle-install_ \
        internal-bundle-uninstall_ \
        build-bundle-dir \
        build-bundle \
        build-macosx-bundle \
        bundle-resource-files \
        bundle-localized-resource-files 

ifeq ($(WITH_DLL),yes)
# This is only for Windows ... on other systems, we don't need to link
# the bundle against the system libraries, which are already linked in
# the application ... linking them both in the bundle and in the
# application would just make things more difficult when the bundle is
# loaded (eg, if the application and the bundle end up being linked to
# different versions of the system libraries ...)
#
# On the contrary, we need it on Windows (FIXME - add an explanation
# of why we need it on Windows)
BUNDLE_LIBS += $(ADDITIONAL_GUI_LIBS) $(AUXILIARY_GUI_LIBS) $(BACKEND_LIBS) \
   $(GUI_LIBS) $(ADDITIONAL_TOOL_LIBS) $(AUXILIARY_TOOL_LIBS) \
   $(FND_LIBS) $(ADDITIONAL_OBJC_LIBS) $(AUXILIARY_OBJC_LIBS) $(OBJC_LIBS) \
   $(SYSTEM_LIBS) $(TARGET_SYSTEM_LIBS)
endif

ALL_BUNDLE_LIBS =						\
    $(shell $(WHICH_LIB_SCRIPT)					\
	$(ALL_LIB_DIRS)						\
	$(BUNDLE_LIBS)						\
	debug=$(debug) profile=$(profile) shared=$(shared)	\
	libext=$(LIBEXT) shared_libext=$(SHARED_LIBEXT))

ifeq ($(WITH_DLL),yes)
TTMP_LIBS := $(ALL_BUNDLE_LIBS)
TTMP_LIBS := $(filter -l%, $(TTMP_LIBS))
# filter all non-static libs (static libs are those ending in _ds, _s, _ps..)
TTMP_LIBS := $(filter-out -l%_ds, $(TTMP_LIBS))
TTMP_LIBS := $(filter-out -l%_s,  $(TTMP_LIBS))
TTMP_LIBS := $(filter-out -l%_dps,$(TTMP_LIBS))
TTMP_LIBS := $(filter-out -l%_ps, $(TTMP_LIBS))
# strip away -l, _p and _d ..
TTMP_LIBS := $(TTMP_LIBS:-l%=%)
TTMP_LIBS := $(TTMP_LIBS:%_d=%)
TTMP_LIBS := $(TTMP_LIBS:%_p=%)
TTMP_LIBS := $(TTMP_LIBS:%_dp=%)
TTMP_LIBS := $(shell echo $(TTMP_LIBS)|tr '-' '_')
TTMP_LIBS := $(TTMP_LIBS:%=-Dlib%_ISDLL=1)
ALL_CPPFLAGS += $(TTMP_LIBS)
BUNDLE_OBJ_EXT = $(DLL_LIBEXT)
endif # WITH_DLL

internal-bundle-all_:: $(GNUSTEP_OBJ_DIR) \
                       build-bundle \
                       build-macosx-bundle

BUNDLE_DIR_NAME = $(GNUSTEP_INSTANCE:=$(BUNDLE_EXTENSION))

GNUSTEP_SHARED_INSTANCE_BUNDLE_RESOURCE_PATH = $(BUNDLE_DIR_NAME)/Resources
include $(GNUSTEP_MAKEFILES)/Instance/Shared/bundle.make

BUNDLE_FILE = \
$(BUNDLE_DIR_NAME)/$(GNUSTEP_TARGET_LDIR)/$(GNUSTEP_INSTANCE)$(BUNDLE_OBJ_EXT)

ifeq ($(BUNDLE_INSTALL_DIR),)
  BUNDLE_INSTALL_DIR = $(GNUSTEP_BUNDLES)
endif

build-bundle:: $(BUNDLE_DIR_NAME)/$(GNUSTEP_TARGET_LDIR) \
               $(BUNDLE_FILE) \
               $(BUNDLE_DIR_NAME)/Resources \
               $(BUNDLE_DIR_NAME)/Resources/Info.plist \
               $(BUNDLE_DIR_NAME)/Resources/Info-gnustep.plist \
               shared-instance-bundle-all

# The rule to build $(BUNDLE_DIR_NAME)/Resources is already provided
# by Instance/Shared/bundle.make

$(BUNDLE_DIR_NAME)/$(GNUSTEP_TARGET_LDIR):
	$(MKDIRS) $@

ifeq ($(WITH_DLL),yes)

$(BUNDLE_FILE) : $(OBJ_FILES_TO_LINK)
	$(DLLWRAP) --driver-name $(CC) \
		-o $(LDOUT)$(BUNDLE_FILE) \
		$(OBJ_FILES_TO_LINK) \
		$(ALL_BUNDLE_LIBS)

else # WITH_DLL

$(BUNDLE_FILE) : $(OBJ_FILES_TO_LINK)
	$(BUNDLE_LD) $(BUNDLE_LDFLAGS) $(ALL_LDFLAGS) \
		-o $(LDOUT)$(BUNDLE_FILE) \
		$(OBJ_FILES_TO_LINK) \
		$(ALL_BUNDLE_LIBS)

endif # WITH_DLL

PRINCIPAL_CLASS = $(strip $($(GNUSTEP_INSTANCE)_PRINCIPAL_CLASS))

ifeq ($(PRINCIPAL_CLASS),)
  PRINCIPAL_CLASS = $(GNUSTEP_INSTANCE)
endif

# MacOSX bundles

$(BUNDLE_DIR_NAME)/Contents :
	$(MKDIRS) $@

$(BUNDLE_DIR_NAME)/Contents/Resources : $(BUNDLE_DIR_NAME)/Contents \
                                        $(BUNDLE_DIR_NAME)/Resources
	@(cd $(BUNDLE_DIR_NAME)/Contents; rm -f Resources; \
	  $(LN_S) ../Resources .)

$(BUNDLE_DIR_NAME)/Contents/Info.plist: $(BUNDLE_DIR_NAME)/Contents
	@(echo "<?xml version='1.0' encoding='utf-8'?>";\
	  echo "<!DOCTYPE plist SYSTEM 'file://localhost/System/Library/DTDs/PropertyList.dtd'>";\
	  echo "<!-- Automatically generated, do not edit! -->";\
	  echo "<plist version='0.9'>";\
	  echo "  <dict>";\
	  echo "    <key>CFBundleExecutable</key>";\
	  echo "    <string>$(GNUSTEP_TARGET_LDIR)/$(GNUSTEP_INSTANCE)${BUNDLE_OBJ_EXT}</string>";\
	  echo "    <key>CFBundleInfoDictionaryVersion</key>";\
	  echo "    <string>6.0</string>";\
	  echo "    <key>CFBundlePackageType</key>";\
	  echo "    <string>BNDL</string>";\
	  echo "    <key>NSPrincipalClass</key>";\
	  echo "    <string>$(PRINCIPAL_CLASS)</string>";\
	  echo "  </dict>";\
	  echo "</plist>";\
	) >$@

build-macosx-bundle :: $(BUNDLE_DIR_NAME)/Contents \
                       $(BUNDLE_DIR_NAME)/Contents/Resources \
                       $(BUNDLE_DIR_NAME)/Contents/Info.plist

MAIN_MODEL_FILE = $(strip $(subst .gmodel,,$(subst .gorm,,$(subst .nib,,$($(GNUSTEP_INSTANCE)_MAIN_MODEL_FILE)))))

# NeXTstep bundles
$(BUNDLE_DIR_NAME)/Resources/Info.plist:
	@(echo "{"; echo '  NOTE = "Automatically generated, do not edit!";'; \
	  echo "  NSExecutable = \"$(GNUSTEP_TARGET_LDIR)/$(GNUSTEP_INSTANCE)${BUNDLE_OBJ_EXT}\";"; \
	  echo "  NSMainNibFile = \"$(MAIN_MODEL_FILE)\";"; \
	  echo "  NSPrincipalClass = \"$(PRINCIPAL_CLASS)\";"; \
	  echo "}") >$@

# GNUstep bundles
$(BUNDLE_DIR_NAME)/Resources/Info-gnustep.plist:
	@(echo "{"; echo '  NOTE = "Automatically generated, do not edit!";'; \
	  echo "  NSExecutable = \"$(GNUSTEP_INSTANCE)${BUNDLE_OBJ_EXT}\";"; \
	  echo "  NSMainNibFile = \"$(MAIN_MODEL_FILE)\";"; \
	  echo "  NSPrincipalClass = \"$(PRINCIPAL_CLASS)\";"; \
	  echo "}") >$@
	@if [ -r "$(GNUSTEP_INSTANCE)Info.plist" ]; then \
	  plmerge $@ $(GNUSTEP_INSTANCE)Info.plist; \
	fi

# Comment on the tar options used in the rule below - 

# The h option to tar makes sure the bundle can contain symbolic links
# to external files (for example templates), and when you install the
# bundle, the symbolic links are replaced with the actual files.  The
# X option is used because otherwise the -h option would dereference
# the Contents/Resources-->Resources symbolic link, and install the
# Resources directory twice.  Instead, we exclude the symbolic link
# from the tar file, then rebuild the link by hand in the installation
# directory.

# Because of compatibility issues with older versions of GNU tar (not
# to speak of non-GNU tars), we use the X option rather than the
# --exclude= option.  The X option requires as argument a file listing
# files to exclude.  We create a temporary file for this, then remove
# it immediately afterwards.

# When rebuilding the link, just as yet another compatibility safety
# measure, we need to make sure that we can manage the case that tar
# was actually broken and didn't honour the X option (and/or the h
# option).  To manage this, we simply do not build the link if
# Resources already exists and is a directory (either a real one or a
# symbolic link, we don't care).

internal-bundle-install_:: $(BUNDLE_INSTALL_DIR) shared-instance-headers-install
	rm -f .tmp.gnustep.exclude; \
	echo "$(BUNDLE_DIR_NAME)/Contents/Resources" > .tmp.gnustep.exclude;\
	rm -rf $(BUNDLE_INSTALL_DIR)/$(BUNDLE_DIR_NAME); \
	$(TAR) chfX - .tmp.gnustep.exclude $(BUNDLE_DIR_NAME) \
	    | (cd $(BUNDLE_INSTALL_DIR); $(TAR) xf -); \
	rm -f .tmp.gnustep.exclude; \
	(cd $(BUNDLE_INSTALL_DIR)/$(BUNDLE_DIR_NAME)/Contents; \
	    if [ ! -d Resources ]; then \
	      rm -f Resources; $(LN_S) ../Resources .; \
	    fi;)
ifneq ($(CHOWN_TO),)
	$(CHOWN) -R $(CHOWN_TO) $(BUNDLE_INSTALL_DIR)/$(BUNDLE_DIR_NAME)
endif
ifeq ($(strip),yes)
	$(STRIP) $(BUNDLE_INSTALL_DIR)/$(BUNDLE_FILE)
endif

$(BUNDLE_INSTALL_DIR):
	$(MKINSTALLDIRS) $@

internal-bundle-uninstall_:: shared-instance-headers-uninstall
	rm -rf $(BUNDLE_INSTALL_DIR)/$(BUNDLE_DIR_NAME)


## Local variables:
## mode: makefile
## End: