commit 3723295a09071f5e8427d8bbb23263d8a5aaaf13
parent b5d473b4ce7e06541d6c40d1bff6bfdf8645e6c7
Author: evenfri <evenfri256@gmail.com>
Date: Fri, 24 Jul 2026 01:10:27 +0800
update
Diffstat:
11 files changed, 59 insertions(+), 21 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -1,6 +1,8 @@
*.o
*.so
+*.a
*.elf
*.bin
*.tar.xz
build/
+mk/mk
diff --git a/install b/install
@@ -11,4 +11,5 @@ sudo mkdir -p /usr/local/plan9/lib
sudo cp -r mk/mk /usr/local/plan9/bin/
sudo cp -r templates/* /usr/local/plan9/src/
+sudo cp -r wrapers/* /usr/local/plan9/bin/
sudo cp -r lib9/lib9.a /usr/local/plan9/lib/
diff --git a/templates/mkcommon b/templates/mkcommon
@@ -1,13 +1,13 @@
%.$o: $hfiles # don't combine with following %.$o rules
%.$o: %.c
- $cc $cflags -c $stem.c
+ $cc $cflags $stem.c
%.$o: %.cc
- $cc $cflags -c $stem.cc
+ $cc $cflags $stem.cc
%.$o: %.s
- $as $aflags $stem.s
+ $as $aflags $stem.s
nuke:V: nuke-common
clean:V: clean-common
diff --git a/templates/mkfile b/templates/mkfile
@@ -37,7 +37,7 @@ mkmk.sh:VD:
) | sed '
s/'$install'/$install/g
s/'$sysname'/$sysname/g
- s;'$PLAN9';$PLAN9;g
+ s;'$LPLAN9';$LPLAN9;g
' >$target
testmkmk:V:
@@ -54,5 +54,5 @@ testcvs:V:
rm ../lib/*.a
mv ../bin/mk ../bin/_mk
rm ../bin/*
- PLAN9="`pwd`/.." export PLAN9
- PATH=$PLAN9/bin:$PATH export PATH
+ LPLAN9="`pwd`/.." export LPLAN9
+ PATH=$LPLAN9/bin:$PATH export PATH
diff --git a/templates/mkhdr b/templates/mkhdr
@@ -1,7 +1,7 @@
-<$PLAN9/src/mkenv
+<$LPLAN9/src/mkenv
-bin=$PLAN9/bin
-libdir=$PLAN9/lib
+bin=$LPLAN9/bin
+libdir=$LPLAN9/lib
o=o
os=$o
@@ -18,4 +18,4 @@ nukefiles=
lib=
shortlib=
-<|cat $PLAN9/config 2>/dev/null || true
+<|cat $LPLAN9/config 2>/dev/null || true
diff --git a/templates/mklib b/templates/mklib
@@ -11,4 +11,4 @@ all install:V: $lib
cleanfiles=$cleanfiles $lib
-<$PLAN9/src/mkcommon
+<$LPLAN9/src/mkcommon
diff --git a/templates/mkmany b/templates/mkmany
@@ -24,4 +24,4 @@ install:V: many-install
cleanfiles=$cleanfiles $progs
nukefiles=$nukefiles ${targ:%=$bin/%}
-<$PLAN9/src/mkcommon
+<$LPLAN9/src/mkcommon
diff --git a/templates/mkone b/templates/mkone
@@ -14,4 +14,4 @@ $bin/%: $o.%
cleanfiles=$cleanfiles $prog
nukefiles=$nukefiles $bin/$targ
-<$PLAN9/src/mkcommon
+<$LPLAN9/src/mkcommon
diff --git a/templates/mksyslib b/templates/mksyslib
@@ -1,14 +1,14 @@
-default:V: $PLAN9/lib/$lib
+default:V: $LPLAN9/lib/$lib
-$PLAN9/lib/$lib(%):N: %
-$PLAN9/lib/$lib: ${ofiles:%=$PLAN9/lib/$lib(%)}
- $ar rsc $PLAN9/lib/$lib $newmember
+$LPLAN9/lib/$lib(%):N: %
+$LPLAN9/lib/$lib: ${ofiles:%=$LPLAN9/lib/$lib(%)}
+ $ar rsc $LPLAN9/lib/$lib $newmember
&:n: &.$o
- $ar rsc $PLAN9/lib/$lib $stem.$o
+ $ar rsc $LPLAN9/lib/$lib $stem.$o
-all install:V: $PLAN9/lib/$lib
+all install:V: $LPLAN9/lib/$lib
-nukefiles=$nukefiles $PLAN9/lib/$lib
+nukefiles=$nukefiles $LPLAN9/lib/$lib
-<$PLAN9/src/mkcommon
+<$LPLAN9/src/mkcommon
diff --git a/wrapers/as b/wrapers/as
@@ -0,0 +1,16 @@
+#!/bin/sh
+s_file=""
+has_o=""
+
+for arg; do
+ case "$arg" in
+ -o) has_o=1 ;;
+ *.s|*.S) s_file="$arg" ;;
+ esac
+done
+
+if [ -n "$s_file" ] && [ -z "$has_o" ]; then
+ exec /usr/bin/as "$@" -o "${s_file%.*}.o"
+fi
+
+exec /usr/bin/as "$@"
diff --git a/wrapers/cc b/wrapers/cc
@@ -0,0 +1,19 @@
+#!/bin/sh
+c_file=""
+has_o=""
+has_c=""
+
+for arg; do
+ case "$arg" in
+ -o) has_o=1 ;;
+ -c) has_c=1 ;;
+ *.c) c_file="$arg" ;;
+ esac
+done
+
+if [ -n "$c_file" ] && [ -z "$has_o" ]; then
+ [ -z "$has_c" ] && set -- -c "$@"
+ exec /usr/bin/cc "$@" -o "${c_file%.c}.o"
+fi
+
+exec /usr/bin/cc "$@"