From 171dd8c781ca98f0ac94d8af7227e777515bdedf Mon Sep 17 00:00:00 2001 From: Oleg Derevenetz Date: Mon, 6 Jan 2025 14:13:24 +0300 Subject: [PATCH 1/7] Unify the Emscripten and non-Emscripten builds --- Makefile.emscripten | 6 ++--- src/dist/Makefile | 10 ------- src/dist/fheroes2-ems/Makefile | 48 ---------------------------------- src/dist/fheroes2/Makefile | 14 +++++++--- 4 files changed, 13 insertions(+), 65 deletions(-) delete mode 100644 src/dist/fheroes2-ems/Makefile diff --git a/Makefile.emscripten b/Makefile.emscripten index 07feece5450..eb0868162be 100644 --- a/Makefile.emscripten +++ b/Makefile.emscripten @@ -30,9 +30,9 @@ all: fheroes2.js fheroes2.js: translations $(MAKE) -C src/dist PLATFORM=emscripten - cp src/dist/fheroes2-ems/fheroes2.data . - cp src/dist/fheroes2-ems/fheroes2.js . - cp src/dist/fheroes2-ems/fheroes2.wasm . + cp src/dist/fheroes2/fheroes2.data . + cp src/dist/fheroes2/fheroes2.js . + cp src/dist/fheroes2/fheroes2.wasm . translations: $(MAKE) -C files/lang diff --git a/src/dist/Makefile b/src/dist/Makefile index 103f1a860cc..4c53f105d13 100644 --- a/src/dist/Makefile +++ b/src/dist/Makefile @@ -159,23 +159,13 @@ ifndef FHEROES2_WITH_SYSTEM_SMACKER $(MAKE) -C thirdparty/libsmacker CCFLAGS="$(CCFLAGS_TP)" CFLAGS="$(CFLAGS_TP)" CXXFLAGS="$(CXXFLAGS_TP)" CPPFLAGS="$(CPPFLAGS_TP)" endif $(MAKE) -C engine -ifeq ($(PLATFORM),emscripten) - $(MAKE) -C fheroes2-ems -else $(MAKE) -C fheroes2 -endif ifdef FHEROES2_WITH_TOOLS $(MAKE) -C tools endif clean: -ifndef FHEROES2_WITH_SYSTEM_SMACKER $(MAKE) -C thirdparty/libsmacker clean -endif $(MAKE) -C engine clean -ifeq ($(PLATFORM),emscripten) - $(MAKE) -C fheroes2-ems clean -else $(MAKE) -C fheroes2 clean -endif $(MAKE) -C tools clean diff --git a/src/dist/fheroes2-ems/Makefile b/src/dist/fheroes2-ems/Makefile deleted file mode 100644 index 200a2fe3c13..00000000000 --- a/src/dist/fheroes2-ems/Makefile +++ /dev/null @@ -1,48 +0,0 @@ -########################################################################### -# fheroes2: https://github.com/ihhub/fheroes2 # -# Copyright (C) 2025 # -# # -# This program is free software; you can redistribute it and/or modify # -# it under the terms of the GNU General Public License as published by # -# the Free Software Foundation; either version 2 of the License, or # -# (at your option) any later version. # -# # -# This program is distributed in the hope that it will be useful, # -# but WITHOUT ANY WARRANTY; without even the implied warranty of # -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # -# GNU General Public License for more details. # -# # -# You should have received a copy of the GNU General Public License # -# along with this program; if not, write to the # -# Free Software Foundation, Inc., # -# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # -########################################################################### - -DEPLIBS := ../engine/libengine.a -CCFLAGS := $(CCFLAGS) -I../../engine - -ifndef FHEROES2_WITH_SYSTEM_SMACKER -DEPLIBS := $(DEPLIBS) ../thirdparty/libsmacker/libsmacker.a -CCFLAGS := $(CCFLAGS) -I../../thirdparty/libsmacker -endif - -SOURCEROOT := ../../fheroes2 -SOURCEDIRS := $(filter %/,$(wildcard $(SOURCEROOT)/*/)) -SOURCES := $(wildcard $(SOURCEROOT)/*/*.cpp) - -VPATH := $(SOURCEDIRS) - -.PHONY: all clean - -all: fheroes2.js - -fheroes2.js: $(notdir $(patsubst %.cpp, %.o, $(SOURCES))) $(DEPLIBS) - $(CXX) -o $@ $^ $(LIBS) $(LDFLAGS) - -%.o: %.cpp - $(CXX) -c -MD $< $(addprefix -I, $(SOURCEDIRS)) $(CCFLAGS) $(CXXFLAGS) $(CPPFLAGS) - -include $(wildcard *.d) - -clean: - rm -f *.d *.o fheroes2.data fheroes2.js fheroes2.wasm diff --git a/src/dist/fheroes2/Makefile b/src/dist/fheroes2/Makefile index 8e6ce3d151a..01bf5938a10 100644 --- a/src/dist/fheroes2/Makefile +++ b/src/dist/fheroes2/Makefile @@ -1,6 +1,6 @@ ########################################################################### # fheroes2: https://github.com/ihhub/fheroes2 # -# Copyright (C) 2021 - 2024 # +# Copyright (C) 2021 - 2025 # # # # This program is free software; you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # @@ -18,6 +18,12 @@ # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # ########################################################################### +ifeq ($(PLATFORM),emscripten) + TARGET := fheroes2.js +else + TARGET := fheroes2 +endif + DEPLIBS := ../engine/libengine.a CCFLAGS := $(CCFLAGS) -I../../engine @@ -34,11 +40,11 @@ VPATH := $(SOURCEDIRS) .PHONY: all pot clean -all: fheroes2 pot +all: $(TARGET) pot pot: fheroes2.pot -fheroes2: $(notdir $(patsubst %.cpp, %.o, $(SOURCES))) $(DEPLIBS) +$(TARGET): $(notdir $(patsubst %.cpp, %.o, $(SOURCES))) $(DEPLIBS) $(CXX) -o $@ $^ $(LIBS) $(LDFLAGS) fheroes2.pot: $(SOURCES) @@ -51,4 +57,4 @@ fheroes2.pot: $(SOURCES) include $(wildcard *.d) clean: - rm -f *.d *.o fheroes2 fheroes2.pot fheroes2.pot~ + rm -f *.d *.o fheroes2 fheroes2.data fheroes2.js fheroes2.wasm fheroes2.pot fheroes2.pot~ From 1bc9791e8e46fdf403a7b0dadd57459be89bcd58 Mon Sep 17 00:00:00 2001 From: Oleg Derevenetz Date: Mon, 6 Jan 2025 14:45:50 +0300 Subject: [PATCH 2/7] Make clean no matter what --- Makefile | 4 ++-- Makefile.emscripten | 2 +- Makefile.switch | 4 ++-- Makefile.vita | 4 ++-- docs/Makefile | 4 ++-- files/lang/Makefile | 4 ++-- src/dist/engine/Makefile | 4 ++-- src/dist/fheroes2/Makefile | 2 +- src/dist/thirdparty/libsmacker/Makefile | 4 ++-- src/dist/tools/Makefile | 4 ++-- 10 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index 5ea7e2f4372..21755cfbe48 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ ########################################################################### # fheroes2: https://github.com/ihhub/fheroes2 # -# Copyright (C) 2021 - 2024 # +# Copyright (C) 2021 - 2025 # # # # This program is free software; you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # @@ -60,4 +60,4 @@ endif clean: $(MAKE) -C src/dist clean $(MAKE) -C files/lang clean - rm -rf fheroes2 fheroes2.app + -rm -rf fheroes2 fheroes2.app diff --git a/Makefile.emscripten b/Makefile.emscripten index eb0868162be..ff1def9fbc7 100644 --- a/Makefile.emscripten +++ b/Makefile.emscripten @@ -40,4 +40,4 @@ translations: clean: $(MAKE) -C src/dist clean $(MAKE) -C files/lang clean - rm -f fheroes2.data fheroes2.js fheroes2.wasm + -rm -f fheroes2.data fheroes2.js fheroes2.wasm diff --git a/Makefile.switch b/Makefile.switch index 86293484ddf..f51159e7f4b 100644 --- a/Makefile.switch +++ b/Makefile.switch @@ -1,6 +1,6 @@ ########################################################################### # fheroes2: https://github.com/ihhub/fheroes2 # -# Copyright (C) 2021 - 2024 # +# Copyright (C) 2021 - 2025 # # # # This program is free software; you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # @@ -40,4 +40,4 @@ all: clean: $(MAKE) -C src/dist clean - rm -f fheroes2.elf fheroes2.nacp fheroes2.nro + -rm -f fheroes2.elf fheroes2.nacp fheroes2.nro diff --git a/Makefile.vita b/Makefile.vita index 956ec8d6694..cc88145ed25 100644 --- a/Makefile.vita +++ b/Makefile.vita @@ -41,7 +41,7 @@ fheroes2.vpk: eboot.bin param.sfo translations --add files/data=files/data \ --add files/lang/vita_temp=files/lang \ fheroes2.vpk - rm -r files/lang/vita_temp + rm -rf files/lang/vita_temp translations: fheroes2.elf $(MAKE) -C files/lang @@ -65,4 +65,4 @@ fheroes2.elf: clean: $(MAKE) -C src/dist clean $(MAKE) -C files/lang clean - rm -f fheroes2.velf fheroes2.elf fheroes2.vpk eboot.bin param.sfo + -rm -f fheroes2.velf fheroes2.elf fheroes2.vpk eboot.bin param.sfo diff --git a/docs/Makefile b/docs/Makefile index 18761f24d8c..9a6c0eb1416 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -1,6 +1,6 @@ ########################################################################### # fheroes2: https://github.com/ihhub/fheroes2 # -# Copyright (C) 2022 - 2024 # +# Copyright (C) 2022 - 2025 # # # # This program is free software; you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # @@ -40,4 +40,4 @@ all: sed -e '$(SEDEX)' fheroes2.6.in > fheroes2.6 clean: - rm -f fheroes2.6 + -rm -f fheroes2.6 diff --git a/files/lang/Makefile b/files/lang/Makefile index 6c731317eef..d53daa78d04 100644 --- a/files/lang/Makefile +++ b/files/lang/Makefile @@ -1,6 +1,6 @@ ########################################################################### # fheroes2: https://github.com/ihhub/fheroes2 # -# Copyright (C) 2024 # +# Copyright (C) 2024 - 2025 # # # # This program is free software; you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # @@ -65,4 +65,4 @@ ro.mo: ro.po sed -e 'y/äëïöőüűÄËÏŐÖÜŰ/aeioouuAEIOOUU/' $< | $(ICONV) -f utf-8 -t ascii//TRANSLIT | msgfmt - -o $@ clean: - rm -f *.mo *.po~ + -rm -f *.mo *.po~ diff --git a/src/dist/engine/Makefile b/src/dist/engine/Makefile index 5e696bd9513..2b6ad67f7ba 100644 --- a/src/dist/engine/Makefile +++ b/src/dist/engine/Makefile @@ -1,6 +1,6 @@ ########################################################################### # fheroes2: https://github.com/ihhub/fheroes2 # -# Copyright (C) 2021 - 2024 # +# Copyright (C) 2021 - 2025 # # # # This program is free software; you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # @@ -37,4 +37,4 @@ libengine.a: $(notdir $(patsubst %.cpp, %.o, $(wildcard $(SOURCEDIR)/*.cpp))) include $(wildcard *.d) clean: - rm -f *.d *.o libengine.a + -rm -f *.d *.o libengine.a diff --git a/src/dist/fheroes2/Makefile b/src/dist/fheroes2/Makefile index 01bf5938a10..43152b4b3d0 100644 --- a/src/dist/fheroes2/Makefile +++ b/src/dist/fheroes2/Makefile @@ -57,4 +57,4 @@ fheroes2.pot: $(SOURCES) include $(wildcard *.d) clean: - rm -f *.d *.o fheroes2 fheroes2.data fheroes2.js fheroes2.wasm fheroes2.pot fheroes2.pot~ + -rm -f *.d *.o fheroes2 fheroes2.data fheroes2.js fheroes2.wasm fheroes2.pot fheroes2.pot~ diff --git a/src/dist/thirdparty/libsmacker/Makefile b/src/dist/thirdparty/libsmacker/Makefile index 7ab8f0503a2..caa8379dccd 100644 --- a/src/dist/thirdparty/libsmacker/Makefile +++ b/src/dist/thirdparty/libsmacker/Makefile @@ -1,6 +1,6 @@ ########################################################################### # fheroes2: https://github.com/ihhub/fheroes2 # -# Copyright (C) 2022 - 2024 # +# Copyright (C) 2022 - 2025 # # # # This program is free software; you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # @@ -31,4 +31,4 @@ smacker.o: ../../../thirdparty/libsmacker/smacker.c include $(wildcard *.d) clean: - rm -f *.d *.o libsmacker.a + -rm -f *.d *.o libsmacker.a diff --git a/src/dist/tools/Makefile b/src/dist/tools/Makefile index 1179485f57a..ad6767ddc7c 100644 --- a/src/dist/tools/Makefile +++ b/src/dist/tools/Makefile @@ -1,6 +1,6 @@ ########################################################################### # fheroes2: https://github.com/ihhub/fheroes2 # -# Copyright (C) 2021 - 2024 # +# Copyright (C) 2021 - 2025 # # # # This program is free software; you can redistribute it and/or modify # # it under the terms of the GNU General Public License as published by # @@ -33,4 +33,4 @@ $(TARGETS): %: %.o ../engine/libengine.a include $(wildcard *.d) clean: - rm -f *.d *.o $(TARGETS) + -rm -f *.d *.o $(TARGETS) From 5cfd8ce38464ffe4144a646e402862c55ec55cf5 Mon Sep 17 00:00:00 2001 From: Oleg Derevenetz Date: Mon, 6 Jan 2025 17:44:28 +0300 Subject: [PATCH 3/7] Simplify the logic even more --- src/dist/Makefile | 10 +++++++++- src/dist/Makefile.emscripten | 2 ++ src/dist/fheroes2/Makefile | 8 +------- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/dist/Makefile b/src/dist/Makefile index 4c53f105d13..c0f1c4e33b8 100644 --- a/src/dist/Makefile +++ b/src/dist/Makefile @@ -80,6 +80,14 @@ endif include Makefile.$(PLATFORM) +# +# Name of the main target executable file +# This name can be platform-specific (and can already be defined in a platform-specific Makefile) +# +ifeq ($(origin TARGET),undefined) +TARGET := fheroes2 +endif + # # Build options for third-party libraries # @@ -150,7 +158,7 @@ endif CCFLAGS := $(CCFLAGS) $(SDL_FLAGS) LIBS := $(SDL_LIBS) $(LIBS) -export CC CXX AR CCFLAGS CFLAGS CXXFLAGS CPPFLAGS LDFLAGS LIBS PLATFORM +export CC CXX AR CCFLAGS CFLAGS CXXFLAGS CPPFLAGS LDFLAGS LIBS TARGET .PHONY: all clean diff --git a/src/dist/Makefile.emscripten b/src/dist/Makefile.emscripten index 6667e6376c0..d242c4b5c19 100644 --- a/src/dist/Makefile.emscripten +++ b/src/dist/Makefile.emscripten @@ -18,6 +18,8 @@ # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # ########################################################################### +TARGET := fheroes2.js + CCFLAGS := $(filter-out -pthread,$(CCFLAGS)) \ --use-port=sdl2 \ --use-port=sdl2_mixer \ diff --git a/src/dist/fheroes2/Makefile b/src/dist/fheroes2/Makefile index 43152b4b3d0..3fa3e29481b 100644 --- a/src/dist/fheroes2/Makefile +++ b/src/dist/fheroes2/Makefile @@ -18,12 +18,6 @@ # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # ########################################################################### -ifeq ($(PLATFORM),emscripten) - TARGET := fheroes2.js -else - TARGET := fheroes2 -endif - DEPLIBS := ../engine/libengine.a CCFLAGS := $(CCFLAGS) -I../../engine @@ -57,4 +51,4 @@ fheroes2.pot: $(SOURCES) include $(wildcard *.d) clean: - -rm -f *.d *.o fheroes2 fheroes2.data fheroes2.js fheroes2.wasm fheroes2.pot fheroes2.pot~ + -rm -f *.d *.o fheroes2 fheroes2.* From 32eb96077d554881415d75aa060209078047b195 Mon Sep 17 00:00:00 2001 From: Oleg Derevenetz Date: Mon, 6 Jan 2025 18:05:13 +0300 Subject: [PATCH 4/7] Update the .gitignore --- .gitignore | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 3793277c993..0997b01caf5 100644 --- a/.gitignore +++ b/.gitignore @@ -98,8 +98,7 @@ android/app/src/main/assets/ .DS_Store # Web build artifacts -*.wasm -*.wasm.map -fheroes2.js fheroes2.data -src/dist/web/dist/* +fheroes2.js +fheroes2.wasm +fheroes2.wasm.map From 312956967334d283bb675a41d050b61036c1c39e Mon Sep 17 00:00:00 2001 From: Oleg Derevenetz Date: Mon, 6 Jan 2025 18:17:11 +0300 Subject: [PATCH 5/7] Specify the SDL2_MIXER_FORMATS at the compile phase as well --- src/dist/Makefile.emscripten | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/dist/Makefile.emscripten b/src/dist/Makefile.emscripten index d242c4b5c19..8010a5fbab2 100644 --- a/src/dist/Makefile.emscripten +++ b/src/dist/Makefile.emscripten @@ -23,7 +23,8 @@ TARGET := fheroes2.js CCFLAGS := $(filter-out -pthread,$(CCFLAGS)) \ --use-port=sdl2 \ --use-port=sdl2_mixer \ - --use-port=zlib + --use-port=zlib \ + -sSDL2_MIXER_FORMATS=mid,mp3,ogg LDFLAGS := $(filter-out -pthread,$(LDFLAGS)) \ --preload-file ../../../files/data/resurrection.h2d@/files/data/resurrection.h2d \ From 600803a8e99c65d55f100be9d008ef86f8c9cac4 Mon Sep 17 00:00:00 2001 From: Oleg Derevenetz Date: Mon, 6 Jan 2025 18:21:40 +0300 Subject: [PATCH 6/7] Copy the fheroes2.wasm.map file if generated --- Makefile.emscripten | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile.emscripten b/Makefile.emscripten index ff1def9fbc7..22deca34c8d 100644 --- a/Makefile.emscripten +++ b/Makefile.emscripten @@ -32,7 +32,8 @@ fheroes2.js: translations $(MAKE) -C src/dist PLATFORM=emscripten cp src/dist/fheroes2/fheroes2.data . cp src/dist/fheroes2/fheroes2.js . - cp src/dist/fheroes2/fheroes2.wasm . + # The fheroes2.wasm.map file can also be generated in debug mode + cp src/dist/fheroes2/fheroes2.wasm* . translations: $(MAKE) -C files/lang @@ -40,4 +41,4 @@ translations: clean: $(MAKE) -C src/dist clean $(MAKE) -C files/lang clean - -rm -f fheroes2.data fheroes2.js fheroes2.wasm + -rm -f fheroes2.data fheroes2.js fheroes2.wasm* From 1f28bdc259404326e58e8d2ef05dc83e49952530 Mon Sep 17 00:00:00 2001 From: Oleg Derevenetz Date: Mon, 6 Jan 2025 18:35:35 +0300 Subject: [PATCH 7/7] Fix the format of the comment --- Makefile.emscripten | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.emscripten b/Makefile.emscripten index 22deca34c8d..fb77ee38392 100644 --- a/Makefile.emscripten +++ b/Makefile.emscripten @@ -32,7 +32,7 @@ fheroes2.js: translations $(MAKE) -C src/dist PLATFORM=emscripten cp src/dist/fheroes2/fheroes2.data . cp src/dist/fheroes2/fheroes2.js . - # The fheroes2.wasm.map file can also be generated in debug mode +# The fheroes2.wasm.map file can also be generated in debug mode cp src/dist/fheroes2/fheroes2.wasm* . translations: