| 1 | ########################################################################### |
| 2 | # fheroes2: https://github.com/ihhub/fheroes2 # |
| 3 | # Copyright (C) 2021 - 2025 # |
| 4 | # # |
| 5 | # This program is free software; you can redistribute it and/or modify # |
| 6 | # it under the terms of the GNU General Public License as published by # |
| 7 | # the Free Software Foundation; either version 2 of the License, or # |
| 8 | # (at your option) any later version. # |
| 9 | # # |
| 10 | # This program is distributed in the hope that it will be useful, # |
| 11 | # but WITHOUT ANY WARRANTY; without even the implied warranty of # |
| 12 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # |
| 13 | # GNU General Public License for more details. # |
| 14 | # # |
| 15 | # You should have received a copy of the GNU General Public License # |
| 16 | # along with this program; if not, write to the # |
| 17 | # Free Software Foundation, Inc., # |
| 18 | # 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # |
| 19 | ########################################################################### |
| 20 | |
| 21 | # Options: |
| 22 | # |
| 23 | # FHEROES2_STRICT_COMPILATION: build in strict compilation mode (turns warnings into errors) |
| 24 | # FHEROES2_WITH_DEBUG: build in debug mode |
| 25 | # FHEROES2_WITH_ASAN: build with UB Sanitizer and Address Sanitizer (small runtime overhead, incompatible with FHEROES2_WITH_TSAN) |
| 26 | # FHEROES2_WITH_TSAN: build with UB Sanitizer and Thread Sanitizer (large runtime overhead, incompatible with FHEROES2_WITH_ASAN) |
| 27 | # FHEROES2_WITH_IMAGE: build with SDL_image (requires libpng) |
| 28 | # FHEROES2_WITH_SYSTEM_SMACKER: build with an external libsmacker instead of the bundled one |
| 29 | # FHEROES2_WITH_TOOLS: build additional tools |
| 30 | # FHEROES2_MACOS_APP_BUNDLE: create a Mac app bundle (only valid when building on macOS) |
| 31 | # FHEROES2_DATA: set the built-in path to the fheroes2 data directory (e.g. /usr/share/fheroes2) |
| 32 | |
| 33 | PROJECT_NAME := fheroes2 |
| 34 | PROJECT_VERSION := $(file < version.txt) |
| 35 | |
| 36 | .PHONY: all clean |
| 37 | |
| 38 | all: |
| 39 | $(MAKE) -C src/dist |
| 40 | $(MAKE) -C files/lang |
| 41 | ifdef FHEROES2_MACOS_APP_BUNDLE |
| 42 | mkdir -p fheroes2.app/Contents/MacOS |
| 43 | mkdir -p fheroes2.app/Contents/Resources/h2d |
| 44 | mkdir -p fheroes2.app/Contents/Resources/maps |
| 45 | mkdir -p fheroes2.app/Contents/Resources/translations |
| 46 | cp files/data/*.h2d fheroes2.app/Contents/Resources/h2d |
| 47 | cp files/lang/*.mo fheroes2.app/Contents/Resources/translations |
| 48 | cp maps/*.fh2m fheroes2.app/Contents/Resources/maps |
| 49 | cp src/dist/fheroes2/fheroes2 fheroes2.app/Contents/MacOS |
| 50 | cp src/resources/fheroes2.icns fheroes2.app/Contents/Resources |
| 51 | sed -e "s/\$${MACOSX_BUNDLE_BUNDLE_NAME}/$(PROJECT_NAME)/" \ |
| 52 | -e "s/\$${MACOSX_BUNDLE_BUNDLE_VERSION}/$(PROJECT_VERSION)/" \ |
| 53 | -e "s/\$${MACOSX_BUNDLE_EXECUTABLE_NAME}/fheroes2/" \ |
| 54 | -e "s/\$${MACOSX_BUNDLE_GUI_IDENTIFIER}/org.fheroes2.$(PROJECT_NAME)/" \ |
| 55 | -e "s/\$${MACOSX_BUNDLE_ICON_FILE}/fheroes2.icns/" \ |
| 56 | -e "s/\$${MACOSX_BUNDLE_SHORT_VERSION_STRING}/$(PROJECT_VERSION)/" src/resources/Info.plist.in > fheroes2.app/Contents/Info.plist |
| 57 | dylibbundler -od -b -x fheroes2.app/Contents/MacOS/fheroes2 -d fheroes2.app/Contents/libs |
| 58 | else |
| 59 | cp src/dist/fheroes2/fheroes2 . |
| 60 | endif |
| 61 | |
| 62 | clean: |
| 63 | $(MAKE) -C src/dist clean |
| 64 | $(MAKE) -C files/lang clean |
| 65 | -rm -rf fheroes2 fheroes2.app |