blob: c162409fb4e4cc57b29b84e58e76ab682a84db94 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001# Makefile for the different targets used to generate full packages of a kernel
2# It uses the generic clean infrastructure of kbuild
3
4# Ignore the following files/directories during tar operation
5TAR_IGNORE := --exclude SCCS --exclude BitKeeper --exclude .svn --exclude CVS
6
7
8# RPM target
9# ---------------------------------------------------------------------------
10# The rpm target generates two rpm files:
11# /usr/src/packages/SRPMS/kernel-2.6.7rc2-1.src.rpm
12# /usr/src/packages/RPMS/i386/kernel-2.6.7rc2-1.<arch>.rpm
13# The src.rpm files includes all source for the kernel being built
14# The <arch>.rpm includes kernel configuration, modules etc.
15#
16# Process to create the rpm files
17# a) clean the kernel
18# b) Generate .spec file
19# c) Build a tar ball, using symlink to make kernel version
20# first entry in the path
21# d) and pack the result to a tar.gz file
22# e) generate the rpm files, based on kernel.spec
23# - Use /. to avoid tar packing just the symlink
24
25# Do we have rpmbuild, otherwise fall back to the older rpm
26RPM := $(shell if [ -x "/usr/bin/rpmbuild" ]; then echo rpmbuild; \
27 else echo rpm; fi)
28
29# Remove hyphens since they have special meaning in RPM filenames
30KERNELPATH := kernel-$(subst -,,$(KERNELRELEASE))
31MKSPEC := $(srctree)/scripts/package/mkspec
32PREV := set -e; cd ..;
33
34# rpm-pkg
Sam Ravnborg01317052006-03-08 18:39:05 +010035# ---------------------------------------------------------------------------
Linus Torvalds1da177e2005-04-16 15:20:36 -070036$(objtree)/kernel.spec: $(MKSPEC) $(srctree)/Makefile
37 $(CONFIG_SHELL) $(MKSPEC) > $@
38
Sam Ravnborg01317052006-03-08 18:39:05 +010039rpm-pkg rpm: $(objtree)/kernel.spec FORCE
Linus Torvalds1da177e2005-04-16 15:20:36 -070040 $(MAKE) clean
41 $(PREV) ln -sf $(srctree) $(KERNELPATH)
42 $(PREV) tar -cz $(RCS_TAR_IGNORE) -f $(KERNELPATH).tar.gz $(KERNELPATH)/.
43 $(PREV) rm $(KERNELPATH)
44
45 set -e; \
46 $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version
47 set -e; \
48 mv -f $(objtree)/.tmp_version $(objtree)/.version
49
Jeremy Kerrc39dd502008-12-01 14:21:03 -080050 $(RPM) $(RPMOPTS) --target $(UTS_MACHINE) -ta ../$(KERNELPATH).tar.gz
Linus Torvalds1da177e2005-04-16 15:20:36 -070051 rm ../$(KERNELPATH).tar.gz
52
53clean-files := $(objtree)/kernel.spec
54
55# binrpm-pkg
Sam Ravnborg01317052006-03-08 18:39:05 +010056# ---------------------------------------------------------------------------
Linus Torvalds1da177e2005-04-16 15:20:36 -070057$(objtree)/binkernel.spec: $(MKSPEC) $(srctree)/Makefile
58 $(CONFIG_SHELL) $(MKSPEC) prebuilt > $@
Paul Smith4f193362006-03-05 17:14:10 -050059
Sam Ravnborg01317052006-03-08 18:39:05 +010060binrpm-pkg: $(objtree)/binkernel.spec FORCE
Sam Ravnborga91f98a2005-07-14 20:26:09 +000061 $(MAKE) KBUILD_SRC=
Linus Torvalds1da177e2005-04-16 15:20:36 -070062 set -e; \
63 $(CONFIG_SHELL) $(srctree)/scripts/mkversion > $(objtree)/.tmp_version
64 set -e; \
65 mv -f $(objtree)/.tmp_version $(objtree)/.version
66
Jeremy Kerrc39dd502008-12-01 14:21:03 -080067 $(RPM) $(RPMOPTS) --define "_builddir $(srctree)" --target \
68 $(UTS_MACHINE) -bb $<
Linus Torvalds1da177e2005-04-16 15:20:36 -070069
70clean-files += $(objtree)/binkernel.spec
71
72# Deb target
73# ---------------------------------------------------------------------------
Sam Ravnborg01317052006-03-08 18:39:05 +010074deb-pkg: FORCE
Sam Ravnborga91f98a2005-07-14 20:26:09 +000075 $(MAKE) KBUILD_SRC=
Linus Torvalds1da177e2005-04-16 15:20:36 -070076 $(CONFIG_SHELL) $(srctree)/scripts/package/builddeb
77
78clean-dirs += $(objtree)/debian/
79
80
Jan-Benedict Glaw6d983fe2005-05-24 11:27:37 +020081# tarball targets
82# ---------------------------------------------------------------------------
Sam Ravnborg01317052006-03-08 18:39:05 +010083tar%pkg: FORCE
Jan-Benedict Glaw6073aa62006-01-01 14:23:47 +010084 $(MAKE) KBUILD_SRC=
Jan-Benedict Glaw6d983fe2005-05-24 11:27:37 +020085 $(CONFIG_SHELL) $(srctree)/scripts/package/buildtar $@
86
87clean-dirs += $(objtree)/tar-install/
88
89
Linus Torvalds1da177e2005-04-16 15:20:36 -070090# Help text displayed when executing 'make help'
91# ---------------------------------------------------------------------------
Sam Ravnborg01317052006-03-08 18:39:05 +010092help: FORCE
Robert P. J. Day899c3842007-11-29 10:46:38 -050093 @echo ' rpm-pkg - Build both source and binary RPM kernel packages'
94 @echo ' binrpm-pkg - Build only the binary kernel package'
Jan-Benedict Glaw6d983fe2005-05-24 11:27:37 +020095 @echo ' deb-pkg - Build the kernel as an deb package'
96 @echo ' tar-pkg - Build the kernel as an uncompressed tarball'
97 @echo ' targz-pkg - Build the kernel as a gzip compressed tarball'
98 @echo ' tarbz2-pkg - Build the kernel as a bzip2 compressed tarball'
Linus Torvalds1da177e2005-04-16 15:20:36 -070099