Skip to contentSkip to conversation

configure/Make: Build libfdt from submodule DTC

PATCH Peter Crosthwaite 1 participant 2 messages Mar 4, 2013 5 messages not in the archive

lore
Share & tools
lore
#3 lore raw
In reply to a message not in the archive
Quoted 28 lines · Peter Maydell
Quoted 26 lines · Peter Crosthwaite

Configure to use the DTC submodule to build libfdt when no system libfdt is found. Prompt to install the DTC submodule if --enable-fdt is set but no DTC can be found.

DTC has no out-of-tree build capability, so the configure will symlink the Makefile and scripts directory in the out of tree build directory and pass in all the needed DTC arguments to make out of tree build happen. Ideally we fix the DTC make to support out of tree, but did it this way to avoid commits to DTC.

---

 Makefile  |   10 ++++++++++
 configure |   29 +++++++++++++++++++++++++----
 2 files changed, 35 insertions(+), 4 deletions(-)
Makefile +0 -0
index 0d9099a..a8956d2 100644
@@ -136,6 +136,15 @@ pixman/Makefile: $(SRC_PATH)/pixman/configure
 $(SRC_PATH)/pixman/configure:
        (cd $(SRC_PATH)/pixman; autoreconf -v --install)
 
Quoted 9 lines

Makefile pixman/Makefile: $(SRC_PATH)/pixman/configure · line 143

Quoted 5 lines
Makefile +5 -0
+DTC_MAKE_ARGS=-I$(SRC_PATH)/dtc VPATH=$(SRC_PATH)/dtc -C dtc V="$(V)" LIBFDT_srcdir=$(SRC_PATH)/dtc/libfdt
+DTC_CFLAGS="$(CFLAGS) $(extra_cflags) -I$(BUILD_DIR)/dtc -I$(SRC_PATH)/dtc -I$(SRC_PATH)/dtc/libfdt"
+
+subdir-dtc:dtc/libfdt dtc/tests
+       $(call quiet-command,$(MAKE) $(DTC_MAKE_ARGS) CPPFLAGS=$(DTC_CFLAGS) LDFLAGS="$(LDFLAGS)" ARFLAGS="$(ARFLAGS)" CC=$(CC) AR=$(AR) LD=$(LD) $(SUBDIR_MAKEFLAGS) libfdt,)

This doesn't work if you configured with --cc='ccache gcc'. I think you have insufficient quoting here.

Yes, CC AR and LD need quotes. Fixed in v3.

Thanks,
Peter

Quoted 83 lines
Quoted 20 lines
Makefile +5 -0
+
+dtc/%:
+       mkdir -p $@
+
 $(SUBDIR_RULES): libqemuutil.a libqemustub.a $(common-obj-y)
 
 ROMSUBDIR_RULES=$(patsubst %,romsubdir-%, $(ROMS))
@@ -253,6 +262,7 @@ distclean: clean
        rm -rf $$d || exit 1 ; \
         done
        if test -f pixman/config.log; then make -C pixman distclean; fi
+       if test -f dtc/version_gen.h; then make $(DTC_MAKE_ARGS) clean; fi
 
 KEYMAPS=da     en-gb  et  fr     fr-ch  is  lt  modifiers  no  pt-br  sv \
 ar      de     en-us  fi  fr-be  hr     it  lv  nl         pl  ru     th \
configure +0 -0
index 088909b..6e40624 100755

configure if test "$fdt" != "no" ; then · line 2379

Quoted 4 lines
configure +1 -0
@@ -2376,11 +2376,28 @@ if test "$fdt" != "no" ; then
 int main(void) { return 0; }
 EOF
   if compile_prog "" "$fdt_libs" ; then
+    #system DTC is good - use it

Spaces between the comment char and the comment would be nice.

Quoted 14 lines
configure +9 -3
     fdt=yes
