Skip to content

Commit

Permalink
Move generation of config-host.h to Makefile from configure
Browse files Browse the repository at this point in the history
Use timestamp based appreach to avoid not needed recompilation.
Add it to rules.mak

Many thanks to Paolo Bonzini for helpding the design, and the debug.

Patchworks-ID: 35190
Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
  • Loading branch information
Juan Quintela authored and Anthony Liguori committed Oct 9, 2009
1 parent deed3cc commit 1215c6e
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 23 deletions.
13 changes: 9 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,23 @@ else
DOCS=
endif

build-all: $(TOOLS) $(DOCS) recurse-all
SUBDIR_MAKEFLAGS=$(if $(V),,--no-print-directory)

build-all: config-host.h
$(call quiet-command, $(MAKE) $(SUBDIR_MAKEFLAGS) $(TOOLS) $(DOCS) recurse-all,)

config-host.mak: configure
ifneq ($(wildcard config-host.mak),)
@echo $@ is out-of-date, running configure
@sed -n "/.*Configured with/s/[^:]*: //p" $@ | sh
endif

SUBDIR_MAKEFLAGS=$(if $(V),,--no-print-directory)
config-host.h: config-host.h-timestamp
config-host.h-timestamp: config-host.mak

SUBDIR_RULES=$(patsubst %,subdir-%, $(TARGET_DIRS))

subdir-%:
subdir-%: config-host.h
$(call quiet-command,$(MAKE) $(SUBDIR_MAKEFLAGS) -C $* V="$(V)" TARGET_DIR="$*/" all,)

$(filter %-softmmu,$(SUBDIR_RULES)): libqemu_common.a
Expand Down Expand Up @@ -200,7 +205,7 @@ clean:
done

distclean: clean
rm -f config-host.mak config-host.h config-host.ld $(DOCS) qemu-options.texi qemu-img-cmds.texi
rm -f config-host.mak config-host.h* config-host.ld $(DOCS) qemu-options.texi qemu-img-cmds.texi
rm -f qemu-{doc,tech}.{info,aux,cp,dvi,fn,info,ky,log,pg,toc,tp,vr}
for d in $(TARGET_DIRS) libhw32 libhw64 libuser; do \
rm -rf $$d || exit 1 ; \
Expand Down
20 changes: 1 addition & 19 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -1800,13 +1800,8 @@ echo "-> Your SDL version is too old - please upgrade to have SDL support"
fi

config_host_mak="config-host.mak"
config_host_h="config-host.h"
config_host_ld="config-host.ld"

#echo "Creating $config_host_mak and $config_host_h"

test -f $config_host_h && mv $config_host_h ${config_host_h}~

echo "# Automatically generated by configure - do not modify" > $config_host_mak
printf "# Configured with:" >> $config_host_mak
printf " '%s'" "$0" "$@" >> $config_host_mak
Expand Down Expand Up @@ -2064,18 +2059,6 @@ echo "LIBS+=$LIBS" >> $config_host_mak
echo "LIBS_TOOLS+=$libs_tools" >> $config_host_mak
echo "EXESUF=$EXESUF" >> $config_host_mak

echo "/* Automatically generated by configure - do not modify */" > $config_host_h

/bin/sh $source_path/create_config < $config_host_mak >> $config_host_h

if test -f ${config_host_h}~ ; then
if cmp -s $config_host_h ${config_host_h}~ ; then
mv ${config_host_h}~ $config_host_h
else
rm ${config_host_h}~
fi
fi

# generate list of library paths for linker script

$ld --verbose -v 2> /dev/null | grep SEARCH_DIR > ${config_host_ld}
Expand Down Expand Up @@ -2474,8 +2457,7 @@ fi
echo "LDFLAGS+=$ldflags" >> $config_mak
echo "QEMU_CFLAGS+=$cflags" >> $config_mak

echo "/* Automatically generated by configure - do not modify */" > $config_h
echo "#include \"../config-host.h\"" >> $config_h
echo "#include \"../config-host.h\"" > $config_h

/bin/sh $source_path/create_config < $config_mak >> $config_h

Expand Down
2 changes: 2 additions & 0 deletions create_config
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
#!/bin/sh

echo "/* Automatically generated by create_config - do not modify */"

while read line; do

case $line in
Expand Down
9 changes: 9 additions & 0 deletions rules.mak
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,12 @@ quiet-command = $(if $(V),$1,$(if $(2),@echo $2 && $1, @$1))

cc-option = $(if $(shell $(CC) $1 $2 -S -o /dev/null -xc /dev/null \
>/dev/null 2>&1 && echo OK), $2, $3)

# Generate timestamp files for .h include files

%.h: %.h-timestamp
@test -f $@ || cp $< $@

%.h-timestamp: %.mak
$(call quiet-command, $(SRC_PATH)/create_config < $< > $@, " GEN $*.h")
@cmp $@ $*.h >/dev/null 2>&1 || cp $@ $*.h

0 comments on commit 1215c6e

Please sign in to comment.