From 8682553498d32d3c18dea41c598ab40de18404a3 Mon Sep 17 00:00:00 2001 From: user Date: Thu, 16 Jul 2026 07:30:34 +0200 Subject: tools: wc, head, and an argc/argv demo (args) + libc.c helpers - c/libc.c: shared C helpers linked into every program - putu (print decimal), atou (parse decimal), argv_parse (tokenize getargs() into argc/argv). - wc: count lines/words/chars of stdin. head [n]: first n lines (drains rest to EOF). args: argc/argv demo. - pid now uses libc putu; build.sh links libc.c; Makefile CBLOBS + libc dep. - README: document the new tools + argv_parse. - verified: 'args one two three' -> argc=3/argv[..]; wc '2 3 16'; head 2. --- Makefile | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 4d59135..857cc0a 100644 --- a/Makefile +++ b/Makefile @@ -19,9 +19,12 @@ $(BUILD)/%.o: src/%.asm | $(BUILD) # C programs: compiled with SDCC into ROM-bank blobs and INCBIN'd by programs.asm CBLOBS := c/chello.bin c/echo.bin c/true.bin c/false.bin c/uname.bin \ - c/pid.bin c/cat.bin + c/pid.bin c/cat.bin c/wc.bin c/head.bin c/args.bin $(BUILD)/programs.o: $(CBLOBS) +# C programs also depend on the shared libc sources +$(CBLOBS): c/libc.c c/gbos.h + c/%.bin: c/%.c c/crt0.s c/libc.s c/build.sh sh c/build.sh $< $@ -- cgit v1.3.1-sl0p