-  else
-    if test "$fdt" = "yes" ; then
-      feature_not_found "fdt"
+  elif test -d ${source_path}/dtc/libfdt ; then
+    #have submodule DTC - use it
+    fdt=yes
+    dtc_internal="yes"
+    mkdir -p dtc
+    if [ "$source_path" != `pwd` ]; then
+       symlink "$source_path/dtc/Makefile" "dtc/Makefile"
+       symlink "$source_path/dtc/scripts" "dtc/scripts"
     fi
+    fdt_cflags="-I\$(SRC_PATH)/dtc/libfdt"

configure if test "$fdt" != "no" ; then · line 2400

Quoted 10 lines
configure +10 -0
+    fdt_libs="-L\$(BUILD_DIR)/dtc/libfdt $fdt_libs"
+  elif test "$fdt" = "yes" ; then
+    #have neither and want - prompt for system/submodule install
+    echo "ERROR: DTC not present. Your options:"
+    echo "  (1) Preferred: Install the DTC devel package"
+    echo "  (2) Fetch the DTC submodule, using:"
+    echo "      git submodule update --init dtc"
+    exit 1
+  else
+    #dont have and dont want

Missing apostrophes.

Quoted 24 lines
configure +5 -2
     fdt_libs=
     fdt=no
   fi
@@ -3259,7 +3276,7 @@ if test "$cpu" = "ppc64" -a "$targetos" != "Darwin" ; then
 fi
 
 # add pixman flags after all config tests are done
-QEMU_CFLAGS="$QEMU_CFLAGS $pixman_cflags"
+QEMU_CFLAGS="$QEMU_CFLAGS $pixman_cflags $fdt_cflags"
 libs_softmmu="$libs_softmmu $pixman_libs"
 
 echo "Install prefix    $prefix"
@@ -4299,6 +4316,10 @@ if [ "$pixman" = "internal" ]; then
   echo "config-host.h: subdir-pixman" >> $config_host_mak
 fi
 
+if [ "$dtc_internal" = "yes" ]; then
+  echo "config-host.h: subdir-dtc" >> $config_host_mak
+fi
+
 # build tree in object directory in case the source is not in the current directory
 DIRS="tests tests/tcg tests/tcg/cris tests/tcg/lm32"
 DIRS="$DIRS pc-bios/optionrom pc-bios/spapr-rtas"
--
Quoted 2 lines

1.7.0.4

-- PMM

#6 lore raw

Re: [Qemu-devel] [PATCH v2 1/3] configure: Put cross compile flags in EXTRA_CFLAGS

In reply to a message not in the archive
Quoted 29 lines · Peter Maydell
Quoted 27 lines · Peter Crosthwaite

The cross compile CFLAGS are needed to properly build pixman (and any other submodules). Only the EXTRA_CFLAGS set is passed to submodules not QEMU_CFLAGS, so put the cross compile flags in EXTRA_CFLAGS instead.

---

 configure |   17 +++++++++--------
 1 files changed, 9 insertions(+), 8 deletions(-)
configure +1 -2
index bf5970f..088909b 100755
@@ -239,8 +239,7 @@ for opt do
   ;;
   --cpu=*) cpu="$optarg"
   ;;
-  --extra-cflags=*) QEMU_CFLAGS="$optarg $QEMU_CFLAGS"
-                    EXTRA_CFLAGS="$optarg"
+  --extra-cflags=*) EXTRA_CFLAGS="$optarg"
   ;;
   --extra-ldflags=*) LDFLAGS="$optarg $LDFLAGS"
                      EXTRA_LDFLAGS="$optarg"
Quoted 11 lines

configure

Quoted 3 lines
configure +2 -0
+QEMU_CFLAGS="$EXTRA_CFLAGS $QEMU_CFLAGS"
+
 default_target_list=""

This change means that flags supplied by the user in --extra-cflags are not used in compile_prog/compile_object/check_define tests that happen before this point where we add the EXTRA_CFLAGS to QEMU_CFLAGS, but then they are used after that. This doesn't seem like a good thing (it would be reverting a fix inserted by commit e2a2ed0).

Ok. Reverted the first hunk of the patch and changed implementation accordingly.

Regards,
Peter

Quoted 2 lines

-- PMM