From 054d5a8bb4f776188fed5ffab9ed44e98f1e11fc Mon Sep 17 00:00:00 2001 From: apio Date: Tue, 8 Nov 2022 18:03:43 +0100 Subject: [PATCH] Build system: Prettify build --- Makefile | 22 +++++++++++----------- apps/Makefile | 6 ++++-- kernel/Makefile | 32 +++++++++++++++++++++----------- libs/libc/Makefile | 33 ++++++++++++++++++++++----------- tools/buildstep.sh | 9 +++++++++ tools/sync-libc.sh | 6 ++++-- 6 files changed, 71 insertions(+), 37 deletions(-) create mode 100755 tools/buildstep.sh diff --git a/Makefile b/Makefile index 99ad75e9..2eb69633 100644 --- a/Makefile +++ b/Makefile @@ -5,22 +5,22 @@ AR := x86_64-luna-ar LD := x86_64-luna-ld build: - tools/sync-libc.sh - @$(MAKE) -C kernel build - @$(MAKE) -C libs build - @$(MAKE) -C apps build + +@tools/sync-libc.sh + +@tools/buildstep.sh kernel build + +@tools/buildstep.sh libs build + +@tools/buildstep.sh apps build clean: initrd-clean - @$(MAKE) -C kernel clean - @$(MAKE) -C libs clean - @$(MAKE) -C apps clean + +@tools/buildstep.sh kernel clean + +@tools/buildstep.sh libs clean + +@tools/buildstep.sh apps clean initrd-clean: rm -f $(LUNA_ROOT)/initrd/boot/moon $(LUNA_ROOT)/Luna.iso rm -rf $(LUNA_ROOT)/initrd/bin install: - @$(MAKE) -C kernel install - @$(MAKE) -C libs install - @$(MAKE) -C apps install - @tools/install-built-ports.sh \ No newline at end of file + +@tools/buildstep.sh kernel install + +@tools/buildstep.sh libs install + +@tools/buildstep.sh apps install + +@tools/install-built-ports.sh \ No newline at end of file diff --git a/apps/Makefile b/apps/Makefile index 66d61d71..0e8c25b3 100644 --- a/apps/Makefile +++ b/apps/Makefile @@ -10,13 +10,15 @@ CFLAGS := -Wall -Wextra -Werror -Os -fno-asynchronous-unwind-tables -ffunction-s $(APPS_BIN)/%: $(APPS_SRC)/%.c @mkdir -p $(@D) - $(CC) $(CFLAGS) -o $@ $^ + @$(CC) $(CFLAGS) -o $@ $^ + @echo " CC $^" build: $(REAL_APPS) install: $(REAL_APPS) @mkdir -p $(LUNA_ROOT)/initrd/bin - cp $(REAL_APPS) $(LUNA_ROOT)/initrd/bin + @cp $(REAL_APPS) $(LUNA_ROOT)/initrd/bin + @echo " INSTALL $(REAL_APPS)" @chmod a+s $(LUNA_ROOT)/initrd/bin/su clean: diff --git a/kernel/Makefile b/kernel/Makefile index bc29af67..14d800c5 100644 --- a/kernel/Makefile +++ b/kernel/Makefile @@ -31,35 +31,43 @@ default: $(MOON_BIN)/moon $(MOON_OBJ)/main.cpp.o: $(MOON_SRC)/main.cpp @mkdir -p $(@D) - $(CXX) $(CFLAGS) -fno-stack-protector $(CXXFLAGS) -o $@ -c $^ + @$(CXX) $(CFLAGS) -fno-stack-protector $(CXXFLAGS) -o $@ -c $^ + @echo " CXX $^" $(MOON_OBJ)/misc/config.cpp.o: $(MOON_SRC)/misc/config.cpp FORCE @mkdir -p $(@D) - $(CXX) $(CFLAGS) $(CXXFLAGS) -o $@ -c $(MOON_SRC)/misc/config.cpp + @$(CXX) $(CFLAGS) $(CXXFLAGS) -o $@ -c $(MOON_SRC)/misc/config.cpp + @echo " CXX $^" $(MOON_OBJ)/init/Init.cpp.o: $(MOON_SRC)/init/Init.cpp @mkdir -p $(@D) - $(CXX) $(CFLAGS) -fno-stack-protector $(CXXFLAGS) -o $@ -c $^ + @$(CXX) $(CFLAGS) -fno-stack-protector $(CXXFLAGS) -o $@ -c $^ + @echo " CXX $^" $(MOON_OBJ)/%.cpp.o: $(MOON_SRC)/%.cpp @mkdir -p $(@D) - $(CXX) $(CFLAGS) $(CXXFLAGS) -o $@ -c $^ + @$(CXX) $(CFLAGS) $(CXXFLAGS) -o $@ -c $^ + @echo " CXX $^" $(MOON_OBJ)/memory/liballoc/liballoc.c.o: $(MOON_SRC)/memory/liballoc/liballoc.c @mkdir -p $(@D) - $(CC) $(CFLAGS) -fno-sanitize=undefined -o $@ -c $^ + @$(CC) $(CFLAGS) -fno-sanitize=undefined -o $@ -c $^ + @echo " CC $^" $(MOON_OBJ)/%.c.o: $(MOON_SRC)/%.c @mkdir -p $(@D) - $(CC) $(CFLAGS) -o $@ -c $^ + @$(CC) $(CFLAGS) -o $@ -c $^ + @echo " CC $^" $(MOON_OBJ)/%.asm.o: $(MOON_SRC)/%.asm @mkdir -p $(@D) - $(ASM) $(ASMFLAGS) -o $@ $^ + @$(ASM) $(ASMFLAGS) -o $@ $^ + @echo " ASM $^" build: $(OBJS) @mkdir -p $(MOON_BIN) - $(CC) $(OBJS) $(LDFLAGS) -o $(MOON_BIN)/moon + @$(CC) $(OBJS) $(LDFLAGS) -o $(MOON_BIN)/moon + @echo " CCLD $(MOON_BIN)/moon" clean: rm -rf $(MOON_OBJ)/* @@ -67,9 +75,11 @@ clean: install: $(MOON_BIN)/moon @mkdir -p $(LUNA_ROOT)/initrd/boot - cp $^ $(LUNA_ROOT)/initrd/boot/moon - $(LUNA_ROOT)/tools/generate-symbols.sh - $(STRIP) $(LUNA_ROOT)/initrd/boot/moon + @cp $^ $(LUNA_ROOT)/initrd/boot/moon + @echo " INSTALL $^" + @$(LUNA_ROOT)/tools/generate-symbols.sh + @$(STRIP) $(LUNA_ROOT)/initrd/boot/moon + @echo " STRIP $(LUNA_ROOT)/initrd/boot/moon" .PHONY: build clean install FORCE FORCE: \ No newline at end of file diff --git a/libs/libc/Makefile b/libs/libc/Makefile index d2b1444b..f36b5579 100644 --- a/libs/libc/Makefile +++ b/libs/libc/Makefile @@ -21,49 +21,60 @@ OBJS += $(patsubst $(LIBC_SRC)/%.asm, $(LIBC_OBJ)/%.asm.o, $(ASM_SRC)) $(LIBC_OBJ)/%.cpp.o: $(LIBC_SRC)/%.cpp @mkdir -p $(@D) - $(CXX) $(CFLAGS) $(CXXFLAGS) -o $@ -c $^ + @$(CXX) $(CFLAGS) $(CXXFLAGS) -o $@ -c $^ + @echo " CXX $^" $(LIBC_OBJ)/%.c.o: $(LIBC_SRC)/%.c @mkdir -p $(@D) - $(CC) $(CFLAGS) -o $@ -c $^ + @$(CC) $(CFLAGS) -o $@ -c $^ + @echo " CC $^" $(LIBC_OBJ)/%.asm.o: $(LIBC_SRC)/%.asm @mkdir -p $(@D) - $(ASM) $(ASMFLAGS) -o $@ $^ + @$(ASM) $(ASMFLAGS) -o $@ $^ + @echo " ASM $^" $(LIBC_BIN)/libc.a: $(OBJS) @mkdir -p $(@D) - $(AR) rcs $@ $(OBJS) + @$(AR) rcs $@ $(OBJS) + @echo " AR $@" $(LIBC_BIN)/crt0.o: $(LIBC_DIR)/crt0.asm @mkdir -p $(@D) - $(ASM) $(ASMFLAGS) -o $@ $^ + @$(ASM) $(ASMFLAGS) -o $@ $^ + @echo " ASM $^" $(LIBC_BIN)/crti.o: $(LIBC_DIR)/crti.asm @mkdir -p $(@D) - $(ASM) $(ASMFLAGS) -o $@ $^ + @$(ASM) $(ASMFLAGS) -o $@ $^ + @echo " ASM $^" $(LIBC_BIN)/crtn.o: $(LIBC_DIR)/crtn.asm @mkdir -p $(@D) - $(ASM) $(ASMFLAGS) -o $@ $^ + @$(ASM) $(ASMFLAGS) -o $@ $^ + @echo " ASM $^" build: $(LIBC_BIN)/crt0.o $(LIBC_BIN)/crti.o $(LIBC_BIN)/crtn.o $(LIBC_BIN)/libc.a $(DESTDIR)/libc.a: $(LIBC_BIN)/libc.a @mkdir -p $(@D) - cp $^ $@ + @cp $^ $@ + @echo " INSTALL $^" $(DESTDIR)/crt0.o: $(LIBC_BIN)/crt0.o @mkdir -p $(@D) - cp $^ $@ + @cp $^ $@ + @echo " INSTALL $^" $(DESTDIR)/crti.o: $(LIBC_BIN)/crti.o @mkdir -p $(@D) - cp $^ $@ + @cp $^ $@ + @echo " INSTALL $^" $(DESTDIR)/crtn.o: $(LIBC_BIN)/crtn.o @mkdir -p $(@D) - cp $^ $@ + @cp $^ $@ + @echo " INSTALL $^" install: $(DESTDIR)/libc.a $(DESTDIR)/crt0.o $(DESTDIR)/crti.o $(DESTDIR)/crtn.o diff --git a/tools/buildstep.sh b/tools/buildstep.sh new file mode 100755 index 00000000..3a5fc095 --- /dev/null +++ b/tools/buildstep.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash + +unset -f filter-lines +filter-lines() +{ + sed $'s|^|\x1b[32m('"$1/$2"$')\x1b[39m |' +} + +make -C $1 $2 | filter-lines $1 $2 \ No newline at end of file diff --git a/tools/sync-libc.sh b/tools/sync-libc.sh index 808bcb04..cf6df110 100755 --- a/tools/sync-libc.sh +++ b/tools/sync-libc.sh @@ -7,5 +7,7 @@ cd $LUNA_ROOT tools/install-headers.sh -make -C libs/libc build -j$(nproc) -make -C libs/libc install -j$(nproc) \ No newline at end of file +cd libs/ + +$LUNA_ROOT/tools/buildstep.sh libc build +$LUNA_ROOT/tools/buildstep.sh libc install \ No newline at end of file