From 3003c252d12651111498e47eb9d372c0e8794a75 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 18 Feb 2021 05:16:15 -0800 Subject: [PATCH 1/3] Makfile: don't print some messages twice --- src/Makefile | 10 +++++++--- src/Makefile.cfg | 10 ++++++---- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/Makefile b/src/Makefile index 42b757940..1186fe915 100644 --- a/src/Makefile +++ b/src/Makefile @@ -2,7 +2,7 @@ # GNU Make makefile for SRB2 ############################################################################# # Copyright (C) 1998-2000 by DooM Legacy Team. -# Copyright (C) 2003-2020 by Sonic Team Junior. +# Copyright (C) 2003-2021 by Sonic Team Junior. # # This program is free software distributed under the # terms of the GNU General Public License, version 2. @@ -79,6 +79,10 @@ # ############################################################################# +ifndef MAKE_RESTARTS +print=$(info $(1)) +endif + ALL_SYSTEMS=\ PANDORA\ LINUX64\ @@ -98,7 +102,7 @@ ALL_SYSTEMS=\ ifeq (,$(filter $(ALL_SYSTEMS),$(.VARIABLES))) ifeq ($(OS),Windows_NT) # all windows are Windows_NT... - $(info Detected a Windows system, compiling for 32-bit MinGW SDL2...) + $(call print,Detected a Windows system, compiling for 32-bit MinGW SDL2...) # go for a 32-bit sdl mingw exe by default MINGW=1 @@ -123,7 +127,7 @@ else # if you on the *nix new_system:=$(new_system)64 endif - $(info Detected $(system) ($(new_system))...) + $(call print,Detected $(system) ($(new_system))...) $(new_system)=1 endif diff --git a/src/Makefile.cfg b/src/Makefile.cfg index f081eacdf..c323f4ffd 100644 --- a/src/Makefile.cfg +++ b/src/Makefile.cfg @@ -60,12 +60,14 @@ ifeq (,$(filter GCC%,$(.VARIABLES))) # If this version is not in the list, default to the latest supported ifeq (,$(filter $(v),$(SUPPORTED_GCC_VERSIONS))) - $(info\ - Your compiler version, GCC $(version), is not supported by the Makefile.\ - The Makefile will assume GCC $(LATEST_GCC_VERSION).) + define line = + Your compiler version, GCC $(version), is not supported by the Makefile. + The Makefile will assume GCC $(LATEST_GCC_VERSION).)) + endef + $(call print,$(line)) GCC$(subst .,,$(LATEST_GCC_VERSION))=1 else - $(info Detected GCC $(version) (GCC$(v))) + $(call print,Detected GCC $(version) (GCC$(v))) GCC$(v)=1 endif endif From 3d32f3145cf1bec85f77c33908a8bfc6772bd779 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 18 Feb 2021 06:15:11 -0800 Subject: [PATCH 2/3] Generate individual dependency files This removes Makefile.depends. Instead, '.d' files are included from the 'dep' directory. This speeds up building because dependencies for every file don't need to be regenerated if only one changes. As a bonus, dependencies also won't be generated if only clean type targets are going to be run. Also added a 'distclean' target, which cleans both objects and dependency files. --- src/Makefile | 57 ++++++++++++++++++++++++------------------------ src/Makefile.cfg | 13 +++++++++++ 2 files changed, 41 insertions(+), 29 deletions(-) diff --git a/src/Makefile b/src/Makefile index 1186fe915..3e8c33624 100644 --- a/src/Makefile +++ b/src/Makefile @@ -24,7 +24,9 @@ # clean # Remove all object files # cleandep -# Remove depend.dep +# Remove dependency files +# distclean +# Remove autogenerated files # dll # compile primary HW render DLL/SO # all_dll @@ -459,7 +461,6 @@ DBGNAME?=$(EXENAME).debug # not too sophisticated dependency OBJS:=$(i_main_o) \ - $(OBJDIR)/comptime.o \ $(OBJDIR)/string.o \ $(OBJDIR)/d_main.o \ $(OBJDIR)/d_clisrv.o \ @@ -539,6 +540,8 @@ OBJS:=$(i_main_o) \ $(i_sound_o) \ $(OBJS) +DEPS:=$(patsubst $(OBJDIR)/%.o,$(DEPDIR)/%.d,$(OBJS)) +OBJS+=$(OBJDIR)/comptime.o ifndef ECHO ifndef NOECHOFILENAMES @@ -559,12 +562,12 @@ OPTS+=-DGETTEXT endif ifdef PANDORA -all: pre-build $(BIN)/$(PNDNAME) +all: $(BIN)/$(PNDNAME) endif ifdef SDL -all: pre-build $(BIN)/$(EXENAME) +all: $(BIN)/$(EXENAME) endif ifdef DUMMY @@ -572,20 +575,15 @@ all: $(BIN)/$(EXENAME) endif cleandep: - $(REMOVE) $(OBJDIR)/depend.dep + $(REMOVE) $(DEPS) $(REMOVE) comptime.h -pre-build: -ifdef WINDOWSHELL - -..\comptime.bat . -else - -@../comptime.sh . -endif - clean: $(REMOVE) *~ *.flc $(REMOVE) $(OBJDIR)/*.o +distclean: clean cleandep + ifdef MINGW $(REMOVE) $(OBJDIR)/*.res endif @@ -667,24 +665,21 @@ endif endif #dependecy made by gcc itself ! -$(OBJS): ifndef DUMMY --include $(OBJDIR)/depend.dep +ifneq (,$(filter-out cleandep clean distclean,$(or $(MAKECMDGOALS),all))) +$(call print,Checking dependency files...) +-include $(DEPS) +endif endif -$(OBJDIR)/depend.dep: - @echo "Creating dependency file, depend.dep" - @echo > comptime.h - -$(MKDIR) $(OBJDIR) - $(CC) $(CFLAGS) -MM *.c > $(OBJDIR)/depend.ped - $(CC) $(CFLAGS) -MM $(INTERFACE)/*.c >> $(OBJDIR)/depend.ped -ifndef NOHW - $(CC) $(CFLAGS) -MM hardware/*.c >> $(OBJDIR)/depend.ped +$(DEPDIR)/%.d: %.c +# windows makes it too hard ! +ifndef WINDOWSHELL +ifndef ECHO + @printf "%-20.20s\r" $< endif - $(CC) $(CFLAGS) -MM blua/*.c >> $(OBJDIR)/depend.ped - @sed -e 's,\(.*\)\.o: ,$(subst /,\/,$(OBJDIR))\/&,g' < $(OBJDIR)/depend.ped > $(OBJDIR)/depend.dep - $(REMOVE) $(OBJDIR)/depend.ped - @echo "Created dependency file, depend.dep" +endif + $(CC) $(CFLAGS) -M -MF $@ -MT $(OBJDIR)/$< $< ifdef VALGRIND $(OBJDIR)/z_zone.o: z_zone.c @@ -692,9 +687,13 @@ $(OBJDIR)/z_zone.o: z_zone.c $(CC) $(CFLAGS) $(WFLAGS) -DHAVE_VALGRIND $(VALGRIND_CFLAGS) -c $< -o $@ endif -$(OBJDIR)/comptime.o: comptime.c pre-build - $(echoName) - $(CC) $(CFLAGS) $(WFLAGS) -c $< -o $@ +$(OBJDIR)/comptime.o:: +ifdef WINDOWSHELL + -..\comptime.bat . +else + -../comptime.sh . +endif + $(CC) $(CFLAGS) $(WFLAGS) -c comptime.c -o $@ $(BIN)/%.mo: locale/%.po -$(MKDIR) $(BIN) diff --git a/src/Makefile.cfg b/src/Makefile.cfg index c323f4ffd..ec19e9f85 100644 --- a/src/Makefile.cfg +++ b/src/Makefile.cfg @@ -363,6 +363,7 @@ i_main_o=$(OBJDIR)/i_main.o #set OBJDIR and BIN's starting place OBJDIR=../objs BIN=../bin +DEPDIR=../dep #Nasm ASM and rm ifdef YASM NASM?=yasm @@ -385,6 +386,7 @@ ifdef DUMMY INTERFACE=dummy OBJDIR:=$(OBJDIR)/dummy BIN:=$(BIN)/dummy + DEPDIR:=$(DEPDIR)/dummy else ifdef LINUX NASMFORMAT=elf -DLINUX @@ -392,9 +394,11 @@ ifdef LINUX ifdef LINUX64 OBJDIR:=$(OBJDIR)/Linux64 BIN:=$(BIN)/Linux64 + DEPDIR:=$(DEPDIR)/Linux64 else OBJDIR:=$(OBJDIR)/Linux BIN:=$(BIN)/Linux + DEPDIR:=$(DEPDIR)/Linux endif else ifdef FREEBSD @@ -404,6 +408,7 @@ ifdef FREEBSD OBJDIR:=$(OBJDIR)/FreeBSD BIN:=$(BIN)/FreeBSD + DEPDIR:=$(DEPDIR)/Linux else ifdef SOLARIS INTERFACE=sdl @@ -412,6 +417,7 @@ ifdef SOLARIS OBJDIR:=$(OBJDIR)/Solaris BIN:=$(BIN)/Solaris + DEPDIR:=$(DEPDIR)/Solaris else ifdef CYGWIN32 INTERFACE=sdl @@ -420,18 +426,21 @@ ifdef CYGWIN32 OBJDIR:=$(OBJDIR)/cygwin BIN:=$(BIN)/Cygwin + DEPDIR:=$(DEPDIR)/Cygwin else ifdef MINGW64 #NASMFORMAT=win64 SDL=1 OBJDIR:=$(OBJDIR)/Mingw64 BIN:=$(BIN)/Mingw64 + DEPDIR:=$(DEPDIR)/Mingw64 else ifdef MINGW NASMFORMAT=win32 SDL=1 OBJDIR:=$(OBJDIR)/Mingw BIN:=$(BIN)/Mingw + DEPDIR:=$(DEPDIR)/Mingw endif endif endif @@ -443,6 +452,7 @@ endif ifdef ARCHNAME OBJDIR:=$(OBJDIR)/$(ARCHNAME) BIN:=$(BIN)/$(ARCHNAME) + DEPDIR:=$(DEPDIR)/$(ARCHNAME) endif OBJDUMP_OPTS?=--wide --source --line-numbers @@ -451,14 +461,17 @@ LD=$(CC) ifdef SDL INTERFACE=sdl OBJDIR:=$(OBJDIR)/SDL + DEPDIR:=$(DEPDIR)/SDL endif ifndef DUMMY ifdef DEBUGMODE OBJDIR:=$(OBJDIR)/Debug BIN:=$(BIN)/Debug + DEPDIR:=$(DEPDIR)/Debug else OBJDIR:=$(OBJDIR)/Release BIN:=$(BIN)/Release + DEPDIR:=$(DEPDIR)/Release endif endif From 747c278bc2380d5f48c0c939de1ef3994d44b6c4 Mon Sep 17 00:00:00 2001 From: James R Date: Thu, 18 Feb 2021 07:03:25 -0800 Subject: [PATCH 3/3] Makefile: add a SILENT flag This makes it print nothing to stdout. Also fixed some irregularities. --- src/Makefile | 37 ++++++++++++++++++++++++++----------- src/Makefile.cfg | 3 ++- 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/src/Makefile b/src/Makefile index 3e8c33624..260175a69 100644 --- a/src/Makefile +++ b/src/Makefile @@ -81,9 +81,16 @@ # ############################################################################# +,=, + +ifeq (,$(filter-out cleandep clean distclean,$(or $(MAKECMDGOALS),all))) +CLEANONLY=1 +else ifndef SILENT +echo=@echo "$(1)" ifndef MAKE_RESTARTS print=$(info $(1)) endif +endif ALL_SYSTEMS=\ PANDORA\ @@ -104,7 +111,7 @@ ALL_SYSTEMS=\ ifeq (,$(filter $(ALL_SYSTEMS),$(.VARIABLES))) ifeq ($(OS),Windows_NT) # all windows are Windows_NT... - $(call print,Detected a Windows system, compiling for 32-bit MinGW SDL2...) + $(call print,Detected a Windows system$(,) compiling for 32-bit MinGW SDL2...) # go for a 32-bit sdl mingw exe by default MINGW=1 @@ -243,6 +250,12 @@ endif MSGFMT?=msgfmt +ifdef WINDOWSHELL + COMPTIME=-..\comptime.bat +else + COMPTIME=-../comptime.sh +endif + ifndef ECHO NASM:=@$(NASM) REMOVE:=@$(REMOVE) @@ -257,6 +270,7 @@ ifndef ECHO MSGFMT:=@$(MSGFMT) UPX:=@$(UPX) UPX_OPTS+=-q + COMPTIME:=@$(COMPTIME) endif ifdef NONET @@ -543,6 +557,7 @@ OBJS:=$(i_main_o) \ DEPS:=$(patsubst $(OBJDIR)/%.o,$(DEPDIR)/%.d,$(OBJS)) OBJS+=$(OBJDIR)/comptime.o +ifndef SILENT ifndef ECHO ifndef NOECHOFILENAMES define echoName = @@ -550,6 +565,7 @@ define echoName = endef endif endif +endif # List of languages to compile. # For reference, this is the command I use to build a srb2.pot file from the source code. @@ -603,11 +619,11 @@ asm: $(BIN)/$(EXENAME): $(POS) $(OBJS) -$(MKDIR) $(BIN) - @echo Linking $(EXENAME)... + $(call echo,Linking $(EXENAME)...) $(LD) $(LDFLAGS) $(OBJS) -o $(BIN)/$(EXENAME) $(LIBS) ifndef VALGRIND ifndef NOOBJDUMP - @echo Dumping debugging info + $(call echo,Dumping debugging info) $(OBJDUMP) $(OBJDUMP_OPTS) $(BIN)/$(EXENAME) > $(BIN)/$(DBGNAME).txt ifdef WINDOWSHELL -$(GZIP) $(GZIP_OPTS) $(BIN)/$(DBGNAME).txt @@ -626,10 +642,10 @@ ifndef NOUPX -$(UPX) $(UPX_OPTS) $(BIN)/$(EXENAME) endif endif - @echo Build is done, please look for $(EXENAME) in $(BIN), \(checking for post steps\) + $(call echo,Build is done$(,) please look for $(EXENAME) in $(BIN)$(,) (checking for post steps)) reobjdump: - @echo Redumping debugging info + $(call echo,Redumping debugging info) $(OBJDUMP) $(OBJDUMP_OPTS) $(BIN)/$(DBGNAME) > $(BIN)/$(DBGNAME).txt ifdef WINDOWSHELL -$(GZIP) $(GZIP_OPTS) $(BIN)/$(DBGNAME).txt @@ -666,7 +682,7 @@ endif #dependecy made by gcc itself ! ifndef DUMMY -ifneq (,$(filter-out cleandep clean distclean,$(or $(MAKECMDGOALS),all))) +ifndef CLEANONLY $(call print,Checking dependency files...) -include $(DEPS) endif @@ -675,7 +691,7 @@ endif $(DEPDIR)/%.d: %.c # windows makes it too hard ! ifndef WINDOWSHELL -ifndef ECHO +ifdef echoName @printf "%-20.20s\r" $< endif endif @@ -688,11 +704,10 @@ $(OBJDIR)/z_zone.o: z_zone.c endif $(OBJDIR)/comptime.o:: -ifdef WINDOWSHELL - -..\comptime.bat . -else - -../comptime.sh . +ifdef echoName + @echo -- comptime.c ... endif + $(COMPTIME) . $(CC) $(CFLAGS) $(WFLAGS) -c comptime.c -o $@ $(BIN)/%.mo: locale/%.po diff --git a/src/Makefile.cfg b/src/Makefile.cfg index ec19e9f85..075cd2d3a 100644 --- a/src/Makefile.cfg +++ b/src/Makefile.cfg @@ -47,7 +47,8 @@ ifdef MACOSX endif # Automatically set version flag, but not if one was manually set -ifeq (,$(filter GCC%,$(.VARIABLES))) +# And don't bother if this is a clean only run +ifeq (,$(filter GCC% CLEANONLY,$(.VARIABLES))) version:=$(shell $(CC) --version) # check if this is in fact GCC ifneq (,$(or $(findstring gcc,$(version)),$(findstring GCC,$(version))))