GCC artifacts now isolated to build/ & bin/

This commit is contained in:
Emile Clark-Boman 2025-07-22 07:03:54 +10:00
parent d2709736e5
commit 9e3e8797f0
2 changed files with 32 additions and 18 deletions

9
.gitignore vendored
View file

@ -1,12 +1,7 @@
*.o build/
*.d bin/
# `make -f Makefile.js` artifacts # `make -f Makefile.js` artifacts
.emscripten_cache .emscripten_cache
js/* js/*
!js/lib.js !js/lib.js
# `make -f Makefile` artifacts
build_filelist
splitimg
temu

View file

@ -22,6 +22,10 @@
# THE SOFTWARE. # THE SOFTWARE.
# #
# artifact paths
BUILD:=build
BIN:=bin
# if set, network filesystem is enabled. libcurl and libcrypto # if set, network filesystem is enabled. libcurl and libcrypto
# (openssl) must be installed. # (openssl) must be installed.
CONFIG_FS_NET=y CONFIG_FS_NET=y
@ -103,33 +107,48 @@ CFLAGS+=-DCONFIG_X86EMU
EMU_OBJS+=x86_cpu.o x86_machine.o ide.o ps2.o vmmouse.o pckbd.o vga.o EMU_OBJS+=x86_cpu.o x86_machine.o ide.o ps2.o vmmouse.o pckbd.o vga.o
endif endif
temu$(EXE): $(EMU_OBJS) # macro to prepend $(BUILD)
$(CC) $(LDFLAGS) -o $@ $^ $(EMU_LIBS) define mkbuild
$(addprefix $(BUILD)/,$(1))
endef
temu$(EXE): $(BUILD) $(BIN) $(EMU_OBJS)
$(CC) $(LDFLAGS) -o $(BIN)/$@ $(call mkbuild,$(EMU_OBJS)) $(EMU_LIBS)
riscv_cpu32.o: riscv_cpu.c riscv_cpu32.o: riscv_cpu.c
$(CC) $(CFLAGS) -DMAX_XLEN=32 -c -o $@ $< $(CC) $(CFLAGS) -DMAX_XLEN=32 -c -o $(BUILD)/$@ $<
riscv_cpu64.o: riscv_cpu.c riscv_cpu64.o: riscv_cpu.c
$(CC) $(CFLAGS) -DMAX_XLEN=64 -c -o $@ $< $(CC) $(CFLAGS) -DMAX_XLEN=64 -c -o $(BUILD)/$@ $<
riscv_cpu128.o: riscv_cpu.c riscv_cpu128.o: riscv_cpu.c
$(CC) $(CFLAGS) -DMAX_XLEN=128 -c -o $@ $< $(CC) $(CFLAGS) -DMAX_XLEN=128 -c -o $(BUILD)/$@ $<
build_filelist: build_filelist.o fs_utils.o cutils.o build_filelist: build_filelist.o fs_utils.o cutils.o
$(CC) $(LDFLAGS) -o $@ $^ -lm $(CC) $(LDFLAGS) -o $(BIN)/$@ $(call mkbuild,$^) -lm
splitimg: splitimg.o splitimg: splitimg.o
$(CC) $(LDFLAGS) -o $@ $^ $(CC) $(LDFLAGS) -o $(BIN)/$@ $(call mkbuild,$^)
install: $(PROGS) install: $(PROGS)
$(STRIP) $(PROGS) $(STRIP) $(PROGS)
$(INSTALL) -m755 $(PROGS) "$(DESTDIR)$(bindir)" $(INSTALL) -m755 $(PROGS) "$(DESTDIR)$(bindir)"
%.o: %.c %.o: %.c
$(CC) $(CFLAGS) -c -o $@ $< $(CC) $(CFLAGS) -c -o $(BUILD)/$@ $<
.PHONY: $(BUILD)
$(BUILD):
@mkdir -p $(BUILD) $(BUILD)/slirp
.PHONY: $(BIN)
$(BIN):
@mkdir -p $@
.PHONY: clean
clean: clean:
rm -f *.o *.d *~ $(PROGS) slirp/*.o slirp/*.d slirp/*~ rm -f *~ $(PROGS)
rm -rf $(BUILD)
-include $(wildcard *.d) -include $(wildcard $(BUILD)/*.d)
-include $(wildcard slirp/*.d) -include $(wildcard $(BUILD)/slirp/*.d)