diff --git a/.gitignore b/.gitignore index 2f8595f..135fc5e 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ -* -!/* -!/**/Makefile -!/**/*.zig +*.o +*.tar.gz +/bin diff --git a/Makefile b/Makefile index bfd69f1..77c9b3e 100644 --- a/Makefile +++ b/Makefile @@ -1,33 +1,20 @@ NAME=coreutils -VERSION=0.0.1 +VERSION := $(shell cat version.zig | grep "pub const version" | awk '{print $$5}' | sed "s/\"//g" | sed "s/;//") PREFIX=/usr MANPREFIX=${PREFIX}/share/man +PROG=cat cp ls mkdir pwd rm touch +CC=zig build-exe +RELEASE=ReleaseSmall -all: - mkdir bin - cd cat && make && mv cat ../bin && rm -rf cat.o && cd .. - cd cp && make && mv cp ../bin && rm -rf cp.o && cd .. - cd ls && make && mv ls ../bin && rm -rf ls.o && cd .. - cd mkdir && make && mv mkdir ../bin && rm -rf mkdir.o && cd .. - cd pwd && make && mv pwd ../bin && rm -rf pwd.o && cd .. - cd rm && make && mv rm ../bin && rm -rf rm.o && cd .. - cd touch && make && mv touch ../bin && rm -rf touch.o && cd .. +all: ${PROG} + +%: %.zig + mkdir -p bin + ${CC} $< -O ${RELEASE} --name $@ + mv $@ bin + mv $@.o bin clean: - rm -rf bin + rm -rf bin/${PROG} -install: all - mkdir -p ${DESTDIR}${PREFIX}/bin - cp -f bin/* ${DESTDIR}${PREFIX}/bin - chmod 755 ${DESTDIR}${PREFIX}/bin/cat - chmod 755 ${DESTDIR}${PREFIX}/bin/cp - chmod 755 ${DESTDIR}${PREFIX}/bin/ls - chmod 755 ${DESTDIR}${PREFIX}/bin/mkdir - chmod 755 ${DESTDIR}${PREFIX}/bin/pwd - chmod 755 ${DESTDIR}${PREFIX}/bin/rm - chmod 755 ${DESTDIR}${PREFIX}/bin/touch - #mkdir -p ${DESTDIR}${MANPREFIX}/man1 - #sed "s/VERSION/${VERSION}/g" < ${NAME}.1 > ${DESTDIR}${MANPREFIX}/man1/${NAME}.1 - #chmod 644 ${DESTDIR}${MANPREFIX}/man1/${NAME}.1 - -.PHONY: all clean dist install +.PHONY: all clean diff --git a/TODO.md b/TODO.md new file mode 100644 index 0000000..87695f4 --- /dev/null +++ b/TODO.md @@ -0,0 +1,73 @@ +* [ ] awk +* [ ] basename +* [-] cat +* [ ] chmod +* [ ] chown +* [ ] cksum +* [-] cp +* [ ] date +* [ ] dd +* [ ] df +* [ ] diff +* [ ] du +* [ ] echo +* [ ] env +* [ ] grep +* [ ] groups +* [ ] head +* [ ] hostid +* [ ] hostname +* [ ] id +* [ ] install +* [ ] kill +* [ ] ln +* [-] ls +* [ ] md5sum +* [x] mkdir +* [ ] mkfifo +* [ ] mknod +* [ ] mktemp +* [ ] mv +* [ ] nl +* [ ] od +* [ ] pathchk +* [ ] pr +* [ ] printenv +* [ ] ptx +* [x] pwd +* [ ] readlink +* [ ] realpath +* [x] rm +* [ ] rmdir +* [ ] runcon +* [ ] seq +* [ ] shred +* [ ] shuf +* [ ] sleep +* [ ] sort +* [ ] split +* [ ] stat +* [ ] stdbuf +* [ ] stty +* [ ] sum +* [ ] tac +* [ ] tail +* [ ] tee +* [ ] test +* [ ] time +* [ ] timeout +* [-] touch +* [ ] tr +* [ ] truncate +* [ ] tsort +* [ ] tty +* [ ] uname +* [ ] unexpand +* [ ] uniq +* [ ] unlink +* [ ] uptime +* [ ] users +* [ ] vdir +* [ ] wc +* [ ] who +* [ ] whoami diff --git a/cat/cat.zig b/cat.zig similarity index 98% rename from cat/cat.zig rename to cat.zig index 3b1ba71..00fce73 100644 --- a/cat/cat.zig +++ b/cat.zig @@ -2,7 +2,7 @@ const std = @import("std"); const fs = std.fs; const io = std.io; -const version = "1.0.0"; +const version = @import("version.zig").version; fn help() !void { const stdof = io.getStdOut().writer(); diff --git a/cat/Makefile b/cat/Makefile deleted file mode 100644 index 4cd4975..0000000 --- a/cat/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -NAME=cat -VERSION := $(shell cat ../Makefile | grep "VERSION=" | sed 's/VERSION=//') -SRC=${NAME}.zig -CC=zig build-exe -RELEASE=ReleaseSmall - -all: - ${CC} ${SRC} -O ${RELEASE} --name ${NAME} - -clean: - rm -f ${NAME} ${NAME}.o - -.PHONY: all clean diff --git a/cp/cp.zig b/cp.zig similarity index 97% rename from cp/cp.zig rename to cp.zig index 99cacf5..84fe97a 100644 --- a/cp/cp.zig +++ b/cp.zig @@ -2,7 +2,7 @@ const std = @import("std"); const fs = std.fs; const io = std.io; -const version = "1.0.0"; +const version = @import("version.zig").version; fn help() !void { const stdof = io.getStdOut().writer(); diff --git a/cp/Makefile b/cp/Makefile deleted file mode 100644 index d370602..0000000 --- a/cp/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -NAME=cp -VERSION := $(shell cat ../Makefile | grep "VERSION=" | sed 's/VERSION=//') -SRC=${NAME}.zig -CC=zig build-exe -RELEASE=ReleaseSmall - -all: - ${CC} ${SRC} -O ${RELEASE} --name ${NAME} - -clean: - rm -f ${NAME} ${NAME}.o - -.PHONY: all clean diff --git a/ls/ls.zig b/ls.zig similarity index 98% rename from ls/ls.zig rename to ls.zig index 38c59d8..6255121 100644 --- a/ls/ls.zig +++ b/ls.zig @@ -2,7 +2,7 @@ const std = @import("std"); const fs = std.fs; const io = std.io; -const version = "1.0.0"; +const version = @import("version.zig").version; fn help() !void { const stdof = io.getStdOut().writer(); diff --git a/ls/Makefile b/ls/Makefile deleted file mode 100644 index 7dd7691..0000000 --- a/ls/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -NAME=ls -VERSION := $(shell cat ../Makefile | grep "VERSION=" | sed 's/VERSION=//') -SRC=${NAME}.zig -CC=zig build-exe -RELEASE=ReleaseSmall - -all: - ${CC} ${SRC} -O ${RELEASE} --name ${NAME} - -clean: - rm -f ${NAME} ${NAME}.o - -.PHONY: all clean diff --git a/mkdir/mkdir.zig b/mkdir.zig similarity index 98% rename from mkdir/mkdir.zig rename to mkdir.zig index 0e1a60f..b7b15f5 100644 --- a/mkdir/mkdir.zig +++ b/mkdir.zig @@ -2,7 +2,7 @@ const std = @import("std"); const fs = std.fs; const io = std.io; -const version = "1.0.0"; +const version = @import("version.zig").version; fn help() !void { const stdof = io.getStdOut().writer(); diff --git a/mkdir/Makefile b/mkdir/Makefile deleted file mode 100644 index 746c1fc..0000000 --- a/mkdir/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -NAME=mkdir -VERSION := $(shell cat ../Makefile | grep "VERSION=" | sed 's/VERSION=//') -SRC=${NAME}.zig -CC=zig build-exe -RELEASE=ReleaseSmall - -all: - ${CC} ${SRC} -O ${RELEASE} --name ${NAME} - -clean: - rm -f ${NAME} ${NAME}.o - -.PHONY: all clean diff --git a/pwd/pwd.zig b/pwd.zig similarity index 97% rename from pwd/pwd.zig rename to pwd.zig index 23cbb9a..20f4c48 100644 --- a/pwd/pwd.zig +++ b/pwd.zig @@ -3,7 +3,7 @@ const io = std.io; const os = std.os; const fs = std.fs; -const version = "1.0.0"; +const version = @import("version.zig").version; fn help() !void { const stdof = io.getStdOut().writer(); diff --git a/pwd/Makefile b/pwd/Makefile deleted file mode 100644 index e0e663c..0000000 --- a/pwd/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -NAME=pwd -VERSION := $(shell cat ../Makefile | grep "VERSION=" | sed 's/VERSION=//') -SRC=${NAME}.zig -CC=zig build-exe -RELEASE=ReleaseSmall - -all: - ${CC} ${SRC} -O ${RELEASE} --name ${NAME} - -clean: - rm -f ${NAME} ${NAME}.o - -.PHONY: all clean diff --git a/rm/rm.zig b/rm.zig similarity index 98% rename from rm/rm.zig rename to rm.zig index e93a205..c854a8f 100644 --- a/rm/rm.zig +++ b/rm.zig @@ -2,7 +2,7 @@ const std = @import("std"); const fs = std.fs; const io = std.io; -const version = "1.0.0"; +const version = @import("version.zig").version; fn help() !void { const stdof = io.getStdOut().writer(); diff --git a/rm/Makefile b/rm/Makefile deleted file mode 100644 index 5ddfa55..0000000 --- a/rm/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -NAME=rm -VERSION := $(shell cat ../Makefile | grep "VERSION=" | sed 's/VERSION=//') -SRC=${NAME}.zig -CC=zig build-exe -RELEASE=ReleaseSmall - -all: - ${CC} ${SRC} -O ${RELEASE} --name ${NAME} - -clean: - rm -f ${NAME} ${NAME}.o - -.PHONY: all clean diff --git a/touch/touch.zig b/touch.zig similarity index 98% rename from touch/touch.zig rename to touch.zig index 6bd21dc..ac24af5 100644 --- a/touch/touch.zig +++ b/touch.zig @@ -2,7 +2,7 @@ const std = @import("std"); const fs = std.fs; const io = std.io; -const version = "1.0.0"; +const version = @import("version.zig").version; fn help() !void { const stdof = io.getStdOut().writer(); diff --git a/touch/Makefile b/touch/Makefile deleted file mode 100644 index 1e0367a..0000000 --- a/touch/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -NAME=touch -VERSION := $(shell cat ../Makefile | grep "VERSION=" | sed 's/VERSION=//') -SRC=${NAME}.zig -CC=zig build-exe -RELEASE=ReleaseSmall - -all: - ${CC} ${SRC} -O ${RELEASE} --name ${NAME} - -clean: - rm -f ${NAME} ${NAME}.o - -.PHONY: all clean diff --git a/version.zig b/version.zig new file mode 100644 index 0000000..ea47ee0 --- /dev/null +++ b/version.zig @@ -0,0 +1 @@ +pub const version = "0.0.1";