4 # Makefile rules to build a RPM spec files and RPM packages
6 # Copyright (C) 2001 Free Software Foundation, Inc.
8 # Author: Nicola Pero <n.pero@mi.flashnet.it>
10 # This file is part of the GNUstep Makefile Package.
12 # This library is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License
14 # as published by the Free Software Foundation; either version 2
15 # of the License, or (at your option) any later version.
17 # You should have received a copy of the GNU General Public
18 # License along with this library; see the file COPYING.LIB.
19 # If not, write to the Free Software Foundation,
20 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
23 # FIXME: Move all this documentation into the documentation
27 # FIXME/TODO: Update for GNUSTEP_BUILD_DIR
30 # rpm puts all tools, bundles, applications, subprojects, libraries,
31 # etc specified in the GNUmakefile into a single rpm. There aren't any
32 # provisions for putting separate apps/tools/etc in separate rpms
33 # (other than putting them in separate dirs).
35 # Note: we don't make development packages separated from the standard
36 # ones. Every package containing a library's object files will also
37 # contain the header files for the library <only the ones which were
38 # declared in the makefile of course>.
41 # You can build two kind of packages:
43 # - debugging packages
45 # First we describe normal packages.
47 # the make package generates automatically:
48 # * the .tgz source file to be copied into where_you_build_rpms/SOURCES/
49 # <generated by source-dist.make>
51 # * the spec file to be copied into where_you_build_rpms/SPECS/
52 # <generate by rpm.make>
54 # at this point, to build the rpm you just do
55 # cd where_you_build_rpms/SPECS/
56 # rpm -ba my_package.spec
58 # If you are *very* lazy, typing `make rpm' will do it all automatically
59 # for you. But in that case, you need to have set the shell environment
60 # variable `RPM_TOPDIR' to the top dir of where you build rpms (eg,
64 # To build the spec file for a package, you need to do two things:
66 # [1] Add - after common.make - the following lines in your GNUmakefile:
68 # PACKAGE_NAME = Gomoku
69 # PACKAGE_VERSION = 1.1.1
71 # (replace them with name, version of your software). This is mainly
72 # needed so that when you build the .tgz and the spec file, they have
73 # names which are in sync. Make sure to keep the library version and
74 # the package version in sync.
76 # The other important variable you may want to set in your makefiles is
78 # GNUSTEP_INSTALLATION_DIR - Installation dir (defaults to GNUSTEP_LOCAL_ROOT)
80 # If your package is relocatable (this is true by default - see below
81 # for how to make it non-relocatable) the user will be able to install
82 # the package elsewhere by using something like `rpm -Uvh --prefix
83 # /home/nicola/GNUstep your_package.rpm' when installing the package.
86 # [2] Provide a $(PACKAGE_NAME).spec.in file, which contains the RPM
87 # spec preamble. Here is an example:
89 # Summary: A table board game
92 # Group: Amusements/Games
93 # Source: http://www.gnustep.it/nicola/Applications/Gomoku/%{gs_name}-%{gs_version}.tar.gz
96 # Gomoku is an extended TicTacToe game for GNUstep. You win the game if
97 # you are able to put 5 of your pieces in a row, column or diagonal. You
98 # loose if the computer does it before you. You can play the game on
99 # boards of different size; the default size is 8 but 10 is also nice to
100 # play. The game has 6 different difficulty levels.
103 # you must not include: `Name', `Version', `BuildRoot' and `Prefix'
104 # entries. These are generated automatically; `Name' and `Version'
105 # from $(PACKAGE_NAME) and $(PACKAGE_VERSION), and so for BuildRoot
106 # and Prefix. you might include all the other tags listed in the RPM
107 # doc if you want. The `Prefix:' entry is automatically included only
108 # if your package is relocatable (should be the default for all
109 # non-system packages. If you want your package to be non-relocatable
110 # (to be used only for system packages which *must* be installed in
111 # GNUSTEP_SYSTEM_ROOT), add the line
113 # RPM_DISABLE_RELOCATABLE=YES
115 # (FIXME improve variable name) to your GNUmakefile. This will not generate
116 # a `Prefix:' line in the spec file.
119 # You can use the following if you need:
120 # %{gs_name} expands to the value of the make variable PACKAGE_NAME
121 # %{gs_version} expands to the value of the make variable PACKAGE_VERSION
122 # (make sure you use them in `Source:' as shown).
126 # A special note: if you need `./configure --prefix=/usr/GNUstep'
127 # (/usr/GNUstep being replaced by your GNUSTEP_SYSTEM_ROOT) to be run
128 # before compilation (usually only needed for GNUstep core libraries
129 # themselves), define the following make variable:
131 # PACKAGE_NEEDS_CONFIGURE = YES
136 # At this point, typing
137 # `make dist' will generate the .tgz (can be used outside rpm.make)
138 # `make specfile' will generate the (matching) specfile.
142 # Debugging packages.
146 # A debugging package is called
147 # $(PACKAGE_NAME)-debug-$(PACKAGE_VERSION) rather than
148 # $(PACKAGE_NAME)-$(PACKAGE_VERSION). The source .tgz have the same
149 # name though. The source rpm package instead has a different name
150 # because it contains the .spec file, which is different between debug
151 # and non debug version.
153 # To build the spec for the debugging package, type `make debug=yes specfile'.
154 # This builds a specfile as for the non-debugging package, except:
156 # It uses $(PACKAGE_NAME)-debug.spec.in rather than
157 # ${PACKAGE_NAME).spec.in if found. (this allows you to customize
158 # package description, summary, release number, group for the
161 # It will compile everything with debugging enabled when building the
164 # It will manage the package having a different name (eg
165 # Gomoku-debug-1.1.1) than the .tgz (eg Gomoku-1.1.1.tgz).
167 # Unless `standalone=yes' (ie, unless you create the specfile using
168 # `make debug=yes standalone=yes specfile') it will perform the following
171 # * build and install the non-debugging software before the debugging one;
172 # * remove from the debugging package all files already included in the
173 # non-debugging one (this is why it needs to build the non-debugging
175 # * add a dependency of the debugging package from the non-debugging one.
177 # <FIXME: Add comments about when is appropriate one and when the other one>
180 # As said before, if you are very lazy, typing something like
183 # `RPM_TOPDIR=/usr/src/redhat' make rpm
185 # will do the whole job once you have written your '.spec.in' file,
186 # and set the PACKAGE_NAME and PACKAGE_VERSION variables in the makefile.
187 # The generated rpm will be in /usr/src/redhat/RPMS/.
194 # If we have been called with something like
196 # make INSTALL_ROOT_DIR=/var/tmp/package-build/ \
197 # GNUSTEP_INSTALLATION_DIR=/var/tmp/package-build/usr/GNUstep/Local \
198 # filelist=yes install
200 # we are being called inside the rpm installation stage, and we need
201 # to produce the file list from the installed files.
203 ifeq ($(filelist),yes)
205 # Build the file-list only at top level
206 # ifeq ($(MAKELEVEL),0)
208 # Determine which file list to build
210 FILE_LIST = $(shell pwd)/file-list-debug
212 FILE_LIST = $(shell pwd)/file-list
215 # Remove the old file list before installing, and initialize the new one.
218 echo "%attr (-, root, root)" >> $(FILE_LIST)
220 # install - done by other GNUmakefiles - NB: must install everything inside
221 # GNUSTEP_INSTALLATION_DIR, or prefix all installation dirs with
222 # $INSTALL_ROOT_DIR such as
223 # $(INSTALL_DATA) page.html $(INSTALL_ROOT_DIR)/usr/local/MySoftware/
224 # instead of $(INSTALL_DATA) page.html /usr/local/MySoftware/
226 # Get the list of files inside GNUSTEP_INSTALL_BASE
227 internal-after-install::
228 for file in `$(TAR) Pcf - $(INSTALL_ROOT_DIR) | $(TAR) t`; do \
229 if [ -d "$$file" ]; then \
230 echo "%dir $$file" > /dev/null; \
232 echo "$$file" >> $(FILE_LIST); \
235 sed -e "s|$(INSTALL_ROOT_DIR)||" $(FILE_LIST) > file-list.tmp
236 mv file-list.tmp $(FILE_LIST)
240 endif # filelist == yes
244 # Manage debug vs non-debug
246 ifneq ($(debug), yes)
247 SPEC_FILE=$(PACKAGE_NAME).spec
248 SPEC_RULES_TEMPLATE=$(GNUSTEP_MAKEFILES)/spec-rules.template
249 SPEC_IN=$(PACKAGE_NAME).spec.in
250 SPEC_SCRIPT_IN=$(PACKAGE_NAME).script.spec.in
253 SPEC_FILE=$(PACKAGE_NAME)-debug.spec
254 ifeq ($(standalone),yes)
255 SPEC_RULES_TEMPLATE=$(GNUSTEP_MAKEFILES)/spec-debug-alone-rules.template
257 SPEC_RULES_TEMPLATE=$(GNUSTEP_MAKEFILES)/spec-debug-rules.template
259 SPEC_IN=$(PACKAGE_NAME)-debug.spec.in
260 SPEC_SCRIPT_IN=$(PACKAGE_NAME)-debug.script.spec.in
261 PACKAGE_EXTENSION="-debug"
264 .PHONY: specfile rpm check-RPM_TOPDIR
267 # The user will type `make specfile' to generate the specfile
269 specfile: $(SPEC_FILE)
272 # Issue a warning if the $(PACKAGE_NAME)-debug.spec.in file is not found
274 $(PACKAGE_NAME)-debug.spec.in:
275 @echo "WARNING - $(PACKAGE_NAME)-debug.spec.in not found!"
276 @echo "You need to create it to build the debugging package."
277 @echo "If you already have a $(PACKAGE_NAME).spec.in, just take it as"
278 @echo "a start for the $(PACKAGE_NAME)-debug.spec.in - and make"
279 @echo "the little necessary changes in summary and description."
283 # This is the real target - depends on having a correct .spec.in file
285 $(SPEC_FILE): $(SPEC_IN)
286 @echo "Generating the spec file..."
289 @echo "## Generated automatically by GNUstep make - do not edit!" >> $@
290 @echo "## Edit the $(SPEC_IN) file instead" >> $@
293 @echo "## Code dynamically generated" >> $@
294 @echo "%define gs_root $(GNUSTEP_SYSTEM_ROOT)" >> $@
295 @echo "%define gs_install_dir $(GNUSTEP_INSTALLATION_DIR)" >> $@
296 @echo "%define gs_name $(PACKAGE_NAME)" >> $@
297 @echo "%define gs_version $(PACKAGE_VERSION)" >> $@
298 ifeq ($(PACKAGE_NEEDS_CONFIGURE),YES)
299 @echo "%define gs_configure YES" >> $@
301 @echo "%define gs_configure NO" >> $@
304 @echo "Name: %{gs_name}$(PACKAGE_EXTENSION)" >> $@
305 @echo "Version: %{gs_version}" >> $@
306 @echo "BuildRoot: /var/tmp/%{gs_name}-buildroot" >> $@
307 ifeq ($(RPM_DISABLE_RELOCATABLE),YES)
308 @echo "Prefix: %{gs_install_dir}" >> $@
311 ifneq ($(standalone),yes)
312 @echo "requires: %{gs_name} = %{gs_version}" >> $@
316 @echo "## Code from $(SPEC_IN)" >> $@
317 @cat $(SPEC_IN) >> $@
319 @echo "## Fixed rules from $(SPEC_RULES_TEMPLATE)" >> $@
320 @cat $(SPEC_RULES_TEMPLATE) >> $@
321 @ if [ -f $(SPEC_SCRIPT_IN) ]; then \
323 echo "## Script rules from $(SPEC_SCRIPT_IN)" >> $@; \
324 cat $(SPEC_SCRIPT_IN) >> $@; \
328 @if [ "$(RPM_TOPDIR)" = "" ]; then \
329 echo "I can't build the RPM if you do not set your RPM_TOPDIR"; \
330 echo "shell variable"; \
334 # In old RPM versions, building was done using 'rpm -ba'; in newer RPM
335 # versions, it can only be done using 'rpmbuild -ba'. Try to support
336 # the old RPM versions by using 'rpm' instead of 'rpmbuild', if
337 # 'rpmbuild' is not available. This hack can presumably be removed
338 # when all RPM versions on earth will have been updated to the new
339 # setup (it might take a while).
341 rpm: check-RPM_TOPDIR dist specfile
342 @echo "Generating the rpm...";
343 ifneq ($(RELEASE_DIR),)
344 @cp $(RELEASE_DIR)/$(PACKAGE_NAME)-$(PACKAGE_VERSION).tar.gz \
345 $(RPM_TOPDIR)/SOURCES/;
347 @cp ../$(PACKAGE_NAME)-$(PACKAGE_VERSION).tar.gz $(RPM_TOPDIR)/SOURCES/;
349 @cp $(SPEC_FILE) $(RPM_TOPDIR)/SPECS/; \
350 cd $(RPM_TOPDIR)/SPECS/; \
351 if which rpmbuild > /dev/null 2>/dev/null; then \
352 rpmbuild="rpmbuild"; \
354 if which rpm > /dev/null 2>/dev/null; then \
357 echo "Error: You don't have rpm installed!"; \
358 rpmbuild="rpmbuild"; \
361 $${rpmbuild} -ba $(SPEC_FILE)
363 ifneq ($(PACKAGE_NAME),)
365 rm -rf $(PACKAGE_NAME).spec $(PACKAGE_NAME)-debug.spec