Skip to content

Commit

Permalink
Use a separate directory for binaries when building using GNU Make (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
oleg-derevenetz authored Dec 8, 2024
1 parent 5ce77ce commit 2804353
Show file tree
Hide file tree
Showing 21 changed files with 313 additions and 320 deletions.
53 changes: 24 additions & 29 deletions .github/workflows/make.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,14 @@ jobs:
LICENSE
./docs/GRAPHICAL_ASSETS.md
./script/agg/extract_agg.sh
./src/tools/82m2wav
./src/tools/bin2txt
./src/tools/extractor
./src/tools/h2dmgr
./src/tools/icn2img
./src/tools/pal2img
./src/tools/til2img
./src/tools/xmi2midi
./src/dist/tools/82m2wav
./src/dist/tools/bin2txt
./src/dist/tools/extractor
./src/dist/tools/h2dmgr
./src/dist/tools/icn2img
./src/dist/tools/pal2img
./src/dist/tools/til2img
./src/dist/tools/xmi2midi
release_name: Ubuntu x86-64 (Linux) build with SDL2 (latest commit)
release_tag: fheroes2-linux-sdl2_dev
- name: Linux x86-64 SDL2 Debug
Expand Down Expand Up @@ -79,14 +79,14 @@ jobs:
LICENSE
./docs/GRAPHICAL_ASSETS.md
./script/agg/extract_agg.sh
./src/tools/82m2wav
./src/tools/bin2txt
./src/tools/extractor
./src/tools/h2dmgr
./src/tools/icn2img
./src/tools/pal2img
./src/tools/til2img
./src/tools/xmi2midi
./src/dist/tools/82m2wav
./src/dist/tools/bin2txt
./src/dist/tools/extractor
./src/dist/tools/h2dmgr
./src/dist/tools/icn2img
./src/dist/tools/pal2img
./src/dist/tools/til2img
./src/dist/tools/xmi2midi
release_name: Ubuntu ARM64 (Linux) build with SDL2 (latest commit)
release_tag: fheroes2-linux-arm-sdl2_dev
- name: Linux ARM64 SDL2 Debug
Expand Down Expand Up @@ -124,14 +124,14 @@ jobs:
LICENSE
./docs/GRAPHICAL_ASSETS.md
./script/agg/extract_agg.sh
./src/tools/82m2wav
./src/tools/bin2txt
./src/tools/extractor
./src/tools/h2dmgr
./src/tools/icn2img
./src/tools/pal2img
./src/tools/til2img
./src/tools/xmi2midi
./src/dist/tools/82m2wav
./src/dist/tools/bin2txt
./src/dist/tools/extractor
./src/dist/tools/h2dmgr
./src/dist/tools/icn2img
./src/dist/tools/pal2img
./src/dist/tools/til2img
./src/dist/tools/xmi2midi
release_name: macOS x86-64 build with SDL2 (latest commit)
release_tag: fheroes2-osx-sdl2_dev
- name: macOS SDL2 App Bundle
Expand Down Expand Up @@ -175,11 +175,6 @@ jobs:
run: |
make -j 2
env: ${{ matrix.config.env }}
- name: Create app bundle
if: ${{ startsWith( matrix.config.os, 'macos-' ) }}
run: |
make -j 2 bundle
env: ${{ matrix.config.env }}
- name: Create package
if: ${{ matrix.config.package_name != '' && matrix.config.package_files != '' }}
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/translation_update.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
echo "PR_BRANCH=$PR_BRANCH" >> "$GITHUB_ENV"
- name: Generate POT
run: |
make -C src/dist -j 2 pot
make -C src/dist/fheroes2 -j 2 pot
- name: Merge PO with POT
run: |
make -C files/lang -j 2 merge
Expand Down
42 changes: 21 additions & 21 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -30,34 +30,34 @@
# FHEROES2_MACOS_APP_BUNDLE: create a Mac app bundle (only valid when building on macOS)
# FHEROES2_DATA: set the built-in path to the fheroes2 data directory (e.g. /usr/share/fheroes2)

TARGET := fheroes2
PROJECT_NAME := fheroes2
PROJECT_VERSION := $(file < version.txt)

.PHONY: all bundle clean
.PHONY: all clean

all:
$(MAKE) -C src
$(MAKE) -C src/dist
$(MAKE) -C files/lang
ifndef FHEROES2_MACOS_APP_BUNDLE
@cp src/dist/$(TARGET) .
endif

bundle:
ifdef FHEROES2_MACOS_APP_BUNDLE
@mkdir -p "src/dist/$(TARGET).app/Contents/Resources/translations"
@mkdir -p "src/dist/$(TARGET).app/Contents/Resources/h2d"
@mkdir -p "src/dist/$(TARGET).app/Contents/MacOS"
@cp ./src/resources/fheroes2.icns "src/dist/$(TARGET).app/Contents/Resources"
@cp ./files/lang/*.mo "src/dist/$(TARGET).app/Contents/Resources/translations"
@cp ./files/data/*.h2d "src/dist/$(TARGET).app/Contents/Resources/h2d"
@sed -e "s/\$${MACOSX_BUNDLE_EXECUTABLE_NAME}/$(TARGET)/" -e "s/\$${MACOSX_BUNDLE_ICON_FILE}/fheroes2.icns/" -e "s/\$${MACOSX_BUNDLE_GUI_IDENTIFIER}/com.fheroes2.$(TARGET)/" -e "s/\$${MACOSX_BUNDLE_BUNDLE_NAME}/$(TARGET)/" -e "s/\$${MACOSX_BUNDLE_BUNDLE_VERSION}/$(PROJECT_VERSION)/" -e "s/\$${MACOSX_BUNDLE_SHORT_VERSION_STRING}/$(PROJECT_VERSION)/" ./src/resources/Info.plist.in > "src/dist/$(TARGET).app/Contents/Info.plist"
@mv "src/dist/$(TARGET)" "src/dist/$(TARGET).app/Contents/MacOS"
@dylibbundler -od -b -x "src/dist/$(TARGET).app/Contents/MacOS/$(TARGET)" -d "src/dist/$(TARGET).app/Contents/libs"
@cp -R "src/dist/$(TARGET).app" .
mkdir -p fheroes2.app/Contents/Resources/translations
mkdir -p fheroes2.app/Contents/Resources/h2d
mkdir -p fheroes2.app/Contents/MacOS
cp src/resources/fheroes2.icns fheroes2.app/Contents/Resources
cp files/lang/*.mo fheroes2.app/Contents/Resources/translations
cp files/data/*.h2d fheroes2.app/Contents/Resources/h2d
sed -e "s/\$${MACOSX_BUNDLE_BUNDLE_NAME}/$(PROJECT_NAME)/" \
-e "s/\$${MACOSX_BUNDLE_BUNDLE_VERSION}/$(PROJECT_VERSION)/" \
-e "s/\$${MACOSX_BUNDLE_EXECUTABLE_NAME}/fheroes2/" \
-e "s/\$${MACOSX_BUNDLE_GUI_IDENTIFIER}/org.fheroes2.$(PROJECT_NAME)/" \
-e "s/\$${MACOSX_BUNDLE_ICON_FILE}/fheroes2.icns/" \
-e "s/\$${MACOSX_BUNDLE_SHORT_VERSION_STRING}/$(PROJECT_VERSION)/" src/resources/Info.plist.in > fheroes2.app/Contents/Info.plist
cp src/dist/fheroes2/fheroes2 fheroes2.app/Contents/MacOS
dylibbundler -od -b -x fheroes2.app/Contents/MacOS/fheroes2 -d fheroes2.app/Contents/libs
else
cp src/dist/fheroes2/fheroes2 .
endif

clean:
$(MAKE) -C src clean
$(MAKE) -C src/dist clean
$(MAKE) -C files/lang clean
@rm -f ./$(TARGET)
@rm -rf ./$(TARGET).app
rm -rf fheroes2 fheroes2.app
17 changes: 7 additions & 10 deletions Makefile.switch
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
###########################################################################
# fheroes2: https://github.com/ihhub/fheroes2 #
# Copyright (C) 2021 - 2023 #
# Copyright (C) 2021 - 2024 #
# #
# 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 #
Expand All @@ -24,9 +24,6 @@
# FHEROES2_WITH_DEBUG: build in debug mode
# FHEROES2_DATA: set the built-in path to the fheroes2 data directory (e.g. /usr/share/fheroes2)

TARGET := fheroes2
MAKE := make

PROJECT_TITLE := fheroes2
PROJECT_AUTHOR := fheroes2 resurrection team
PROJECT_VERSION := $(file < version.txt)
Expand All @@ -36,11 +33,11 @@ PATH := $(PATH):/opt/devkitpro/portlibs/switch/bin/:/opt/devkitpro/tools/bin/
.PHONY: all clean

all:
$(MAKE) -f Makefile -C src PLATFORM=switch
@cp src/dist/$(TARGET) $(TARGET).elf
nacptool --create "$(PROJECT_TITLE)" "$(PROJECT_AUTHOR)" "$(PROJECT_VERSION)" $(TARGET).nacp
elf2nro $(TARGET).elf $(TARGET).nro --icon=files/images/platform/switch/icon.jpg --nacp=$(TARGET).nacp
$(MAKE) -C src/dist PLATFORM=switch
cp src/dist/fheroes2/fheroes2 fheroes2.elf
nacptool --create "$(PROJECT_TITLE)" "$(PROJECT_AUTHOR)" "$(PROJECT_VERSION)" fheroes2.nacp
elf2nro fheroes2.elf fheroes2.nro --icon=files/images/platform/switch/icon.jpg --nacp=fheroes2.nacp

clean:
$(MAKE) -f Makefile -C src clean
@rm -rf $(TARGET).elf $(TARGET).nacp $(TARGET).nro
$(MAKE) -C src/dist clean
rm -f fheroes2.elf fheroes2.nacp fheroes2.nro
33 changes: 14 additions & 19 deletions Makefile.vita
Original file line number Diff line number Diff line change
Expand Up @@ -24,50 +24,45 @@
# FHEROES2_WITH_DEBUG: build in debug mode
# FHEROES2_DATA: set the built-in path to the fheroes2 data directory (e.g. /usr/share/fheroes2)

TARGET := fheroes2
MAKE := make

PROJECT_TITLE := fheroes2
PROJECT_TITLEID := FHOMM0002
PROJECT_VERSION := $(file < version.txt)

.PHONY: all clean $(TARGET).vpk param.sfo $(TARGET).elf translations

all: package
.PHONY: all clean fheroes2.vpk param.sfo fheroes2.elf translations

package: $(TARGET).vpk
all: fheroes2.vpk

$(TARGET).vpk: eboot.bin param.sfo translations
fheroes2.vpk: eboot.bin param.sfo translations
vita-pack-vpk -s param.sfo -b eboot.bin \
--add files/images/platform/psv/sce_sys/icon0.png=sce_sys/icon0.png \
--add files/images/platform/psv/sce_sys/livearea/contents/bg.png=sce_sys/livearea/contents/bg.png \
--add files/images/platform/psv/sce_sys/livearea/contents/startup.png=sce_sys/livearea/contents/startup.png \
--add files/images/platform/psv/sce_sys/livearea/contents/template.xml=sce_sys/livearea/contents/template.xml \
--add files/data=files/data \
--add files/lang/vita_temp=files/lang \
$(TARGET).vpk
@rm -r files/lang/vita_temp
fheroes2.vpk
rm -r files/lang/vita_temp

translations: $(TARGET).elf
translations: fheroes2.elf
$(MAKE) -C files/lang
mkdir -p files/lang/vita_temp
cp files/lang/*.mo files/lang/vita_temp

eboot.bin: $(TARGET).velf
vita-make-fself $(TARGET).velf eboot.bin
eboot.bin: fheroes2.velf
vita-make-fself fheroes2.velf eboot.bin

param.sfo:
vita-mksfoex -s TITLE_ID="$(PROJECT_TITLEID)" -s APP_VER="$(PROJECT_VERSION)" "$(PROJECT_TITLE)" param.sfo

$(TARGET).velf: $(TARGET).elf
fheroes2.velf: fheroes2.elf
arm-vita-eabi-strip -g $<
vita-elf-create $< $@

$(TARGET).elf:
$(MAKE) -f Makefile -C src PLATFORM=vita
@cp src/dist/$(TARGET) $(TARGET).elf
fheroes2.elf:
$(MAKE) -C src/dist PLATFORM=vita
cp src/dist/fheroes2/fheroes2 fheroes2.elf

clean:
$(MAKE) -f Makefile -C src clean
$(MAKE) -C src/dist clean
$(MAKE) -C files/lang clean
@rm -rf $(TARGET).velf $(TARGET).elf $(TARGET).vpk eboot.bin param.sfo
rm -f fheroes2.velf fheroes2.elf fheroes2.vpk eboot.bin param.sfo
7 changes: 3 additions & 4 deletions docs/INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,11 +126,10 @@ Follow the [**instructions below**](#macos-resources) to gather resources necess
<a name="macos-native-app"></a>
### macOS native app

* Download the source and compile with the `-DMACOS_APP_BUNDLE=ON` option (if using CMake) or using the following commands (with make):
* Download the source and compile with the `-DMACOS_APP_BUNDLE=ON` option (if using CMake) or using the following command (with make):

```sh
make FHEROES2_MACOS_APP_BUNDLE=ON
make FHEROES2_MACOS_APP_BUNDLE=ON bundle
```

Follow the [**instructions below**](#macos-resources) to gather resources necessary for fheroes2 to function as expected.
Expand Down Expand Up @@ -159,8 +158,8 @@ Once you obtain the fheroes2 executable using any of the options above, you shou
* If you don't have a legally purchased copy of the original game, you can download and install the demo version of the original game
by running the download demo script. The script can be run from the following paths depending on how you installed fheroes2:
* `fheroes2-install-demo` if you used a package manager (MacPorts or Homebrew);
* `script/homm2/download_demo_version_for_app_bundles.sh` if you built from source using the [**macOS native app**](#macos-native-app) method;
* `script/homm2/download_demo_version.sh` for all other cases.
* `script/demo/download_demo_version_for_app_bundle.sh` if you built from source using the [**macOS native app**](#macos-native-app) method;
* `script/demo/download_demo_version.sh` for all other cases.

<a name="linux"></a>
## Linux
Expand Down
6 changes: 3 additions & 3 deletions docs/Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
###########################################################################
# fheroes2: https://github.com/ihhub/fheroes2 #
# Copyright (C) 2022 #
# Copyright (C) 2022 - 2024 #
# #
# 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 #
Expand Down Expand Up @@ -37,7 +37,7 @@ endif
.PHONY: all clean

all:
@sed -e '$(SEDEX)' fheroes2.6.in > fheroes2.6
sed -e '$(SEDEX)' fheroes2.6.in > fheroes2.6

clean:
@rm -f fheroes2.6
rm -f fheroes2.6
8 changes: 4 additions & 4 deletions docs/TRANSLATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -144,10 +144,10 @@ example creature names or castle buildings.

## Updating PO templates and translatable strings in PO files

Currently all PO files are automatically updated with new strings after each commit that brings changes to the ingame text. If for whatever
reason you still need to update strings locally, this can be achieved by running the command below in `src/dist` to generate a new portable
object template (POT) file. Windows users will need to set up an environment that lets them run `make`, like Windows Subsystem for Linux (WSL)
or [**Cygwin**](https://www.cygwin.com/)/[**MSYS2**](https://www.msys2.org/).
Currently all PO files are automatically updated with new strings after each commit that brings changes to the ingame text. If for whatever reason
you still need to update strings locally, this can be achieved by running the command below in `src/dist/fheroes2` to generate a new portable object
template (POT) file. Windows users will need to set up an environment that lets them run `make`, like Windows Subsystem for Linux (WSL) or
[**Cygwin**](https://www.cygwin.com/)/[**MSYS2**](https://www.msys2.org/).

```bash
make pot
Expand Down
2 changes: 1 addition & 1 deletion files/lang/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ MSGFMT = sed -e '1,20 s/UTF-8/$(1)/' $< | $(ICONV) -f utf-8 -t $(1) | if msgfmt

all: $(patsubst %.po, %.mo, $(wildcard *.po))

merge: ../../src/dist/fheroes2.pot
merge: ../../src/dist/fheroes2/fheroes2.pot
for i in $(wildcard *.po); do msgmerge -U --no-location $$i $<; done

# Czech, Hungarian, Polish and Slovak versions use CP1250
Expand Down
Loading

0 comments on commit 2804353

Please sign in to comment.