All of lore.kernel.org
 help / color / mirror / Atom feed
From: LIU Zhiwei <zhiwei_liu@c-sky.com>
To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org
Cc: peter.maydell@linaro.org, richard.henderson@linaro.org,
	wxy194768@alibaba-inc.com, chihmin.chao@sifive.com,
	wenmeng_zhang@c-sky.com, Alistair.Francis@wdc.com,
	alex.bennee@linaro.org, LIU Zhiwei <zhiwei_liu@c-sky.com>
Subject: [PATCH 11/11] riscv: Add configure script
Date: Sun, 12 Jul 2020 00:16:55 +0800	[thread overview]
Message-ID: <20200711161655.2856-12-zhiwei_liu@c-sky.com> (raw)
In-Reply-To: <20200711161655.2856-1-zhiwei_liu@c-sky.com>

For RV64 risu, make CFLAGS="-march=rv64g"

Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com>
---
 configure          |   4 +-
 upstream/configure | 204 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 207 insertions(+), 1 deletion(-)
 create mode 100644 upstream/configure

diff --git a/configure b/configure
index ca2d7db..00624d3 100755
--- a/configure
+++ b/configure
@@ -58,6 +58,8 @@ guess_arch() {
         ARCH="m68k"
     elif check_define __powerpc64__ ; then
         ARCH="ppc64"
+    elif check_define __riscv && check_define _LP64; then
+        ARCH="riscv64"
     else
         echo "This cpu is not supported by risu. Try -h. " >&2
         exit 1
@@ -139,7 +141,7 @@ Some influential environment variables:
                prefixed with the given string.
 
   ARCH         force target architecture instead of trying to detect it.
-               Valid values=[arm|aarch64|ppc64|ppc64le|m68k]
+               Valid values=[arm|aarch64|ppc64|ppc64le|m68k|riscv64]
 
   CC           C compiler command
   CFLAGS       C compiler flags
diff --git a/upstream/configure b/upstream/configure
new file mode 100644
index 0000000..297cd3a
--- /dev/null
+++ b/upstream/configure
@@ -0,0 +1,204 @@
+#!/bin/sh
+# simple risu configure script
+#
+# Copyright (c) 2013 Linaro Limited
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#      Claudio Fontana (Linaro) - initial implementation
+
+# Locate the directory where this configure script is
+SRCDIR="$(cd "$(dirname "$0")"; pwd)"
+
+# Temporary directory used for files created by this script.
+# Like autoconf (and like QEMU) we put this directory in the
+# build directory, which means we can just give it a fixed name and
+# blow it away when configure is run, and we don't need to jump
+# through complicated hoops to delete it when configure exits
+# abnormally (it may be useful for debug purposes on an
+# abnormal exit).
+tmp_dir="config-temp"
+rm -rf "$tmp_dir"
+mkdir -p "$tmp_dir"
+if [ $? -ne 0 ]; then
+    echo "ERROR: could not create temporary directory"
+    exit 1
+fi
+
+compile() {
+    $CC $CFLAGS -c -o ${1}.o ${1}.c 2>/dev/null
+}
+
+link() {
+    $LD $LDFLAGS -l${2} -o ${1} ${1}.o 2>/dev/null
+}
+
+check_define() {
+    c=${tmp_dir}/check_define_${1}
+    cat > ${c}.c <<EOF
+#if !defined($1)
+#error $1 not defined
+#endif
+int main(void) { return 0; }
+EOF
+    compile $c
+}
+
+guess_arch() {
+    if check_define __aarch64__ ; then
+        ARCH="aarch64"
+    elif check_define __arm__ ; then
+        ARCH="arm"
+    elif check_define __i386__ || check_define __x86_64__ ; then
+        ARCH="i386"
+    elif check_define __m68k__ ; then
+        ARCH="m68k"
+    elif check_define __powerpc64__ ; then
+        ARCH="ppc64"
+    elif check_define __riscv ; then
+        if __riscv_xlen == 64; then
+            ARCH="riscv64"
+        elif __riscv_xlen == 32; then
+            ARCH="riscv32"
+        else
+            echo "__riscv_xlen is not supported by risu. " >&2
+            exit 1
+        fi
+    else
+        echo "This cpu is not supported by risu. Try -h. " >&2
+        exit 1
+    fi
+}
+
+check_type() {
+    c=${tmp_dir}/check_type_${1}
+    cat > ${c}.c <<EOF
+#include <inttypes.h>
+#include <stdint.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+
+int main(void) { $1 thisone; return 0; }
+EOF
+    compile $c
+}
+
+check_lib() {
+    c=${tmp_dir}/check_lib${1}
+    cat > ${c}.c <<EOF
+#include <stdint.h>
+#include <$2.h>
+
+int main(void) { $3; return 0; }
+EOF
+    compile $c && link $c $1
+}
+
+generate_config() {
+    cfg=config.h
+    echo "generating config.h..."
+
+    echo "/* config.h - generated by the 'configure' script */" > $cfg
+    echo "#ifndef CONFIG_H" >> $cfg
+    echo "#define CONFIG_H 1" >> $cfg
+
+    if check_lib z zlib "zlibVersion()"; then
+        echo "#define HAVE_ZLIB 1" >> $cfg
+        LDFLAGS=-lz
+    fi
+
+    echo "#endif /* CONFIG_H */" >> $cfg
+
+    echo "...done"
+}
+
+generate_makefilein() {
+    m=Makefile.in
+    echo "generating Makefile.in..."
+
+    echo "# Makefile.in - generated by the 'configure' script" > $m
+    echo "ARCH:=${ARCH}" >> $m
+    echo "CC:=${CC}" >> $m
+    echo "CPPFLAGS:=${CPPFLAGS}" >> $m
+    echo "LDFLAGS:=${LDFLAGS}" >> $m
+    echo "AS:=${AS}" >> $m
+    echo "OBJCOPY:=${OBJCOPY}" >> $m
+    echo "OBJDUMP:=${OBJDUMP}" >> $m
+    echo "STATIC:=${STATIC}" >> $m
+    echo "SRCDIR:=${SRCDIR}" >> $m
+    echo "BUILD_INC:=${BUILD_INC}" >> $m
+
+    echo "...done"
+}
+
+usage() {
+    cat <<EOF
+Usage: [VAR=VALUE]... ./configure [-h|--help] [-s|--static]
+
+  -s/--static - force a static build of risu
+
+To assign environment variables (e.g., CC, CFLAGS...), specify them as
+VAR=VALUE.  See below for descriptions of some of the useful variables.
+
+Some influential environment variables:
+  CROSS_PREFIX cross-compiler prefix, defaults to gcc and other tools
+               prefixed with the given string.
+
+  ARCH         force target architecture instead of trying to detect it.
+               Valid values=[arm|aarch64|ppc64|ppc64le|m68k|riscv64]
+
+  CC           C compiler command
+  CFLAGS       C compiler flags
+  CPPFLAGS     C preprocessor flags, e.g. -I<include dir>
+
+  AS           assembler command
+  OBJCOPY      object copy utility command
+  OBJDUMP      object dump utility command
+
+EOF
+}
+
+# STARTUP: entry point
+STATIC=""
+
+for opt do
+  case "$opt" in
+      --help | -h)
+          usage;
+          exit 0;;
+      --static | -s)
+          STATIC="-static"
+          ;;
+
+  esac
+done
+
+CC="${CC-${CROSS_PREFIX}gcc}"
+AS="${AS-${CROSS_PREFIX}as}"
+LD="${LD-${CROSS_PREFIX}ld}"
+OBJCOPY="${OBJCOPY-${CROSS_PREFIX}objcopy}"
+OBJDUMP="${OBJDUMP-${CROSS_PREFIX}objdump}"
+
+if test "x${ARCH}" = "x"; then
+    guess_arch
+fi
+
+# Are we in a separate build tree? If so, link the Makefile
+# so that 'make' works.
+if test ! -e Makefile || test -s Makefile; then
+    echo "linking Makefile..."
+    BUILD_INC="-I $(pwd)"
+    ln -sf "${SRCDIR}/Makefile" .
+fi
+
+generate_config
+generate_makefilein
+
+rm -r "$tmp_dir"
+
+echo "type 'make' to start the build"
+exit 0
+
-- 
2.23.0



