| 1 |
# Makefile to build and perform other useful operations on the Castle Game Engine. |
| 2 |
# |
| 3 |
# Requires using GNU make. |
| 4 |
# - On Linux and most other Unixes, just call "make". |
| 5 |
# - On FreeBSD call "gmake". |
| 6 |
# - On Windows, install Cygwin ( http://www.cygwin.com/ ) with "make" package. |
| 7 |
# Make sure that when you type "make" it executes Cygwin's "make": |
| 8 |
# Cygwin's directory (like c:/cygwin64/bin/) should be on $PATH environment variable |
| 9 |
# *before* other directories with "make" implementations, like |
| 10 |
# - FPC directory that includes "make" from MinGW (it is GNU make but cannot execute bash scripts) |
| 11 |
# - Delphi directory that includes Embarcadero "make" (it's not GNU make and will fail). |
| 12 |
# |
| 13 |
# Most useful targets of this Makefile: |
| 14 |
# |
| 15 |
# default (default target) -- |
| 16 |
# Build the most useful things: |
| 17 |
# - tools not depending on LCL (including build tool) |
| 18 |
# - editor |
| 19 |
# Also, register all Lazarus packages. |
| 20 |
# Also, place all tools and editor in bin/ subdirectory. |
| 21 |
# |
| 22 |
# tools -- |
| 23 |
# Build all tools that don't depend on LCL. |
| 24 |
# Right now it means: all tools except castle-editor. |
| 25 |
# |
| 26 |
# examples -- |
| 27 |
# Compile most examples and tools (that don't use Lazarus LCL). |
| 28 |
# Lazarus is not required (LCL dependent examples are not compiled). |
| 29 |
# |
| 30 |
# This compilation method calls our "build tool" to compile examples |
| 31 |
# and other tools (build tool, in turn, calls a compiler like FPC or Delphi). |
| 32 |
# |
| 33 |
# The exception is when compiling the "build tool" itself, |
| 34 |
# then we call FPC directly. (Although we *could* use |
| 35 |
# the "build tool" to compile (bootstrap) itself, but it's not what |
| 36 |
# people expect by default, so we don't do it for now.) |
| 37 |
# |
| 38 |
# examples-laz -- |
| 39 |
# Compile all examples and tools using Lazarus (lazbuild). |
| 40 |
# This compilation method uses our .lpi project files, |
| 41 |
# and compiles every program by the lazbuild utility. |
| 42 |
# Lazarus and FPC installation is required. |
| 43 |
# |
| 44 |
# build-using-fpmake: |
| 45 |
# Compile all units using FpMake. |
| 46 |
# We support this as an optional build approach to CGE and applications using CGE. |
| 47 |
# See https://castle-engine.io/fpmake . |
| 48 |
# |
| 49 |
# clean -- |
| 50 |
# Delete FPC temporary files, Delphi temporary files, |
| 51 |
# Lazarus temporary files (*.compiled), |
| 52 |
# binaries of example programs and tools. |
| 53 |
|
| 54 |
# detect platform-specific things -------------------------------------------- |
| 55 |
|
| 56 |
# FIND := Unix/Cygwin "find" utility (*not* Windows "find" command which has completely different use) |
| 57 |
# SED := GNU sed (*not* other sed implementations) |
| 58 |
# EXE_EXTENSION := extension of executable files (with leading dot, if any) |
| 59 |
|
| 60 |
SED := sed |
| 61 |
FIND := find |
| 62 |
INSTALL := install |
| 63 |
EXE_EXTENSION := |
| 64 |
|
| 65 |
# Detect Windows when $OS is Windows_NT or win64. |
| 66 |
# Other $OS, including when $OS is empty / undefined, must be non-Windows. |
| 67 |
# See https://stackoverflow.com/questions/7656425/makefile-ifeq-logical-or#9802777 |
| 68 |
# to how this trick to detect an alternative works. |
| 69 |
ifneq (,$(filter $(OS),Windows_NT win64)) |
| 70 |
$(info Detected OS: Windows) |
| 71 |
|
| 72 |
# On Windows avoid using Windows built-in "find" program. Use the Cygwin "find". |
| 73 |
FIND := `cygpath --mixed /bin/find` |
| 74 |
EXE_EXTENSION := .exe |
| 75 |
else |
| 76 |
# Only on Unix, you can use "uname" to further detect Unix variants, |
| 77 |
# see https://stackoverflow.com/questions/714100/os-detecting-makefile |
| 78 |
UNAME_S := $(shell uname -s) |
| 79 |
$(info Detected OS: $(UNAME_S)) |
| 80 |
|
| 81 |
# On macOS, use gsed and ginstall (e.g. from Homebrew, use "brew install gnu-sed coreutils"). |
| 82 |
# See https://www.topbug.net/blog/2013/04/14/install-and-use-gnu-command-line-tools-in-mac-os-x/ |
| 83 |
# http://www.legendu.net/en/blog/install-gnu-utils-using-homebrew/ |
| 84 |
ifeq ($(UNAME_S),Darwin) |
| 85 |
SED := gsed |
| 86 |
INSTALL := ginstall |
| 87 |
endif |
| 88 |
endif |
| 89 |
|
| 90 |
# config --------------------------------------------------------------------- |
| 91 |
|
| 92 |
# By default, use build tool compiled by tools/build-tool/castle-engine_compile.sh . |
| 93 |
# This is easy, and when not cross-compiling, things will just work out-of-the-box, |
| 94 |
# Makefile will always first build the build tool, then use it. |
| 95 |
# |
| 96 |
# You can override it on the command-line like "make BUILD_TOOL=castle-engine" |
| 97 |
# to use build tool on $PATH . |
| 98 |
# This is more reliable in some scenarios: |
| 99 |
# |
| 100 |
# - We will use build tool for current (source) system, even if CASTLE_FPC_OPTIONS |
| 101 |
# uses -T${OS} -P${CPU} to indicate a different (target) system, |
| 102 |
# so castle-engine_compile.sh doesn't build for current system. |
| 103 |
# |
| 104 |
# - Build tool can exist outside of CGE, and thus it exists regardless of "make clean" etc. |
| 105 |
# |
| 106 |
BUILD_TOOL = ./tools/build-tool/castle-engine$(EXE_EXTENSION) |
| 107 |
|
| 108 |
# compiling tools ------------------------------------------------------------ |
| 109 |
|
| 110 |
.PHONY: default |
| 111 |
default: tools |
| 112 |
lazbuild $(CASTLE_LAZBUILD_OPTIONS) --add-package-link packages/castle_base.lpk |
| 113 |
lazbuild $(CASTLE_LAZBUILD_OPTIONS) --add-package-link packages/castle_window.lpk |
| 114 |
lazbuild $(CASTLE_LAZBUILD_OPTIONS) --add-package-link packages/castle_components.lpk |
| 115 |
lazbuild $(CASTLE_LAZBUILD_OPTIONS) --add-package-link packages/castle_editor_components.lpk |
| 116 |
lazbuild $(CASTLE_LAZBUILD_OPTIONS) tools/castle-editor/castle_editor.lpi |
| 117 |
# move binaries to bin/ |
| 118 |
$(INSTALL) -d bin/ |
| 119 |
$(INSTALL) tools/texture-font-to-pascal/texture-font-to-pascal$(EXE_EXTENSION) bin/ |
| 120 |
$(INSTALL) tools/image-to-pascal/image-to-pascal$(EXE_EXTENSION) bin/ |
| 121 |
$(INSTALL) tools/castle-curves/castle-curves$(EXE_EXTENSION) bin/ |
| 122 |
$(INSTALL) tools/build-tool/castle-engine$(EXE_EXTENSION) bin/ |
| 123 |
$(INSTALL) tools/to-data-uri/to-data-uri$(EXE_EXTENSION) bin/ |
| 124 |
$(INSTALL) tools/castle-editor/castle-editor$(EXE_EXTENSION) bin/ |
| 125 |
|
| 126 |
.PHONY: tools |
| 127 |
tools: |
| 128 |
# Compile build tool first, used to compile other tools and examples |
| 129 |
tools/build-tool/castle-engine_compile.sh |
| 130 |
$(BUILD_TOOL) $(CASTLE_ENGINE_TOOL_OPTIONS) --project tools/castle-curves/ compile |
| 131 |
$(BUILD_TOOL) $(CASTLE_ENGINE_TOOL_OPTIONS) --project tools/image-to-pascal/ compile |
| 132 |
$(BUILD_TOOL) $(CASTLE_ENGINE_TOOL_OPTIONS) --project tools/texture-font-to-pascal/ compile |
| 133 |
$(BUILD_TOOL) $(CASTLE_ENGINE_TOOL_OPTIONS) --project tools/to-data-uri/ compile |
| 134 |
|
| 135 |
# install / uninstall -------------------------------------------------------- |
| 136 |
# |
| 137 |
# Note that this *does not* take care of installing the unit files. |
| 138 |
# So it does not copy .ppu/.o files, it does not change your /etc/fpc.cfg |
| 139 |
# or ~/.fpc.cfg. There are many ways how to install unit files, |
| 140 |
# we leave this step up to you. |
| 141 |
# See https://castle-engine.io/engine.php for documentation. |
| 142 |
# |
| 143 |
# Below we only take care of installing the tools. |
| 144 |
# By default they are installed system-wide to /usr/local , |
| 145 |
# so you can run "make" followed by "sudo make install" to have the tools |
| 146 |
# ready on a typical Unix system. |
| 147 |
|
| 148 |
# Standard installation dirs, following conventions on |
| 149 |
# http://www.gnu.org/prep/standards/html_node/Directory-Variables.html#Directory-Variables |
| 150 |
PREFIX=$(DESTDIR)/usr/local |
| 151 |
EXEC_PREFIX=$(PREFIX) |
| 152 |
BINDIR=$(EXEC_PREFIX)/bin |
| 153 |
DATAROOTDIR=$(PREFIX)/share |
| 154 |
DATADIR=$(DATAROOTDIR) |
| 155 |
|
| 156 |
.PHONY: install |
| 157 |
install: |
| 158 |
echo 'Installing tools to $(BINDIR)' |
| 159 |
$(INSTALL) -d $(BINDIR) |
| 160 |
$(INSTALL) tools/texture-font-to-pascal/texture-font-to-pascal$(EXE_EXTENSION) $(BINDIR) |
| 161 |
$(INSTALL) tools/image-to-pascal/image-to-pascal$(EXE_EXTENSION) $(BINDIR) |
| 162 |
$(INSTALL) tools/castle-curves/castle-curves$(EXE_EXTENSION) $(BINDIR) |
| 163 |
$(INSTALL) tools/build-tool/castle-engine$(EXE_EXTENSION) $(BINDIR) |
| 164 |
$(INSTALL) tools/to-data-uri/to-data-uri$(EXE_EXTENSION) $(BINDIR) |
| 165 |
# cp -R tools/build-tool/data $(DATADIR)/castle-engine |
| 166 |
echo 'Installing data to $(DATADIR)/castle-engine/' |
| 167 |
$(INSTALL) -d $(DATADIR) |
| 168 |
cd tools/build-tool/data/ && \ |
| 169 |
"$(FIND)" . -type f -exec $(INSTALL) --mode 644 -D '{}' $(DATADIR)/castle-engine/'{}' ';' |
| 170 |
|
| 171 |
.PHONY: uninstall |
| 172 |
uninstall: |
| 173 |
rm -f $(BINDIR)/texture-font-to-pascal$(EXE_EXTENSION) \ |
| 174 |
$(BINDIR)/image-to-pascal$(EXE_EXTENSION) \ |
| 175 |
$(BINDIR)/castle-curves$(EXE_EXTENSION) \ |
| 176 |
$(BINDIR)/castle-engine$(EXE_EXTENSION) \ |
| 177 |
$(BINDIR)/to-data-uri$(EXE_EXTENSION) |
| 178 |
rm -Rf $(DATADIR)/castle-engine |
| 179 |
|
| 180 |
# Strip libraries that cannot be distributed in Debian package of CGE. |
| 181 |
# - Some of them (some bundled Windows, Android libs) cannot be recompiled |
| 182 |
# automatically and easily for now (although they are open-source), |
| 183 |
# and are not of sufficient interest to the Debian users. |
| 184 |
# - Some (Gradle) should be better used by depending on |
| 185 |
# the appropriate Debian package. |
| 186 |
.PHONY: strip-precompiled-libraries |
| 187 |
strip-precompiled-libraries: |
| 188 |
rm -Rf tools/build-tool/data/external_libraries/ \ |
| 189 |
tools/build-tool/data/android/integrated-services/sound/ \ |
| 190 |
tools/build-tool/data/android/integrated-services/ogg_vorbis/ \ |
| 191 |
tools/build-tool/data/android/integrated-services/freetype/ \ |
| 192 |
tools/build-tool/data/android/base/gradle/ \ |
| 193 |
tools/build-tool/data/android/base/gradlew \ |
| 194 |
tools/build-tool/data/android/base/gradlew.bat \ |
| 195 |
tools/build-tool/data/android/integrated/gradle/ \ |
| 196 |
tools/build-tool/data/android/integrated/gradlew \ |
| 197 |
tools/build-tool/data/android/integrated/gradlew.bat |
| 198 |
|
| 199 |
# compiling examples ----------------------------------------------------------- |
| 200 |
|
| 201 |
# For GitHub Actions, we need to conserve disk space in some cases, as it is limited to ~15 GB. |
| 202 |
# |
| 203 |
# When CASTLE_CONSERVE_DISK_SPACE is |
| 204 |
# - true -> prefixing command with $(DO_IF_CONSERVE_DISK_SPACE) makes this command execute. |
| 205 |
# - anything else -> prefixing command with $(DO_IF_CONSERVE_DISK_SPACE) makes this command not execute. |
| 206 |
# |
| 207 |
ifeq ($(CASTLE_CONSERVE_DISK_SPACE),true) |
| 208 |
DO_IF_CONSERVE_DISK_SPACE:= |
| 209 |
else |
| 210 |
DO_IF_CONSERVE_DISK_SPACE:=true |
| 211 |
endif |
| 212 |
|
| 213 |
# Note that examples with CastleEngineManifest.xml are not listed here. |
| 214 |
# They will be found and compiled by a Makefile rule that searches using |
| 215 |
# "find ... -iname CastleEngineManifest.xml ..." . |
| 216 |
|
| 217 |
EXAMPLES_BASE_NAMES := |
| 218 |
|
| 219 |
# Note that src/deprecated_library/castleengine must be compiled before |
| 220 |
# cge_dynlib_tester, otherwise linking cge_dynlib_tester will fail. |
| 221 |
EXAMPLES_LAZARUS_BASE_NAMES := \ |
| 222 |
src/deprecated_library/castleengine \ |
| 223 |
examples/deprecated_library/lazarus_library_tester/cge_dynlib_tester |
| 224 |
|
| 225 |
EXAMPLES_UNIX_EXECUTABLES := $(EXAMPLES_BASE_NAMES) \ |
| 226 |
$(EXAMPLES_LAZARUS_BASE_NAMES) |
| 227 |
|
| 228 |
EXAMPLES_WINDOWS_EXECUTABLES := $(addsuffix .exe,$(EXAMPLES_BASE_NAMES)) \ |
| 229 |
$(addsuffix .exe,$(EXAMPLES_LAZARUS_BASE_NAMES)) |
| 230 |
|
| 231 |
# Test compiling single CGE editor template. |
| 232 |
# Requires CGE_TEMPLATE to be defined. |
| 233 |
.PHONY: test-editor-template |
| 234 |
test-editor-template: |
| 235 |
rm -Rf temporary-test-projects |
| 236 |
$(BUILD_TOOL) $(CASTLE_ENGINE_TOOL_OPTIONS) create test-project --project-parent-dir temporary-test-projects --project-template $(CGE_TEMPLATE) |
| 237 |
$(BUILD_TOOL) $(CASTLE_ENGINE_TOOL_OPTIONS) --project temporary-test-projects/test-project compile |
| 238 |
rm -Rf temporary-test-projects |
| 239 |
|
| 240 |
# Test compiling CGE editor templates |
| 241 |
.PHONY: test-editor-templates |
| 242 |
test-editor-templates: |
| 243 |
$(MAKE) --no-print-directory test-editor-template CGE_TEMPLATE=3d_fps_game |
| 244 |
$(MAKE) --no-print-directory test-editor-template CGE_TEMPLATE=2d_game |
| 245 |
$(MAKE) --no-print-directory test-editor-template CGE_TEMPLATE=empty |
| 246 |
$(MAKE) --no-print-directory test-editor-template CGE_TEMPLATE=3d_model_viewer |
| 247 |
|
| 248 |
.PHONY: examples |
| 249 |
examples: |
| 250 |
# Compile build tool first, used to compile other tools and examples. |
| 251 |
tools/build-tool/castle-engine_compile.sh |
| 252 |
|
| 253 |
# Compile all examples and tools with CastleEngineManifest.xml inside. |
| 254 |
# |
| 255 |
# We want this to fail if some application failed to compile. |
| 256 |
# Unfortunately find seems to ignore -exec result. |
| 257 |
# (see e.g. https://unix.stackexchange.com/questions/392970/how-to-get-the-exit-code-of-commands-started-by-find ) |
| 258 |
# And we cannot use -execdir. |
| 259 |
# We also cannot use find ... | xargs, we need to execute 2 commands for each (compile and clean). |
| 260 |
# |
| 261 |
# So we use find to generate list of projects, then run using simple "for" over them. |
| 262 |
# |
| 263 |
# Exceptions: We do not process: |
| 264 |
# |
| 265 |
# - examples/network/tcp_connection/: because it requires Indy which may not be installed. |
| 266 |
# |
| 267 |
# - tests/delphi_tests: because it requires Delphi, which is not available on non-Windows. |
| 268 |
# |
| 269 |
# - examples/deprecated_library: bacause it requires library first (we could build it.. |
| 270 |
# but it is already tested by examples-laz). |
| 271 |
# |
| 272 |
# - tools/build-tool: because |
| 273 |
# - compilation is tested by "make tools" already, |
| 274 |
# - we don't want to clean it, to have it available for "make test-editor-templates" after this |
| 275 |
# - on Windows, we'd have to make a copy of castle-engine, as you cannot replace own exe. |
| 276 |
"$(FIND)" . \ |
| 277 |
'(' -path ./examples/network/tcp_connection -prune ')' -o \ |
| 278 |
'(' -path ./tools/castle-editor/data/project_templates -prune ')' -o \ |
| 279 |
'(' -path ./tools/build-tool -prune ')' -o \ |
| 280 |
'(' -path ./tests/delphi_tests -prune ')' -o \ |
| 281 |
'(' -path ./examples/delphi -prune ')' -o \ |
| 282 |
'(' -path ./examples/deprecated_library/lazarus_library_tester -prune ')' -o \ |
| 283 |
'(' -type d -iname castle-engine-output -prune ')' -o \ |
| 284 |
'(' -type f -iname CastleEngineManifest.xml -print ')' > \ |
| 285 |
/tmp/cge-projects.txt |
| 286 |
echo 'Found projects: '`wc -l < /tmp/cge-projects.txt` |
| 287 |
set -e && for MANIFEST in `cat /tmp/cge-projects.txt`; do \ |
| 288 |
echo 'Compiling project '$${MANIFEST}; \ |
| 289 |
$(BUILD_TOOL) $(CASTLE_ENGINE_TOOL_OPTIONS) --project $${MANIFEST} compile; \ |
| 290 |
$(DO_IF_CONSERVE_DISK_SPACE) $(BUILD_TOOL) $(CASTLE_ENGINE_TOOL_OPTIONS) --project $${MANIFEST} clean; \ |
| 291 |
done |
| 292 |
|
| 293 |
# Compile editor templates |
| 294 |
$(MAKE) test-editor-templates |
| 295 |
|
| 296 |
# This a bit simpler than "make examples", it assumes |
| 297 |
# - build tool is already build, in $(BUILD_TOOL) |
| 298 |
# - doesn't deal with template tests |
| 299 |
# - only searches examples/ subdir |
| 300 |
# |
| 301 |
# TODO: We don't automatically build examples/delphi/cpp_builder, |
| 302 |
# our build tool doesn't support C++ Builder compilation now. |
| 303 |
.PHONY: examples-delphi |
| 304 |
examples-delphi: |
| 305 |
"$(FIND)" ./examples/ \ |
| 306 |
'(' -path ./examples/castlescript/image_make_by_script -prune ')' -o \ |
| 307 |
'(' -path ./examples/localization -prune ')' -o \ |
| 308 |
'(' -path ./examples/audio/audio_player -prune ')' -o \ |
| 309 |
'(' -path ./examples/audio/test_sound_source_allocator -prune ')' -o \ |
| 310 |
'(' -path ./examples/deprecated_random_generator -prune ')' -o \ |
| 311 |
'(' -path ./examples/deprecated_library -prune ')' -o \ |
| 312 |
'(' -path ./examples/lazarus -prune ')' -o \ |
| 313 |
'(' -path ./examples/delphi/cpp_builder -prune ')' -o \ |
| 314 |
'(' -iname CastleEngineManifest.xml -print ')' > \ |
| 315 |
/tmp/cge-delphi-projects.txt |
| 316 |
echo 'Found projects: '`wc -l < /tmp/cge-delphi-projects.txt` |
| 317 |
set -e && for MANIFEST in `cat /tmp/cge-delphi-projects.txt`; do \ |
| 318 |
echo 'Compiling project '$${MANIFEST}; \ |
| 319 |
$(BUILD_TOOL) $(CASTLE_ENGINE_TOOL_OPTIONS) --project $${MANIFEST} --compiler=delphi compile; \ |
| 320 |
done |
| 321 |
|
| 322 |
.PHONY: examples-laz |
| 323 |
examples-laz: |
| 324 |
lazbuild $(CASTLE_LAZBUILD_OPTIONS) packages/castle_base.lpk |
| 325 |
lazbuild $(CASTLE_LAZBUILD_OPTIONS) packages/castle_window.lpk |
| 326 |
lazbuild $(CASTLE_LAZBUILD_OPTIONS) packages/castle_components.lpk |
| 327 |
lazbuild $(CASTLE_LAZBUILD_OPTIONS) packages/castle_editor_components.lpk |
| 328 |
set -e && for PROJECT_LPI in $(EXAMPLES_BASE_NAMES) $(EXAMPLES_LAZARUS_BASE_NAMES); do \ |
| 329 |
./tools/internal/lazbuild_retry $${PROJECT_LPI}.lpi; \ |
| 330 |
done |
| 331 |
"$(FIND)" . \ |
| 332 |
'(' -path ./examples/network/tcp_connection -prune ')' -o \ |
| 333 |
'(' -path ./src/vampyre_imaginglib -prune ')' -o \ |
| 334 |
'(' -path ./tools/castle-editor/data/project_templates -prune ')' -o \ |
| 335 |
'(' -path ./tools/build-tool/tests/data -prune ')' -o \ |
| 336 |
'(' -path ./tools/build-tool/data -prune ')' -o \ |
| 337 |
'(' -path ./examples/deprecated_library -prune ')' -o \ |
| 338 |
'(' -path ./tools/castle-editor/components/mbColorLib/examples -prune ')' -o \ |
| 339 |
'(' -iname '*.lpi' -print ')' > \ |
| 340 |
/tmp/cge-laz-projects.txt |
| 341 |
echo 'Found projects: '`wc -l < /tmp/cge-laz-projects.txt` |
| 342 |
set -e && for PROJECT_LPI in `cat /tmp/cge-laz-projects.txt`; do \ |
| 343 |
echo 'Compiling project '$${PROJECT_LPI}; \ |
| 344 |
./tools/internal/lazbuild_retry $${PROJECT_LPI}; \ |
| 345 |
$(DO_IF_CONSERVE_DISK_SPACE) git clean --force -d -x "`dirname $${PROJECT_LPI}`"; \ |
| 346 |
done |
| 347 |
|
| 348 |
# Cleanup things in examples/ subdir, |
| 349 |
# produced by compilation (using "make examples*" or other methods of compilation) |
| 350 |
# and execution of the examples. |
| 351 |
.PHONY: cleanexamples |
| 352 |
cleanexamples: |
| 353 |
rm -f $(EXAMPLES_UNIX_EXECUTABLES) $(EXAMPLES_WINDOWS_EXECUTABLES) |
| 354 |
rm -Rf \ |
| 355 |
examples/deprecated_library/build-qt_library_tester-* \ |
| 356 |
examples/deprecated_library/lazarus_library_tester/*.app \ |
| 357 |
examples/fonts/font_draw_over_image_output.png \ |
| 358 |
examples/short_api_samples/transform_save_load/aaa.castle-transform |
| 359 |
# lazarus produces lib/ subdirectories during compilation |
| 360 |
"$(FIND)" examples/ -type d -name lib -prune -exec rm -Rf '{}' ';' |
| 361 |
|
| 362 |
# cleaning ------------------------------------------------------------ |
| 363 |
|
| 364 |
.PHONY: clean |
| 365 |
|
| 366 |
clean: cleanexamples |
| 367 |
"$(FIND)" . -type f '(' -iname '*.ow' -or \ |
| 368 |
-iname '*.ppw' -or \ |
| 369 |
-iname '*.aw' -or \ |
| 370 |
-iname '*.o' -or \ |
| 371 |
-iname '*.or' -or \ |
| 372 |
-iname '*.ppu' -or \ |
| 373 |
'(' -iname '*.a' -and -not -iwholename '*/vampyre_imaginglib/*' ')' -or \ |
| 374 |
'(' -iname '*.res' -and \ |
| 375 |
-not -iwholename '*/vampyre_imaginglib/*' -and \ |
| 376 |
-not -iwholename '*/mbColorLib/*' -and \ |
| 377 |
-not -iwholename '*/examples/delphi/*' ')' \ |
| 378 |
-or \ |
| 379 |
-iname '*.rsj' -or \ |
| 380 |
-iname '*.compiled' -or \ |
| 381 |
-iname '*.lps' -or \ |
| 382 |
-iname '*.libimp*.a' -or \ |
| 383 |
-iname '*.apk' -or \ |
| 384 |
-iname '*.aab' -or \ |
| 385 |
-iname '*.dbg' -or \ |
| 386 |
-iname '*.dcu' -or \ |
| 387 |
-iname '*.dpu' -or \ |
| 388 |
-iname '*.bpi' -or \ |
| 389 |
-iname '*.dproj.local' -or \ |
| 390 |
-iname '*.identcache' -or \ |
| 391 |
-iname '*.rsm' -or \ |
| 392 |
-iname '*.log' ')' \ |
| 393 |
-print \ |
| 394 |
| xargs rm -f |
| 395 |
# Note: *.app directory is a macOS bundle, |
| 396 |
# we *do not* remove it here anymore as it would break pack_release. |
| 397 |
"$(FIND)" . -type d '(' -name 'lib' -or \ |
| 398 |
-name 'backup' -or \ |
| 399 |
-name 'castle-engine-output' -or \ |
| 400 |
-name '__recovery' ')' \ |
| 401 |
-exec rm -Rf '{}' ';' -prune |
| 402 |
rm -Rf bin/ \ |
| 403 |
castle-engine-copy$(EXE_EXTENSION) \ |
| 404 |
packages/castle_base.pas \ |
| 405 |
packages/castle_window.pas \ |
| 406 |
packages/castle_components.pas \ |
| 407 |
packages/castle_editor_components.pas \ |
| 408 |
packages/alternative_castle_window_based_on_lcl.pas \ |
| 409 |
tests/test_castle_game_engine \ |
| 410 |
tests/test_castle_game_engine.exe \ |
| 411 |
tests/castle-tester \ |
| 412 |
tests/castle-tester.exe |
| 413 |
$(MAKE) -C doc/man/man1/ clean |
| 414 |
# fpmake stuff (binary, units/ produced by fpmake compilation, configs) |
| 415 |
rm -Rf fpmake fpmake.exe units/ *.fpm .fppkg .config |
| 416 |
rm -Rf src/deprecated_library/ios-output/\ |
| 417 |
src/deprecated_library/libcastleengine.dylib \ |
| 418 |
src/deprecated_library/castleengine.dll \ |
| 419 |
src/deprecated_library/libcastleengine.so |
| 420 |
# Clean every project with CastleEngineManifest.xml . |
| 421 |
# |
| 422 |
# Avoid a project in project_templates, |
| 423 |
# that has CastleEngineManifest.xml with macros, and would cause errors: |
| 424 |
# """ Project name contains invalid characters: "${PROJECT_NAME}" """ . |
| 425 |
# |
| 426 |
# Avoid project in build-tool/tests/data that is not a real project |
| 427 |
# (will never be compiled). |
| 428 |
# |
| 429 |
# Note: This may cause errors if build tool doesn't exist anymore, ignore them. |
| 430 |
"$(FIND)" . \ |
| 431 |
'(' -path ./tools/castle-editor/data/project_templates -prune ')' -or \ |
| 432 |
'(' -path ./tools/build-tool/tests/data -prune ')' -or \ |
| 433 |
'(' -iname CastleEngineManifest.xml \ |
| 434 |
-execdir $(BUILD_TOOL) clean ';' ')' |
| 435 |
|
| 436 |
# tests ---------------------------------------- |
| 437 |
|
| 438 |
# Build and run tests. |
| 439 |
.PHONY: tests |
| 440 |
tests: |
| 441 |
tools/build-tool/castle-engine_compile.sh |
| 442 |
# Build and run check_packages |
| 443 |
$(BUILD_TOOL) $(CASTLE_ENGINE_TOOL_OPTIONS) --project tools/internal/check_packages/ clean |
| 444 |
$(BUILD_TOOL) $(CASTLE_ENGINE_TOOL_OPTIONS) --project tools/internal/check_packages/ --mode=debug compile |
| 445 |
$(BUILD_TOOL) $(CASTLE_ENGINE_TOOL_OPTIONS) --project tools/internal/check_packages/ run -- ../../../ |
| 446 |
# Conserve disk space for GH actions |
| 447 |
$(BUILD_TOOL) $(CASTLE_ENGINE_TOOL_OPTIONS) --project tools/internal/check_packages/ clean |
| 448 |
# Run in debug mode |
| 449 |
$(BUILD_TOOL) $(CASTLE_ENGINE_TOOL_OPTIONS) --project tests/ clean |
| 450 |
$(BUILD_TOOL) $(CASTLE_ENGINE_TOOL_OPTIONS) --project tests/ --mode=debug compile |
| 451 |
$(BUILD_TOOL) $(CASTLE_ENGINE_TOOL_OPTIONS) --project tests/ run -- --console --no-window-create |
| 452 |
# Run in debug mode, testing DecimalSeparator = comma |
| 453 |
$(BUILD_TOOL) $(CASTLE_ENGINE_TOOL_OPTIONS) --project tests/ clean |
| 454 |
$(BUILD_TOOL) $(CASTLE_ENGINE_TOOL_OPTIONS) --project tests/ --mode=debug --compiler-option=-dCASTLE_TEST_DECIMAL_SEPARATOR_COMMA compile |
| 455 |
$(BUILD_TOOL) $(CASTLE_ENGINE_TOOL_OPTIONS) --project tests/ run -- --console --no-window-create |
| 456 |
# Run in debug mode without LibPng |
| 457 |
# (useful to test image processing, e.g. TTestImages.TestLoadImage, without libpng, which matters for mobile now) |
| 458 |
$(BUILD_TOOL) $(CASTLE_ENGINE_TOOL_OPTIONS) --project tests/ clean |
| 459 |
$(BUILD_TOOL) $(CASTLE_ENGINE_TOOL_OPTIONS) --project tests/ --mode=debug --compiler-option=-dCASTLE_DISABLE_LIBPNG compile |
| 460 |
$(BUILD_TOOL) $(CASTLE_ENGINE_TOOL_OPTIONS) --project tests/ run -- --console --no-window-create |
| 461 |
# Run in release mode, since all tests must pass the same when optimizations are enabled |
| 462 |
$(BUILD_TOOL) $(CASTLE_ENGINE_TOOL_OPTIONS) --project tests/ clean |
| 463 |
$(BUILD_TOOL) $(CASTLE_ENGINE_TOOL_OPTIONS) --project tests/ --mode=release compile |
| 464 |
$(BUILD_TOOL) $(CASTLE_ENGINE_TOOL_OPTIONS) --project tests/ run -- --console --no-window-create |
| 465 |
# Conserve disk space for GH actions |
| 466 |
$(BUILD_TOOL) $(CASTLE_ENGINE_TOOL_OPTIONS) --project tests/ clean |
| 467 |
# Run tests in tools/build-tool/tests |
| 468 |
$(BUILD_TOOL) $(CASTLE_ENGINE_TOOL_OPTIONS) --project tools/build-tool/tests/ clean |
| 469 |
$(BUILD_TOOL) $(CASTLE_ENGINE_TOOL_OPTIONS) --project tools/build-tool/tests/ --mode=debug compile |
| 470 |
$(BUILD_TOOL) $(CASTLE_ENGINE_TOOL_OPTIONS) --project tools/build-tool/tests/ run -- --all |
| 471 |
# Conserve disk space for GH actions |
| 472 |
$(BUILD_TOOL) $(CASTLE_ENGINE_TOOL_OPTIONS) --project tools/build-tool/tests/ clean |
| 473 |
|
| 474 |
# fpmake --------------------------------------------------------------------- |
| 475 |
|
| 476 |
.PHONY: build-using-fpmake |
| 477 |
build-using-fpmake: |
| 478 |
fpc fpmake.pp |
| 479 |
@echo 'Running fpmake.' |
| 480 |
@echo ' If this fails saying that "rtl" is not found -> set FPCDIR environment variable, see http://wiki.freepascal.org/FPMake .' |
| 481 |
@echo ' If this fails saying that "opengl" package is not found -> you maybe have broken FPC installation without Package.fpc files, consider using "export CASTLE_PACKAGE_NO_DEPENDENCIES=true" as a workaround.' |
| 482 |
# Workaround FPC >= 3.x problem (bug?) --- it ignores $FPCDIR, but --globalunitdir works |
| 483 |
if [ '(' -n "$(FPCDIR)" ')' ]; then \ |
| 484 |
./fpmake --globalunitdir="$(FPCDIR)"; \ |
| 485 |
else \ |
| 486 |
./fpmake; \ |
| 487 |
fi |
| 488 |
|
| 489 |
# Full test that fpmake compilation process works |
| 490 |
# (see https://castle-engine.io/fpmake ) |
| 491 |
.PHONY: test-fpmake |
| 492 |
test-fpmake: build-using-fpmake |
| 493 |
# Test fpmake with --nofpccfg, to make sure our dependencies in fpmake.pp are correct |
| 494 |
./fpmake clean --verbose |
| 495 |
if [ '(' -n "$(FPCDIR)" ')' ]; then \ |
| 496 |
./fpmake --globalunitdir="$(FPCDIR)" --nofpccfg --verbose; \ |
| 497 |
else \ |
| 498 |
./fpmake --nofpccfg --verbose; \ |
| 499 |
fi |
| 500 |
|
| 501 |
# eof ------------------------------------------------------------ |