diff options
author | Vladimir Azarov <avm@intermediate-node.net> | 2024-11-27 20:55:42 +0100 |
---|---|---|
committer | Vladimir Azarov <avm@intermediate-node.net> | 2024-11-27 22:10:44 +0100 |
commit | 06e5eea08d5c06fcca00a469608b288696ae81d1 (patch) | |
tree | 2d48b0542d36104fbaa73be50f28953990e9f27b /configure | |
parent | f7789809675968b753f9b40e298d23b2f7ab4c61 (diff) |
Include directive. Variable assignment from environment
Diffstat (limited to 'configure')
-rwxr-xr-x | configure | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/configure b/configure new file mode 100755 index 0000000..4fe0876 --- /dev/null +++ b/configure @@ -0,0 +1,64 @@ +#!/bin/sh -e + +# +# This file is part of musl-mod: modified version of Musl libc library. +# musl-mod in general and this file specifically are available under +# MIT license. See COPYRIGHT file. +# + +defined() { + [ x"$2" = x ] && echo $1 is undefined && exit 1 + echo $1 = $2 +} + +pexec() { + echo $@ + $@ +} + +print_help() { + cat <<EOF +$0: configuration script for compiling musl + --help print this help + --prefix=<dir> directory where to install musl +EOF + exit 0 +} + +prefix=/tmp + +for arg; do + case $arg in + --prefix=*) + prefix=${arg#--prefix=} + ;; + --help) + print_help + ;; + *) + echo $args: unknown argument && exit 1 + ;; + esac +done + +: ${CC:=gcc} +: ${LD:=ld} + +arch=x86_64 + +gcc_prefix=$(dirname $(gcc -print-libgcc-file-name)) + +tool_cflags="-Wall -nostdinc -Wno-main \ + -ffreestanding -fno-pic -fno-stack-protector \ + -Igenerated/include -Iarch/$arch \ + -I${gcc_prefix}/include -Iarch/generic" + +cflags="$tool_cflags $CFLAGS" + +echo prefix = $prefix >config.mk + +[ -f tools/musl-make ] && exit 0 + +pexec $CC $cflags -c -o tools/common.o tools/common.c +pexec $CC $cflags -c -o tools/musl-make.o tools/musl-make.c +pexec $LD -nostdlib -o tools/musl-make tools/musl-make.o tools/common.o |