Patchwork [v1,2/2] configure/Make: Build libfdt from submodule DTC

login
register
mail settings
Submitter Peter Crosthwaite
Date Feb. 7, 2013, 6:08 a.m.
Message ID <32bc2333-cf5c-4494-a774-ddfae772def9@TX2EHSMHS008.ehs.local>
Download mbox | patch
Permalink /patch/218823/
State New
Headers show

Comments

Peter Crosthwaite - Feb. 7, 2013, 6:08 a.m.
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.

Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
---
 Makefile  |   10 ++++++++++
 configure |   29 +++++++++++++++++++++++++----
 2 files changed, 35 insertions(+), 4 deletions(-)
Alexander Graf - Feb. 12, 2013, 9:55 p.m.
On 07.02.2013, at 07:08, Peter Crosthwaite wrote:

> 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.
> 
> Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
> ---
> Makefile  |   10 ++++++++++
> configure |   29 +++++++++++++++++++++++++----
> 2 files changed, 35 insertions(+), 4 deletions(-)
> 
> diff --git a/Makefile b/Makefile
> index 0d9099a..cfa77c7 100644
> --- a/Makefile
> +++ b/Makefile
> @@ -136,6 +136,15 @@ pixman/Makefile: $(SRC_PATH)/pixman/configure
> $(SRC_PATH)/pixman/configure:
> 	(cd $(SRC_PATH)/pixman; autoreconf -v --install)
> 
> +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) CC=$(CC) AR=$(AR) LD=$(LD) $(SUBDIR_MAKEFLAGS) libfdt,)

I do remember that compiling pixman cross was having trouble. Have you verified that it works here?

> +
> +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 \
> diff --git a/configure b/configure
> index 8789324..a0b265a 100755
> --- a/configure
> +++ b/configure
> @@ -2375,11 +2375,28 @@ if test "$fdt" != "no" ; then
> int main(void) { return 0; }
> EOF
>   if compile_prog "" "$fdt_libs" ; then
> +    #system DTC is good - use it
>     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

Where does this get created? We need to make sure we compile into the foreign object dir if the user provides one (I don't remember the details how that worked though).


Alex

> +    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"
> +    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
>     fdt_libs=
>     fdt=no
>   fi
> @@ -3242,7 +3259,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"
> @@ -4278,6 +4295,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"
> -- 
> 1.7.0.4
> 
>
Peter Crosthwaite - Feb. 12, 2013, 11:24 p.m.
Hi Alex,

On Wed, Feb 13, 2013 at 7:55 AM, Alexander Graf <agraf@suse.de> wrote:
>
> On 07.02.2013, at 07:08, Peter Crosthwaite wrote:
>
>> 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.
>>
>> Signed-off-by: Peter Crosthwaite <peter.crosthwaite@xilinx.com>
>> ---
>> Makefile  |   10 ++++++++++
>> configure |   29 +++++++++++++++++++++++++----
>> 2 files changed, 35 insertions(+), 4 deletions(-)
>>
>> diff --git a/Makefile b/Makefile
>> index 0d9099a..cfa77c7 100644
>> --- a/Makefile
>> +++ b/Makefile
>> @@ -136,6 +136,15 @@ pixman/Makefile: $(SRC_PATH)/pixman/configure
>> $(SRC_PATH)/pixman/configure:
>>       (cd $(SRC_PATH)/pixman; autoreconf -v --install)
>>
>> +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) CC=$(CC) AR=$(AR) LD=$(LD) $(SUBDIR_MAKEFLAGS) libfdt,)
>
> I do remember that compiling pixman cross was having trouble. Have you verified that it works here?
>

Its a case of speak of the devil, as we are just today finishing our
own little cross compile flow and submodule pixman did fail for us. We
have a resolution and we should have patches to fix this (or at least
an RFC) shortly. Will fix this DTC make as well in V2 as some changes
were required here for cross along the same lines.

>> +
>> +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 \
>> diff --git a/configure b/configure
>> index 8789324..a0b265a 100755
>> --- a/configure
>> +++ b/configure
>> @@ -2375,11 +2375,28 @@ if test "$fdt" != "no" ; then
>> int main(void) { return 0; }
>> EOF
>>   if compile_prog "" "$fdt_libs" ; then
>> +    #system DTC is good - use it
>>     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
>
> Where does this get created? We need to make sure we compile into the foreign object dir if the user provides one (I don't remember the details how that worked though).
>

In the out of tree build directory. This is where all the compiled
objects will be placed in out of tree build. For an in tree build its
a nop as that dir will already exist in source.

Regards,
Peter

>
> Alex
>
>> +    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"
>> +    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
>>     fdt_libs=
>>     fdt=no
>>   fi
>> @@ -3242,7 +3259,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"
>> @@ -4278,6 +4295,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"
>> --
>> 1.7.0.4
>>
>>
>
>

Patch

diff --git a/Makefile b/Makefile
index 0d9099a..cfa77c7 100644
--- a/Makefile
+++ b/Makefile
@@ -136,6 +136,15 @@  pixman/Makefile: $(SRC_PATH)/pixman/configure
 $(SRC_PATH)/pixman/configure:
 	(cd $(SRC_PATH)/pixman; autoreconf -v --install)
 
+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) CC=$(CC) AR=$(AR) LD=$(LD) $(SUBDIR_MAKEFLAGS) libfdt,)
+
+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 \
diff --git a/configure b/configure
index 8789324..a0b265a 100755
--- a/configure
+++ b/configure
@@ -2375,11 +2375,28 @@  if test "$fdt" != "no" ; then
 int main(void) { return 0; }
 EOF
   if compile_prog "" "$fdt_libs" ; then
+    #system DTC is good - use it
     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"
+    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
     fdt_libs=
     fdt=no
   fi
@@ -3242,7 +3259,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"
@@ -4278,6 +4295,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"