Skip to content

Commit

Permalink
Clean up terminal output (#163)
Browse files Browse the repository at this point in the history
* cleanup terminal output

* fixes
  • Loading branch information
Yanis002 authored Jan 7, 2025
1 parent ffa9992 commit e6fca95
Show file tree
Hide file tree
Showing 15 changed files with 254 additions and 178 deletions.
20 changes: 1 addition & 19 deletions .make_hackeroot.mk
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,7 @@ else
$(error Unable to detect a suitable MIPS toolchain installed)
endif

# Verbose toggle
V := @
ifeq (VERBOSE, 1)
V=
endif

# Colors
NO_COL := \033[0m
GREEN := \033[0;32m
BLUE := \033[0;36m
YELLOW := \033[0;33m
BLINK := \033[32;5m

PRINT := printf

# Generic print function for make rules
define print
$(V)echo -e "$(GREEN)$(1) $(YELLOW)$(2)$(GREEN) -> $(BLUE)$(3)$(NO_COL)"
endef
-include tools/print_rules.mk

# Enable optimization flags to use GDB on Ares
ARES_GDB := 1
Expand Down
126 changes: 64 additions & 62 deletions Makefile

Large diffs are not rendered by default.

43 changes: 24 additions & 19 deletions tools/Flips/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
MAKEFLAGS += --no-builtin-rules --no-print-directory

#This script creates a debug-optimized binary by default. If you're on Linux, you'll get a faster binary from make.sh.

SRCDIR := $(abspath $(patsubst %/,%,$(dir $(abspath $(lastword $(MAKEFILE_LIST))))))
Expand Down Expand Up @@ -69,11 +71,13 @@ ifeq ($(TARGET),gtk)
endif
endif

-include ../print_rules.mk

all: $(FNAME_$(TARGET))
obj:
mkdir obj
$(V)mkdir obj
clean: | obj
rm obj/* || true
$(V)rm obj/* || true

ifeq ($(TARGET),windows)
XFILES += obj/rc.o
Expand All @@ -92,28 +96,29 @@ ifeq ($(TARGET),gtk)
endif

$(FNAME_$(TARGET)): $(SOURCES) $(XFILES)
$(CXX) $^ -std=c++98 $(CFLAGS_G) $(MOREFLAGS) $(CPPFLAGS) $(CFLAGS) $(CXXFLAGS) $(LFLAGS) -o$@
$(call print_two_args,Compiling:,$<,$@)
$(V)$(CXX) $^ -std=c++98 $(CFLAGS_G) $(MOREFLAGS) $(CPPFLAGS) $(CFLAGS) $(CXXFLAGS) $(LFLAGS) -o$@
ifeq ($(CFLAGS),-g)
echo 'Compiled Floating IPS in debug mode; for better performance, use ./make.sh instead'
$(V)echo 'Compiled Floating IPS in debug mode; for better performance, use ./make.sh instead'
endif

ifeq ($(TARGET),gtk)
install: all
mkdir -p $(DESTDIR)$(BINDIR)
mkdir -p $(DESTDIR)$(DATAROOTDIR)/applications
mkdir -p $(DESTDIR)$(DATAROOTDIR)/icons/hicolor/scalable/apps
mkdir -p $(DESTDIR)$(DATAROOTDIR)/icons/hicolor/symbolic/apps
mkdir -p $(DESTDIR)$(DATAROOTDIR)/metainfo
install -p -m755 $(FNAME_$(TARGET)) $(DESTDIR)$(BINDIR)
install -p -m755 $(SRCDIR)/data/com.github.Alcaro.Flips.desktop $(DESTDIR)$(DATAROOTDIR)/applications
install -p -m644 $(SRCDIR)/data/com.github.Alcaro.Flips.svg $(DESTDIR)$(DATAROOTDIR)/icons/hicolor/scalable/apps
install -p -m644 $(SRCDIR)/data/com.github.Alcaro.Flips-symbolic.svg $(DESTDIR)$(DATAROOTDIR)/icons/hicolor/symbolic/apps
install -p -m644 $(SRCDIR)/data/com.github.Alcaro.Flips.metainfo.xml $(DESTDIR)$(DATAROOTDIR)/metainfo
$(V)mkdir -p $(DESTDIR)$(BINDIR)
$(V)mkdir -p $(DESTDIR)$(DATAROOTDIR)/applications
$(V)mkdir -p $(DESTDIR)$(DATAROOTDIR)/icons/hicolor/scalable/apps
$(V)mkdir -p $(DESTDIR)$(DATAROOTDIR)/icons/hicolor/symbolic/apps
$(V)mkdir -p $(DESTDIR)$(DATAROOTDIR)/metainfo
$(V)install -p -m755 $(FNAME_$(TARGET)) $(DESTDIR)$(BINDIR)
$(V)install -p -m755 $(SRCDIR)/data/com.github.Alcaro.Flips.desktop $(DESTDIR)$(DATAROOTDIR)/applications
$(V)install -p -m644 $(SRCDIR)/data/com.github.Alcaro.Flips.svg $(DESTDIR)$(DATAROOTDIR)/icons/hicolor/scalable/apps
$(V)install -p -m644 $(SRCDIR)/data/com.github.Alcaro.Flips-symbolic.svg $(DESTDIR)$(DATAROOTDIR)/icons/hicolor/symbolic/apps
$(V)install -p -m644 $(SRCDIR)/data/com.github.Alcaro.Flips.metainfo.xml $(DESTDIR)$(DATAROOTDIR)/metainfo

uninstall:
rm -f $(DESTDIR)$(BINDIR)/$(FNAME_$(TARGET))
rm -f $(DESTDIR)$(DATAROOTDIR)/applications/com.github.Alcaro.Flips.desktop
rm -f $(DESTDIR)$(DATAROOTDIR)/icons/hicolor/scalable/apps/com.github.Alcaro.Flips.svg
rm -f $(DESTDIR)$(DATAROOTDIR)/icons/hicolor/symbolic/apps/com.github.Alcaro.Flips-symbolic.svg
rm -f $(DESTDIR)$(DATAROOTDIR)/metainfo/com.github.Alcaro.Flips.metainfo.xml
$(V)rm -f $(DESTDIR)$(BINDIR)/$(FNAME_$(TARGET))
$(V)rm -f $(DESTDIR)$(DATAROOTDIR)/applications/com.github.Alcaro.Flips.desktop
$(V)rm -f $(DESTDIR)$(DATAROOTDIR)/icons/hicolor/scalable/apps/com.github.Alcaro.Flips.svg
$(V)rm -f $(DESTDIR)$(DATAROOTDIR)/icons/hicolor/symbolic/apps/com.github.Alcaro.Flips-symbolic.svg
$(V)rm -f $(DESTDIR)$(DATAROOTDIR)/metainfo/com.github.Alcaro.Flips.metainfo.xml
endif
61 changes: 36 additions & 25 deletions tools/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
MAKEFLAGS += --no-builtin-rules --no-print-directory

CFLAGS := -Wall -Wextra -pedantic -std=c99 -g -O2
PROGRAMS := elf2rom makeromfs mkdmadata mkldscript preprocess_pragmas reloc_prereq

Expand Down Expand Up @@ -34,32 +36,40 @@ ifneq ($(LLD),0)
CFLAGS += -fuse-ld=lld
endif

-include print_rules.mk

all: $(PROGRAMS) $(IDO_RECOMP_5_3_DIR) $(IDO_RECOMP_7_1_DIR) $(EGCS_DIR)
$(MAKE) -C ZAPD
$(MAKE) -C fado
$(call print_no_args,Building ZAPD...)
$(V)$(MAKE) -C ZAPD
$(call print_no_args,Building fado...)
$(V)$(MAKE) -C fado
$(call print_no_args,Building gzinject...)
ifeq ($(wildcard ./gzinject/Makefile),)
cd ./gzinject && ./configure
$(V)cd ./gzinject && ./configure
endif
$(MAKE) -C gzinject
$(MAKE) -C z64compress
$(MAKE) -C Flips TARGET=cli
$(MAKE) -C audio
$(V)$(MAKE) -C gzinject
$(call print_no_args,Building z64compress...)
$(V)$(MAKE) -C z64compress
$(call print_no_args,Building Flips...)
$(V)$(MAKE) -C Flips TARGET=cli
$(call print_no_args,Building audio tools...)
$(V)$(MAKE) -C audio

clean:
$(RM) $(PROGRAMS) $(addsuffix .exe,$(PROGRAMS))
$(RM) -r ido_recomp egcs
$(MAKE) -C ZAPD clean
$(MAKE) -C fado clean
$(V)$(RM) $(PROGRAMS) $(addsuffix .exe,$(PROGRAMS))
$(V)$(RM) -r ido_recomp egcs
$(V)$(MAKE) -C ZAPD clean
$(V)$(MAKE) -C fado clean
ifneq ($(wildcard ./gzinject/Makefile),)
$(MAKE) -C gzinject clean
$(V)$(MAKE) -C gzinject distclean
endif
$(MAKE) -C z64compress clean
$(MAKE) -C Flips clean
rm Flips/flips
$(MAKE) -C audio clean
$(V)$(MAKE) -C z64compress clean
$(V)$(MAKE) -C Flips clean
$(V)rm Flips/flips
$(V)$(MAKE) -C audio clean

distclean: clean
$(MAKE) -C audio distclean
$(V)$(MAKE) -C audio distclean

.PHONY: all clean distclean

Expand All @@ -73,20 +83,21 @@ reloc_prereq_SOURCES := reloc_prereq.c spec.c util.c

define COMPILE =
$(1): $($1_SOURCES)
$(CC) $(CFLAGS) $$^ -o $$@
$(call print_two_args,Compiling:,$$^,$$@)
$(V)$(CC) $(CFLAGS) $$^ -o $$@
endef

$(foreach p,$(PROGRAMS),$(eval $(call COMPILE,$(p))))

$(IDO_RECOMP_5_3_DIR):
mkdir -p $@
curl -sL https://github.com/decompals/ido-static-recomp/releases/download/$(IDO_RECOMP_VERSION)/ido-5.3-recomp-$(DETECTED_OS).tar.gz | tar xz -C $@
$(V)mkdir -p $@
$(V)curl -sL https://github.com/decompals/ido-static-recomp/releases/download/$(IDO_RECOMP_VERSION)/ido-5.3-recomp-$(DETECTED_OS).tar.gz | tar xz -C $@

$(IDO_RECOMP_7_1_DIR):
mkdir -p $@
curl -sL https://github.com/decompals/ido-static-recomp/releases/download/$(IDO_RECOMP_VERSION)/ido-7.1-recomp-$(DETECTED_OS).tar.gz | tar xz -C $@
$(V)mkdir -p $@
$(V)curl -sL https://github.com/decompals/ido-static-recomp/releases/download/$(IDO_RECOMP_VERSION)/ido-7.1-recomp-$(DETECTED_OS).tar.gz | tar xz -C $@

$(EGCS_DIR):
mkdir -p $@
curl -sL https://github.com/decompals/mips-binutils-egcs-2.9.5/releases/download/$(EGCS_BINUTILS_VERSION)/mips-binutils-egcs-2.9.5-$(DETECTED_OS).tar.gz | tar xz -C $@
curl -sL https://github.com/decompals/mips-gcc-egcs-2.91.66/releases/download/$(EGCS_GCC_VERSION)/mips-gcc-egcs-2.91.66-$(DETECTED_OS).tar.gz | tar xz -C $@
$(V)mkdir -p $@
$(V)curl -sL https://github.com/decompals/mips-binutils-egcs-2.9.5/releases/download/$(EGCS_BINUTILS_VERSION)/mips-binutils-egcs-2.9.5-$(DETECTED_OS).tar.gz | tar xz -C $@
$(V)curl -sL https://github.com/decompals/mips-gcc-egcs-2.91.66/releases/download/$(EGCS_GCC_VERSION)/mips-gcc-egcs-2.91.66-$(DETECTED_OS).tar.gz | tar xz -C $@
12 changes: 8 additions & 4 deletions tools/ZAPD/ExporterTest/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
MAKEFLAGS += --no-builtin-rules --no-print-directory

# Only used for standalone compilation, usually inherits these from the main makefile
CXXFLAGS ?= -Wall -Wextra -O2 -g -std=c++17

Expand All @@ -11,18 +13,20 @@ LIB := ExporterTest.a
# create build directories
$(shell mkdir -p $(foreach dir,$(SRC_DIRS),build/$(dir)))

-include ../../print_rules.mk

all: $(LIB)

clean:
rm -rf build $(LIB)
$(V)rm -rf build $(LIB)

format:
clang-format-14 -i $(CPP_FILES) $(H_FILES)
$(V)clang-format-14 -i $(CPP_FILES) $(H_FILES)

.PHONY: all clean format

build/%.o: %.cpp
$(CXX) $(CXXFLAGS) $(OPTFLAGS) -I ./ -I ../ZAPD -I ../ZAPDUtils -I ../lib/tinyxml2 -c $(OUTPUT_OPTION) $<
$(V)$(CXX) $(CXXFLAGS) $(OPTFLAGS) -I ./ -I ../ZAPD -I ../ZAPDUtils -I ../lib/tinyxml2 -c $(OUTPUT_OPTION) $<

$(LIB): $(O_FILES)
$(AR) rcs $@ $^
$(V)$(AR) rcs $@ $^
34 changes: 19 additions & 15 deletions tools/ZAPD/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
MAKEFLAGS += --no-builtin-rules --no-print-directory

# use variables in submakes
export
OPTIMIZATION_ON ?= 1
Expand Down Expand Up @@ -103,49 +105,51 @@ O_FILES += build/ZAPD/BuildInfo.o
# create build directories
$(shell mkdir -p $(foreach dir,$(SRC_DIRS),build/$(dir)))

-include ../print_rules.mk

# Main targets
all: ZAPD.out copycheck

build/ZAPD/BuildInfo.o:
python3 ZAPD/genbuildinfo.py $(COPYCHECK_ARGS)
$(CXX) $(CXXFLAGS) $(OPTFLAGS) $(INC) -c $(OUTPUT_OPTION) build/ZAPD/BuildInfo.cpp
$(V)python3 ZAPD/genbuildinfo.py $(COPYCHECK_ARGS)
$(V)$(CXX) $(CXXFLAGS) $(OPTFLAGS) $(INC) -c $(OUTPUT_OPTION) build/ZAPD/BuildInfo.cpp

copycheck: ZAPD.out
python3 copycheck.py
$(V)python3 copycheck.py

clean:
rm -rf build ZAPD.out
$(MAKE) -C lib/libgfxd clean
$(MAKE) -C ZAPDUtils clean
$(MAKE) -C ExporterTest clean
$(V)rm -rf build ZAPD.out
$(V)$(MAKE) -C lib/libgfxd clean
$(V)$(MAKE) -C ZAPDUtils clean
$(V)$(MAKE) -C ExporterTest clean

rebuild: clean all

format:
clang-format-14 -i $(ZAPD_CPP_FILES) $(ZAPD_H_FILES)
$(MAKE) -C ZAPDUtils format
$(MAKE) -C ExporterTest format
$(V)clang-format-14 -i $(ZAPD_CPP_FILES) $(ZAPD_H_FILES)
$(V)$(MAKE) -C ZAPDUtils format
$(V)$(MAKE) -C ExporterTest format

.PHONY: all build/ZAPD/BuildInfo.o copycheck clean rebuild format

build/%.o: %.cpp
$(CXX) $(CXXFLAGS) $(OPTFLAGS) $(INC) -c $(OUTPUT_OPTION) $<
$(call print_two_args,Compiling:,$<,$@)
$(V)$(CXX) $(CXXFLAGS) $(OPTFLAGS) $(INC) -c $(OUTPUT_OPTION) $<


# Submakes
lib/libgfxd/libgfxd.a:
$(MAKE) -C lib/libgfxd
$(V)$(MAKE) -C lib/libgfxd

.PHONY: ExporterTest
ExporterTest:
$(MAKE) -C ExporterTest
$(V)$(MAKE) -C ExporterTest

.PHONY: ZAPDUtils
ZAPDUtils:
$(MAKE) -C ZAPDUtils
$(V)$(MAKE) -C ZAPDUtils


# Linking
ZAPD.out: $(O_FILES) lib/libgfxd/libgfxd.a ExporterTest ZAPDUtils
$(CXX) $(CXXFLAGS) $(O_FILES) lib/libgfxd/libgfxd.a ZAPDUtils/ZAPDUtils.a $(EXPORTERS) $(LDFLAGS) $(OUTPUT_OPTION)
$(V)$(CXX) $(CXXFLAGS) $(O_FILES) lib/libgfxd/libgfxd.a ZAPDUtils/ZAPDUtils.a $(EXPORTERS) $(LDFLAGS) $(OUTPUT_OPTION)
13 changes: 9 additions & 4 deletions tools/ZAPD/ZAPDUtils/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
MAKEFLAGS += --no-builtin-rules --no-print-directory

# Only used for standalone compilation, usually inherits these from the main makefile
CXXFLAGS ?= -Wall -Wextra -O2 -g -std=c++17

Expand All @@ -11,18 +13,21 @@ LIB := ZAPDUtils.a
# create build directories
$(shell mkdir -p $(foreach dir,$(SRC_DIRS),build/$(dir)))

-include ../../print_rules.mk

all: $(LIB)

clean:
rm -rf build $(LIB)
$(V)rm -rf build $(LIB)

format:
clang-format-14 -i $(CPP_FILES) $(H_FILES)
$(V)clang-format-14 -i $(CPP_FILES) $(H_FILES)

.PHONY: all clean format

build/%.o: %.cpp
$(CXX) $(CXXFLAGS) $(OPTFLAGS) -c $(OUTPUT_OPTION) $<
$(call print_two_args,Compiling:,$<,$@)
$(V)$(CXX) $(CXXFLAGS) $(OPTFLAGS) -c $(OUTPUT_OPTION) $<

$(LIB): $(O_FILES)
$(AR) rcs $@ $^
$(V)$(AR) rcs $@ $^
10 changes: 7 additions & 3 deletions tools/ZAPD/lib/libgfxd/Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
MAKEFLAGS += --no-builtin-rules --no-print-directory

CFLAGS = -Wall -O2 -g
UC_OBJ = uc_f3d.o uc_f3db.o uc_f3dex.o uc_f3dexb.o uc_f3dex2.o
OBJ = gfxd.o $(UC_OBJ)
Expand All @@ -6,20 +8,22 @@ LIB = libgfxd.a
CPPFLAGS-$(MT) += -DCONFIG_MT
CPPFLAGS += $(CPPFLAGS-y)

-include ../../print_rules.mk

.PHONY: all
all: $(LIB)

.PHONY: clean
clean:
rm -f $(OBJ) $(LIB)
$(V)rm -f $(OBJ) $(LIB)

.INTERMEDIATE: $(OBJ)

$(OBJ): gbi.h gfxd.h priv.h
$(UC_OBJ): uc.c uc_argfn.c uc_argtbl.c uc_macrofn.c uc_macrotbl.c

$(LIB): $(OBJ)
$(AR) rcs $@ $^
$(V)$(AR) rcs $@ $^

%.o: %.c
$(COMPILE.c) $(OUTPUT_OPTION) $<
$(V)$(COMPILE.c) $(OUTPUT_OPTION) $<
Loading

0 comments on commit e6fca95

Please sign in to comment.