summaryrefslogtreecommitdiff
path: root/compile_make.sh
diff options
context:
space:
mode:
authorVladimir Azarov <avm@intermediate-node.net>2024-11-05 20:24:40 +0100
committerVladimir Azarov <avm@intermediate-node.net>2024-11-05 21:49:55 +0100
commitf777f6a9450d2bd5fc7ec531e6fb69f79942499a (patch)
treedc33cd941f49708274a74548862ba7b133013c55 /compile_make.sh
parent3972268b97b789a8212ea9bc7d1b9ce9905a68d8 (diff)
Musl make
Diffstat (limited to 'compile_make.sh')
-rwxr-xr-xcompile_make.sh29
1 files changed, 29 insertions, 0 deletions
diff --git a/compile_make.sh b/compile_make.sh
new file mode 100755
index 0000000..78bc6c0
--- /dev/null
+++ b/compile_make.sh
@@ -0,0 +1,29 @@
+#!/bin/sh -e
+
+defined() {
+ [ x"$2" = x ] && echo $1 is undefined && exit 1
+ echo $1 = $2
+}
+
+pexec() {
+ echo $@
+ $@
+}
+
+defined CC "$CC"
+defined 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"
+
+pexec $CC $cflags -c -o tools/common.o tools/common.c
+pexec $CC $cflags -c -o tools/make.o tools/make.c
+pexec $LD -nostdlib -o tools/make tools/make.o tools/common.o