#!/usr/bin/make -f # # Based on the work by Marcus Brinkmann # Rewritten by Guillem Jover # include /usr/share/dpkg/pkg-info.mk NOEPOCH_VERSION := $(shell echo $(DEB_VERSION) | sed -e 's/.*://g') TAR_VERSION := $(shell echo $(NOEPOCH_VERSION) | sed -e 's/-.*//g') UPSTREAM_VERSION := $(shell echo $(TAR_VERSION) | sed -e 's/\.dfsg.*//g') NOGIT_VERSION := $(shell echo $(UPSTREAM_VERSION) | sed -e 's/+git[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]//g') MAJOR := $(shell echo $(VERSION) | sed -e 's/\..*//g') include /usr/share/dpkg/architecture.mk ifeq (,$(filter custom,$(DEB_BUILD_OPTIONS))) CUSTOM := VERSION := $(NOGIT_VERSION) else CUSTOM := .custom.$(shell date +'%Y%m%d') VERSION := $(NOEPOCH_VERSION)$(CUSTOM) endif ifeq ($(DEB_HOST_ARCH_CPU),amd64) MACHINE := amd64 else MACHINE := 486 endif NCPUS := 8 pkg := gnumach-image-$(VERSION)-$(MACHINE)-up pkg_dbg := gnumach-image-$(VERSION)-$(MACHINE)-up-dbg pkg_udeb := kernel-image-$(VERSION)-$(MACHINE)-di pkg_xen := gnumach-image-$(VERSION)-xen-$(MACHINE) pkg_xen_dbg := gnumach-image-$(VERSION)-xen-$(MACHINE)-dbg pkg_xen_udeb := kernel-image-$(VERSION)-xen-$(MACHINE)-di pkg_pae := gnumach-image-$(VERSION)-$(MACHINE)-pae pkg_pae_dbg := gnumach-image-$(VERSION)-$(MACHINE)-pae-dbg pkg_smp := gnumach-image-$(VERSION)-$(MACHINE)-smp pkg_smp_dbg := gnumach-image-$(VERSION)-$(MACHINE)-smp-dbg pkg_common := gnumach-common pkg_dev := gnumach-dev ifeq ($(DEB_HOST_ARCH_CPU),i386) nopkg_pae := -N$(pkg_pae) nopkg_pae_dbg := -N$(pkg_pae_dbg) nopkg_smp := -N$(pkg_smp) nopkg_smp_dbg := -N$(pkg_smp_dbg) endif D := $(CURDIR)/debian/tmp D_DBG := $(D)-dbg D_UDEB := $(D)-udeb D_XEN := $(D)-xen D_XEN_DBG := $(D)-xen-dbg D_XEN_UDEB := $(D)-xen-udeb D_PAE := $(D)-pae D_PAE_DBG := $(D)-pae-dbg D_SMP := $(D)-smp D_SMP_DBG := $(D)-smp-dbg export PARALLEL_HOME := $(CURDIR)/.parallel CCASFLAGS = -fdebug-prefix-map=$(CURDIR)=. CFLAGS = -ffile-prefix-map=$(CURDIR)=. -Wall -g -pipe -fno-strict-aliasing -no-pie -fno-PIE -fno-pie -Wformat -Werror=format-security LDFLAGS = -no-pie ifneq (,$(filter noopt,$(DEB_BUILD_OPTIONS))) CFLAGS += -O0 else CFLAGS += -O2 endif ifneq (,$(filter parallel=%,$(DEB_BUILD_OPTIONS))) DEB_PARALLEL_JOBS ?= $(patsubst parallel=%,%,$(filter parallel=%,$(DEB_BUILD_OPTIONS))) endif ifneq (,$(DEB_PARALLEL_JOBS)) MAKEFLAGS += -j$(DEB_PARALLEL_JOBS) endif common_configure := \ --build=$(DEB_BUILD_GNU_TYPE) \ --host=$(DEB_HOST_GNU_CPU)-gnu \ --prefix=/usr \ --exec-prefix=/ \ --includedir=/usr/include/$(DEB_HOST_MULTIARCH) \ --disable-net-group \ --disable-pcmcia-group \ --disable-wireless-group ifeq ($(DEB_HOST_ARCH),hurd-amd64) common_configure += \ --disable-user32 endif debian/control: debian/control.stamp debian/control.stamp: debian/control.in ifneq (,$(filter custom,$(DEB_BUILD_OPTIONS))) @echo Building a custom kernel: "$(VERSION)" else @echo Building a stock kernel: "$(VERSION)" endif sed -e 's/@version@/$(VERSION)/g' < $< > debian/control touch $@ configure: configure.ac autoreconf -fi define doconfigure build$(1)/config.status: configure dh_testdir -mkdir build$(1) cd build$(1) && PACKAGE_VERSION_SUFFIX=$(CUSTOM)$(1)-$(MACHINE) ../configure \ CCASFLAGS="$(CCASFLAGS)" \ CFLAGS="$(CFLAGS)" \ LDFLAGS="$(LDFLAGS)" \ $(common_configure) \ $(2) build$(1)-dbg/config.status: configure dh_testdir -mkdir build$(1)-dbg cd build$(1)-dbg && PACKAGE_VERSION_SUFFIX=$(CUSTOM)$(1)-$(MACHINE)-dbg ../configure --enable-kdb \ CCASFLAGS="$(CCASFLAGS)" \ CFLAGS="$(CFLAGS)" \ LDFLAGS="$(LDFLAGS)" \ $(common_configure) \ $(2) endef $(eval $(call doconfigure,,)) $(eval $(call doconfigure,-xen,--enable-platform=xen)) $(eval $(call doconfigure,-pae,--enable-pae)) $(eval $(call doconfigure,-smp,--enable-apic --enable-ncpus=$(NCPUS))) define _dobuild build-arch: build$(1)$(2)/stamp build$(1)$(2)/stamp: build$(1)$(2)/config.status doc/mach.info dh_testdir $(MAKE) -C build$(1)$(2) ifeq ($(DEB_HOST_ARCH_OS),linux) ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS))) parallel --fg --tmux --semaphore --semaphorename gnumach-build $(MAKE) -C build$(1)$(2) check ; \ RET=$$$$? ; cat build$(1)$(2)/tests/test-*.log build$(1)$(2)/test-suite.log ; exit $$$$RET endif endif touch $$@ endef define dobuild $(eval $(call _dobuild,$1,)) ifeq ($(filter pkg.gnumach.nodbg,$(DEB_BUILD_PROFILES)),) $(eval $(call _dobuild,$1,-dbg)) endif endef ifeq ($(filter stage1,$(DEB_BUILD_PROFILES)),) $(eval $(call dobuild,)) ifeq ($(filter pkg.gnumach.onlyup,$(DEB_BUILD_PROFILES)),) ifeq ($(filter pkg.gnumach.noxen,$(DEB_BUILD_PROFILES)),) $(eval $(call dobuild,-xen)) endif ifeq ($(DEB_HOST_ARCH_CPU),i386) ifeq ($(filter pkg.gnumach.nopae,$(DEB_BUILD_PROFILES)),) $(eval $(call dobuild,-pae)) endif ifeq ($(filter pkg.gnumach.nosmp,$(DEB_BUILD_PROFILES)),) $(eval $(call dobuild,-smp)) endif endif endif else build-arch: build/config.status endif build-indep: build-arch build: build-arch build-indep doc/mach.info: build/config.status dh_testdir $(MAKE) -C build ../doc/mach.info clean: dh_testdir rm -f debian/control.stamp rm -f machine rm -rf build build-xen build-pae build-smp build-dbg build-xen-dbg build-pae-dbg build-smp-dbg $(D_UDEB) $(D_XEN_UDEB) $(D_XEN) $(D_PAE) $(D_SMP) $(D_DBG) $(D_XEN_DBG) $(D_PAE_DBG) $(D_SMP_DBG) # Clean up autogenerated cruft rm -rf autom4te.cache build-aux rm -f aclocal.m4 config.h.in configure INSTALL Makefile.in rm -f doc/mach.info* doc/stamp-vti doc/version.texi find -name '*~' -o -name '*.rej' -o -name '*.orig' | xargs rm -f rm -f debian/gnumach-image-*.preinst rm -f debian/gnumach-image-*.prerm rm -f debian/gnumach-image-*.postinst rm -f debian/gnumach-image-*.postrm rm -rf $(PARALLEL_HOME) dh_clean ifeq ($(filter stage1,$(DEB_BUILD_PROFILES)),) define _doinstall $(MAKE) -C build$(1) install DESTDIR=$(2) endef define doinstall $(call _doinstall,$(1),$(3)) mv $(3)/boot/gnumach $(3)/boot/gnumach-$(VERSION)$(1)-$(MACHINE)$(2) endef ifeq ($(filter pkg.gnumach.nodbg,$(DEB_BUILD_PROFILES)),) define _doinstall_dbg $(call _doinstall,$(1)-dbg,$(3)) mv $(3)/boot/gnumach $(3)/boot/gnumach-$(VERSION)$(1)-$(MACHINE)$(2)-dbg endef else define _doinstall_dbg endef endif define doinstall_dbg $(call doinstall,$(1),$(2),$(3)) $(call _doinstall_dbg,$(1),$(2),$(4)) endef define doinstall_dbg_udeb $(call doinstall_dbg,$(1),$(2),$(3),$(4)) mkdir -p $(5)/boot cp $(3)/boot/gnumach-$(VERSION)$(1)-$(MACHINE)$(2) $(5)/boot/gnumach endef install: build dh_testdir dh_testroot dh_prep -a -rm -rf $(D_DBG) dh_installdirs -a $(call doinstall_dbg_udeb,,-up,$(D),$(D_DBG),$(D_UDEB)) ifeq ($(filter pkg.gnumach.onlyup,$(DEB_BUILD_PROFILES)),) ifeq ($(filter pkg.gnumach.noxen,$(DEB_BUILD_PROFILES)),) $(call doinstall_dbg_udeb,-xen,,$(D_XEN),$(D_XEN_DBG),$(D_XEN_UDEB)) endif ifeq ($(DEB_HOST_ARCH_CPU),i386) ifeq ($(filter pkg.gnumach.nopae,$(DEB_BUILD_PROFILES)),) $(call doinstall_dbg,,-pae,$(D_PAE),$(D_PAE_DBG)) endif ifeq ($(filter pkg.gnumach.nosmp,$(DEB_BUILD_PROFILES)),) $(call doinstall_dbg,,-smp,$(D_SMP),$(D_SMP_DBG)) endif endif endif ifeq ($(DEB_HOST_ARCH_OS),hurd) for script in preinst prerm postinst postrm ; do \ for prefix in "" -xen ; do \ for suffix in -up -pae -smp ; do \ for dbg in "" -dbg ; do \ sed -e "s/@VERSION@/$(VERSION)/g" \ -e "s/@RELEASE@/$(VERSION)$$prefix-$(MACHINE)$$suffix$$dbg/g" \ debian/gnumach-image.$$script.in \ > debian/gnumach-image-$(VERSION)$$prefix-$(MACHINE)$$suffix$$dbg.$$script ; \ done ; \ done ; \ done ; \ done endif else $(MAKE) -C build install-data \ DESTDIR=$(D) endif binary: binary-indep binary-arch binary-indep: install debian/control.stamp dh_testdir dh_testroot dh_install -i --sourcedir=$(D) dh_installdocs -i dh_installchangelogs -i -k ChangeLog dh_installinfo -i dh_compress -i dh_fixperms -i dh_installdeb -i dh_gencontrol -i dh_md5sums -i dh_builddeb -i binary-arch: install debian/control.stamp dh_testdir dh_testroot dh_install -a -N$(pkg_dbg) -N$(pkg_udeb) -N$(pkg_xen) -N$(pkg_xen_dbg) -N$(pkg_xen_udeb) $(nopkg_pae) $(nopkg_pae_dbg) $(nopkg_smp) $(nopkg_smp_dbg) --sourcedir=$(D) dh_install -p$(pkg) --sourcedir=$(D) boot dh_install -p$(pkg_dbg) --sourcedir=$(D_DBG) boot dh_install -p$(pkg_udeb) --sourcedir=$(D_UDEB) boot dh_install -p$(pkg_xen) --sourcedir=$(D_XEN) boot dh_install -p$(pkg_xen_dbg) --sourcedir=$(D_XEN_DBG) boot dh_install -p$(pkg_xen_udeb) --sourcedir=$(D_XEN_UDEB) boot ifeq ($(DEB_HOST_ARCH_CPU),i386) dh_install -p$(pkg_pae) --sourcedir=$(D_PAE) boot dh_install -p$(pkg_pae_dbg) --sourcedir=$(D_PAE_DBG) boot dh_install -p$(pkg_smp) --sourcedir=$(D_SMP) boot dh_install -p$(pkg_smp_dbg) --sourcedir=$(D_SMP_DBG) boot endif dh_installdocs -p$(pkg) README NEWS i386/README-Drivers dh_installdocs -p$(pkg_dbg) README NEWS i386/README-Drivers dh_installdocs -p$(pkg_xen) README NEWS dh_installdocs -p$(pkg_xen_dbg) README NEWS ifeq ($(DEB_HOST_ARCH_CPU),i386) dh_installdocs -p$(pkg_pae) README NEWS dh_installdocs -p$(pkg_pae_dbg) README NEWS dh_installdocs -p$(pkg_smp) README NEWS dh_installdocs -p$(pkg_smp_dbg) README NEWS endif dh_installdocs -a dh_installchangelogs -a -k ChangeLog dh_installinfo -a dh_link -a dh_strip -a -N$(pkg_dbg) -N$(pkg_xen_dbg) $(nopkg_pae_dbg) $(nopkg_smp_dbg) dh_compress -a -N$(pkg) -N$(pkg_dbg) -N$(pkg_udeb) -N$(pkg_xen) -N$(pkg_xen_dbg) -N$(pkg_xen_udeb) $(nopkg_pae) $(nopkg_pae_dbg) $(nopkg_smp) $(nopkg_smp_dbg) dh_compress -p$(pkg) boot/gnumach-$(VERSION)-$(MACHINE)-up dh_compress -p$(pkg_dbg) boot/gnumach-$(VERSION)-$(MACHINE)-up-dbg dh_compress -p$(pkg_udeb) boot/gnumach dh_compress -p$(pkg_xen) boot/gnumach-$(VERSION)-xen-$(MACHINE) dh_compress -p$(pkg_xen_dbg) boot/gnumach-$(VERSION)-xen-$(MACHINE)-dbg dh_compress -p$(pkg_xen_udeb) boot/gnumach ifeq ($(DEB_HOST_ARCH_CPU),i386) dh_compress -p$(pkg_pae) boot/gnumach-$(VERSION)-$(MACHINE)-pae dh_compress -p$(pkg_pae_dbg) boot/gnumach-$(VERSION)-$(MACHINE)-pae-dbg dh_compress -p$(pkg_smp) boot/gnumach-$(VERSION)-$(MACHINE)-smp dh_compress -p$(pkg_smp_dbg) boot/gnumach-$(VERSION)-$(MACHINE)-smp-dbg endif dh_fixperms -a dh_installdeb -a dh_gencontrol -a dh_md5sums -a dh_builddeb -a .PHONY: build build-arch build-indep clean .PHONY: install binary binary-indep binary-arch