[2/2] bootstrap: auto generate platform list

Message ID 20151119100418.GI5478@localhost.localdomain
State New
Headers show

Commit Message

Anders Roxell Nov. 19, 2015, 10:04 a.m.
On 2015-11-19 08:43, Nicolas Morey-Chaisemartin wrote:
> This list all the available platforms looking for
>  platform/*/m4/configure.m4 and generate the appropriate m4
>  file for the configure.ac to include
> 
> Signed-off-by: Nicolas Morey-Chaisemartin <nmorey@kalray.eu>
> ---
>  bootstrap    | 23 +++++++++++++++++++++++
>  configure.ac |  9 +--------
>  2 files changed, 24 insertions(+), 8 deletions(-)
> 
> diff --git a/bootstrap b/bootstrap
> index 7c3d220..daa8c58 100755
> --- a/bootstrap
> +++ b/bootstrap
> @@ -1,5 +1,28 @@
>  #! /bin/sh
>  set -x
> +
> +# Auto generate the platform list
> +PLATFORM_M4S=$(ls platform/*/m4/configure.m4)
> +PLATFORMS=$(basename -a ${PLATFORM_M4S//\/m4\/configure\.m4/})
> +GEN_M4="m4/platforms.m4"
> +
> +prefix=""
> +echo "# Auto-Generated platform list" > $GEN_M4
> +for platform in $PLATFORMS; do
> +	cat << EOF >> $GEN_M4
> +${prefix}if test "\${with_platform}" == "${platform}";
> +then
> +	m4_include([./platform/${platform}/m4/configure.m4])
> +EOF
> +	prefix="el"
> +done
> +cat << EOF >> $GEN_M4
> +else
> +    echo "UNSUPPORTED PLATFORM: \${with_platform}"
> +    exit 1
> +fi
> +EOF
> +
>  aclocal -I config -I m4
>  libtoolize --copy
>  autoheader
> diff --git a/configure.ac b/configure.ac
> index 0d7860b..157e5f3 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -87,14 +87,7 @@ netmap_support=no
>  
>  ##########################################################################
>  # Run platform specific checks and settings
> -##########################################################################
> -if test "${with_platform}" == "linux-generic";
> -then
> -    m4_include([./platform/linux-generic/m4/configure.m4])
> -else
> -    echo "UNSUPPORTED PLATFORM: ${with_platform}"
> -    exit 1
> -fi
> +m4_include([m4/platforms.m4])
>  
>  ##########################################################################
>  # Set conditionals as computed within platform specific files
> -- 
> 2.6.3.372.gcb93895
> 

+ ls platform/linux-generic/m4/configure.m4
platform/linux-satan/m4/configure.m4
+ PLATFORM_M4S=platform/linux-generic/m4/configure.m4
platform/linux-satan/m4/configure.m4
./bootstrap: 6: ./bootstrap: Bad substitution
+ PLATFORMS=
+ GEN_M4=m4/platforms.m4
+ prefix=
+ echo # Auto-Generated platform list
+ cat
+ aclocal -I config -I m4


what do you think about adding this, think it fixed it for me.



Cheers,
Anders

Patch

diff --git a/bootstrap b/bootstrap
index daa8c58..75523f0 100755
--- a/bootstrap
+++ b/bootstrap
@@ -3,16 +3,16 @@  set -x
 
 # Auto generate the platform list
 PLATFORM_M4S=$(ls platform/*/m4/configure.m4)
-PLATFORMS=$(basename -a ${PLATFORM_M4S//\/m4\/configure\.m4/})
 GEN_M4="m4/platforms.m4"
 
 prefix=""
 echo "# Auto-Generated platform list" > $GEN_M4
-for platform in $PLATFORMS; do
+for platform_m4 in $PLATFORM_M4S; do
+       platform=$(echo ${platform_m4}|awk -F'/' '{print $2}')
        cat << EOF >> $GEN_M4
 ${prefix}if test "\${with_platform}" == "${platform}";
 then
-       m4_include([./platform/${platform}/m4/configure.m4])
+    m4_include([./${platform_m4}])
 EOF
        prefix="el"
 done