xref: /freebsd/sys/contrib/openzfs/config/rpm.am (revision d9a42747950146bf03cda7f6e25d219253f8a57a)
1###############################################################################
2# Copyright (C) 2007-2013 Lawrence Livermore National Security, LLC.
3# Copyright (C) 2007 The Regents of the University of California.
4# Written by Brian Behlendorf <behlendorf1@llnl.gov>.
5###############################################################################
6# Build targets for RPM packages.
7###############################################################################
8
9PHONY += srpm srpms srpm-kmod srpm-dkms srpm-utils
10PHONY += rpm rpms rpm-kmod rpm-dkms rpm-utils rpm-utils-initramfs
11PHONY += srpm-common rpm-common rpm-local
12
13srpm-kmod srpm-dkms srpm-utils: dist
14
15srpm-kmod:
16	$(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}-kmod" \
17		def='${SRPM_DEFINE_COMMON} ${SRPM_DEFINE_KMOD}' srpm-common
18
19srpm-dkms:
20	$(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}-dkms" \
21		def='${SRPM_DEFINE_COMMON} ${SRPM_DEFINE_DKMS}' srpm-common
22
23srpm-utils:
24	$(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}" \
25		def='${SRPM_DEFINE_COMMON} ${SRPM_DEFINE_UTIL}' srpm-common
26
27srpm: srpm-kmod srpm-dkms srpm-utils
28srpms: srpm-kmod srpm-dkms srpm-utils
29
30rpm-kmod: srpm-kmod
31	$(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}-kmod" \
32		def='${RPM_DEFINE_COMMON} ${RPM_DEFINE_KMOD}' rpm-common
33
34rpm-dkms: srpm-dkms
35	$(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}-dkms" \
36		def='${RPM_DEFINE_COMMON} ${RPM_DEFINE_DKMS}' rpm-common
37
38# The rpm-utils and rpm-utils-initramfs targets are identical except for the
39# zfs-initramfs package: rpm-utils never includes it, rpm-utils-initramfs
40# includes it if detected at configure time. The zfs-initramfs package does
41# not work on any known RPM-based distribution and the resulting RPM is only
42# used to create a Debian package. The rpm-utils-initramfs target is not
43# intended to be specified by the user directly, it is provided as a
44# dependency of the deb-utils target.
45
46rpm-utils: srpm-utils
47	$(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}" \
48		def='${RPM_DEFINE_COMMON} ${RPM_DEFINE_UTIL}' rpm-common
49
50rpm-utils-initramfs: srpm-utils
51	$(MAKE) $(AM_MAKEFLAGS) pkg="${PACKAGE}" \
52		def='${RPM_DEFINE_COMMON} ${RPM_DEFINE_UTIL} ${RPM_DEFINE_INITRAMFS}' rpm-common
53
54rpm: rpm-kmod rpm-dkms rpm-utils
55rpms: rpm-kmod rpm-dkms rpm-utils
56
57rpm-local:
58	@(if test "${HAVE_RPMBUILD}" = "no"; then \
59		echo -e "\n" \
60	"*** Required util ${RPMBUILD} missing.  Please install the\n" \
61	"*** package for your distribution which provides ${RPMBUILD},\n" \
62	"*** re-run configure, and try again.\n"; \
63		exit 1; \
64	fi; \
65	mkdir -p $(rpmbuild)/TMP && \
66	mkdir -p $(rpmbuild)/BUILD && \
67	mkdir -p $(rpmbuild)/RPMS && \
68	mkdir -p $(rpmbuild)/SRPMS && \
69	mkdir -p $(rpmbuild)/SPECS && \
70	cp ${RPM_SPEC_DIR}/$(rpmspec) $(rpmbuild)/SPECS && \
71	mkdir -p $(rpmbuild)/SOURCES && \
72	cp $(top_srcdir)/scripts/kmodtool $(rpmbuild)/SOURCES && \
73	cp $(distdir).tar.gz $(rpmbuild)/SOURCES)
74
75srpm-common:
76	@(dist=`$(RPM) --eval %{?dist}`; \
77	rpmpkg=$(pkg)-$(VERSION)-$(RELEASE)$$dist*src.rpm; \
78	rpmspec=$(pkg).spec; \
79	rpmbuild=`mktemp -t -d $(PACKAGE)-build-$$USER-XXXXXXXX`; \
80	$(MAKE) $(AM_MAKEFLAGS) \
81		rpmbuild="$$rpmbuild" \
82		rpmspec="$$rpmspec" \
83		rpm-local || exit 1; \
84	LANG=C $(RPMBUILD) \
85		--define "_tmppath $$rpmbuild/TMP" \
86		--define "_topdir $$rpmbuild" \
87		$(def) -bs $$rpmbuild/SPECS/$$rpmspec || exit 1; \
88	cp $$rpmbuild/SRPMS/$$rpmpkg . || exit 1; \
89	rm -R $$rpmbuild)
90
91rpm-common:
92	@(dist=`$(RPM) --eval %{?dist}`; \
93	rpmpkg=$(pkg)-$(VERSION)-$(RELEASE)$$dist*src.rpm; \
94	rpmspec=$(pkg).spec; \
95	rpmbuild=`mktemp -t -d $(PACKAGE)-build-$$USER-XXXXXXXX`; \
96	$(MAKE) $(AM_MAKEFLAGS) \
97		rpmbuild="$$rpmbuild" \
98		rpmspec="$$rpmspec" \
99		rpm-local || exit 1; \
100	LANG=C ${RPMBUILD} \
101		--define "_tmppath $$rpmbuild/TMP" \
102		--define "_topdir $$rpmbuild" \
103		$(def) --rebuild $$rpmpkg || exit 1; \
104	cp $$rpmbuild/RPMS/*/* . || exit 1; \
105	rm -R $$rpmbuild)
106