Build system: Prettify build

This commit is contained in:
apio 2022-11-08 18:03:43 +01:00
parent 00f9981f51
commit 054d5a8bb4
6 changed files with 71 additions and 37 deletions

View File

@ -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
+@tools/buildstep.sh kernel install
+@tools/buildstep.sh libs install
+@tools/buildstep.sh apps install
+@tools/install-built-ports.sh

View File

@ -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:

View File

@ -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:

View File

@ -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

9
tools/buildstep.sh Executable file
View File

@ -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

View File

@ -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)
cd libs/
$LUNA_ROOT/tools/buildstep.sh libc build
$LUNA_ROOT/tools/buildstep.sh libc install