From 4cf4468eb452b153d792a30aba70aaf1ab69afb5 Mon Sep 17 00:00:00 2001 From: Your Name Date: Tue, 19 Dec 2023 16:13:27 +0300 Subject: [PATCH] New build system --- Makefile | 11 ---- build.sh | 26 +++++++-- builder/builder.c | 84 ---------------------------- builder/config.h | 24 -------- console-tools/clear/build.sh | 2 + console-tools/{ => clear}/clear.c | 0 console-tools/reset/build.sh | 2 + console-tools/{ => reset}/reset.c | 0 coreutils/{ => basename}/basename.c | 0 coreutils/basename/build.sh | 2 + coreutils/cat/build.sh | 2 + coreutils/{ => cat}/cat.c | 0 coreutils/chgrp/build.sh | 2 + coreutils/{ => chgrp}/chgrp.c | 2 - coreutils/chmod/build.sh | 2 + coreutils/{ => chmod}/chmod.c | 0 coreutils/chown/build.sh | 2 + coreutils/{ => chown}/chown.c | 2 +- coreutils/chroot/build.sh | 2 + coreutils/{ => chroot}/chroot.c | 0 coreutils/cmp/build.sh | 2 + coreutils/{ => cmp}/cmp.c | 0 coreutils/cp/build.sh | 2 + coreutils/{ => cp}/cp.c | 0 coreutils/dirname/build.sh | 2 + coreutils/{ => dirname}/dirname.c | 0 coreutils/du/build.sh | 2 + coreutils/{ => du}/du.c | 0 coreutils/echo/build.sh | 2 + coreutils/{ => echo}/echo.c | 0 coreutils/env/build.sh | 2 + coreutils/{ => env}/env.c | 2 +- coreutils/false/build.sh | 2 + coreutils/{ => false}/false.c | 0 coreutils/head/build.sh | 2 + coreutils/{ => head}/head.c | 0 coreutils/id/build.sh | 2 + coreutils/{ => id}/id.c | 0 coreutils/ln/build.sh | 2 + coreutils/{ => ln}/ln.c | 0 coreutils/logname/build.sh | 2 + coreutils/{ => logname}/logname.c | 0 coreutils/ls/build.sh | 2 + coreutils/{ => ls}/ls.c | 0 coreutils/mkdir/build.sh | 2 + coreutils/{ => mkdir}/mkdir.c | 0 coreutils/mkfifo.c | 21 ------- coreutils/mkfifo/build.sh | 2 + coreutils/mkfifo/mkfifo.c | 52 +++++++++++++++++ coreutils/mknod/build.sh | 2 + coreutils/{ => mknod}/mknod.c | 4 +- coreutils/mktemp/build.sh | 2 + coreutils/{ => mktemp}/mktemp.c | 0 coreutils/mv/build.sh | 2 + coreutils/{ => mv}/mv.c | 0 coreutils/nice/build.sh | 2 + coreutils/{ => nice}/nice.c | 0 coreutils/nl/build.sh | 2 + coreutils/{ => nl}/nl.c | 0 coreutils/nohup/build.sh | 2 + coreutils/{ => nohup}/nohup.c | 0 coreutils/printenv/build.sh | 2 + coreutils/{ => printenv}/printenv.c | 0 coreutils/pwd/build.sh | 2 + coreutils/{ => pwd}/pwd.c | 0 coreutils/renice/build.sh | 2 + coreutils/{ => renice}/renice.c | 0 coreutils/rev/build.sh | 2 + coreutils/{ => rev}/rev.c | 0 coreutils/rm/build.sh | 2 + coreutils/{ => rm}/rm.c | 0 coreutils/shred/build.sh | 2 + coreutils/{ => shred}/shred.c | 0 coreutils/sleep/build.sh | 2 + coreutils/{ => sleep}/sleep.c | 0 coreutils/sync/build.sh | 2 + coreutils/{ => sync}/sync.c | 0 coreutils/tee/build.sh | 2 + coreutils/{ => tee}/tee.c | 0 coreutils/touch/build.sh | 2 + coreutils/{ => touch}/touch.c | 0 coreutils/true/build.sh | 2 + coreutils/{ => true}/true.c | 0 coreutils/tty/build.sh | 2 + coreutils/{ => tty}/tty.c | 0 coreutils/uname/build.sh | 2 + coreutils/{ => uname}/uname.c | 0 coreutils/wc/build.sh | 2 + coreutils/{ => wc}/wc.c | 0 coreutils/whoami/build.sh | 2 + coreutils/{ => whoami}/whoami.c | 0 coreutils/yes/build.sh | 2 + coreutils/{ => yes}/yes.c | 0 findutils/xargs/build.sh | 2 + findutils/{ => xargs}/xargs.c | 0 libmu/mount_opts.h | 13 +++++ libmu/parse_mount.h | 9 +++ loginutils/nologin/build.sh | 2 + loginutils/{ => nologin}/nologin.c | 0 miscutils/spark/build.sh | 2 + miscutils/{ => spark}/spark.c | 0 networking/hostname/build.sh | 2 + networking/{ => hostname}/hostname.c | 0 networking/nc/build.sh | 2 + networking/{ => nc}/nc.c | 0 procps/kill/build.sh | 2 + procps/{ => kill}/kill.c | 0 procps/uptime/build.sh | 2 + procps/{ => uptime}/uptime.c | 0 shell/rc/build.sh | 2 + shell/{ => rc}/rc.c | 0 sysutils-linux/dmesg/build.sh | 2 + sysutils-linux/{ => dmesg}/dmesg.c | 0 sysutils/mount/build.sh | 2 + sysutils/{ => mount}/mount.c | 10 ++-- 115 files changed, 214 insertions(+), 154 deletions(-) delete mode 100644 Makefile delete mode 100644 builder/builder.c delete mode 100644 builder/config.h create mode 100755 console-tools/clear/build.sh rename console-tools/{ => clear}/clear.c (100%) create mode 100755 console-tools/reset/build.sh rename console-tools/{ => reset}/reset.c (100%) rename coreutils/{ => basename}/basename.c (100%) create mode 100755 coreutils/basename/build.sh create mode 100755 coreutils/cat/build.sh rename coreutils/{ => cat}/cat.c (100%) create mode 100755 coreutils/chgrp/build.sh rename coreutils/{ => chgrp}/chgrp.c (99%) create mode 100755 coreutils/chmod/build.sh rename coreutils/{ => chmod}/chmod.c (100%) create mode 100755 coreutils/chown/build.sh rename coreutils/{ => chown}/chown.c (96%) create mode 100755 coreutils/chroot/build.sh rename coreutils/{ => chroot}/chroot.c (100%) create mode 100755 coreutils/cmp/build.sh rename coreutils/{ => cmp}/cmp.c (100%) create mode 100755 coreutils/cp/build.sh rename coreutils/{ => cp}/cp.c (100%) create mode 100755 coreutils/dirname/build.sh rename coreutils/{ => dirname}/dirname.c (100%) create mode 100755 coreutils/du/build.sh rename coreutils/{ => du}/du.c (100%) create mode 100755 coreutils/echo/build.sh rename coreutils/{ => echo}/echo.c (100%) create mode 100755 coreutils/env/build.sh rename coreutils/{ => env}/env.c (89%) create mode 100755 coreutils/false/build.sh rename coreutils/{ => false}/false.c (100%) create mode 100755 coreutils/head/build.sh rename coreutils/{ => head}/head.c (100%) create mode 100755 coreutils/id/build.sh rename coreutils/{ => id}/id.c (100%) create mode 100755 coreutils/ln/build.sh rename coreutils/{ => ln}/ln.c (100%) create mode 100755 coreutils/logname/build.sh rename coreutils/{ => logname}/logname.c (100%) create mode 100755 coreutils/ls/build.sh rename coreutils/{ => ls}/ls.c (100%) create mode 100755 coreutils/mkdir/build.sh rename coreutils/{ => mkdir}/mkdir.c (100%) delete mode 100644 coreutils/mkfifo.c create mode 100755 coreutils/mkfifo/build.sh create mode 100644 coreutils/mkfifo/mkfifo.c create mode 100755 coreutils/mknod/build.sh rename coreutils/{ => mknod}/mknod.c (93%) create mode 100755 coreutils/mktemp/build.sh rename coreutils/{ => mktemp}/mktemp.c (100%) create mode 100755 coreutils/mv/build.sh rename coreutils/{ => mv}/mv.c (100%) create mode 100755 coreutils/nice/build.sh rename coreutils/{ => nice}/nice.c (100%) create mode 100755 coreutils/nl/build.sh rename coreutils/{ => nl}/nl.c (100%) create mode 100755 coreutils/nohup/build.sh rename coreutils/{ => nohup}/nohup.c (100%) create mode 100755 coreutils/printenv/build.sh rename coreutils/{ => printenv}/printenv.c (100%) create mode 100755 coreutils/pwd/build.sh rename coreutils/{ => pwd}/pwd.c (100%) create mode 100755 coreutils/renice/build.sh rename coreutils/{ => renice}/renice.c (100%) create mode 100755 coreutils/rev/build.sh rename coreutils/{ => rev}/rev.c (100%) create mode 100755 coreutils/rm/build.sh rename coreutils/{ => rm}/rm.c (100%) create mode 100755 coreutils/shred/build.sh rename coreutils/{ => shred}/shred.c (100%) create mode 100755 coreutils/sleep/build.sh rename coreutils/{ => sleep}/sleep.c (100%) create mode 100755 coreutils/sync/build.sh rename coreutils/{ => sync}/sync.c (100%) create mode 100755 coreutils/tee/build.sh rename coreutils/{ => tee}/tee.c (100%) create mode 100755 coreutils/touch/build.sh rename coreutils/{ => touch}/touch.c (100%) create mode 100755 coreutils/true/build.sh rename coreutils/{ => true}/true.c (100%) create mode 100755 coreutils/tty/build.sh rename coreutils/{ => tty}/tty.c (100%) create mode 100755 coreutils/uname/build.sh rename coreutils/{ => uname}/uname.c (100%) create mode 100755 coreutils/wc/build.sh rename coreutils/{ => wc}/wc.c (100%) create mode 100755 coreutils/whoami/build.sh rename coreutils/{ => whoami}/whoami.c (100%) create mode 100755 coreutils/yes/build.sh rename coreutils/{ => yes}/yes.c (100%) create mode 100755 findutils/xargs/build.sh rename findutils/{ => xargs}/xargs.c (100%) create mode 100644 libmu/mount_opts.h create mode 100644 libmu/parse_mount.h create mode 100755 loginutils/nologin/build.sh rename loginutils/{ => nologin}/nologin.c (100%) create mode 100755 miscutils/spark/build.sh rename miscutils/{ => spark}/spark.c (100%) create mode 100755 networking/hostname/build.sh rename networking/{ => hostname}/hostname.c (100%) create mode 100755 networking/nc/build.sh rename networking/{ => nc}/nc.c (100%) create mode 100755 procps/kill/build.sh rename procps/{ => kill}/kill.c (100%) create mode 100755 procps/uptime/build.sh rename procps/{ => uptime}/uptime.c (100%) create mode 100755 shell/rc/build.sh rename shell/{ => rc}/rc.c (100%) create mode 100755 sysutils-linux/dmesg/build.sh rename sysutils-linux/{ => dmesg}/dmesg.c (100%) create mode 100755 sysutils/mount/build.sh rename sysutils/{ => mount}/mount.c (84%) diff --git a/Makefile b/Makefile deleted file mode 100644 index 81059e2..0000000 --- a/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -CFLAGS?=-Wall -Wextra -pedantic -Ibuilder -Ilibmu -Os -s -CC?=cc - -all: - $(CC) builder/builder.c $(CFLAGS) -obuild - ./build - rm build - -clean: - rm bin/* - rm build diff --git a/build.sh b/build.sh index 8756d4d..a8fe8f7 100755 --- a/build.sh +++ b/build.sh @@ -1,4 +1,22 @@ -#!/bin/sh -cc builder/builder.c -Wall -Wextra -pedantic -Ibuilder -Ilibmu -Os -s -obuild -./build -rm build +#!/bin/bash +PROJECT_DIR=$(pwd) +CFLAGS="-Wall -Wextra -I$PROJECT_DIR -I$PROJECT_DIR/libmu -lm" +projects="console-tools coreutils sysutils sysutils-linux findutils networking miscutils shell loginutils procps" +CC=cc + +#Compile +for project in $projects; do + echo "Chdir" $project + + for p in $project/*; do + echo " * Makeing" $p + + for i in $p; do + cd $PROJECT_DIR/$i + echo " * Compile" $i + env CC=$CC CFLAGS="$CFLAGS" OUTPUT="-o $PROJECT_DIR"/bin/$(basename $i) ./build.sh + cd $PROJECT_DIR + done + echo + done +done diff --git a/builder/builder.c b/builder/builder.c deleted file mode 100644 index 5bb97e9..0000000 --- a/builder/builder.c +++ /dev/null @@ -1,84 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include "make_path.h" -#include "config.h" - -void remove_suffix(char *base, const char *suffix) { - char *ptr = base + strlen(base) - strlen(suffix); - if (!strcmp(ptr, suffix)) - *ptr = '\0'; -} - -char *MakePath(const char *src, const char *output_dir) { - char *dup = strdup(src); - if (dup == NULL) { - fprintf(stderr, "builder: strdup failed\n"); - exit(1); - } - - remove_suffix(dup, ".c"); - char *new_path = mu_make_path("builder", output_dir, dup); - if (new_path == NULL) { - free(dup); - exit(1); - } - - free(dup); - return new_path; -} - -void Compile(const char *src, const char *output_dir) { - char *path = MakePath(src, output_dir); - printf(CC_FMT, src, path); - - pid_t pid; - if ((pid = fork()) == 0) - execlp(CC, CC, CFLAGS, src, "-o", path, NULL); - - else if (pid == -1) { - fprintf(stderr, "builder: fork failed\n"); - exit(1); - } - - free(path); - - int status = 0; - waitpid(pid, &status, 0); - if (status) - exit(status); -} - -void ListAndCompile(const char *dir, const char *output_dir) { - if (chdir(dir) < 0) { - fprintf(stderr, "builder: %s: %s\n", dir, strerror(errno)); - exit(1); - } - - printf(CHDIR_FMT, dir); - DIR *dp = opendir("."); - - struct dirent *ep; - while ((ep = readdir(dp)) != NULL) { - if (!strcmp(ep->d_name, ".") || !strcmp(ep->d_name, "..")) - continue; - - Compile(ep->d_name, output_dir); - } - - closedir(dp); - chdir(".."); -} - -int main(void) { - for (size_t i = 0; i < sizeof(objects) / sizeof(char *); i++) - ListAndCompile(objects[i], "../bin"); - - return 0; -} diff --git a/builder/config.h b/builder/config.h deleted file mode 100644 index 8d808b1..0000000 --- a/builder/config.h +++ /dev/null @@ -1,24 +0,0 @@ -#ifndef _CONFIG_H -#define _CONFIG_H - -const char *objects[] = { - "console-tools", - "coreutils", - "networking", - "procps", - "findutils", - "sysutils", - "sysutils-linux", - "miscutils", - "shell" -}; - -#define CHDIR_FMT "Making \033[32m%s\033[0m\n" -#define CC_FMT "CC %10s -> %s\n" - -/* Need by spark */ -#define LDFLAGS "-lm" - -#define CFLAGS "-Wall", "-Werror", "-Wextra", "-pedantic", "-flto", "-Os", "-s", "-I../libmu", "-I../", LDFLAGS -#define CC "cc" -#endif diff --git a/console-tools/clear/build.sh b/console-tools/clear/build.sh new file mode 100755 index 0000000..3b2db38 --- /dev/null +++ b/console-tools/clear/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ./*.c $CFLAGS $OUTPUT | xargs $CC diff --git a/console-tools/clear.c b/console-tools/clear/clear.c similarity index 100% rename from console-tools/clear.c rename to console-tools/clear/clear.c diff --git a/console-tools/reset/build.sh b/console-tools/reset/build.sh new file mode 100755 index 0000000..3b2db38 --- /dev/null +++ b/console-tools/reset/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ./*.c $CFLAGS $OUTPUT | xargs $CC diff --git a/console-tools/reset.c b/console-tools/reset/reset.c similarity index 100% rename from console-tools/reset.c rename to console-tools/reset/reset.c diff --git a/coreutils/basename.c b/coreutils/basename/basename.c similarity index 100% rename from coreutils/basename.c rename to coreutils/basename/basename.c diff --git a/coreutils/basename/build.sh b/coreutils/basename/build.sh new file mode 100755 index 0000000..3b2db38 --- /dev/null +++ b/coreutils/basename/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ./*.c $CFLAGS $OUTPUT | xargs $CC diff --git a/coreutils/cat/build.sh b/coreutils/cat/build.sh new file mode 100755 index 0000000..3b2db38 --- /dev/null +++ b/coreutils/cat/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ./*.c $CFLAGS $OUTPUT | xargs $CC diff --git a/coreutils/cat.c b/coreutils/cat/cat.c similarity index 100% rename from coreutils/cat.c rename to coreutils/cat/cat.c diff --git a/coreutils/chgrp/build.sh b/coreutils/chgrp/build.sh new file mode 100755 index 0000000..3b2db38 --- /dev/null +++ b/coreutils/chgrp/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ./*.c $CFLAGS $OUTPUT | xargs $CC diff --git a/coreutils/chgrp.c b/coreutils/chgrp/chgrp.c similarity index 99% rename from coreutils/chgrp.c rename to coreutils/chgrp/chgrp.c index 821b343..2768b04 100644 --- a/coreutils/chgrp.c +++ b/coreutils/chgrp/chgrp.c @@ -82,5 +82,3 @@ int main(int argc, char **argv) { return ret; } - - diff --git a/coreutils/chmod/build.sh b/coreutils/chmod/build.sh new file mode 100755 index 0000000..3b2db38 --- /dev/null +++ b/coreutils/chmod/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ./*.c $CFLAGS $OUTPUT | xargs $CC diff --git a/coreutils/chmod.c b/coreutils/chmod/chmod.c similarity index 100% rename from coreutils/chmod.c rename to coreutils/chmod/chmod.c diff --git a/coreutils/chown/build.sh b/coreutils/chown/build.sh new file mode 100755 index 0000000..3b2db38 --- /dev/null +++ b/coreutils/chown/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ./*.c $CFLAGS $OUTPUT | xargs $CC diff --git a/coreutils/chown.c b/coreutils/chown/chown.c similarity index 96% rename from coreutils/chown.c rename to coreutils/chown/chown.c index bb35c56..86d3266 100644 --- a/coreutils/chown.c +++ b/coreutils/chown/chown.c @@ -90,7 +90,7 @@ int main(int argc, char **argv) { break; default: - printf("chown USER[:[GRP]] [file1 file2...]\n\t[-H If a command line argument is a symbolic link]\n\t[-R Recursive]\n\t[-f Silent]\n"); + printf("chown USER[:[GRP]] [file1 file2...]\n\t[-H If a command line argument is a symbolic link]\n\t[-R Recursive] [-f Silent]\n"); return 0; } } diff --git a/coreutils/chroot/build.sh b/coreutils/chroot/build.sh new file mode 100755 index 0000000..3b2db38 --- /dev/null +++ b/coreutils/chroot/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ./*.c $CFLAGS $OUTPUT | xargs $CC diff --git a/coreutils/chroot.c b/coreutils/chroot/chroot.c similarity index 100% rename from coreutils/chroot.c rename to coreutils/chroot/chroot.c diff --git a/coreutils/cmp/build.sh b/coreutils/cmp/build.sh new file mode 100755 index 0000000..3b2db38 --- /dev/null +++ b/coreutils/cmp/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ./*.c $CFLAGS $OUTPUT | xargs $CC diff --git a/coreutils/cmp.c b/coreutils/cmp/cmp.c similarity index 100% rename from coreutils/cmp.c rename to coreutils/cmp/cmp.c diff --git a/coreutils/cp/build.sh b/coreutils/cp/build.sh new file mode 100755 index 0000000..3b2db38 --- /dev/null +++ b/coreutils/cp/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ./*.c $CFLAGS $OUTPUT | xargs $CC diff --git a/coreutils/cp.c b/coreutils/cp/cp.c similarity index 100% rename from coreutils/cp.c rename to coreutils/cp/cp.c diff --git a/coreutils/dirname/build.sh b/coreutils/dirname/build.sh new file mode 100755 index 0000000..3b2db38 --- /dev/null +++ b/coreutils/dirname/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ./*.c $CFLAGS $OUTPUT | xargs $CC diff --git a/coreutils/dirname.c b/coreutils/dirname/dirname.c similarity index 100% rename from coreutils/dirname.c rename to coreutils/dirname/dirname.c diff --git a/coreutils/du/build.sh b/coreutils/du/build.sh new file mode 100755 index 0000000..3b2db38 --- /dev/null +++ b/coreutils/du/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ./*.c $CFLAGS $OUTPUT | xargs $CC diff --git a/coreutils/du.c b/coreutils/du/du.c similarity index 100% rename from coreutils/du.c rename to coreutils/du/du.c diff --git a/coreutils/echo/build.sh b/coreutils/echo/build.sh new file mode 100755 index 0000000..3b2db38 --- /dev/null +++ b/coreutils/echo/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ./*.c $CFLAGS $OUTPUT | xargs $CC diff --git a/coreutils/echo.c b/coreutils/echo/echo.c similarity index 100% rename from coreutils/echo.c rename to coreutils/echo/echo.c diff --git a/coreutils/env/build.sh b/coreutils/env/build.sh new file mode 100755 index 0000000..3b2db38 --- /dev/null +++ b/coreutils/env/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ./*.c $CFLAGS $OUTPUT | xargs $CC diff --git a/coreutils/env.c b/coreutils/env/env.c similarity index 89% rename from coreutils/env.c rename to coreutils/env/env.c index cca6670..09aa151 100644 --- a/coreutils/env.c +++ b/coreutils/env/env.c @@ -28,6 +28,6 @@ int main(const int argc, char **argv, const char **envp) { } execvp(argv[i], argv + i); - fprintf(stderr, "env: %s\n", strerror(errno)); + fprintf(stderr, "env: %s: %s\n", argv[i], strerror(errno)); return 1; } diff --git a/coreutils/false/build.sh b/coreutils/false/build.sh new file mode 100755 index 0000000..3b2db38 --- /dev/null +++ b/coreutils/false/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ./*.c $CFLAGS $OUTPUT | xargs $CC diff --git a/coreutils/false.c b/coreutils/false/false.c similarity index 100% rename from coreutils/false.c rename to coreutils/false/false.c diff --git a/coreutils/head/build.sh b/coreutils/head/build.sh new file mode 100755 index 0000000..3b2db38 --- /dev/null +++ b/coreutils/head/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ./*.c $CFLAGS $OUTPUT | xargs $CC diff --git a/coreutils/head.c b/coreutils/head/head.c similarity index 100% rename from coreutils/head.c rename to coreutils/head/head.c diff --git a/coreutils/id/build.sh b/coreutils/id/build.sh new file mode 100755 index 0000000..3b2db38 --- /dev/null +++ b/coreutils/id/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ./*.c $CFLAGS $OUTPUT | xargs $CC diff --git a/coreutils/id.c b/coreutils/id/id.c similarity index 100% rename from coreutils/id.c rename to coreutils/id/id.c diff --git a/coreutils/ln/build.sh b/coreutils/ln/build.sh new file mode 100755 index 0000000..3b2db38 --- /dev/null +++ b/coreutils/ln/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ./*.c $CFLAGS $OUTPUT | xargs $CC diff --git a/coreutils/ln.c b/coreutils/ln/ln.c similarity index 100% rename from coreutils/ln.c rename to coreutils/ln/ln.c diff --git a/coreutils/logname/build.sh b/coreutils/logname/build.sh new file mode 100755 index 0000000..3b2db38 --- /dev/null +++ b/coreutils/logname/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ./*.c $CFLAGS $OUTPUT | xargs $CC diff --git a/coreutils/logname.c b/coreutils/logname/logname.c similarity index 100% rename from coreutils/logname.c rename to coreutils/logname/logname.c diff --git a/coreutils/ls/build.sh b/coreutils/ls/build.sh new file mode 100755 index 0000000..3b2db38 --- /dev/null +++ b/coreutils/ls/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ./*.c $CFLAGS $OUTPUT | xargs $CC diff --git a/coreutils/ls.c b/coreutils/ls/ls.c similarity index 100% rename from coreutils/ls.c rename to coreutils/ls/ls.c diff --git a/coreutils/mkdir/build.sh b/coreutils/mkdir/build.sh new file mode 100755 index 0000000..3b2db38 --- /dev/null +++ b/coreutils/mkdir/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ./*.c $CFLAGS $OUTPUT | xargs $CC diff --git a/coreutils/mkdir.c b/coreutils/mkdir/mkdir.c similarity index 100% rename from coreutils/mkdir.c rename to coreutils/mkdir/mkdir.c diff --git a/coreutils/mkfifo.c b/coreutils/mkfifo.c deleted file mode 100644 index adf7158..0000000 --- a/coreutils/mkfifo.c +++ /dev/null @@ -1,21 +0,0 @@ -#include -#include -#include -#include -#include - -int main(const int argc, const char **argv) { - if (argc == 1) { - printf("mkfifo: missing operand\n"); - return 1; - } - - for (int i = 1; i < argc; i++) { - if (mkfifo(argv[i], 0666)) { - fprintf(stderr, "mkfifo: %s %s\n", argv[i], strerror(errno)); - return 1; - } - } - - return 0; -} diff --git a/coreutils/mkfifo/build.sh b/coreutils/mkfifo/build.sh new file mode 100755 index 0000000..3b2db38 --- /dev/null +++ b/coreutils/mkfifo/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ./*.c $CFLAGS $OUTPUT | xargs $CC diff --git a/coreutils/mkfifo/mkfifo.c b/coreutils/mkfifo/mkfifo.c new file mode 100644 index 0000000..3f858d7 --- /dev/null +++ b/coreutils/mkfifo/mkfifo.c @@ -0,0 +1,52 @@ +#include +#include +#include +#include +#include +#include + +long parse_long(const char *str) { + char *ptr = NULL; + long value = strtol(str, &ptr, 10); + + if (*ptr) { + fprintf(stderr, "mkfifo: not a number: %s\n", str); + exit(1); + } + + else if (value < 1) { + fprintf(stderr, "mknod: number is negative: %s\n", str); + exit(1); + } + + return value; +} + +int main(int argc, char **argv) { + mode_t mode = 0666; + + int opt; + while ((opt = getopt(argc, argv, "m:")) != -1) { + switch (opt) { + case 'm': + mode = parse_long(optarg); + break; + + default: + printf("mkfifo [file1 file2...]\n\t[-m Mode]\n"); + return 0; + } + } + + argv += optind; + argc -= optind; + + for (int i = 0; i < argc; i++) { + if (mkfifo(argv[i], mode)) { + fprintf(stderr, "mkfifo: %s %s\n", argv[i], strerror(errno)); + return 1; + } + } + + return 0; +} diff --git a/coreutils/mknod/build.sh b/coreutils/mknod/build.sh new file mode 100755 index 0000000..3b2db38 --- /dev/null +++ b/coreutils/mknod/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ./*.c $CFLAGS $OUTPUT | xargs $CC diff --git a/coreutils/mknod.c b/coreutils/mknod/mknod.c similarity index 93% rename from coreutils/mknod.c rename to coreutils/mknod/mknod.c index 6ea7ec5..5fa1ee5 100644 --- a/coreutils/mknod.c +++ b/coreutils/mknod/mknod.c @@ -10,7 +10,7 @@ #include #include "parse_mode.h" -long parse_int(const char *str) { +long parse_long(const char *str) { char *ptr = NULL; long value = strtol(str, &ptr, 10); @@ -53,7 +53,7 @@ int main(int argc, char **argv) { dev_t dev = 0; if (argc == 4) - dev = makedev(parse_int(argv[2]), parse_int(argv[3])); + dev = makedev(parse_long(argv[2]), parse_long(argv[3])); if (!strncmp("b", argv[1], 1)) mode |= S_IFBLK; diff --git a/coreutils/mktemp/build.sh b/coreutils/mktemp/build.sh new file mode 100755 index 0000000..3b2db38 --- /dev/null +++ b/coreutils/mktemp/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ./*.c $CFLAGS $OUTPUT | xargs $CC diff --git a/coreutils/mktemp.c b/coreutils/mktemp/mktemp.c similarity index 100% rename from coreutils/mktemp.c rename to coreutils/mktemp/mktemp.c diff --git a/coreutils/mv/build.sh b/coreutils/mv/build.sh new file mode 100755 index 0000000..3b2db38 --- /dev/null +++ b/coreutils/mv/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ./*.c $CFLAGS $OUTPUT | xargs $CC diff --git a/coreutils/mv.c b/coreutils/mv/mv.c similarity index 100% rename from coreutils/mv.c rename to coreutils/mv/mv.c diff --git a/coreutils/nice/build.sh b/coreutils/nice/build.sh new file mode 100755 index 0000000..3b2db38 --- /dev/null +++ b/coreutils/nice/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ./*.c $CFLAGS $OUTPUT | xargs $CC diff --git a/coreutils/nice.c b/coreutils/nice/nice.c similarity index 100% rename from coreutils/nice.c rename to coreutils/nice/nice.c diff --git a/coreutils/nl/build.sh b/coreutils/nl/build.sh new file mode 100755 index 0000000..3b2db38 --- /dev/null +++ b/coreutils/nl/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ./*.c $CFLAGS $OUTPUT | xargs $CC diff --git a/coreutils/nl.c b/coreutils/nl/nl.c similarity index 100% rename from coreutils/nl.c rename to coreutils/nl/nl.c diff --git a/coreutils/nohup/build.sh b/coreutils/nohup/build.sh new file mode 100755 index 0000000..3b2db38 --- /dev/null +++ b/coreutils/nohup/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ./*.c $CFLAGS $OUTPUT | xargs $CC diff --git a/coreutils/nohup.c b/coreutils/nohup/nohup.c similarity index 100% rename from coreutils/nohup.c rename to coreutils/nohup/nohup.c diff --git a/coreutils/printenv/build.sh b/coreutils/printenv/build.sh new file mode 100755 index 0000000..3b2db38 --- /dev/null +++ b/coreutils/printenv/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ./*.c $CFLAGS $OUTPUT | xargs $CC diff --git a/coreutils/printenv.c b/coreutils/printenv/printenv.c similarity index 100% rename from coreutils/printenv.c rename to coreutils/printenv/printenv.c diff --git a/coreutils/pwd/build.sh b/coreutils/pwd/build.sh new file mode 100755 index 0000000..3b2db38 --- /dev/null +++ b/coreutils/pwd/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ./*.c $CFLAGS $OUTPUT | xargs $CC diff --git a/coreutils/pwd.c b/coreutils/pwd/pwd.c similarity index 100% rename from coreutils/pwd.c rename to coreutils/pwd/pwd.c diff --git a/coreutils/renice/build.sh b/coreutils/renice/build.sh new file mode 100755 index 0000000..3b2db38 --- /dev/null +++ b/coreutils/renice/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ./*.c $CFLAGS $OUTPUT | xargs $CC diff --git a/coreutils/renice.c b/coreutils/renice/renice.c similarity index 100% rename from coreutils/renice.c rename to coreutils/renice/renice.c diff --git a/coreutils/rev/build.sh b/coreutils/rev/build.sh new file mode 100755 index 0000000..3b2db38 --- /dev/null +++ b/coreutils/rev/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ./*.c $CFLAGS $OUTPUT | xargs $CC diff --git a/coreutils/rev.c b/coreutils/rev/rev.c similarity index 100% rename from coreutils/rev.c rename to coreutils/rev/rev.c diff --git a/coreutils/rm/build.sh b/coreutils/rm/build.sh new file mode 100755 index 0000000..3b2db38 --- /dev/null +++ b/coreutils/rm/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ./*.c $CFLAGS $OUTPUT | xargs $CC diff --git a/coreutils/rm.c b/coreutils/rm/rm.c similarity index 100% rename from coreutils/rm.c rename to coreutils/rm/rm.c diff --git a/coreutils/shred/build.sh b/coreutils/shred/build.sh new file mode 100755 index 0000000..3b2db38 --- /dev/null +++ b/coreutils/shred/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ./*.c $CFLAGS $OUTPUT | xargs $CC diff --git a/coreutils/shred.c b/coreutils/shred/shred.c similarity index 100% rename from coreutils/shred.c rename to coreutils/shred/shred.c diff --git a/coreutils/sleep/build.sh b/coreutils/sleep/build.sh new file mode 100755 index 0000000..3b2db38 --- /dev/null +++ b/coreutils/sleep/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ./*.c $CFLAGS $OUTPUT | xargs $CC diff --git a/coreutils/sleep.c b/coreutils/sleep/sleep.c similarity index 100% rename from coreutils/sleep.c rename to coreutils/sleep/sleep.c diff --git a/coreutils/sync/build.sh b/coreutils/sync/build.sh new file mode 100755 index 0000000..3b2db38 --- /dev/null +++ b/coreutils/sync/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ./*.c $CFLAGS $OUTPUT | xargs $CC diff --git a/coreutils/sync.c b/coreutils/sync/sync.c similarity index 100% rename from coreutils/sync.c rename to coreutils/sync/sync.c diff --git a/coreutils/tee/build.sh b/coreutils/tee/build.sh new file mode 100755 index 0000000..3b2db38 --- /dev/null +++ b/coreutils/tee/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ./*.c $CFLAGS $OUTPUT | xargs $CC diff --git a/coreutils/tee.c b/coreutils/tee/tee.c similarity index 100% rename from coreutils/tee.c rename to coreutils/tee/tee.c diff --git a/coreutils/touch/build.sh b/coreutils/touch/build.sh new file mode 100755 index 0000000..3b2db38 --- /dev/null +++ b/coreutils/touch/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ./*.c $CFLAGS $OUTPUT | xargs $CC diff --git a/coreutils/touch.c b/coreutils/touch/touch.c similarity index 100% rename from coreutils/touch.c rename to coreutils/touch/touch.c diff --git a/coreutils/true/build.sh b/coreutils/true/build.sh new file mode 100755 index 0000000..3b2db38 --- /dev/null +++ b/coreutils/true/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ./*.c $CFLAGS $OUTPUT | xargs $CC diff --git a/coreutils/true.c b/coreutils/true/true.c similarity index 100% rename from coreutils/true.c rename to coreutils/true/true.c diff --git a/coreutils/tty/build.sh b/coreutils/tty/build.sh new file mode 100755 index 0000000..3b2db38 --- /dev/null +++ b/coreutils/tty/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ./*.c $CFLAGS $OUTPUT | xargs $CC diff --git a/coreutils/tty.c b/coreutils/tty/tty.c similarity index 100% rename from coreutils/tty.c rename to coreutils/tty/tty.c diff --git a/coreutils/uname/build.sh b/coreutils/uname/build.sh new file mode 100755 index 0000000..3b2db38 --- /dev/null +++ b/coreutils/uname/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ./*.c $CFLAGS $OUTPUT | xargs $CC diff --git a/coreutils/uname.c b/coreutils/uname/uname.c similarity index 100% rename from coreutils/uname.c rename to coreutils/uname/uname.c diff --git a/coreutils/wc/build.sh b/coreutils/wc/build.sh new file mode 100755 index 0000000..3b2db38 --- /dev/null +++ b/coreutils/wc/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ./*.c $CFLAGS $OUTPUT | xargs $CC diff --git a/coreutils/wc.c b/coreutils/wc/wc.c similarity index 100% rename from coreutils/wc.c rename to coreutils/wc/wc.c diff --git a/coreutils/whoami/build.sh b/coreutils/whoami/build.sh new file mode 100755 index 0000000..3b2db38 --- /dev/null +++ b/coreutils/whoami/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ./*.c $CFLAGS $OUTPUT | xargs $CC diff --git a/coreutils/whoami.c b/coreutils/whoami/whoami.c similarity index 100% rename from coreutils/whoami.c rename to coreutils/whoami/whoami.c diff --git a/coreutils/yes/build.sh b/coreutils/yes/build.sh new file mode 100755 index 0000000..3b2db38 --- /dev/null +++ b/coreutils/yes/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ./*.c $CFLAGS $OUTPUT | xargs $CC diff --git a/coreutils/yes.c b/coreutils/yes/yes.c similarity index 100% rename from coreutils/yes.c rename to coreutils/yes/yes.c diff --git a/findutils/xargs/build.sh b/findutils/xargs/build.sh new file mode 100755 index 0000000..3b2db38 --- /dev/null +++ b/findutils/xargs/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ./*.c $CFLAGS $OUTPUT | xargs $CC diff --git a/findutils/xargs.c b/findutils/xargs/xargs.c similarity index 100% rename from findutils/xargs.c rename to findutils/xargs/xargs.c diff --git a/libmu/mount_opts.h b/libmu/mount_opts.h new file mode 100644 index 0000000..a28ec0e --- /dev/null +++ b/libmu/mount_opts.h @@ -0,0 +1,13 @@ +#ifndef _MOUNT_OPTS_H +#define _MOUNT_OPTS_H + +typedef struct { + char *title; + unsigned long opt +} MU_OPTS + +MU_OPTS mu_mount_opts[] = { + {"ro", }, +} + +#endif diff --git a/libmu/parse_mount.h b/libmu/parse_mount.h new file mode 100644 index 0000000..b83bacf --- /dev/null +++ b/libmu/parse_mount.h @@ -0,0 +1,9 @@ +#ifndef _PARSE_MOUNT_H +#define _PARSE_MOUNT_H + +unsigned long mu_parse_opts(const char *str) { + (void)str; + return 0; +} + +#endif diff --git a/loginutils/nologin/build.sh b/loginutils/nologin/build.sh new file mode 100755 index 0000000..3b2db38 --- /dev/null +++ b/loginutils/nologin/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ./*.c $CFLAGS $OUTPUT | xargs $CC diff --git a/loginutils/nologin.c b/loginutils/nologin/nologin.c similarity index 100% rename from loginutils/nologin.c rename to loginutils/nologin/nologin.c diff --git a/miscutils/spark/build.sh b/miscutils/spark/build.sh new file mode 100755 index 0000000..3b2db38 --- /dev/null +++ b/miscutils/spark/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ./*.c $CFLAGS $OUTPUT | xargs $CC diff --git a/miscutils/spark.c b/miscutils/spark/spark.c similarity index 100% rename from miscutils/spark.c rename to miscutils/spark/spark.c diff --git a/networking/hostname/build.sh b/networking/hostname/build.sh new file mode 100755 index 0000000..3b2db38 --- /dev/null +++ b/networking/hostname/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ./*.c $CFLAGS $OUTPUT | xargs $CC diff --git a/networking/hostname.c b/networking/hostname/hostname.c similarity index 100% rename from networking/hostname.c rename to networking/hostname/hostname.c diff --git a/networking/nc/build.sh b/networking/nc/build.sh new file mode 100755 index 0000000..3b2db38 --- /dev/null +++ b/networking/nc/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ./*.c $CFLAGS $OUTPUT | xargs $CC diff --git a/networking/nc.c b/networking/nc/nc.c similarity index 100% rename from networking/nc.c rename to networking/nc/nc.c diff --git a/procps/kill/build.sh b/procps/kill/build.sh new file mode 100755 index 0000000..3b2db38 --- /dev/null +++ b/procps/kill/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ./*.c $CFLAGS $OUTPUT | xargs $CC diff --git a/procps/kill.c b/procps/kill/kill.c similarity index 100% rename from procps/kill.c rename to procps/kill/kill.c diff --git a/procps/uptime/build.sh b/procps/uptime/build.sh new file mode 100755 index 0000000..3b2db38 --- /dev/null +++ b/procps/uptime/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ./*.c $CFLAGS $OUTPUT | xargs $CC diff --git a/procps/uptime.c b/procps/uptime/uptime.c similarity index 100% rename from procps/uptime.c rename to procps/uptime/uptime.c diff --git a/shell/rc/build.sh b/shell/rc/build.sh new file mode 100755 index 0000000..3b2db38 --- /dev/null +++ b/shell/rc/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ./*.c $CFLAGS $OUTPUT | xargs $CC diff --git a/shell/rc.c b/shell/rc/rc.c similarity index 100% rename from shell/rc.c rename to shell/rc/rc.c diff --git a/sysutils-linux/dmesg/build.sh b/sysutils-linux/dmesg/build.sh new file mode 100755 index 0000000..3b2db38 --- /dev/null +++ b/sysutils-linux/dmesg/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ./*.c $CFLAGS $OUTPUT | xargs $CC diff --git a/sysutils-linux/dmesg.c b/sysutils-linux/dmesg/dmesg.c similarity index 100% rename from sysutils-linux/dmesg.c rename to sysutils-linux/dmesg/dmesg.c diff --git a/sysutils/mount/build.sh b/sysutils/mount/build.sh new file mode 100755 index 0000000..3b2db38 --- /dev/null +++ b/sysutils/mount/build.sh @@ -0,0 +1,2 @@ +#!/bin/sh +echo ./*.c $CFLAGS $OUTPUT | xargs $CC diff --git a/sysutils/mount.c b/sysutils/mount/mount.c similarity index 84% rename from sysutils/mount.c rename to sysutils/mount/mount.c index e749aed..d9972d3 100644 --- a/sysutils/mount.c +++ b/sysutils/mount/mount.c @@ -4,7 +4,7 @@ #include #include #include -#include +#include "parse_mount.h" #include "config.h" int do_mount(const char *src, const char *dst, const char *fs_type, unsigned long opt) { @@ -47,9 +47,10 @@ void parse_fstab(void) { int main(int argc, char **argv) { char *fs_type = MOUNT_DEF_FS; + unsigned long mode = 0; int opt; - while ((opt = getopt(argc, argv, "t:ao")) != -1) { + while ((opt = getopt(argc, argv, "t:ao:")) != -1) { switch (opt) { case 'a': parse_fstab(); @@ -60,6 +61,7 @@ int main(int argc, char **argv) { break; case 'o': + mode = mu_parse_opts(optarg); break; default: @@ -72,10 +74,10 @@ int main(int argc, char **argv) { argv += optind; if (argc == 2) - return do_mount(argv[0], argv[1], fs_type, 0); + return do_mount(argv[0], argv[1], fs_type, mode); else if (argc == 1) - return do_mount(fs_type, argv[0], fs_type, 0); + return do_mount(NULL, argv[0], fs_type, mode); return 0; }