[PATCH RISU] configure: Support native OpenBSD builds

Philippe Mathieu-Daudé posted 1 patch 3 days, 22 hours ago
There is a newer version of this series
configure | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
[PATCH RISU] configure: Support native OpenBSD builds
Posted by Philippe Mathieu-Daudé 3 days, 22 hours ago
OpenBSD has no gcc, use cc. Also do not run 'ln -sf Makefile .' in an
in-tree build: BSD ln replaces the Makefile by a symlink to itself.

Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
---
 configure | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/configure b/configure
index 39275a2..ec351f0 100755
--- a/configure
+++ b/configure
@@ -171,6 +171,10 @@ for opt do
   esac
 done
 
+# OpenBSD has no gcc, its native compiler is cc (clang)
+if test "x${CROSS_PREFIX}" = "x" && test "$(uname -s)" = "OpenBSD"; then
+    CC="${CC-cc}"
+fi
 CC="${CC-${CROSS_PREFIX}gcc}"
 AS="${AS-${CROSS_PREFIX}as}"
 LD="${LD-${CROSS_PREFIX}ld}"
@@ -183,7 +187,8 @@ 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
+# (not in-tree: BSD "ln -sf" would turn the Makefile into a loop)
+if test "${SRCDIR}" != "$(pwd)"; then
     echo "linking Makefile..."
     BUILD_INC="-I $(pwd)"
     ln -sf "${SRCDIR}/Makefile" .
-- 
2.55.0


Re: [PATCH RISU] configure: Support native OpenBSD builds
Posted by Richard Henderson 3 days, 21 hours ago
On 12/2/26 13:43, Philippe Mathieu-Daudé wrote:
> OpenBSD has no gcc, use cc. Also do not run 'ln -sf Makefile .' in an
> in-tree build: BSD ln replaces the Makefile by a symlink to itself.
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@oss.qualcomm.com>
> ---
>   configure | 7 ++++++-
>   1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/configure b/configure
> index 39275a2..ec351f0 100755
> --- a/configure
> +++ b/configure
> @@ -171,6 +171,10 @@ for opt do
>     esac
>   done
>   
> +# OpenBSD has no gcc, its native compiler is cc (clang)
> +if test "x${CROSS_PREFIX}" = "x" && test "$(uname -s)" = "OpenBSD"; then
> +    CC="${CC-cc}"
> +fi
>   CC="${CC-${CROSS_PREFIX}gcc}"
>   AS="${AS-${CROSS_PREFIX}as}"
>   LD="${LD-${CROSS_PREFIX}ld}"
> @@ -183,7 +187,8 @@ 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
> +# (not in-tree: BSD "ln -sf" would turn the Makefile into a loop)
> +if test "${SRCDIR}" != "$(pwd)"; then
>       echo "linking Makefile..."
>       BUILD_INC="-I $(pwd)"
>       ln -sf "${SRCDIR}/Makefile" .

Maybe better to match qemu:

# Preferred compiler:
#  ${CC} (if set)
#  ${cross_prefix}gcc (if cross-prefix specified)
#  system compiler
if test -z "${CC}${cross_prefix}"; then
   cc="cc"
else
   cc="${CC-${cross_prefix}gcc}"
fi


r~