xref: /freebsd/sys/contrib/openzfs/config/rpm.am (revision 6580f5c38dd5b01aeeaed16b370f1a12423437f0)
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 "_builddir $$rpmbuild/BUILD" \
87		--define "_rpmdir $$rpmbuild/RPMS" \
88		--define "_srcrpmdir $$rpmbuild/SRPMS" \
89		--define "_specdir $$rpmbuild/SPECS" \
90		--define "_sourcedir $$rpmbuild/SOURCES" \
91		--define "_topdir $$rpmbuild" \
92		$(def) -bs $$rpmbuild/SPECS/$$rpmspec || exit 1; \
93	cp $$rpmbuild/SRPMS/$$rpmpkg . || exit 1; \
94	rm -R $$rpmbuild)
95
96rpm-common:
97	@(dist=`$(RPM) --eval %{?dist}`; \
98	rpmpkg=$(pkg)-$(VERSION)-$(RELEASE)$$dist*src.rpm; \
99	rpmspec=$(pkg).spec; \
100	rpmbuild=`mktemp -t -d $(PACKAGE)-build-$$USER-XXXXXXXX`; \
101	$(MAKE) $(AM_MAKEFLAGS) \
102		rpmbuild="$$rpmbuild" \
103		rpmspec="$$rpmspec" \
104		rpm-local || exit 1; \
105	LANG=C ${RPMBUILD} \
106		--define "_tmppath $$rpmbuild/TMP" \
107		--define "_builddir $$rpmbuild/BUILD" \
108		--define "_rpmdir $$rpmbuild/RPMS" \
109		--define "_srcrpmdir $$rpmbuild/SRPMS" \
110		--define "_specdir $$rpmbuild/SPECS" \
111		--define "_sourcedir $$rpmbuild/SOURCES" \
112		--define "_topdir $$rpmbuild" \
113		$(def) --rebuild $$rpmpkg || exit 1; \
114	cp $$rpmbuild/RPMS/*/* . || exit 1; \
115	rm -R $$rpmbuild)
116