qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: ideas towards requiring VPATH build


From: Eric Blake
Subject: Re: ideas towards requiring VPATH build
Date: Mon, 14 Oct 2019 09:23:57 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.1.0

On 10/11/19 4:28 PM, Eric Blake wrote:
I know we've talked about enforcing a VPATH build, but haven't yet flipped the switch.  This week, I've played with using a VPATH build (cd qemu; mkdir -p build; cd ./build; ../configure ...; make ...), but find my old habits of expecting an in-tree build to just work (cd qemu; make ...) hard to overcome.  So this is what I've come up with: if you place the following file in-tree, then any 'make ...' command you type in-tree without using -C will have the same effect as if you had typed the same command in the build directory, but without having to manually remember to switch to the build directory.

Perhaps this can be a starting point for a patch to actually include this file in qemu.git as part of the larger effort to force VPATH builds, while still having the convenience of in-tree make working for those who were used to it.  (I places an echo and sleep in my file to remind myself when I forgot to use the build directory, but that is not mandatory if we want GNUmakefile stored in qemu.git).

Presumably, any full switch to force a VPATH build would also include creating the build directory as needed (my hack assumes that it already exists).

$ cat GNUmakefile
# Hack for redirecting while reminding myself to use distinct builddir
%: force
     @echo 'changing directory to build...'
     @sleep 2
     @$(MAKE) -C build -f Makefile $(MAKECMDGOALS)
force: ;
GNUmakefile: ;

Works for 'make all' or 'make check', but doesn't quite work for 'make'. For that, I had to add:

ifeq ($(MAKECMDGOALS),)
recurse: all
endif

prior to the %: line (the name 'recurse' is not special, it merely has to be something unlikely to be in the actual Makefile, and appear as the first rule with a dependency on the name of the real first rule in Makefile, so that when make is invoked without a target, we still end up invoking the actual Makefile rather than our GNUmakefile shim claiming that 'force' has nothing to do).

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org



reply via email to

[Prev in Thread] Current Thread [Next in Thread]