commit: 28a40f1004ea3b35cc156788cbfb3aef901335c9
parent 6e35702085fd059b6ce5849a5771193085275073
Author: Haelwenn (lanodan) Monnier <contact@hacktivis.me>
Date: Wed, 29 May 2024 15:15:55 +0200
Switch from makeless.sh to a simpler bootstrap.sh
Diffstat:
5 files changed, 52 insertions(+), 89 deletions(-)
diff --git a/README.md b/README.md
@@ -11,7 +11,7 @@ Developed on Linux+musl, automatically tested on FreeBSD and NetBSD thanks to [S
- C99 Compiler + POSIX C Library
- POSIX yacc(1) implementation
- POSIX Shell
-- POSIX Make (optional, see `makeless.sh`)
+- POSIX Make
- (optional, test) ATF: <https://github.com/jmmv/atf>
- (optional, test) Kyua: <https://github.com/jmmv/kyua>
- (optional, test) bwrap: <https://github.com/containers/bubblewrap/> For safely overlaying false files on the root filesystem
@@ -23,6 +23,7 @@ Developed on Linux+musl, automatically tested on FreeBSD and NetBSD thanks to [S
- The `./configure` script isn't auto*hell based, you can pass it arguments via key-value arguments or environment variables
- You can define the `NO_BWRAP` environment variable to skip the bwrap-based tests which can cause issues in some environments like Gentoo `sandbox`
- If you want statically linked executables, pass `LDSTATIC=-static` to configure (environment or argument)
+- `./bootstrap.sh` will compile the few utilities used by `./configure` for you
## Design differences
- All programs prefix their messages with their name. This way you don't end up with context-less messages in scripts.
diff --git a/bootstrap-regen.sh b/bootstrap-regen.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+# SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
+# SPDX-License-Identifier: MPL-2.0
+
+# List of commands used by ./configure
+#
+# Can be checked with:
+# $ strace -o configure.strace -f -e execve ./configure
+# $ grep -F -e 'execve(' configure.strace | cut -f2 -d '"' | xargs -n1 basename | sort -u
+#commands="cat grep printf rm sed tr"
+commands="cat printf rm tr"
+targets="$(printf 'cmd/%s ' $commands)"
+
+make clean
+(
+ printf '#!/bin/sh
+# SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
+# SPDX-License-Identifier: MPL-2.0
+# Generated using ./bootstrap-regen.sh
+: ${CC:=cc}
+: ${YACC:=yacc}
+: ${CFLAGS:=-Os -Wall}
+
+set -ex
+
+'
+ make -n CC='$$CC' CFLAGS='$$CFLAGS' LDFLAGS='$$LDFLAGS' LDSTATIC='$$LDSTATIC' YACC='$$YACC' $targets | grep -vF .c.gcov
+
+ printf "
+./cmd/printf '\\nDone, you should now be able to run PATH=cmd/:\$PATH ./configure\\n'
+"
+)> bootstrap.sh
diff --git a/bootstrap.sh b/bootstrap.sh
@@ -0,0 +1,18 @@
+#!/bin/sh
+# SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
+# SPDX-License-Identifier: MPL-2.0
+# Generated using ./bootstrap-regen.sh
+: ${CC:=cc}
+: ${YACC:=yacc}
+: ${CFLAGS:=-Os -Wall}
+
+set -ex
+
+$CC -std=c99 $CFLAGS -o cmd/cat cmd/cat.c $LDFLAGS $LDSTATIC
+$CC -std=c99 $CFLAGS -o cmd/printf cmd/printf.c $LDFLAGS $LDSTATIC
+$CC -std=c99 $CFLAGS -o cmd/rm cmd/rm.c lib/consent.c $LDFLAGS $LDSTATIC
+$CC -std=c99 $CFLAGS -o cmd/tr cmd/tr.c lib/tr_str.c $LDFLAGS $LDSTATIC
+
+printf '
+Done, you should now be able to run PATH=cmd/:$PATH ./configure
+'
diff --git a/makeless-regen.sh b/makeless-regen.sh
@@ -1,21 +0,0 @@
-#!/bin/sh
-# SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
-# SPDX-License-Identifier: MPL-2.0
-
-make clean
-(
- printf '#!/bin/sh
-# SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
-# SPDX-License-Identifier: MPL-2.0
-# Generated using ./makeless-regen.sh
-# Intended to make it easier to bootstrap a working system, not for regular usage
-: ${CC:=cc}
-: ${YACC:=yacc}
-: ${CFLAGS:=-Os -Wall}
-: ${M4:=m4}
-
-set -ex
-
-'
- make -n CC='$$CC' CFLAGS='$$CFLAGS' LDFLAGS='$$LDFLAGS' LDSTATIC='$$LDSTATIC' YACC='$$YACC' M4='$$M4' | grep -vF .c.gcov
-)> makeless.sh
diff --git a/makeless.sh b/makeless.sh
@@ -1,67 +0,0 @@
-#!/bin/sh
-# SPDX-FileCopyrightText: 2017 Haelwenn (lanodan) Monnier <contact+utils@hacktivis.me>
-# SPDX-License-Identifier: MPL-2.0
-# Generated using ./makeless-regen.sh
-# Intended to make it easier to bootstrap a working system, not for regular usage
-: ${CC:=cc}
-: ${YACC:=yacc}
-: ${CFLAGS:=-Os -Wall}
-: ${M4:=m4}
-
-set -ex
-
-$CC -std=c99 $CFLAGS -o cmd/arch cmd/arch.c $LDFLAGS $LDSTATIC
-$CC -std=c99 $CFLAGS -o cmd/base64 cmd/base64.c $LDFLAGS $LDSTATIC
-$CC -std=c99 $CFLAGS -o cmd/basename cmd/basename.c $LDFLAGS $LDSTATIC
-$CC -std=c99 $CFLAGS -o cmd/cat cmd/cat.c $LDFLAGS $LDSTATIC
-$CC -std=c99 $CFLAGS -o cmd/chmod cmd/chmod.c lib/mode.c lib/symbolize_mode.c $LDFLAGS $LDSTATIC
-$CC -std=c99 $CFLAGS -o cmd/chown cmd/chown.c lib/fs.c lib/user_group_parse.c $LDFLAGS $LDSTATIC
-$CC -std=c99 $CFLAGS -o cmd/chroot cmd/chroot.c $LDFLAGS $LDSTATIC
-$CC -std=c99 $CFLAGS -o cmd/cmp cmd/cmp.c $LDFLAGS $LDSTATIC
-$CC -std=c99 $CFLAGS -o cmd/date cmd/date.c lib/iso_parse.c $LDFLAGS $LDSTATIC
-$CC -std=c99 $CFLAGS -o cmd/df cmd/df.c lib/humanize.c $LDFLAGS $LDSTATIC
-$CC -std=c99 $CFLAGS -o cmd/dirname cmd/dirname.c $LDFLAGS $LDSTATIC
-$CC -std=c99 $CFLAGS -o cmd/echo cmd/echo.c $LDFLAGS $LDSTATIC
-$CC -std=c99 $CFLAGS -o cmd/env cmd/env.c $LDFLAGS $LDSTATIC
-$CC -std=c99 $CFLAGS -o cmd/false cmd/false.c $LDFLAGS $LDSTATIC
-$CC -std=c99 $CFLAGS -o cmd/head cmd/head.c lib/truncation.c $LDFLAGS $LDSTATIC
-$CC -std=c99 $CFLAGS -o cmd/id cmd/id.c $LDFLAGS $LDSTATIC
-$CC -std=c99 $CFLAGS -o cmd/install cmd/install.c lib/mode.c lib/user_group_parse.c lib/fs.c lib/mkdir.c $LDFLAGS $LDSTATIC
-$CC -std=c99 $CFLAGS -o cmd/link cmd/link.c $LDFLAGS $LDSTATIC
-$CC -std=c99 $CFLAGS -o cmd/ln cmd/ln.c $LDFLAGS $LDSTATIC
-$CC -std=c99 $CFLAGS -o cmd/logname cmd/logname.c $LDFLAGS $LDSTATIC
-$CC -std=c99 $CFLAGS -o cmd/mkdir cmd/mkdir.c lib/mode.c lib/mkdir.c $LDFLAGS $LDSTATIC
-$CC -std=c99 $CFLAGS -o cmd/mkfifo cmd/mkfifo.c lib/mode.c $LDFLAGS $LDSTATIC
-$CC -std=c99 $CFLAGS -o cmd/mknod cmd/mknod.c lib/mode.c $LDFLAGS $LDSTATIC
-$CC -std=c99 $CFLAGS -o cmd/mv cmd/mv.c lib/consent.c lib/fs.c $LDFLAGS $LDSTATIC
-$CC -std=c99 $CFLAGS -o cmd/nice cmd/nice.c $LDFLAGS $LDSTATIC
-$CC -std=c99 $CFLAGS -o cmd/nohup cmd/nohup.c $LDFLAGS $LDSTATIC
-$CC -std=c99 $CFLAGS -o cmd/nproc cmd/nproc.c $LDFLAGS $LDSTATIC
-$CC -std=c99 $CFLAGS -o cmd/pathchk cmd/pathchk.c $LDFLAGS $LDSTATIC
-$CC -std=c99 $CFLAGS -o cmd/printf cmd/printf.c $LDFLAGS $LDSTATIC
-$CC -std=c99 $CFLAGS -o cmd/pwd cmd/pwd.c $LDFLAGS $LDSTATIC
-$CC -std=c99 $CFLAGS -o cmd/realpath cmd/realpath.c lib/fs.c $LDFLAGS $LDSTATIC
-$CC -std=c99 $CFLAGS -o cmd/rm cmd/rm.c lib/consent.c $LDFLAGS $LDSTATIC
-$CC -std=c99 $CFLAGS -o cmd/rmdir cmd/rmdir.c $LDFLAGS $LDSTATIC
-$CC -std=c99 $CFLAGS -o cmd/seq cmd/seq.c -lm $LDFLAGS $LDSTATIC
-$CC -std=c99 $CFLAGS -o cmd/sleep cmd/sleep.c lib/strtodur.c $LDFLAGS $LDSTATIC
-$CC -std=c99 $CFLAGS -o cmd/strings cmd/strings.c $LDFLAGS $LDSTATIC
-$CC -std=c99 $CFLAGS -o cmd/sync cmd/sync.c $LDFLAGS $LDSTATIC
-$CC -std=c99 $CFLAGS -o cmd/tee cmd/tee.c $LDFLAGS $LDSTATIC
-$CC -std=c99 $CFLAGS -o cmd/test cmd/test.c $LDFLAGS $LDSTATIC
-$CC -std=c99 $CFLAGS -o cmd/time cmd/time.c $LDFLAGS $LDSTATIC
-$CC -std=c99 $CFLAGS -o cmd/timeout cmd/timeout.c lib/strtodur.c $LDFLAGS $LDSTATIC
-$CC -std=c99 $CFLAGS -o cmd/touch cmd/touch.c lib/iso_parse.c $LDFLAGS $LDSTATIC
-$CC -std=c99 $CFLAGS -o cmd/tr cmd/tr.c lib/tr_str.c $LDFLAGS $LDSTATIC
-$CC -std=c99 $CFLAGS -o cmd/true cmd/true.c $LDFLAGS $LDSTATIC
-$CC -std=c99 $CFLAGS -o cmd/truncate cmd/truncate.c lib/truncation.c $LDFLAGS $LDSTATIC
-$CC -std=c99 $CFLAGS -o cmd/tty cmd/tty.c $LDFLAGS $LDSTATIC
-$CC -std=c99 $CFLAGS -o cmd/uname cmd/uname.c $LDFLAGS $LDSTATIC
-$CC -std=c99 $CFLAGS -o cmd/uniq cmd/uniq.c $LDFLAGS $LDSTATIC
-$CC -std=c99 $CFLAGS -o cmd/unlink cmd/unlink.c $LDFLAGS $LDSTATIC
-$CC -std=c99 $CFLAGS -o cmd/wc cmd/wc.c $LDFLAGS $LDSTATIC
-$CC -std=c99 $CFLAGS -o cmd/which cmd/which.c $LDFLAGS $LDSTATIC
-$YACC -b cmd/expr cmd/expr.y
-$CC -std=c99 $CFLAGS -o cmd/expr cmd/expr.tab.c $LDFLAGS $LDSTATIC
-$M4 cmd/date.1.in > build/cmd/date.1
-$M4 cmd/touch.1.in > build/cmd/touch.1