WARNING: multiple messages have this Message-ID (diff)
From: LIU Zhiwei <zhiwei_liu@c-sky.com>
To: qemu-devel@nongnu.org, qemu-riscv@nongnu.org
Cc: richard.henderson@linaro.org, Alistair.Francis@wdc.com,
	chihmin.chao@sifive.com, alex.bennee@linaro.org,
	peter.maydell@linaro.org, wenmeng_zhang@c-sky.com,
	wxy194768@alibaba-inc.com, LIU Zhiwei <zhiwei_liu@c-sky.com>
Subject: [PATCH 11/11] riscv: Add configure script
Date: Sun, 12 Jul 2020 00:16:55 +0800	[thread overview]
Message-ID: <20200711161655.2856-12-zhiwei_liu@c-sky.com> (raw)
In-Reply-To: <20200711161655.2856-1-zhiwei_liu@c-sky.com>

For RV64 risu, make CFLAGS="-march=rv64g"

Signed-off-by: LIU Zhiwei <zhiwei_liu@c-sky.com>
---
 configure          |   4 +-
 upstream/configure | 204 +++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 207 insertions(+), 1 deletion(-)
 create mode 100644 upstream/configure

diff --git a/configure b/configure
index ca2d7db..00624d3 100755
--- a/configure
+++ b/configure
@@ -58,6 +58,8 @@ guess_arch() {
         ARCH="m68k"
     elif check_define __powerpc64__ ; then
         ARCH="ppc64"
+    elif check_define __riscv && check_define _LP64; then
+        ARCH="riscv64"
     else
         echo "This cpu is not supported by risu. Try -h. " >&2
         exit 1
@@ -139,7 +141,7 @@ Some influential environment variables:
                prefixed with the given string.
 
   ARCH         force target architecture instead of trying to detect it.
-               Valid values=[arm|aarch64|ppc64|ppc64le|m68k]
+               Valid values=[arm|aarch64|ppc64|ppc64le|m68k|riscv64]
 
   CC           C compiler command
   CFLAGS       C compiler flags
diff --git a/upstream/configure b/upstream/configure
new file mode 100644
index 0000000..297cd3a
--- /dev/null
+++ b/upstream/configure
@@ -0,0 +1,204 @@
+#!/bin/sh
+# simple risu configure script
+#
+# Copyright (c) 2013 Linaro Limited
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+#
+# Contributors:
+#      Claudio Fontana (Linaro) - initial implementation
+
+# Locate the directory where this configure script is
+SRCDIR="$(cd "$(dirname "$0")"; pwd)"
+
+# Temporary directory used for files created by this script.
+# Like autoconf (and like QEMU) we put this directory in the
+# build directory, which means we can just give it a fixed name and
+# blow it away when configure is run, and we don't need to jump
+# through complicated hoops to delete it when configure exits
+# abnormally (it may be useful for debug purposes on an
+# abnormal exit).
+tmp_dir="config-temp"
+rm -rf "$tmp_dir"
+mkdir -p "$tmp_dir"
+if [ $? -ne 0 ]; then
+    echo "ERROR: could not create temporary directory"
+    exit 1
+fi
+
+compile() {
+    $CC $CFLAGS -c -o ${1}.o ${1}.c 2>/dev/null
+}
+
+link() {
+    $LD $LDFLAGS -l${2} -o ${1} ${1}.o 2>/dev/null
+}
+
+check_define() {
+    c=${tmp_dir}/check_define_${1}
+    cat > ${c}.c <<EOF
+#if !defined($1)
+#error $1 not defined
+#endif
+int main(void) { return 0; }
+EOF
+    compile $c
+}
+
+guess_arch() {
+    if check_define __aarch64__ ; then
+        ARCH="aarch64"
+    elif check_define __arm__ ; then
+        ARCH="arm"
+    elif check_define __i386__ || check_define __x86_64__ ; then
+        ARCH="i386"
+    elif check_define __m68k__ ; then
+        ARCH="m68k"
+    elif check_define __powerpc64__ ; then
+        ARCH="ppc64"
+    elif check_define __riscv ; then
+        if __riscv_xlen == 64; then
+            ARCH="riscv64"
+        elif __riscv_xlen == 32; then
+            ARCH="riscv32"
+        else
+            echo "__riscv_xlen is not supported by risu. " >&2
+            exit 1
+        fi
+    else
+        echo "This cpu is not supported by risu. Try -h. " >&2
+        exit 1
+    fi
+}
+
+check_type() {
+    c=${tmp_dir}/check_type_${1}
+    cat > ${c}.c <<EOF
+#include <inttypes.h>
+#include <stdint.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+
+int main(void) { $1 thisone; return 0; }
+EOF
+    compile $c
+}
+
+check_lib() {
+    c=${tmp_dir}/check_lib${1}
+    cat > ${c}.c <<EOF
+#include <stdint.h>
+#include <$2.h>
+
+int main(void) { $3; return 0; }
+EOF
+    compile $c && link $c $1
+}
+
+generate_config() {
+    cfg=config.h
+    echo "generating config.h..."
+
+    echo "/* config.h - generated by the 'configure' script */" > $cfg
+    echo "#ifndef CONFIG_H" >> $cfg
+    echo "#define CONFIG_H 1" >> $cfg
+
+    if check_lib z zlib "zlibVersion()"; then
+        echo "#define HAVE_ZLIB 1" >> $cfg
+        LDFLAGS=-lz
+    fi
+
+    echo "#endif /* CONFIG_H */" >> $cfg
+
+    echo "...done"
+}
+
+generate_makefilein() {
+    m=Makefile.in
+    echo "generating Makefile.in..."
+
+    echo "# Makefile.in - generated by the 'configure' script" > $m
+    echo "ARCH:=${ARCH}" >> $m
+    echo "CC:=${CC}" >> $m
+    echo "CPPFLAGS:=${CPPFLAGS}" >> $m
+    echo "LDFLAGS:=${LDFLAGS}" >> $m
+    echo "AS:=${AS}" >> $m
+    echo "OBJCOPY:=${OBJCOPY}" >> $m
+    echo "OBJDUMP:=${OBJDUMP}" >> $m
+    echo "STATIC:=${STATIC}" >> $m
+    echo "SRCDIR:=${SRCDIR}" >> $m
+    echo "BUILD_INC:=${BUILD_INC}" >> $m
+
+    echo "...done"
+}
+
+usage() {
+    cat <<EOF
+Usage: [VAR=VALUE]... ./configure [-h|--help] [-s|--static]
+
+  -s/--static - force a static build of risu
+
+To assign environment variables (e.g., CC, CFLAGS...), specify them as
+VAR=VALUE.  See below for descriptions of some of the useful variables.
+
+Some influential environment variables:
+  CROSS_PREFIX cross-compiler prefix, defaults to gcc and other tools
+               prefixed with the given string.
+
+  ARCH         force target architecture instead of trying to detect it.
+               Valid values=[arm|aarch64|ppc64|ppc64le|m68k|riscv64]
+
+  CC           C compiler command
+  CFLAGS       C compiler flags
+  CPPFLAGS     C preprocessor flags, e.g. -I<include dir>
+
+  AS           assembler command
+  OBJCOPY      object copy utility command
+  OBJDUMP      object dump utility command
+
+EOF
+}
+
+# STARTUP: entry point
+STATIC=""
+
+for opt do
+  case "$opt" in
+      --help | -h)
+          usage;
+          exit 0;;
+      --static | -s)
+          STATIC="-static"
+          ;;
+
+  esac
+done
+
+CC="${CC-${CROSS_PREFIX}gcc}"
+AS="${AS-${CROSS_PREFIX}as}"
+LD="${LD-${CROSS_PREFIX}ld}"
+OBJCOPY="${OBJCOPY-${CROSS_PREFIX}objcopy}"
+OBJDUMP="${OBJDUMP-${CROSS_PREFIX}objdump}"
+
+if test "x${ARCH}" = "x"; then
+    guess_arch
+fi
+
+# Are we in a separate build tree? If so, link the Makefile
+# so that 'make' works.
+if test ! -e Makefile || test -s Makefile; then
+    echo "linking Makefile..."
+    BUILD_INC="-I $(pwd)"
+    ln -sf "${SRCDIR}/Makefile" .
+fi
+
+generate_config
+generate_makefilein
+
+rm -r "$tmp_dir"
+
+echo "type 'make' to start the build"
+exit 0
+
-- 
2.23.0



  parent reply	other threads:[~2020-07-11 16:21 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-11 16:16 [PATCH 00/11] RISC-V risu porting LIU Zhiwei
2020-07-11 16:16 ` LIU Zhiwei
2020-07-11 16:16 ` [PATCH 01/11] riscv: Add RV64I instructions description LIU Zhiwei
2020-07-11 16:16   ` LIU Zhiwei
2020-07-11 16:16 ` [PATCH 02/11] riscv: Add RV64M " LIU Zhiwei
2020-07-11 16:16   ` LIU Zhiwei
2020-07-11 16:16 ` [PATCH 03/11] riscv: Add RV64A " LIU Zhiwei
2020-07-11 16:16   ` LIU Zhiwei
2020-07-11 16:16 ` [PATCH 04/11] riscv: Add RV64F " LIU Zhiwei
2020-07-11 16:16   ` LIU Zhiwei
2020-07-11 16:16 ` [PATCH 05/11] riscv: Add RV64D " LIU Zhiwei
2020-07-11 16:16   ` LIU Zhiwei
2020-07-11 16:16 ` [PATCH 06/11] riscv: Add RV64C " LIU Zhiwei
2020-07-11 16:16   ` LIU Zhiwei
2020-07-11 16:16 ` [PATCH 07/11] riscv: Generate payload scripts LIU Zhiwei
2020-07-11 16:16   ` LIU Zhiwei
2020-07-11 16:16 ` [PATCH 08/11] riscv: Add standard test case LIU Zhiwei
2020-07-11 16:16   ` LIU Zhiwei
2020-07-11 16:16 ` [PATCH 09/11] riscv: Define riscv struct reginfo LIU Zhiwei
2020-07-11 16:16   ` LIU Zhiwei
2020-07-11 16:16 ` [PATCH 10/11] riscv: Implement payload load interfaces LIU Zhiwei
2020-07-11 16:16   ` LIU Zhiwei
2020-07-11 16:16 ` LIU Zhiwei [this message]
2020-07-11 16:16   ` [PATCH 11/11] riscv: Add configure script LIU Zhiwei
2020-07-22  2:50 ` [PATCH 00/11] RISC-V risu porting LIU Zhiwei
2020-07-22  2:50   ` LIU Zhiwei

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200711161655.2856-12-zhiwei_liu@c-sky.com \
    --to=zhiwei_liu@c-sky.com \
    --cc=Alistair.Francis@wdc.com \
    --cc=alex.bennee@linaro.org \
    --cc=chihmin.chao@sifive.com \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-riscv@nongnu.org \
    --cc=richard.henderson@linaro.org \
    --cc=wenmeng_zhang@c-sky.com \
    --cc=wxy194768@alibaba-inc.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.