ideas towards requiring VPATH build
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: ;
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
Quoted 6 lines · Eric Blake
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).
Quoted 8 lines
$ 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).
Signature · 3 lines
Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org