Ticket #59257: qemu-out-of-source.patch

File qemu-out-of-source.patch, 3.8 KB (added by Ionic (Mihai Moldovan), 5 years ago)

Switch to out-of-source builds to work around reconfiguration problems.

  • emulators/qemu/Portfile

    commit 196a9447baa5d26bf7043d98ad0e13c5e649ea9c
    Author: Mihai Moldovan <ionic@macports.org>
    Date:   Fri Nov 22 17:51:29 2019 +0100
    
        emulators/qemu: fix builds using out-of-source builds. Revbump.
        
        This targets mostly older platforms, but also generally changes behavior
        to a more correct one.
        
        The qemu build system is buggy when it comes to in-source-builds. Due to
        Makefile dependencies, it always tries to reconfigure using a special
        generated file at install time and also re-compiles the whole project.
        This would normally be just an annoyance, but because not all parameters
        are passed through (exported) correctly, the second build diverges from
        the correct first one.
        
        It shouldn't come as a surprise that Linux distros seem to use
        out-of-source builds for qemu, which nicely works around that problem.
        
        Additionally, older platforms have an mktemp implementation that always
        expects a template as its parameter, but the Makefile doesn't prove one
        in some cases. Hence, switch to GNU coreutils's on 10.10-, but keep
        using mktemp on more recent platforms because it seems to work fine
        there.
        
        Fixes: https://trac.macports.org/ticket/59257
    
    diff --git a/emulators/qemu/Portfile b/emulators/qemu/Portfile
    index 3f58aa5462d..27beae19a53 100644
    a b PortGroup legacysupport 1.0 
    88
    99name                    qemu
    1010version                 4.1.0
    11 revision                0
     11revision                1
    1212categories              emulators
    1313license                 GPL-2+
    1414platforms               darwin
    pre-configure { 
    106106    configure.args-append --target-list=${target_list}
    107107}
    108108
     109# The qemu build system bugs out when using in-source-tree builds.
     110# During builds, files are generated in directories such as pc-bios, which are
     111# prerequites to the config-host.mak file. The latter gets generated during a
     112# configure run and can (in theory) be used for reconfiguring the package.
     113# Practically, this reconfiguration fails because it doesn't take special flags
     114# into account like LDFLAGS and the like, so we have to avoid reconfiguring
     115# qemu.
     116# Additionally, just "touch"ing the file doesn't work either, because it is a
     117# prerequisite of other generated file which will, likewise, be generated twice.
     118# Using out-of-source builds we can work around this issue in a pretty nice way.
     119configure.dir   "${workpath}/build"
     120
     121configure.cmd   "${worksrcpath}/configure"
     122build.dir       "${workpath}/build"
     123
     124pre-configure {
     125    file mkdir ${configure.dir}
     126}
     127
    109128# disable silent rules
    110129build.args-append       V=1
    111130
    platform darwin 8 { 
    205224    build.cmd ${prefix}/bin/gmake
    206225}
    207226
     227platform darwin {
     228    if {${os.major} < 15} {
     229        depends_build-append    port:coreutils
     230        patchfiles-append       patch-Makefile-legacy-mktemp-to-coreutils.diff
     231    }
     232}
     233
    208234livecheck.type  regex
    209235livecheck.url   [lindex ${master_sites} 0]
    210236livecheck.regex ${name}-(\\d+(?:\\.\\d+)*)(?:-\\d+)*\\.tar
  • new file emulators/qemu/files/patch-Makefile-legacy-mktemp-to-coreutils.diff

    diff --git a/emulators/qemu/files/patch-Makefile-legacy-mktemp-to-coreutils.diff b/emulators/qemu/files/patch-Makefile-legacy-mktemp-to-coreutils.diff
    new file mode 100644
    index 00000000000..2031f84cbb2
    - +  
     1--- a/Makefile  2019-08-15 21:01:42.000000000 +0200
     2+++ b/Makefile  2019-11-22 13:38:08.000000000 +0100
     3@@ -879,7 +879,7 @@ ifdef INSTALL_BLOBS
     4 endif
     5 ifneq ($(DESCS),)
     6        $(INSTALL_DIR) "$(DESTDIR)$(qemu_datadir)/firmware"
     7-       set -e; tmpf=$$(mktemp); trap 'rm -f -- "$$tmpf"' EXIT; \
     8+       set -e; tmpf=$$(gmktemp); trap 'rm -f -- "$$tmpf"' EXIT; \
     9        for x in $(DESCS); do \
     10                sed -e 's,@DATADIR@,$(qemu_datadir),' \
     11                        "$(SRC_PATH)/pc-bios/descriptors/$$x" > "$$tmpf"; \