| 1 |
########################################################################### |
| 2 |
# fheroes2: https://github.com/ihhub/fheroes2 # |
| 3 |
# Copyright (C) 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 |
TARGET := fheroes2.js |
| 22 |
|
| 23 |
SDL2_MIXER_FORMATS := mid,mp3,ogg |
| 24 |
|
| 25 |
CCFLAGS := $(CCFLAGS) \ |
| 26 |
--use-port=sdl2 \ |
| 27 |
--use-port=sdl2_mixer \ |
| 28 |
--use-port=zlib \ |
| 29 |
-sSDL2_MIXER_FORMATS=$(SDL2_MIXER_FORMATS) \ |
| 30 |
-sSTRICT |
| 31 |
|
| 32 |
LDFLAGS := $(LDFLAGS) \ |
| 33 |
$(patsubst %, --preload-file ../%@/files/data/, $(wildcard ../../files/data/*.h2d)) \ |
| 34 |
$(patsubst %, --preload-file ../%@/files/lang/, $(wildcard ../../files/lang/*.mo)) \ |
| 35 |
--preload-file ../../../files/timidity/timidity.cfg@/files/timidity/ \ |
| 36 |
$(patsubst %, --preload-file ../%@/files/timidity/instruments/, $(wildcard ../../files/timidity/instruments/*.pat)) \ |
| 37 |
$(patsubst %, --preload-file ../%@/maps/, $(wildcard ../../maps/*.fh2m)) \ |
| 38 |
-sALLOW_MEMORY_GROWTH \ |
| 39 |
-sASYNCIFY \ |
| 40 |
-sASYNCIFY_STACK_SIZE=64kb \ |
| 41 |
-sINCOMING_MODULE_JS_API=canvas,preRun,setStatus \ |
| 42 |
-sINITIAL_MEMORY=128mb \ |
| 43 |
-sMEMORY_GROWTH_LINEAR_STEP=32mb \ |
| 44 |
-sNO_DISABLE_EXCEPTION_CATCHING \ |
| 45 |
-sSDL2_MIXER_FORMATS=$(SDL2_MIXER_FORMATS) \ |
| 46 |
-sSTACK_SIZE=256kb \ |
| 47 |
-sSTRICT \ |
| 48 |
-lGL \ |
| 49 |
-lhtml5 \ |
| 50 |
-lidbfs.js |
| 51 |
|
| 52 |
ifdef FHEROES2_WITH_DEBUG |
| 53 |
CCFLAGS := $(CCFLAGS) -gsource-map |
| 54 |
LDFLAGS := $(LDFLAGS) -O0 -gsource-map |
| 55 |
else |
| 56 |
CCFLAGS := $(CCFLAGS) -flto |
| 57 |
LDFLAGS := $(LDFLAGS) -O3 -flto |
| 58 |
endif |
| 59 |
|
| 60 |
ifdef FHEROES2_WITH_THREADS |
| 61 |
LDFLAGS := $(LDFLAGS) \ |
| 62 |
-Wno-pthreads-mem-growth \ |
| 63 |
-sALLOW_BLOCKING_ON_MAIN_THREAD \ |
| 64 |
-sENVIRONMENT=web,worker \ |
| 65 |
-sPTHREAD_POOL_SIZE=8 |
| 66 |
else |
| 67 |
CCFLAGS := $(filter-out -pthread,$(CCFLAGS)) |
| 68 |
|
| 69 |
LDFLAGS := $(filter-out -pthread,$(LDFLAGS)) \ |
| 70 |
-sENVIRONMENT=web \ |
| 71 |
-sNO_ALLOW_BLOCKING_ON_MAIN_THREAD |
| 72 |
endif |