Update: Merge branch 'jgrpp_master_cmake' into jgrpp_cmake
@ -0,0 +1,237 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
project(OpenTTD)
|
||||
|
||||
if (CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
|
||||
message(FATAL_ERROR "In-source builds not allowed. Please run \"cmake ..\" from the bin directory")
|
||||
endif (CMAKE_SOURCE_DIR STREQUAL CMAKE_BINARY_DIR)
|
||||
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
|
||||
|
||||
# Use GNUInstallDirs to allow customisation
|
||||
# but set our own default data dir
|
||||
if (NOT CMAKE_INSTALL_DATADIR)
|
||||
set(CMAKE_INSTALL_DATADIR "share/games")
|
||||
endif (NOT CMAKE_INSTALL_DATADIR)
|
||||
include(GNUInstallDirs)
|
||||
|
||||
include(Options)
|
||||
set_options()
|
||||
set_directory_options()
|
||||
|
||||
include(Static)
|
||||
set_static_if_needed()
|
||||
|
||||
# Prefer -pthread over -lpthread, which is often the better option of the two.
|
||||
set(CMAKE_THREAD_PREFER_PTHREAD YES)
|
||||
# Make sure we have Threads available.
|
||||
find_package(Threads REQUIRED)
|
||||
|
||||
find_package(ZLIB)
|
||||
find_package(LibLZMA)
|
||||
find_package(LZO)
|
||||
find_package(PNG)
|
||||
if (NOT WIN32)
|
||||
find_package(SDL2)
|
||||
if (NOT SDL2_FOUND)
|
||||
find_package(SDL)
|
||||
endif( NOT SDL2_FOUND)
|
||||
find_package(Allegro)
|
||||
find_package(Fluidsynth)
|
||||
find_package(Freetype)
|
||||
find_package(Fontconfig)
|
||||
find_package(ICU OPTIONAL_COMPONENTS i18n lx)
|
||||
find_package(XDG_basedir)
|
||||
endif (NOT WIN32)
|
||||
if (APPLE)
|
||||
find_package(Iconv)
|
||||
|
||||
find_library(AUDIOTOOLBOX_LIBRARY AudioToolbox)
|
||||
find_library(AUDIOUNIT_LIBRARY AudioUnit)
|
||||
find_library(COCOA_LIBRARY Cocoa)
|
||||
endif (APPLE)
|
||||
|
||||
if (MSVC)
|
||||
find_package(Editbin REQUIRED)
|
||||
endif (MSVC)
|
||||
|
||||
find_package(SSE)
|
||||
find_package(Xaudio2)
|
||||
|
||||
find_package(Grfcodec)
|
||||
|
||||
# IPO is only properly supported from CMake 3.9. Despite the fact we are
|
||||
# CMake 3.5, still enable IPO if we detect we are 3.9+.
|
||||
if (POLICY CMP0069)
|
||||
cmake_policy(SET CMP0069 NEW)
|
||||
include(CheckIPOSupported)
|
||||
check_ipo_supported(RESULT IPO_FOUND)
|
||||
endif (POLICY CMP0069)
|
||||
|
||||
show_options()
|
||||
|
||||
if (UNIX AND NOT APPLE AND NOT OPTION_DEDICATED)
|
||||
if (NOT SDL_FOUND AND NOT SDL2_FOUND)
|
||||
message(FATAL_ERROR "SDL or SDL2 is required for this platform")
|
||||
endif (NOT SDL_FOUND AND NOT SDL2_FOUND)
|
||||
endif (UNIX AND NOT APPLE AND NOT OPTION_DEDICATED)
|
||||
if (APPLE)
|
||||
if (NOT AUDIOTOOLBOX_LIBRARY)
|
||||
message(FATAL_ERROR "AudioToolbox is required for this platform")
|
||||
endif (NOT AUDIOTOOLBOX_LIBRARY)
|
||||
if (NOT AUDIOUNIT_LIBRARY)
|
||||
message(FATAL_ERROR "AudioUnit is required for this platform")
|
||||
endif (NOT AUDIOUNIT_LIBRARY)
|
||||
if (NOT COCOA_LIBRARY)
|
||||
message(FATAL_ERROR "Cocoa is required for this platform")
|
||||
endif (NOT COCOA_LIBRARY)
|
||||
endif (APPLE)
|
||||
|
||||
if (MSVC)
|
||||
# C++17 for MSVC
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
else (MSVC)
|
||||
# C++11 for all other targets
|
||||
set(CMAKE_CXX_STANDARD 11)
|
||||
endif (MSVC)
|
||||
|
||||
set(CMAKE_CXX_STANDARD_REQUIRED YES)
|
||||
set(CMAKE_CXX_EXTENSIONS NO)
|
||||
|
||||
set(CMAKE_EXPORT_COMPILE_COMMANDS YES)
|
||||
|
||||
list(APPEND GENERATED_SOURCE_FILES "${CMAKE_BINARY_DIR}/generated/rev.cpp")
|
||||
if (WIN32)
|
||||
list(APPEND GENERATED_SOURCE_FILES "${CMAKE_BINARY_DIR}/generated/ottdres.rc")
|
||||
endif (WIN32)
|
||||
|
||||
# Generate a target to determine version, which is execute every 'make' run
|
||||
add_custom_target(find_version
|
||||
${CMAKE_COMMAND}
|
||||
-DFIND_VERSION_BINARY_DIR=${CMAKE_BINARY_DIR}/generated
|
||||
-DCPACK_BINARY_DIR=${CMAKE_BINARY_DIR}
|
||||
-P "${CMAKE_SOURCE_DIR}/cmake/scripts/FindVersion.cmake"
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
BYPRODUCTS ${GENERATED_SOURCE_FILES}
|
||||
)
|
||||
|
||||
include(SourceList)
|
||||
include(Endian)
|
||||
add_endian_definition()
|
||||
|
||||
# Needed by rev.cpp
|
||||
include_directories(${CMAKE_SOURCE_DIR}/src)
|
||||
# Needed by everything that uses Squirrel
|
||||
include_directories(${CMAKE_SOURCE_DIR}/src/3rdparty/squirrel/include)
|
||||
|
||||
include(CompileFlags)
|
||||
compile_flags()
|
||||
|
||||
add_executable(openttd WIN32 ${GENERATED_SOURCE_FILES})
|
||||
# All other files are added via target_sources()
|
||||
|
||||
include(AddCustomXXXTimestamp)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/src)
|
||||
add_subdirectory(${CMAKE_SOURCE_DIR}/media/baseset)
|
||||
|
||||
add_dependencies(openttd
|
||||
find_version)
|
||||
|
||||
target_link_libraries(openttd
|
||||
openttd::languages
|
||||
openttd::settings
|
||||
openttd::basesets
|
||||
Threads::Threads
|
||||
)
|
||||
|
||||
if (IPO_FOUND)
|
||||
set_target_properties(openttd PROPERTIES INTERPROCEDURAL_OPTIMIZATION_RELEASE True)
|
||||
set_target_properties(openttd PROPERTIES INTERPROCEDURAL_OPTIMIZATION_MINSIZEREL True)
|
||||
set_target_properties(openttd PROPERTIES INTERPROCEDURAL_OPTIMIZATION_RELWITHDEBINFO True)
|
||||
endif (IPO_FOUND)
|
||||
set_target_properties(openttd PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}/bin")
|
||||
process_compile_flags()
|
||||
|
||||
if (APPLE OR UNIX)
|
||||
add_definitions(-DUNIX)
|
||||
endif (APPLE OR UNIX)
|
||||
|
||||
include(LinkPackage)
|
||||
link_package(PNG TARGET PNG::PNG ENCOURAGED)
|
||||
link_package(ZLIB TARGET ZLIB::ZLIB ENCOURAGED)
|
||||
link_package(LIBLZMA TARGET LibLZMA::LibLZMA ENCOURAGED)
|
||||
link_package(LZO ENCOURAGED)
|
||||
link_package(XDG_basedir)
|
||||
|
||||
if (NOT OPTION_DEDICATED)
|
||||
link_package(Fluidsynth)
|
||||
link_package(SDL)
|
||||
link_package(SDL2 TARGET SDL2::SDL2)
|
||||
link_package(Allegro)
|
||||
link_package(FREETYPE TARGET Freetype::Freetype)
|
||||
link_package(Fontconfig TARGET Fontconfig::Fontconfig)
|
||||
link_package(ICU_lx)
|
||||
link_package(ICU_i18n)
|
||||
endif (NOT OPTION_DEDICATED)
|
||||
|
||||
if (APPLE)
|
||||
link_package(Iconv TARGET Iconv::Iconv)
|
||||
|
||||
target_link_libraries(openttd
|
||||
${AUDIOTOOLBOX_LIBRARY}
|
||||
${AUDIOUNIT_LIBRARY}
|
||||
${COCOA_LIBRARY}
|
||||
)
|
||||
|
||||
add_definitions(
|
||||
-DWITH_COCOA
|
||||
-DENABLE_COCOA_QUARTZ
|
||||
)
|
||||
endif (APPLE)
|
||||
|
||||
if (NOT PERSONAL_DIR STREQUAL "(not set)")
|
||||
add_definitions(
|
||||
-DWITH_PERSONAL_DIR
|
||||
-DPERSONAL_DIR="${PERSONAL_DIR}"
|
||||
)
|
||||
endif (NOT PERSONAL_DIR STREQUAL "(not set)")
|
||||
|
||||
if (NOT SHARED_DIR STREQUAL "(not set)")
|
||||
add_definitions(
|
||||
-DWITH_SHARED_DIR
|
||||
-DSHARED_DIR="${SHARED_DIR}"
|
||||
)
|
||||
endif (NOT SHARED_DIR STREQUAL "(not set)")
|
||||
|
||||
if (NOT GLOBAL_DIR STREQUAL "(not set)")
|
||||
add_definitions(
|
||||
-DGLOBAL_DATA_DIR="${GLOBAL_DIR}"
|
||||
)
|
||||
endif (NOT GLOBAL_DIR STREQUAL "(not set)")
|
||||
|
||||
link_package(SSE)
|
||||
|
||||
add_definitions_based_on_options()
|
||||
|
||||
if (WIN32)
|
||||
add_definitions(
|
||||
-DUNICODE
|
||||
-D_UNICODE
|
||||
-DWITH_UNISCRIBE
|
||||
)
|
||||
|
||||
target_link_libraries(openttd
|
||||
ws2_32
|
||||
winmm
|
||||
imm32
|
||||
)
|
||||
endif (WIN32)
|
||||
|
||||
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
add_definitions(-D_SQ64)
|
||||
endif (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
|
||||
include(CreateRegression)
|
||||
create_regression()
|
||||
|
||||
include(InstallAndPackage)
|
@ -0,0 +1,12 @@
|
||||
# Make the current version available to CPack
|
||||
set(CPACK_PACKAGE_VERSION "@REV_VERSION@")
|
||||
|
||||
# Name the output file with the correct version
|
||||
string(REPLACE "#CPACK_PACKAGE_VERSION#" "@REV_VERSION@" CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}")
|
||||
|
||||
if (CPACK_BUNDLE_PLIST_SOURCE)
|
||||
# Rewrite the Info.plist.in to contain the correct version
|
||||
file(READ ${CPACK_BUNDLE_PLIST_SOURCE} INFO_PLIST_CONTENT)
|
||||
string(REPLACE "#CPACK_PACKAGE_VERSION#" "@REV_VERSION@" INFO_PLIST_CONTENT "${INFO_PLIST_CONTENT}")
|
||||
file(WRITE ${CPACK_BUNDLE_PLIST} "${INFO_PLIST_CONTENT}")
|
||||
endif (CPACK_BUNDLE_PLIST_SOURCE)
|
@ -1,232 +0,0 @@
|
||||
# This file is part of OpenTTD.
|
||||
# OpenTTD 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, version 2.
|
||||
# OpenTTD 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 OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#
|
||||
# Creation of bundles
|
||||
#
|
||||
|
||||
# The revision is needed for the bundle name and creating an OSX application bundle.
|
||||
# Detect the revision
|
||||
VERSIONS := $(shell AWK="$(AWK)" "$(ROOT_DIR)/findversion.sh")
|
||||
VERSION := $(shell echo "$(VERSIONS)" | cut -f 1 -d' ')
|
||||
|
||||
# Make sure we have something in VERSION
|
||||
ifeq ($(VERSION),)
|
||||
VERSION := norev000
|
||||
endif
|
||||
|
||||
ifndef BUNDLE_NAME
|
||||
BUNDLE_NAME = openttd-custom-$(VERSION)-$(OS)
|
||||
ifeq ($(OS),MINGW)
|
||||
BUNDLE_NAME := $(BUNDLE_NAME)-win$(CPU_TYPE)
|
||||
endif
|
||||
endif
|
||||
|
||||
# An OSX application bundle needs the data files, lang files and openttd executable in a different location.
|
||||
ifdef OSXAPP
|
||||
AI_DIR = $(BUNDLE_DIR)/$(OSXAPP)/Contents/Resources/ai
|
||||
GAME_DIR = $(BUNDLE_DIR)/$(OSXAPP)/Contents/Resources/game
|
||||
BASESET_DIR = $(BUNDLE_DIR)/$(OSXAPP)/Contents/Resources/baseset
|
||||
LANG_DIR = $(BUNDLE_DIR)/$(OSXAPP)/Contents/Resources/lang
|
||||
DATA_DIR = $(BUNDLE_DIR)/$(OSXAPP)/Contents/Resources/data
|
||||
TTD_DIR = $(BUNDLE_DIR)/$(OSXAPP)/Contents/MacOS
|
||||
else
|
||||
AI_DIR = $(BUNDLE_DIR)/ai
|
||||
GAME_DIR = $(BUNDLE_DIR)/game
|
||||
BASESET_DIR = $(BUNDLE_DIR)/baseset
|
||||
LANG_DIR = $(BUNDLE_DIR)/lang
|
||||
DATA_DIR = $(BUNDLE_DIR)/data
|
||||
TTD_DIR = $(BUNDLE_DIR)
|
||||
endif
|
||||
|
||||
bundle: all
|
||||
@echo '[BUNDLE] Constructing bundle'
|
||||
$(Q)rm -rf "$(BUNDLE_DIR)"
|
||||
$(Q)mkdir -p "$(BUNDLE_DIR)"
|
||||
$(Q)mkdir -p "$(BUNDLE_DIR)/docs"
|
||||
$(Q)mkdir -p "$(BUNDLE_DIR)/media"
|
||||
$(Q)mkdir -p "$(BUNDLE_DIR)/scripts"
|
||||
$(Q)mkdir -p "$(TTD_DIR)"
|
||||
$(Q)mkdir -p "$(AI_DIR)"
|
||||
$(Q)mkdir -p "$(GAME_DIR)"
|
||||
$(Q)mkdir -p "$(BASESET_DIR)"
|
||||
$(Q)mkdir -p "$(LANG_DIR)"
|
||||
$(Q)mkdir -p "$(DATA_DIR)"
|
||||
ifdef OSXAPP
|
||||
$(Q)mkdir -p "$(BUNDLE_DIR)/$(OSXAPP)/Contents/Resources"
|
||||
$(Q)echo "APPL????" > "$(BUNDLE_DIR)/$(OSXAPP)/Contents/PkgInfo"
|
||||
$(Q)cp "$(ROOT_DIR)/os/macosx/openttd.icns" "$(BUNDLE_DIR)/$(OSXAPP)/Contents/Resources/openttd.icns"
|
||||
$(Q)$(ROOT_DIR)/os/macosx/plistgen.sh "$(BUNDLE_DIR)/$(OSXAPP)" "$(VERSION)"
|
||||
$(Q)cp "$(ROOT_DIR)/os/macosx/splash.png" "$(BASESET_DIR)"
|
||||
endif
|
||||
ifeq ($(OS),UNIX)
|
||||
$(Q)cp "$(ROOT_DIR)/media/openttd.32.bmp" "$(BASESET_DIR)/"
|
||||
endif
|
||||
$(Q)cp "$(BIN_DIR)/$(TTD)" "$(TTD_DIR)/"
|
||||
$(Q)cp "$(BIN_DIR)/ai/"compat_*.nut "$(AI_DIR)/"
|
||||
$(Q)cp "$(BIN_DIR)/game/"compat_*.nut "$(GAME_DIR)/"
|
||||
$(Q)cp "$(BIN_DIR)/baseset/"*.grf "$(BASESET_DIR)/"
|
||||
$(Q)cp "$(BIN_DIR)/baseset/"*.obg "$(BASESET_DIR)/"
|
||||
$(Q)cp "$(BIN_DIR)/baseset/"*.obs "$(BASESET_DIR)/"
|
||||
$(Q)cp "$(BIN_DIR)/baseset/opntitle.dat" "$(BASESET_DIR)/"
|
||||
$(Q)cp "$(BIN_DIR)/baseset/"*.obm "$(BASESET_DIR)/"
|
||||
$(Q)cp "$(BIN_DIR)/lang/"*.lng "$(LANG_DIR)/"
|
||||
$(Q)cp "$(BIN_DIR)/data/"*.grf "$(DATA_DIR)/"
|
||||
$(Q)cp "$(ROOT_DIR)/README.md" "$(BUNDLE_DIR)/"
|
||||
$(Q)cp "$(ROOT_DIR)/COPYING.md" "$(BUNDLE_DIR)/"
|
||||
$(Q)cp "$(ROOT_DIR)/known-bugs.txt" "$(BUNDLE_DIR)/"
|
||||
$(Q)cp "$(ROOT_DIR)/docs/multiplayer.md" "$(BUNDLE_DIR)/docs/"
|
||||
$(Q)cp "$(ROOT_DIR)/changelog.txt" "$(BUNDLE_DIR)/"
|
||||
$(Q)cp "$(ROOT_DIR)/jgrpp-changelog.md" "$(BUNDLE_DIR)/"
|
||||
ifdef MAN_DIR
|
||||
$(Q)mkdir -p "$(BUNDLE_DIR)/man/"
|
||||
$(Q)cp "$(ROOT_DIR)/docs/openttd.6" "$(BUNDLE_DIR)/man/"
|
||||
$(Q)gzip -9 "$(BUNDLE_DIR)/man/openttd.6"
|
||||
endif
|
||||
$(Q)cp "$(ROOT_DIR)/media/openttd.32.xpm" "$(BUNDLE_DIR)/media/"
|
||||
$(Q)cp "$(ROOT_DIR)/media/openttd."*.png "$(BUNDLE_DIR)/media/"
|
||||
$(Q)cp "$(BIN_DIR)/scripts/"* "$(BUNDLE_DIR)/scripts/"
|
||||
ifdef MENU_DIR
|
||||
$(Q)cp "$(ROOT_DIR)/media/openttd.desktop" "$(BUNDLE_DIR)/media/"
|
||||
$(Q)$(AWK) -f "$(ROOT_DIR)/media/openttd.desktop.translation.awk" "$(SRC_DIR)/lang/"*.txt | LC_ALL=C $(SORT) | $(AWK) -f "$(ROOT_DIR)/media/openttd.desktop.filter.awk" >> "$(BUNDLE_DIR)/media/openttd.desktop"
|
||||
$(Q)sed s/=openttd/=$(BINARY_NAME)/g "$(BUNDLE_DIR)/media/openttd.desktop" > "$(ROOT_DIR)/media/openttd.desktop.install"
|
||||
endif
|
||||
ifeq ($(TTD), openttd.exe)
|
||||
$(Q)unix2dos "$(BUNDLE_DIR)/docs/"* "$(BUNDLE_DIR)/changelog.txt" "$(BUNDLE_DIR)/known-bugs.txt" "$(BUNDLE_DIR)/"*.md
|
||||
endif
|
||||
|
||||
### Packing the current bundle into several compressed file formats ###
|
||||
#
|
||||
# Zips & dmgs do not contain a root folder, i.e. they have files in the root of the zip/dmg.
|
||||
# gzip, bzip2 and lha archives have a root folder, with the same name as the bundle.
|
||||
#
|
||||
# One can supply a custom name by adding BUNDLE_NAME:=<name> to the make command.
|
||||
#
|
||||
bundle_zip: bundle
|
||||
@echo '[BUNDLE] Creating $(BUNDLE_NAME).zip'
|
||||
$(Q)mkdir -p "$(BUNDLES_DIR)"
|
||||
$(Q)cd "$(BUNDLE_DIR)" && zip -r $(shell if test -z "$(VERBOSE)"; then echo '-q'; fi) "$(BUNDLES_DIR)/$(BUNDLE_NAME).zip" .
|
||||
|
||||
bundle_7z: bundle
|
||||
@echo '[BUNDLE] Creating $(BUNDLE_NAME).7z'
|
||||
$(Q)mkdir -p "$(BUNDLES_DIR)"
|
||||
$(Q)cd "$(BUNDLE_DIR)" && 7z a "$(BUNDLES_DIR)/$(BUNDLE_NAME).7z" .
|
||||
|
||||
bundle_gzip: bundle
|
||||
@echo '[BUNDLE] Creating $(BUNDLE_NAME).tar.gz'
|
||||
$(Q)mkdir -p "$(BUNDLES_DIR)/.gzip/$(BUNDLE_NAME)"
|
||||
$(Q)cp -R "$(BUNDLE_DIR)/"* "$(BUNDLES_DIR)/.gzip/$(BUNDLE_NAME)/"
|
||||
$(Q)cd "$(BUNDLES_DIR)/.gzip" && tar -zc$(shell if test -n "$(VERBOSE)"; then echo 'v'; fi)f "$(BUNDLES_DIR)/$(BUNDLE_NAME).tar.gz" "$(BUNDLE_NAME)"
|
||||
$(Q)rm -rf "$(BUNDLES_DIR)/.gzip"
|
||||
|
||||
bundle_bzip2: bundle
|
||||
@echo '[BUNDLE] Creating $(BUNDLE_NAME).tar.bz2'
|
||||
$(Q)mkdir -p "$(BUNDLES_DIR)/.bzip2/$(BUNDLE_NAME)"
|
||||
$(Q)cp -R "$(BUNDLE_DIR)/"* "$(BUNDLES_DIR)/.bzip2/$(BUNDLE_NAME)/"
|
||||
$(Q)cd "$(BUNDLES_DIR)/.bzip2" && tar -jc$(shell if test -n "$(VERBOSE)"; then echo 'v'; fi)f "$(BUNDLES_DIR)/$(BUNDLE_NAME).tar.bz2" "$(BUNDLE_NAME)"
|
||||
$(Q)rm -rf "$(BUNDLES_DIR)/.bzip2"
|
||||
|
||||
bundle_lzma: bundle
|
||||
@echo '[BUNDLE] Creating $(BUNDLE_NAME).tar.lzma'
|
||||
$(Q)mkdir -p "$(BUNDLES_DIR)/.lzma/$(BUNDLE_NAME)"
|
||||
$(Q)cp -R "$(BUNDLE_DIR)/"* "$(BUNDLES_DIR)/.lzma/$(BUNDLE_NAME)/"
|
||||
$(Q)cd "$(BUNDLES_DIR)/.lzma" && tar --lzma -c$(shell if test -n "$(VERBOSE)"; then echo 'v'; fi)f "$(BUNDLES_DIR)/$(BUNDLE_NAME).tar.lzma" "$(BUNDLE_NAME)"
|
||||
$(Q)rm -rf "$(BUNDLES_DIR)/.lzma"
|
||||
|
||||
bundle_xz: bundle
|
||||
@echo '[BUNDLE] Creating $(BUNDLE_NAME).tar.xz'
|
||||
$(Q)mkdir -p "$(BUNDLES_DIR)/.xz/$(BUNDLE_NAME)"
|
||||
$(Q)cp -R "$(BUNDLE_DIR)/"* "$(BUNDLES_DIR)/.xz/$(BUNDLE_NAME)/"
|
||||
$(Q)cd "$(BUNDLES_DIR)/.xz" && tar --xz -c$(shell if test -n "$(VERBOSE)"; then echo 'v'; fi)f "$(BUNDLES_DIR)/$(BUNDLE_NAME).tar.xz" "$(BUNDLE_NAME)"
|
||||
$(Q)rm -rf "$(BUNDLES_DIR)/.xz"
|
||||
|
||||
bundle_lha: bundle
|
||||
@echo '[BUNDLE] Creating $(BUNDLE_NAME).lha'
|
||||
$(Q)mkdir -p "$(BUNDLES_DIR)/.lha/$(BUNDLE_NAME)"
|
||||
$(Q)cp -R "$(BUNDLE_DIR)/"* "$(BUNDLES_DIR)/.lha/$(BUNDLE_NAME)/"
|
||||
$(Q)cd "$(BUNDLES_DIR)/.lha" && lha ao6 "$(BUNDLES_DIR)/$(BUNDLE_NAME).lha" "$(BUNDLE_NAME)"
|
||||
$(Q)rm -rf "$(BUNDLES_DIR)/.lha"
|
||||
|
||||
bundle_dmg: bundle
|
||||
@echo '[BUNDLE] Creating $(BUNDLE_NAME).dmg'
|
||||
$(Q)mkdir -p "$(BUNDLES_DIR)/OpenTTD $(VERSION)"
|
||||
$(Q)cp -R "$(BUNDLE_DIR)/" "$(BUNDLES_DIR)/OpenTTD $(VERSION)"
|
||||
$(Q)hdiutil create -ov -format UDZO -srcfolder "$(BUNDLES_DIR)/OpenTTD $(VERSION)" "$(BUNDLES_DIR)/$(BUNDLE_NAME).dmg"
|
||||
$(Q)rm -fr "$(BUNDLES_DIR)/OpenTTD $(VERSION)"
|
||||
|
||||
bundle_exe: all
|
||||
@echo '[BUNDLE] Creating $(BUNDLE_NAME).exe'
|
||||
$(Q)mkdir -p "$(BUNDLES_DIR)"
|
||||
$(Q)unix2dos "$(ROOT_DIR)/docs/"* "$(ROOT_DIR)/changelog.txt" "$(ROOT_DIR)/known-bugs.txt" "$(ROOT_DIR)/"*.md
|
||||
$(Q)cd $(ROOT_DIR)/os/windows/installer && makensis.exe //DVERSION_INCLUDE=version_$(PLATFORM).txt install.nsi
|
||||
$(Q)mv $(ROOT_DIR)/os/windows/installer/*$(PLATFORM).exe "$(BUNDLES_DIR)/$(BUNDLE_NAME).exe"
|
||||
|
||||
ifdef OSXAPP
|
||||
install:
|
||||
@echo '[INSTALL] Cannot install the OSX Application Bundle'
|
||||
else
|
||||
install: bundle
|
||||
@echo '[INSTALL] Installing OpenTTD'
|
||||
$(Q)install -d "$(INSTALL_BINARY_DIR)"
|
||||
$(Q)install -d "$(INSTALL_ICON_DIR)"
|
||||
$(Q)install -d "$(INSTALL_DATA_DIR)/ai"
|
||||
$(Q)install -d "$(INSTALL_DATA_DIR)/game"
|
||||
$(Q)install -d "$(INSTALL_DATA_DIR)/baseset"
|
||||
$(Q)install -d "$(INSTALL_DATA_DIR)/lang"
|
||||
$(Q)install -d "$(INSTALL_DATA_DIR)/scripts"
|
||||
$(Q)install -d "$(INSTALL_DATA_DIR)/data"
|
||||
ifeq ($(TTD), openttd.exe)
|
||||
$(Q)install -m 755 "$(BUNDLE_DIR)/$(TTD)" "$(INSTALL_BINARY_DIR)/${BINARY_NAME}.exe"
|
||||
else
|
||||
$(Q)install -m 755 "$(BUNDLE_DIR)/$(TTD)" "$(INSTALL_BINARY_DIR)/${BINARY_NAME}"
|
||||
endif
|
||||
$(Q)install -m 644 "$(BUNDLE_DIR)/lang/"* "$(INSTALL_DATA_DIR)/lang"
|
||||
$(Q)install -m 644 "$(BUNDLE_DIR)/ai/"* "$(INSTALL_DATA_DIR)/ai"
|
||||
$(Q)install -m 644 "$(BUNDLE_DIR)/game/"* "$(INSTALL_DATA_DIR)/game"
|
||||
$(Q)install -m 644 "$(BUNDLE_DIR)/baseset/"* "$(INSTALL_DATA_DIR)/baseset"
|
||||
$(Q)install -m 644 "$(BUNDLE_DIR)/data/"* "$(INSTALL_DATA_DIR)/data"
|
||||
$(Q)install -m 644 "$(BUNDLE_DIR)/scripts/"* "$(INSTALL_DATA_DIR)/scripts"
|
||||
ifndef DO_NOT_INSTALL_DOCS
|
||||
$(Q)install -d "$(INSTALL_DOC_DIR)"
|
||||
$(Q)install -m 644 "$(BUNDLE_DIR)/docs/"* "$(BUNDLE_DIR)/README.md" "$(BUNDLE_DIR)/known-bugs.txt" "$(INSTALL_DOC_DIR)"
|
||||
endif
|
||||
ifndef DO_NOT_INSTALL_CHANGELOG
|
||||
$(Q)install -d "$(INSTALL_DOC_DIR)"
|
||||
$(Q)install -m 644 "$(BUNDLE_DIR)/changelog.txt" "$(INSTALL_DOC_DIR)"
|
||||
$(Q)install -m 644 "$(BUNDLE_DIR)/jgrpp-changelog.md" "$(INSTALL_DOC_DIR)"
|
||||
endif
|
||||
ifndef DO_NOT_INSTALL_LICENSE
|
||||
$(Q)install -d "$(INSTALL_DOC_DIR)"
|
||||
$(Q)install -m 644 "$(BUNDLE_DIR)/COPYING.md" "$(INSTALL_DOC_DIR)"
|
||||
endif
|
||||
$(Q)install -m 644 "$(BUNDLE_DIR)/media/openttd.32.xpm" "$(INSTALL_ICON_DIR)/${BINARY_NAME}.32.xpm"
|
||||
ifdef ICON_THEME_DIR
|
||||
$(Q)install -d "$(INSTALL_ICON_THEME_DIR)"
|
||||
$(Q)install -d "$(INSTALL_ICON_THEME_DIR)/16x16/apps"
|
||||
$(Q)install -m 644 "$(BUNDLE_DIR)/media/openttd.16.png" "$(INSTALL_ICON_THEME_DIR)/16x16/apps/${BINARY_NAME}.png"
|
||||
$(Q)install -d "$(INSTALL_ICON_THEME_DIR)/32x32/apps"
|
||||
$(Q)install -m 644 "$(BUNDLE_DIR)/media/openttd.32.png" "$(INSTALL_ICON_THEME_DIR)/32x32/apps/${BINARY_NAME}.png"
|
||||
$(Q)install -d "$(INSTALL_ICON_THEME_DIR)/48x48/apps"
|
||||
$(Q)install -m 644 "$(BUNDLE_DIR)/media/openttd.48.png" "$(INSTALL_ICON_THEME_DIR)/48x48/apps/${BINARY_NAME}.png"
|
||||
$(Q)install -d "$(INSTALL_ICON_THEME_DIR)/64x64/apps"
|
||||
$(Q)install -m 644 "$(BUNDLE_DIR)/media/openttd.64.png" "$(INSTALL_ICON_THEME_DIR)/64x64/apps/${BINARY_NAME}.png"
|
||||
$(Q)install -d "$(INSTALL_ICON_THEME_DIR)/128x128/apps"
|
||||
$(Q)install -m 644 "$(BUNDLE_DIR)/media/openttd.128.png" "$(INSTALL_ICON_THEME_DIR)/128x128/apps/${BINARY_NAME}.png"
|
||||
$(Q)install -d "$(INSTALL_ICON_THEME_DIR)/256x256/apps"
|
||||
$(Q)install -m 644 "$(BUNDLE_DIR)/media/openttd.256.png" "$(INSTALL_ICON_THEME_DIR)/256x256/apps/${BINARY_NAME}.png"
|
||||
else
|
||||
$(Q)install -m 644 "$(BUNDLE_DIR)/media/"*.png "$(INSTALL_ICON_DIR)"
|
||||
endif
|
||||
ifdef MAN_DIR
|
||||
ifndef DO_NOT_INSTALL_MAN
|
||||
$(Q)install -d "$(INSTALL_MAN_DIR)"
|
||||
$(Q)install -m 644 "$(BUNDLE_DIR)/man/openttd.6.gz" "$(INSTALL_MAN_DIR)/${BINARY_NAME}.6.gz"
|
||||
endif
|
||||
endif
|
||||
ifdef MENU_DIR
|
||||
$(Q)install -d "$(INSTALL_MENU_DIR)"
|
||||
$(Q)install -m 644 "$(ROOT_DIR)/media/openttd.desktop.install" "$(INSTALL_MENU_DIR)/${BINARY_NAME}.desktop"
|
||||
endif
|
||||
endif # OSXAPP
|
@ -1,116 +0,0 @@
|
||||
# This file is part of OpenTTD.
|
||||
# OpenTTD 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, version 2.
|
||||
# OpenTTD 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 OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
# Building requires GRFCodec.
|
||||
#
|
||||
# Recent versions (including sources) can be found at:
|
||||
# http://www.openttd.org/download-grfcodec
|
||||
#
|
||||
# The mercurial repository can be found at:
|
||||
# http://hg.openttdcoop.org/grfcodec
|
||||
#
|
||||
|
||||
|
||||
ROOT_DIR = !!ROOT_DIR!!
|
||||
GRF_DIR = $(ROOT_DIR)/media/extra_grf
|
||||
BASESET_DIR = $(ROOT_DIR)/media/baseset
|
||||
LANG_DIR = $(ROOT_DIR)/src/lang
|
||||
BIN_DIR = !!BIN_DIR!!/baseset
|
||||
OBJS_DIR = !!GRF_OBJS_DIR!!
|
||||
OS = !!OS!!
|
||||
STAGE = !!STAGE!!
|
||||
|
||||
# Check if we want to show what we are doing
|
||||
ifdef VERBOSE
|
||||
Q =
|
||||
E = @true
|
||||
else
|
||||
Q = @
|
||||
E = @echo
|
||||
endif
|
||||
|
||||
GRFCODEC := !!GRFCODEC!!
|
||||
NFORENUM := !!NFORENUM!!
|
||||
CC_BUILD := !!CC_BUILD!!
|
||||
MD5SUM := $(shell [ "$(OS)" = "OSX" ] && echo "md5 -r" || echo "md5sum")
|
||||
|
||||
# Some "should not be changed" settings.
|
||||
NFO_FILES := $(GRF_DIR)/*.nfo $(GRF_DIR)/rivers/*.nfo
|
||||
PNG_FILES := $(GRF_DIR)/*.png $(GRF_DIR)/rivers/*.png
|
||||
|
||||
# List of target files.
|
||||
OBT_FILES := $(BIN_DIR)/orig_dos.obg
|
||||
OBT_FILES += $(BIN_DIR)/orig_dos_de.obg
|
||||
OBT_FILES += $(BIN_DIR)/orig_win.obg
|
||||
OBT_FILES += $(BIN_DIR)/orig_dos.obs
|
||||
OBT_FILES += $(BIN_DIR)/orig_win.obs
|
||||
OBT_FILES += $(BIN_DIR)/no_sound.obs
|
||||
OBT_FILES += $(BIN_DIR)/orig_dos.obm
|
||||
OBT_FILES += $(BIN_DIR)/orig_win.obm
|
||||
OBT_FILES += $(BIN_DIR)/no_music.obm
|
||||
OBT_FILES += $(BIN_DIR)/orig_tto.obm
|
||||
|
||||
# Build the GRF.
|
||||
all: $(OBT_FILES)
|
||||
ifdef GRFCODEC
|
||||
all: $(BIN_DIR)/openttd.grf $(BIN_DIR)/orig_extra.grf
|
||||
endif
|
||||
|
||||
$(OBJS_DIR)/langfiles.tmp: $(LANG_DIR)/*.txt
|
||||
$(E) '$(STAGE) Collecting baseset translations'
|
||||
$(Q) cat $^ > $@
|
||||
|
||||
$(BIN_DIR)/%.obg: $(BASESET_DIR)/%.obg $(BIN_DIR)/orig_extra.grf $(OBJS_DIR)/langfiles.tmp $(BASESET_DIR)/translations.awk
|
||||
$(E) '$(STAGE) Updating $(notdir $@)'
|
||||
$(Q) sed 's/^ORIG_EXTRA.GRF = *[0-9a-f]*$$/ORIG_EXTRA.GRF = '`$(MD5SUM) $(BIN_DIR)/orig_extra.grf | sed 's@ .*@@'`'/' $< > $@.tmp
|
||||
$(Q) awk -v langfiles='$(OBJS_DIR)/langfiles.tmp' -f $(BASESET_DIR)/translations.awk $@.tmp >$@
|
||||
$(Q) rm $@.tmp
|
||||
|
||||
$(BIN_DIR)/%.obs: $(BASESET_DIR)/%.obs $(OBJS_DIR)/langfiles.tmp $(BASESET_DIR)/translations.awk
|
||||
$(E) '$(STAGE) Updating $(notdir $@)'
|
||||
$(Q) awk -v langfiles='$(OBJS_DIR)/langfiles.tmp' -f $(BASESET_DIR)/translations.awk $< >$@
|
||||
|
||||
$(BIN_DIR)/%.obm: $(BASESET_DIR)/%.obm $(OBJS_DIR)/langfiles.tmp $(BASESET_DIR)/translations.awk
|
||||
$(E) '$(STAGE) Updating $(notdir $@)'
|
||||
$(Q) awk -v langfiles='$(OBJS_DIR)/langfiles.tmp' -f $(BASESET_DIR)/translations.awk $< >$@
|
||||
|
||||
# Guard against trying to run GRFCODEC/NFORENUM without either being set.
|
||||
ifdef GRFCODEC
|
||||
ifdef NFORENUM
|
||||
|
||||
# Compile extra grf
|
||||
$(BIN_DIR)/openttd.grf: $(PNG_FILES) $(NFO_FILES) $(GRF_DIR)/assemble_nfo.awk
|
||||
$(E) '$(STAGE) Assembling openttd.nfo'
|
||||
$(Q)-mkdir -p $(OBJS_DIR)/sprites
|
||||
$(Q)-cp $(PNG_FILES) $(OBJS_DIR)/sprites 2> /dev/null
|
||||
$(Q) awk -f $(GRF_DIR)/assemble_nfo.awk $(GRF_DIR)/openttd.nfo > $(OBJS_DIR)/sprites/openttd.nfo
|
||||
$(Q) $(NFORENUM) -s $(OBJS_DIR)/sprites/openttd.nfo
|
||||
$(E) '$(STAGE) Compiling openttd.grf'
|
||||
$(Q) $(GRFCODEC) -n -s -e -p1 $(OBJS_DIR)/openttd.grf
|
||||
$(Q)cp $(OBJS_DIR)/openttd.grf $(BIN_DIR)/openttd.grf
|
||||
|
||||
# The copy operation of PNG_FILES is duplicated from the target 'openttd.grf', thus those targets may not run in parallel.
|
||||
$(BIN_DIR)/orig_extra.grf: $(PNG_FILES) $(NFO_FILES) $(GRF_DIR)/assemble_nfo.awk | $(BIN_DIR)/openttd.grf
|
||||
$(E) '$(STAGE) Assembling orig_extra.nfo'
|
||||
$(Q)-mkdir -p $(OBJS_DIR)/sprites
|
||||
$(Q)-cp $(PNG_FILES) $(OBJS_DIR)/sprites 2> /dev/null
|
||||
$(Q) awk -f $(GRF_DIR)/assemble_nfo.awk $(GRF_DIR)/orig_extra.nfo > $(OBJS_DIR)/sprites/orig_extra.nfo
|
||||
$(Q) $(NFORENUM) -s $(OBJS_DIR)/sprites/orig_extra.nfo
|
||||
$(E) '$(STAGE) Compiling orig_extra.grf'
|
||||
$(Q) $(GRFCODEC) -n -s -e -p1 $(OBJS_DIR)/orig_extra.grf
|
||||
$(Q)cp $(OBJS_DIR)/orig_extra.grf $(BIN_DIR)/orig_extra.grf
|
||||
|
||||
endif
|
||||
endif
|
||||
|
||||
# Clean up temporary files.
|
||||
clean:
|
||||
$(Q)rm -f *.bak *.grf $(OBT_FILES)
|
||||
|
||||
# Clean up temporary files
|
||||
mrproper: clean
|
||||
$(Q)rm -fr sprites
|
||||
|
||||
.PHONY: all mrproper depend clean
|
@ -1,186 +0,0 @@
|
||||
# This file is part of OpenTTD.
|
||||
# OpenTTD 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, version 2.
|
||||
# OpenTTD 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 OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
# Check if we want to show what we are doing
|
||||
ifdef VERBOSE
|
||||
Q =
|
||||
else
|
||||
Q = @
|
||||
endif
|
||||
|
||||
include Makefile.am
|
||||
|
||||
CONFIG_CACHE_PWD = !!CONFIG_CACHE_PWD!!
|
||||
CONFIG_CACHE_SOURCE_LIST = !!CONFIG_CACHE_SOURCE_LIST!!
|
||||
BIN_DIR = !!BIN_DIR!!
|
||||
ICON_THEME_DIR = !!ICON_THEME_DIR!!
|
||||
MAN_DIR = !!MAN_DIR!!
|
||||
MENU_DIR = !!MENU_DIR!!
|
||||
SRC_DIR = !!SRC_DIR!!
|
||||
ROOT_DIR = !!ROOT_DIR!!
|
||||
BUNDLE_DIR = "$(ROOT_DIR)/bundle"
|
||||
BUNDLES_DIR = "$(ROOT_DIR)/bundles"
|
||||
INSTALL_DIR = !!INSTALL_DIR!!
|
||||
INSTALL_BINARY_DIR = "$(INSTALL_DIR)/"!!BINARY_DIR!!
|
||||
INSTALL_MAN_DIR = "$(INSTALL_DIR)/$(MAN_DIR)"
|
||||
INSTALL_MENU_DIR = "$(INSTALL_DIR)/$(MENU_DIR)"
|
||||
INSTALL_ICON_DIR = "$(INSTALL_DIR)/"!!ICON_DIR!!
|
||||
INSTALL_ICON_THEME_DIR = "$(INSTALL_DIR)/$(ICON_THEME_DIR)"
|
||||
INSTALL_DATA_DIR = "$(INSTALL_DIR)/"!!DATA_DIR!!
|
||||
INSTALL_DOC_DIR = "$(INSTALL_DIR)/"!!DOC_DIR!!
|
||||
SOURCE_LIST = !!SOURCE_LIST!!
|
||||
CONFIGURE_FILES = !!CONFIGURE_FILES!!
|
||||
BINARY_NAME = !!BINARY_NAME!!
|
||||
STRIP = !!STRIP!!
|
||||
TTD = !!TTD!!
|
||||
TTDS = $(SRC_DIRS:%=%/$(TTD))
|
||||
OS = !!OS!!
|
||||
CPU_TYPE = !!CPU_TYPE!!
|
||||
OSXAPP = !!OSXAPP!!
|
||||
LIPO = !!LIPO!!
|
||||
AWK = !!AWK!!
|
||||
SORT = !!SORT!!
|
||||
DISTCC = !!DISTCC!!
|
||||
|
||||
RES := $(shell if [ ! -f $(CONFIG_CACHE_PWD) ] || [ "`pwd`" != "`cat $(CONFIG_CACHE_PWD)`" ]; then echo "`pwd`" > $(CONFIG_CACHE_PWD); fi )
|
||||
RES := $(shell if [ ! -f $(CONFIG_CACHE_SOURCE_LIST) ] || [ -n "`cmp $(CONFIG_CACHE_SOURCE_LIST) $(SOURCE_LIST) 2>/dev/null`" ]; then cp $(SOURCE_LIST) $(CONFIG_CACHE_SOURCE_LIST); fi )
|
||||
|
||||
all: config.pwd config.cache
|
||||
ifdef DISTCC
|
||||
@if [ -z "`echo '$(MFLAGS)' | grep '\-j'`" ]; then echo; echo "WARNING: you enabled distcc support, but you don't seem to be using the -jN parameter"; echo; fi
|
||||
endif
|
||||
@for dir in $(DIRS); do \
|
||||
$(MAKE) -C $$dir all || exit 1; \
|
||||
done
|
||||
ifdef LIPO
|
||||
# Lipo is an OSX thing. If it is defined, it means we are building for universal,
|
||||
# and so we have have to combine the binaries into one big binary
|
||||
|
||||
# Remove the last binary made by the last compiled target
|
||||
$(Q)rm -f $(BIN_DIR)/$(TTD)
|
||||
# Make all the binaries into one
|
||||
$(Q)$(LIPO) -create -output $(BIN_DIR)/$(TTD) $(TTDS)
|
||||
endif
|
||||
|
||||
help:
|
||||
@echo "Available make commands:"
|
||||
@echo ""
|
||||
@echo "Compilation:"
|
||||
@echo " all compile the executable and the lang files"
|
||||
@echo " lang compile the lang files only"
|
||||
@echo "Clean up:"
|
||||
@echo " clean remove the files generated during compilation"
|
||||
@echo " mrproper remove the files generated during configuration and compilation"
|
||||
@echo "Run after compilation:"
|
||||
@echo " run execute openttd after the compilation"
|
||||
@echo " run-gdb execute openttd in debug mode after the compilation"
|
||||
@echo " run-prof execute openttd in profiling mode after the compilation"
|
||||
@echo "Installation:"
|
||||
@echo " install install the compiled files and the data-files after the compilation"
|
||||
@echo " bundle create the base for an installation bundle"
|
||||
@echo " bundle_zip create the zip installation bundle"
|
||||
@echo " bundle_gzip create the gzip installation bundle"
|
||||
@echo " bundle_bzip2 create the bzip2 installation bundle"
|
||||
@echo " bundle_lha create the lha installation bundle"
|
||||
@echo " bundle_dmg create the dmg installation bundle"
|
||||
|
||||
config.pwd: $(CONFIG_CACHE_PWD)
|
||||
$(MAKE) reconfigure
|
||||
|
||||
config.cache: $(CONFIG_CACHE_SOURCE_LIST) $(CONFIGURE_FILES)
|
||||
$(MAKE) reconfigure
|
||||
|
||||
reconfigure:
|
||||
ifeq ($(shell if test -f config.cache; then echo 1; fi), 1)
|
||||
@echo "----------------"
|
||||
@echo "The system detected that source.list or any configure file is altered."
|
||||
@echo " Going to reconfigure with last known settings..."
|
||||
@echo "----------------"
|
||||
# Make sure we don't lock config.cache
|
||||
@$(shell cat config.cache | sed 's@\\ @\\\\ @g') || exit 1
|
||||
@echo "----------------"
|
||||
@echo "Reconfig done. Please re-execute make."
|
||||
@echo "----------------"
|
||||
else
|
||||
@echo "----------------"
|
||||
@echo "Have not found a configuration, please run configure first."
|
||||
@echo "----------------"
|
||||
@exit 1
|
||||
endif
|
||||
|
||||
clean:
|
||||
@for dir in $(DIRS); do \
|
||||
$(MAKE) -C $$dir clean; \
|
||||
done
|
||||
$(Q)rm -rf $(BUNDLE_TARGET)
|
||||
|
||||
lang:
|
||||
@for dir in $(LANG_DIRS); do \
|
||||
$(MAKE) -C $$dir all; \
|
||||
done
|
||||
|
||||
mrproper:
|
||||
@for dir in $(DIRS); do \
|
||||
$(MAKE) -C $$dir mrproper; \
|
||||
done
|
||||
# Don't be tempted to merge these two for loops. Doing that breaks make
|
||||
# --dry-run, since make has this "feature" that it always runs commands
|
||||
# containing $(MAKE), even when --dry-run is passed. The objective is of
|
||||
# course to also get a dry-run of submakes, but make is not smart enough
|
||||
# to see that a for loop runs both a submake and an actual command.
|
||||
@for dir in $(DIRS); do \
|
||||
rm -f $$dir/Makefile; \
|
||||
done
|
||||
$(Q)rm -rf objs
|
||||
$(Q)rm -f Makefile Makefile.am Makefile.bundle
|
||||
$(Q)rm -f media/openttd.desktop media/openttd.desktop.install
|
||||
$(Q)rm -f $(CONFIG_CACHE_SOURCE_LIST) config.cache config.pwd config.log $(CONFIG_CACHE_PWD)
|
||||
# directories for bundle generation
|
||||
$(Q)rm -rf $(BUNDLE_DIR)
|
||||
$(Q)rm -rf $(BUNDLES_DIR)
|
||||
# output of profiling
|
||||
$(Q)rm -f $(BIN_DIR)/gmon.out
|
||||
# output of generating 'API' documentation
|
||||
$(Q)rm -rf $(ROOT_DIR)/docs/source
|
||||
$(Q)rm -rf $(ROOT_DIR)/docs/aidocs
|
||||
$(Q)rm -rf $(ROOT_DIR)/docs/gamedocs
|
||||
# directories created by OpenTTD on regression testing
|
||||
$(Q)rm -rf $(BIN_DIR)/ai/regression/content_download $(BIN_DIR)/ai/regression/save $(BIN_DIR)/ai/regression/scenario
|
||||
distclean: mrproper
|
||||
|
||||
maintainer-clean: distclean
|
||||
$(Q)rm -f $(BIN_DIR)/baseset/openttd.grf $(BIN_DIR)/baseset/orig_extra.grf $(BIN_DIR)/baseset/*.obg $(BIN_DIR)/baseset/*.obs $(BIN_DIR)/baseset/*.obm
|
||||
|
||||
depend:
|
||||
@for dir in $(SRC_DIRS); do \
|
||||
$(MAKE) -C $$dir depend; \
|
||||
done
|
||||
|
||||
run: all
|
||||
$(Q)cd !!BIN_DIR!! && ./!!TTD!! $(OPENTTD_ARGS)
|
||||
|
||||
run-gdb: all
|
||||
$(Q)cd !!BIN_DIR!! && gdb --ex run --args ./!!TTD!! $(OPENTTD_ARGS)
|
||||
|
||||
run-prof: all
|
||||
$(Q)cd !!BIN_DIR!! && ./!!TTD!! $(OPENTTD_ARGS) && gprof !!TTD!! | less
|
||||
|
||||
regression: all
|
||||
$(Q)cd !!BIN_DIR!! && sh ai/regression/run.sh
|
||||
test: regression
|
||||
|
||||
%.o:
|
||||
@for dir in $(SRC_DIRS); do \
|
||||
$(MAKE) -C $$dir $(@:src/%=%); \
|
||||
done
|
||||
|
||||
%.lng:
|
||||
@for dir in $(LANG_DIRS); do \
|
||||
$(MAKE) -C $$dir $@; \
|
||||
done
|
||||
|
||||
.PHONY: test distclean mrproper clean
|
||||
|
||||
include Makefile.bundle
|
@ -1,87 +0,0 @@
|
||||
# This file is part of OpenTTD.
|
||||
# OpenTTD 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, version 2.
|
||||
# OpenTTD 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 OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
STRGEN = !!STRGEN!!
|
||||
SRC_DIR = !!SRC_DIR!!
|
||||
LANG_DIR = !!LANG_DIR!!
|
||||
BIN_DIR = !!BIN_DIR!!
|
||||
LANGS_SRC = $(shell ls $(LANG_DIR)/*.txt)
|
||||
LANGS = $(LANGS_SRC:$(LANG_DIR)/%.txt=%.lng)
|
||||
CXX_BUILD = !!CXX_BUILD!!
|
||||
CFLAGS_BUILD = !!CFLAGS_BUILD!!
|
||||
CXXFLAGS_BUILD= !!CXXFLAGS_BUILD!!
|
||||
LDFLAGS_BUILD = !!LDFLAGS_BUILD!!
|
||||
STRGEN_FLAGS = !!STRGEN_FLAGS!!
|
||||
STAGE = !!STAGE!!
|
||||
LANG_SUPPRESS = !!LANG_SUPPRESS!!
|
||||
LANG_OBJS_DIR = !!LANG_OBJS_DIR!!
|
||||
|
||||
ifeq ($(LANG_SUPPRESS), yes)
|
||||
LANG_ERRORS = >/dev/null 2>&1
|
||||
endif
|
||||
|
||||
# Check if we want to show what we are doing
|
||||
ifdef VERBOSE
|
||||
Q =
|
||||
E = @true
|
||||
else
|
||||
Q = @
|
||||
E = @echo
|
||||
endif
|
||||
|
||||
RES := $(shell mkdir -p $(BIN_DIR)/lang )
|
||||
|
||||
all: table/strings.h $(LANGS)
|
||||
|
||||
strgen_base.o: $(SRC_DIR)/strgen/strgen_base.cpp $(SRC_DIR)/strgen/strgen.h $(SRC_DIR)/table/control_codes.h $(SRC_DIR)/table/strgen_tables.h $(SRC_DIR)/safeguards.h
|
||||
$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)'
|
||||
$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSTRGEN -c -o $@ $<
|
||||
|
||||
strgen.o: $(SRC_DIR)/strgen/strgen.cpp $(SRC_DIR)/strgen/strgen.h $(SRC_DIR)/table/control_codes.h $(SRC_DIR)/table/strgen_tables.h $(SRC_DIR)/safeguards.h
|
||||
$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)'
|
||||
$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSTRGEN -c -o $@ $<
|
||||
|
||||
string.o: $(SRC_DIR)/string.cpp $(SRC_DIR)/safeguards.h
|
||||
$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)'
|
||||
$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSTRGEN -c -o $@ $<
|
||||
|
||||
alloc_func.o: $(SRC_DIR)/core/alloc_func.cpp $(SRC_DIR)/safeguards.h
|
||||
$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)'
|
||||
$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSTRGEN -c -o $@ $<
|
||||
|
||||
getoptdata.o: $(SRC_DIR)/misc/getoptdata.cpp $(SRC_DIR)/misc/getoptdata.h $(SRC_DIR)/safeguards.h
|
||||
$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/misc/%.cpp=%.cpp)'
|
||||
$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSTRGEN -c -o $@ $<
|
||||
|
||||
lang/english.txt: $(LANG_DIR)/english.txt
|
||||
$(Q)mkdir -p lang
|
||||
$(Q)cp $(LANG_DIR)/english.txt lang/english.txt
|
||||
|
||||
$(STRGEN): alloc_func.o string.o strgen_base.o strgen.o getoptdata.o
|
||||
$(E) '$(STAGE) Compiling and Linking $@'
|
||||
$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) $(LDFLAGS_BUILD) $^ -o $@
|
||||
|
||||
table/strings.h: lang/english.txt $(STRGEN)
|
||||
$(E) '$(STAGE) Generating $@'
|
||||
@mkdir -p table
|
||||
$(Q)./$(STRGEN) -s $(LANG_DIR) -d table
|
||||
|
||||
$(LANGS): %.lng: $(LANG_DIR)/%.txt $(STRGEN) lang/english.txt
|
||||
$(E) '$(STAGE) Compiling language $(*F)'
|
||||
$(Q)./$(STRGEN) $(STRGEN_FLAGS) -s $(LANG_DIR) -d $(LANG_OBJS_DIR) $< $(LANG_ERRORS) && cp $@ $(BIN_DIR)/lang || true # Do not fail all languages when one fails
|
||||
|
||||
depend:
|
||||
|
||||
clean:
|
||||
$(E) '$(STAGE) Cleaning up language files'
|
||||
$(Q)rm -f strgen_base.o strgen.o string.o alloc_func.o getoptdata.o table/strings.h $(STRGEN) $(LANGS) $(LANGS:%=$(BIN_DIR)/lang/%) lang/english.*
|
||||
|
||||
mrproper: clean
|
||||
$(Q)rm -rf $(BIN_DIR)/lang
|
||||
|
||||
%.lng:
|
||||
@echo '$(STAGE) No such language: $(@:%.lng=%)'
|
||||
|
||||
.PHONY: all mrproper depend clean
|
@ -1,45 +0,0 @@
|
||||
# This file is part of OpenTTD.
|
||||
# OpenTTD 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, version 2.
|
||||
# OpenTTD 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 OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
#
|
||||
# Makefile for creating bundles of MSVC's binaries in the same way as we make
|
||||
# the zip bundles for ALL other OSes.
|
||||
#
|
||||
# Usage: make -f Makefile.msvc PLATFORM=[Win32|x64] BUNDLE_NAME=openttd-<version>-win[32|64]
|
||||
# or make -f Makefile.msvc PLATFORM=[Win32|x64] BUNDLE_NAME=OTTD-win[32|64]-nightly-<revision>
|
||||
#
|
||||
|
||||
# Check if we want to show what we are doing
|
||||
ifdef VERBOSE
|
||||
Q =
|
||||
else
|
||||
Q = @
|
||||
endif
|
||||
|
||||
AWK = "awk"
|
||||
ROOT_DIR := $(shell pwd)
|
||||
BIN_DIR = "$(ROOT_DIR)/bin"
|
||||
SRC_DIR = "$(ROOT_DIR)/src"
|
||||
BUNDLE_DIR = "$(ROOT_DIR)/bundle"
|
||||
BUNDLES_DIR = "$(ROOT_DIR)/bundles"
|
||||
TTD = openttd.exe
|
||||
PDB = openttd.pdb
|
||||
MODE = Release
|
||||
TARGET := $(shell echo $(PLATFORM) | sed "s@win64@x64@;s@win32@Win32@")
|
||||
|
||||
all:
|
||||
$(Q)cp objs/$(TARGET)/$(MODE)/$(TTD) $(BIN_DIR)/$(TTD)
|
||||
|
||||
include Makefile.bundle.in
|
||||
|
||||
bundle_pdb:
|
||||
@echo '[BUNDLE] Creating $(BUNDLE_NAME).pdb.xz'
|
||||
$(Q)mkdir -p "$(BUNDLES_DIR)"
|
||||
$(Q)cp objs/$(TARGET)/Release/$(PDB) $(BUNDLES_DIR)/$(BUNDLE_NAME).pdb
|
||||
$(Q)xz -9 $(BUNDLES_DIR)/$(BUNDLE_NAME).pdb
|
||||
|
||||
regression: all
|
||||
$(Q)cp bin/$(TTD) bin/openttd
|
||||
$(Q)cd bin && sh ai/regression/run.sh
|
@ -1,63 +0,0 @@
|
||||
# This file is part of OpenTTD.
|
||||
# OpenTTD 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, version 2.
|
||||
# OpenTTD 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 OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
SETTINGSGEN = !!SETTINGSGEN!!
|
||||
SRC_DIR = !!SRC_DIR!!
|
||||
CXX_BUILD = !!CXX_BUILD!!
|
||||
CFLAGS_BUILD = !!CFLAGS_BUILD!!
|
||||
CXXFLAGS_BUILD = !!CXXFLAGS_BUILD!!
|
||||
LDFLAGS_BUILD = !!LDFLAGS_BUILD!!
|
||||
STAGE = !!STAGE!!
|
||||
SETTING_OBJS_DIR = !!SETTING_OBJS_DIR!!
|
||||
|
||||
# Check if we want to show what we are doing
|
||||
ifdef VERBOSE
|
||||
Q =
|
||||
E = @true
|
||||
else
|
||||
Q = @
|
||||
E = @echo
|
||||
endif
|
||||
|
||||
all: table/settings.h
|
||||
|
||||
settingsgen.o: $(SRC_DIR)/settingsgen/settingsgen.cpp $(SRC_DIR)/string_func.h $(SRC_DIR)/strings_type.h $(SRC_DIR)/misc/getoptdata.h $(SRC_DIR)/ini_type.h $(SRC_DIR)/core/smallvec_type.hpp $(SRC_DIR)/safeguards.h
|
||||
$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)'
|
||||
$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSETTINGSGEN -c -o $@ $<
|
||||
|
||||
alloc_func.o: $(SRC_DIR)/core/alloc_func.cpp $(SRC_DIR)/safeguards.h
|
||||
$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)'
|
||||
$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSETTINGSGEN -c -o $@ $<
|
||||
|
||||
getoptdata.o: $(SRC_DIR)/misc/getoptdata.cpp $(SRC_DIR)/misc/getoptdata.h $(SRC_DIR)/safeguards.h
|
||||
$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/misc/%.cpp=%.cpp)'
|
||||
$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSETTINGSGEN -c -o $@ $<
|
||||
|
||||
string.o: $(SRC_DIR)/string.cpp $(SRC_DIR)/safeguards.h
|
||||
$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)'
|
||||
$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSETTINGSGEN -c -o $@ $<
|
||||
|
||||
ini_load.o: $(SRC_DIR)/ini_load.cpp $(SRC_DIR)/core/alloc_func.hpp $(SRC_DIR)/core/mem_func.hpp $(SRC_DIR)/ini_type.h $(SRC_DIR)/string_func.h $(SRC_DIR)/safeguards.h
|
||||
$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)'
|
||||
$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) -DSETTINGSGEN -c -o $@ $<
|
||||
|
||||
$(SETTINGSGEN): alloc_func.o string.o ini_load.o settingsgen.o getoptdata.o
|
||||
$(E) '$(STAGE) Compiling and Linking $@'
|
||||
$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) $(LDFLAGS_BUILD) $^ -o $@
|
||||
|
||||
table/settings.h: $(SETTINGSGEN) $(SRC_DIR)/table/settings.h.preamble $(SRC_DIR)/table/settings.h.postamble $(SRC_DIR)/table/*.ini
|
||||
$(E) '$(STAGE) Generating $@'
|
||||
@mkdir -p table
|
||||
$(Q)./$(SETTINGSGEN) -o table/settings.h -b $(SRC_DIR)/table/settings.h.preamble -a $(SRC_DIR)/table/settings.h.postamble $(SRC_DIR)/table/*.ini
|
||||
|
||||
depend:
|
||||
|
||||
clean:
|
||||
$(E) '$(STAGE) Cleaning up settings files'
|
||||
$(Q)rm -f settingsgen.o alloc_func.o getoptdata.o string.o ini_load.o $(SETTINGSGEN) table/settings.h
|
||||
|
||||
mrproper: clean
|
||||
|
||||
.PHONY: all mrproper depend clean
|
@ -1,302 +0,0 @@
|
||||
# This file is part of OpenTTD.
|
||||
# OpenTTD 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, version 2.
|
||||
# OpenTTD 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 OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
CC_HOST = !!CC_HOST!!
|
||||
CXX_HOST = !!CXX_HOST!!
|
||||
CC_BUILD = !!CC_BUILD!!
|
||||
CXX_BUILD = !!CXX_BUILD!!
|
||||
WINDRES = !!WINDRES!!
|
||||
STRIP = !!STRIP!!
|
||||
CFLAGS = !!CFLAGS!!
|
||||
CFLAGS_BUILD = !!CFLAGS_BUILD!!
|
||||
CXXFLAGS = !!CXXFLAGS!!
|
||||
CXXFLAGS_BUILD = !!CXXFLAGS_BUILD!!
|
||||
LIBS = !!LIBS!!
|
||||
LDFLAGS = !!LDFLAGS!!
|
||||
LDFLAGS_BUILD = !!LDFLAGS_BUILD!!
|
||||
ROOT_DIR = !!ROOT_DIR!!
|
||||
BIN_DIR = !!BIN_DIR!!
|
||||
LANG_DIR = !!LANG_DIR!!
|
||||
SRC_OBJS_DIR = !!SRC_OBJS_DIR!!
|
||||
LANG_OBJS_DIR = !!LANG_OBJS_DIR!!
|
||||
SETTING_OBJS_DIR= !!SETTING_OBJS_DIR!!
|
||||
SRC_DIR = !!SRC_DIR!!
|
||||
SCRIPT_SRC_DIR = !!SCRIPT_SRC_DIR!!
|
||||
MEDIA_DIR = !!MEDIA_DIR!!
|
||||
TTD = !!TTD!!
|
||||
STRGEN = !!STRGEN!!
|
||||
DEPEND = !!DEPEND!!
|
||||
OS = !!OS!!
|
||||
STAGE = !!STAGE!!
|
||||
MAKEDEPEND = !!MAKEDEPEND!!
|
||||
CFLAGS_MAKEDEP = !!CFLAGS_MAKEDEP!!
|
||||
SORT = !!SORT!!
|
||||
AWK = !!AWK!!
|
||||
CONFIGURE_INVOCATION = !!CONFIGURE_INVOCATION!!
|
||||
CONFIG_CACHE_COMPILER = $(SRC_OBJS_DIR)/!!CONFIG_CACHE_COMPILER!!
|
||||
CONFIG_CACHE_LINKER = $(SRC_OBJS_DIR)/!!CONFIG_CACHE_LINKER!!
|
||||
CONFIG_CACHE_SOURCE = $(SRC_OBJS_DIR)/!!CONFIG_CACHE_SOURCE!!
|
||||
CONFIG_CACHE_VERSION = $(SRC_OBJS_DIR)/!!CONFIG_CACHE_VERSION!!
|
||||
CONFIG_CACHE_INVOCATION = $(SRC_OBJS_DIR)/!!CONFIG_CACHE_INVOCATION!!
|
||||
|
||||
OBJS_C := !!OBJS_C!!
|
||||
OBJS_CPP := !!OBJS_CPP!!
|
||||
OBJS_MM := !!OBJS_MM!!
|
||||
OBJS_RC := !!OBJS_RC!!
|
||||
OBJS := $(OBJS_C) $(OBJS_CPP) $(OBJS_MM) $(OBJS_RC)
|
||||
SRCS := !!SRCS!!
|
||||
|
||||
# All C-files depend on those 3 files
|
||||
FILE_DEP := $(CONFIG_CACHE_COMPILER)
|
||||
# Create all dirs and subdirs
|
||||
RES := $(shell mkdir -p $(BIN_DIR) $(sort $(dir $(OBJS))))
|
||||
|
||||
CFLAGS += -I $(SRC_OBJS_DIR) -I $(LANG_OBJS_DIR) -I $(SETTING_OBJS_DIR)
|
||||
CFLAGS_MAKEDEP += -I $(SRC_OBJS_DIR) -I $(LANG_OBJS_DIR) -I $(SETTING_OBJS_DIR)
|
||||
ifdef SCRIPT_SRC_DIR
|
||||
CFLAGS_MAKEDEP += -I $(SCRIPT_SRC_DIR)
|
||||
endif
|
||||
|
||||
# Check if we want to show what we are doing
|
||||
ifdef VERBOSE
|
||||
Q =
|
||||
E = @true
|
||||
else
|
||||
Q = @
|
||||
E = @echo
|
||||
endif
|
||||
|
||||
# Our default target
|
||||
all: $(BIN_DIR)/$(TTD)
|
||||
|
||||
# This are 2 rules that are pointing back to STRGEN stuff.
|
||||
# There is not really a need to have them here, but in case
|
||||
# some weirdo wants to run 'make' in the 'src' dir and expects
|
||||
# the languages to be recompiled, this catches that case and
|
||||
# takes care of it nicely.
|
||||
$(LANG_OBJS_DIR)/$(STRGEN):
|
||||
$(MAKE) -C $(LANG_OBJS_DIR) $(STRGEN)
|
||||
|
||||
$(LANG_OBJS_DIR)/table/strings.h: $(LANG_DIR)/english.txt $(LANG_OBJS_DIR)/$(STRGEN)
|
||||
$(MAKE) -C $(LANG_OBJS_DIR) table/strings.h
|
||||
|
||||
# Always run version detection, so we always have an accurate modified
|
||||
# flag
|
||||
VERSIONS := $(shell AWK="$(AWK)" "$(ROOT_DIR)/findversion.sh")
|
||||
MODIFIED := $(shell echo "$(VERSIONS)" | cut -f 3 -d' ')
|
||||
|
||||
# Use autodetected revisions
|
||||
VERSION := $(shell echo "$(VERSIONS)" | cut -f 1 -d' ')
|
||||
ISODATE := $(shell echo "$(VERSIONS)" | cut -f 2 -d' ')
|
||||
GITHASH := $(shell echo "$(VERSIONS)" | cut -f 4 -d' ')
|
||||
ISTAG := $(shell echo "$(VERSIONS)" | cut -f 5 -d' ')
|
||||
ISSTABLETAG := $(shell echo "$(VERSIONS)" | cut -f 6 -d' ')
|
||||
YEAR := $(shell echo "$(VERSIONS)" | cut -f 7 -d' ')
|
||||
|
||||
# Make sure we have something in VERSION and ISODATE
|
||||
ifeq ($(VERSION),)
|
||||
VERSION := norev000
|
||||
endif
|
||||
ifeq ($(ISODATE),)
|
||||
ISODATE := 00000000
|
||||
endif
|
||||
|
||||
# This helps to recompile if flags change
|
||||
RES := $(shell if [ "`cat $(CONFIG_CACHE_COMPILER) 2>/dev/null`" != "$(CFLAGS) $(CXXFLAGS)" ]; then echo "$(CFLAGS) $(CXXFLAGS)" > $(CONFIG_CACHE_COMPILER); fi )
|
||||
RES := $(shell if [ "`cat $(CONFIG_CACHE_LINKER) 2>/dev/null`" != "$(LDFLAGS) $(LIBS)" ]; then echo "$(LDFLAGS) $(LIBS)" > $(CONFIG_CACHE_LINKER); fi )
|
||||
|
||||
# If there is a change in the source-file-list, make sure we recheck the deps
|
||||
RES := $(shell if [ "`cat $(CONFIG_CACHE_SOURCE) 2>/dev/null`" != "$(SRCS)" ]; then echo "$(SRCS)" > $(CONFIG_CACHE_SOURCE); fi )
|
||||
# If there is a change in the revision, make sure we recompile rev.cpp
|
||||
RES := $(shell if [ "`cat $(CONFIG_CACHE_VERSION) 2>/dev/null`" != "$(VERSION) $(MODIFIED)" ]; then echo "$(VERSION) $(MODIFIED)" > $(CONFIG_CACHE_VERSION); fi )
|
||||
# If there is a change in the configure invocation, make sure we recompile rev.cpp
|
||||
RES := $(shell if [ "`cat $(CONFIG_CACHE_INVOCATION) 2>/dev/null`" != "$(CONFIGURE_INVOCATION)" ]; then echo "$(CONFIGURE_INVOCATION)" > $(CONFIG_CACHE_INVOCATION); fi )
|
||||
|
||||
FILTER_OUT = $(foreach v,$(2),$(if $(findstring $(1),$(v)),,$(v)))
|
||||
CONFIGURE_DEFINES := $(strip $(call FILTER_OUT,_DIR=,$(patsubst -D%,%,$(filter -D%,$(CFLAGS)))))
|
||||
|
||||
ifndef MAKEDEPEND
|
||||
# The slow, but always correct, dep-check
|
||||
DEP_MASK := %.d
|
||||
DEPS := $(OBJS:%.o=%.d)
|
||||
|
||||
# Only include the deps if we are compiling everything
|
||||
ifeq ($(filter %.o clean mrproper, $(MAKECMDGOALS)),)
|
||||
-include $(DEPS)
|
||||
else
|
||||
# In case we want to compile a single target, include the .d file for it
|
||||
ifneq ($(filter %.o, $(MAKECMDGOALS)),)
|
||||
SINGLE_DEP := $(filter %.o, $(MAKECMDGOALS))
|
||||
-include $(SINGLE_DEP:%.o=%.d)
|
||||
endif
|
||||
endif
|
||||
|
||||
# Find the deps via GCC. Rarely wrong, but a bit slow
|
||||
|
||||
$(OBJS_C:%.o=%.d): %.d: $(SRC_DIR)/%.c $(FILE_DEP)
|
||||
$(E) '$(STAGE) DEP $(<:$(SRC_DIR)/%.c=%.c)'
|
||||
$(Q)$(CC_HOST) $(CFLAGS) -MM $< | sed 's@^$(@F:%.d=%.o):@$@ $(@:%.d=%.o):@' > $@
|
||||
|
||||
$(OBJS_CPP:%.o=%.d): %.d: $(SRC_DIR)/%.cpp $(FILE_DEP)
|
||||
$(E) '$(STAGE) DEP $(<:$(SRC_DIR)/%.cpp=%.cpp)'
|
||||
$(Q)$(CXX_HOST) $(CFLAGS) $(CXXFLAGS) -MM $< | sed 's@^$(@F:%.d=%.o):@$@ $(@:%.d=%.o):@' > $@
|
||||
|
||||
$(OBJS_MM:%.o=%.d): %.d: $(SRC_DIR)/%.mm $(FILE_DEP)
|
||||
$(E) '$(STAGE) DEP $(<:$(SRC_DIR)/%.mm=%.mm)'
|
||||
$(Q)$(CXX_HOST) $(CFLAGS) $(CXXFLAGS) -MM $< | sed 's@^$(@F:%.d=%.o):@$@ $(@:%.d=%.o):@' > $@
|
||||
|
||||
$(OBJS_RC:%.o=%.d): %.d: $(SRC_DIR)/%.rc $(FILE_DEP)
|
||||
$(E) '$(STAGE) DEP $(<:$(SRC_DIR)/%.rc=%.rc)'
|
||||
$(Q)touch $@
|
||||
|
||||
else
|
||||
# The much faster, but can be wrong, dep-check
|
||||
DEP_MASK :=
|
||||
DEPS := Makefile.dep
|
||||
|
||||
# Only include the deps if we are not cleaning
|
||||
ifeq ($(filter depend clean mrproper, $(MAKECMDGOALS)),)
|
||||
-include Makefile.dep
|
||||
endif
|
||||
|
||||
ifeq ("$(SRC_OBJS_DIR)/$(DEPEND)","$(MAKEDEPEND)")
|
||||
DEP := $(MAKEDEPEND)
|
||||
$(SRC_OBJS_DIR)/$(DEPEND): $(SRC_DIR)/depend/depend.cpp
|
||||
$(E) '$(STAGE) Compiling and linking $(DEPEND)'
|
||||
$(Q)$(CXX_BUILD) $(CFLAGS_BUILD) $(CXXFLAGS_BUILD) $(LDFLAGS_BUILD) -o $@ $<
|
||||
endif
|
||||
|
||||
# Macro for invoking a command on groups of 100 words at a time
|
||||
# (analogous to xargs(1)). The macro invokes itself recursively
|
||||
# until the list of words is depleted.
|
||||
#
|
||||
# Usage: $(call xargs,COMMAND,LIST)
|
||||
#
|
||||
# COMMAND should be a shell command to which the words will be
|
||||
# appended as arguments in groups of 100.
|
||||
define xargs
|
||||
$(1) $(wordlist 1,100,$(2))
|
||||
$(if $(word 101,$(2)),$(call xargs,$(1),$(wordlist 101,$(words $(2)),$(2))))
|
||||
endef
|
||||
|
||||
# Make sure that only 'make depend' ALWAYS triggers a recheck
|
||||
ifeq ($(filter depend, $(MAKECMDGOALS)),)
|
||||
Makefile.dep: $(FILE_DEP) $(SRCS:%=$(SRC_DIR)/%) $(CONFIG_CACHE_SOURCE) $(DEP)
|
||||
else
|
||||
Makefile.dep: $(FILE_DEP) $(SRCS:%=$(SRC_DIR)/%) $(DEP) FORCE
|
||||
endif
|
||||
$(E) '$(STAGE) DEP CHECK (all files)'
|
||||
$(Q)rm -f Makefile.dep.tmp
|
||||
$(Q)touch Makefile.dep.tmp
|
||||
|
||||
# Calculate the deps via makedepend
|
||||
$(call xargs,$(Q)$(MAKEDEPEND) -f$(SRC_OBJS_DIR)/Makefile.dep.tmp -o.o -Y -v -a -- $(CFLAGS_MAKEDEP) -- 2>/dev/null,$(SRCS:%=$(SRC_DIR)/%))
|
||||
|
||||
# Remove all comments and includes that don't start with $(SRC_DIR)
|
||||
# Remove $(SRC_DIR) from object-file-name
|
||||
@$(AWK) ' \
|
||||
/^# DO NOT/ { print $$0 ; next} \
|
||||
/^#/ {next} \
|
||||
/: / { \
|
||||
left = NF - 1; \
|
||||
for (n = 2; n <= NF; n++) { \
|
||||
if (match($$n, "^$(ROOT_DIR)") == 0) { \
|
||||
$$n = ""; \
|
||||
left--; \
|
||||
} \
|
||||
} \
|
||||
gsub("$(SRC_DIR)/", "", $$1); \
|
||||
if (left > 0) { \
|
||||
print $$0; \
|
||||
$$1 = "Makefile.dep:"; \
|
||||
print $$0; \
|
||||
} \
|
||||
next \
|
||||
} \
|
||||
{ \
|
||||
print $$0 \
|
||||
} \
|
||||
' < Makefile.dep.tmp | sed 's@ *@ @g;s@ $$@@' | LC_ALL=C $(SORT) > Makefile.dep
|
||||
|
||||
$(Q)rm -f Makefile.dep.tmp Makefile.dep.tmp.bak
|
||||
|
||||
endif
|
||||
|
||||
# Avoid problems with deps if a .h/.hpp/.hpp.sq file is deleted without the deps
|
||||
# being updated. Now the Makefile continues, the deps are recreated
|
||||
# and all will be fine.
|
||||
%.h %.hpp %.hpp.sq:
|
||||
@true
|
||||
|
||||
|
||||
# Compile all the files according to the targets
|
||||
|
||||
$(OBJS_C): %.o: $(SRC_DIR)/%.c $(DEP_MASK) $(FILE_DEP)
|
||||
$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.c=%.c)'
|
||||
$(Q)$(CC_HOST) $(CFLAGS) -c -o $@ $<
|
||||
|
||||
$(filter-out %sse2.o, $(filter-out %ssse3.o, $(filter-out %sse4.o, $(OBJS_CPP)))): %.o: $(SRC_DIR)/%.cpp $(DEP_MASK) $(FILE_DEP)
|
||||
$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)'
|
||||
$(Q)$(CXX_HOST) $(CFLAGS) $(CXXFLAGS) -c -o $@ $<
|
||||
|
||||
$(filter %sse2.o, $(OBJS_CPP)): %.o: $(SRC_DIR)/%.cpp $(DEP_MASK) $(FILE_DEP)
|
||||
$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)'
|
||||
$(Q)$(CXX_HOST) $(CFLAGS) $(CXXFLAGS) -c -msse2 -o $@ $<
|
||||
|
||||
$(filter %ssse3.o, $(OBJS_CPP)): %.o: $(SRC_DIR)/%.cpp $(DEP_MASK) $(FILE_DEP)
|
||||
$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)'
|
||||
$(Q)$(CXX_HOST) $(CFLAGS) $(CXXFLAGS) -c -mssse3 -o $@ $<
|
||||
|
||||
$(filter %sse4.o, $(OBJS_CPP)): %.o: $(SRC_DIR)/%.cpp $(DEP_MASK) $(FILE_DEP)
|
||||
$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.cpp=%.cpp)'
|
||||
$(Q)$(CXX_HOST) $(CFLAGS) $(CXXFLAGS) -c -msse4.1 -o $@ $<
|
||||
|
||||
$(OBJS_MM): %.o: $(SRC_DIR)/%.mm $(DEP_MASK) $(FILE_DEP)
|
||||
$(E) '$(STAGE) Compiling $(<:$(SRC_DIR)/%.mm=%.mm)'
|
||||
$(Q)$(CXX_HOST) $(CFLAGS) $(CXXFLAGS) -c -o $@ $<
|
||||
|
||||
$(OBJS_RC): %.o: $(SRC_DIR)/%.rc $(FILE_DEP)
|
||||
$(E) '$(STAGE) Compiling resource $(<:$(SRC_DIR)/%.rc=%.rc)'
|
||||
$(Q)$(WINDRES) -o $@ $<
|
||||
|
||||
$(BIN_DIR)/$(TTD): $(TTD)
|
||||
$(Q)cp $(TTD) $(BIN_DIR)/$(TTD)
|
||||
ifeq ($(OS), UNIX)
|
||||
$(Q)cp $(MEDIA_DIR)/openttd.32.bmp $(BIN_DIR)/baseset/
|
||||
endif
|
||||
ifeq ($(OS), OSX)
|
||||
$(Q)cp $(ROOT_DIR)/os/macosx/splash.png $(BIN_DIR)/baseset/
|
||||
endif
|
||||
|
||||
$(TTD): $(OBJS) $(CONFIG_CACHE_LINKER)
|
||||
$(E) '$(STAGE) Linking $@'
|
||||
$(Q)+$(CXX_HOST) $(LDFLAGS) $(OBJS) $(LIBS) -o $@
|
||||
ifdef STRIP
|
||||
$(Q)$(STRIP) $@
|
||||
endif
|
||||
|
||||
# Revision files
|
||||
|
||||
$(SRC_DIR)/rev.cpp: $(CONFIG_CACHE_VERSION) $(CONFIG_CACHE_INVOCATION) $(SRC_DIR)/rev.cpp.in
|
||||
$(Q)cat $(SRC_DIR)/rev.cpp.in | sed "s@\!\!ISODATE\!\!@$(ISODATE)@g;s@!!VERSION!!@$(VERSION)@g;s@!!MODIFIED!!@$(MODIFIED)@g;s@!!DATE!!@`date +%d.%m.%y`@g;s@!!GITHASH!!@$(GITHASH)@g;s@!!ISTAG!!@$(ISTAG)@g;s@!!ISSTABLETAG!!@$(ISSTABLETAG)@g;s@!!YEAR!!@$(YEAR)@g;s@\!\!CONFIGURE_INVOCATION\!\!@$(subst \",\\\\\\\",$(subst @,\\@,$(CONFIGURE_INVOCATION)))@g;s@\!\!CONFIGURE_DEFINES\!\!@$(subst \",\\\\\\\",$(subst @,\\@,$(subst \\,\\\\,$(CONFIGURE_DEFINES))))@g;" > $(SRC_DIR)/rev.cpp
|
||||
|
||||
$(SRC_DIR)/os/windows/ottdres.rc: $(CONFIG_CACHE_VERSION) $(SRC_DIR)/os/windows/ottdres.rc.in
|
||||
$(Q)cat $(SRC_DIR)/os/windows/ottdres.rc.in | sed "s@\!\!ISODATE\!\!@$(ISODATE)@g;s@!!VERSION!!@$(VERSION)@g;s@!!DATE!!@`date +%d.%m.%y`@g;s@!!GITHASH!!@$(GITHASH)@g;s@!!ISTAG!!@$(ISTAG)@g;s@!!ISSTABLETAG!!@$(ISSTABLETAG)@g;s@!!YEAR!!@$(YEAR)@g" > $(SRC_DIR)/os/windows/ottdres.rc
|
||||
|
||||
FORCE:
|
||||
|
||||
depend: $(DEPS)
|
||||
|
||||
clean:
|
||||
$(E) '$(STAGE) Cleaning up object files'
|
||||
$(Q)rm -f $(DEPS) $(OBJS) $(TTD) $(DEPEND) $(TTD:%=$(BIN_DIR)/%) $(BIN_DIR)/baseset/openttd.32.bmp $(CONFIG_CACHE_COMPILER) $(CONFIG_CACHE_LINKER) $(CONFIG_CACHE_SOURCE)
|
||||
|
||||
mrproper: clean
|
||||
$(Q)rm -f $(SRC_DIR)/rev.cpp $(SRC_DIR)/os/windows/ottdres.rc
|
||||
|
||||
%.o:
|
||||
@echo '$(STAGE) No such source-file: $(@:%.o=%).[c|cpp|mm|rc]'
|
||||
|
||||
.PHONY: all mrproper depend clean FORCE
|
@ -1,8 +1,13 @@
|
||||
parameters:
|
||||
SharedFolder: '/usr/local/share/games/openttd'
|
||||
PrefixCommand: ''
|
||||
|
||||
steps:
|
||||
- bash: |
|
||||
set -ex
|
||||
cd bin/baseset
|
||||
curl -L https://cdn.openttd.org/opengfx-releases/0.6.0/opengfx-0.6.0-all.zip > opengfx-all.zip
|
||||
unzip opengfx-all.zip
|
||||
rm -f opengfx-all.zip
|
||||
${{ parameters.PrefixCommand }} mkdir -p "${{ parameters.SharedFolder }}/baseset"
|
||||
cd "${{ parameters.SharedFolder }}/baseset"
|
||||
${{ parameters.PrefixCommand }} curl -L https://cdn.openttd.org/opengfx-releases/0.6.0/opengfx-0.6.0-all.zip -o opengfx-all.zip
|
||||
${{ parameters.PrefixCommand }} unzip opengfx-all.zip
|
||||
${{ parameters.PrefixCommand }} rm -f opengfx-all.zip
|
||||
displayName: 'Install OpenGFX'
|
||||
|
@ -1,5 +1,5 @@
|
||||
steps:
|
||||
# Because we run the compile in a docker (under root), we are not owner
|
||||
# of the 'bundles' folder. Fix that by executing a chown on it.
|
||||
- bash: sudo chown -R $(id -u):$(id -g) bundles
|
||||
- bash: sudo chown -R $(id -u):$(id -g) build/bundles
|
||||
displayName: 'Claim bundles folder back'
|
||||
|
@ -1,5 +1,9 @@
|
||||
steps:
|
||||
- script: './configure PKG_CONFIG_PATH=/usr/local/lib/pkgconfig --enable-static'
|
||||
displayName: 'Configure'
|
||||
- script: 'make -j2'
|
||||
- script: |
|
||||
set -ex
|
||||
|
||||
mkdir build
|
||||
cd build
|
||||
cmake ..
|
||||
make -j2
|
||||
displayName: 'Build'
|
||||
|
@ -1,11 +1,17 @@
|
||||
parameters:
|
||||
BuildPlatform: ''
|
||||
BuildArch: ''
|
||||
VcpkgTargetTriplet: ''
|
||||
BuildConfiguration: ''
|
||||
OptionUseNSIS: 'OFF'
|
||||
|
||||
steps:
|
||||
- task: CMake@1
|
||||
displayName: 'Configure'
|
||||
inputs:
|
||||
cmakeArgs: '.. -G "Visual Studio 15 2017" -A ${{ parameters.BuildArch }} -DCMAKE_TOOLCHAIN_FILE="c:\vcpkg\scripts\buildsystems\vcpkg.cmake" -DVCPKG_TARGET_TRIPLET="${{ parameters.VcpkgTargetTriplet }}" -DOPTION_USE_NSIS="${{ parameters.OptionUseNSIS }}"'
|
||||
- task: VSBuild@1
|
||||
displayName: 'Build'
|
||||
inputs:
|
||||
solution: 'projects/openttd_vs141.sln'
|
||||
platform: ${{ parameters.BuildPlatform }}
|
||||
solution: build/openttd.vcxproj
|
||||
configuration: ${{ parameters.BuildConfiguration }}
|
||||
maximumCpuCount: true
|
||||
|
@ -1,26 +0,0 @@
|
||||
parameters:
|
||||
condition: true
|
||||
|
||||
steps:
|
||||
- bash: |
|
||||
set -ex
|
||||
|
||||
mkdir nsis-plugin; cd nsis-plugin
|
||||
curl -L https://devs.openttd.org/~truebrain/nsis-plugins/Nsis7z.zip > Nsis7z.zip
|
||||
unzip Nsis7z.zip
|
||||
cp -R Plugins/* "/c/Program Files (x86)/NSIS/Plugins/"
|
||||
cd ..; rm -rf nsis-plugin
|
||||
|
||||
mkdir nsis-plugin; cd nsis-plugin
|
||||
curl -L https://devs.openttd.org/~truebrain/nsis-plugins/NsisGetVersion.zip > NsisGetVersion.zip
|
||||
unzip NsisGetVersion.zip
|
||||
cp -R Plugins/* "/c/Program Files (x86)/NSIS/Plugins/x86-ansi/"
|
||||
cd ..; rm -rf nsis-plugin
|
||||
|
||||
mkdir nsis-plugin; cd nsis-plugin
|
||||
curl -L https://devs.openttd.org/~truebrain/nsis-plugins/NsisFindProc.zip > NsisFindProc.zip
|
||||
unzip NsisFindProc.zip
|
||||
cp -R *.dll "/c/Program Files (x86)/NSIS/Plugins/x86-ansi/"
|
||||
cd ..; rm -rf nsis-plugin
|
||||
displayName: 'Install NSIS with the 7z, GetVersion, and FindProc plugins'
|
||||
condition: and(succeeded(), ${{ parameters.condition }})
|
@ -1,67 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
if ! [ -f ai/regression/completeness.sh ]; then
|
||||
echo "Make sure you are in the root of OpenTTD before starting this script."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cat ai/regression/tst_*/main.nut | tr ';' '\n' | awk '
|
||||
/^function/ {
|
||||
for (local in locals) {
|
||||
delete locals[local]
|
||||
}
|
||||
if (match($0, "function Regression::Start") || match($0, "function Regression::Stop")) next
|
||||
locals["this"] = "AIControllerSquirrel"
|
||||
}
|
||||
|
||||
/local/ {
|
||||
gsub(".*local", "local")
|
||||
if (match($4, "^AI")) {
|
||||
sub("\\(.*", "", $4)
|
||||
locals[$2] = $4
|
||||
}
|
||||
}
|
||||
|
||||
/Valuate/ {
|
||||
gsub(".*Valuate\\(", "")
|
||||
gsub("\\).*", "")
|
||||
gsub(",.*", "")
|
||||
gsub("\\.", "::")
|
||||
print $0
|
||||
}
|
||||
|
||||
/\./ {
|
||||
for (local in locals) {
|
||||
if (match($0, local ".")) {
|
||||
fname = substr($0, index($0, local "."))
|
||||
sub("\\(.*", "", fname)
|
||||
sub("\\.", "::", fname)
|
||||
sub(local, locals[local], fname)
|
||||
print fname
|
||||
if (match(locals[local], "List")) {
|
||||
sub(locals[local], "AIAbstractList", fname)
|
||||
print fname
|
||||
}
|
||||
}
|
||||
}
|
||||
# We want to remove everything before the FIRST occurrence of AI.
|
||||
# If we do not remove any other occurrences of AI from the string
|
||||
# we will remove everything before the LAST occurrence of AI, so
|
||||
# do some little magic to make it work the way we want.
|
||||
sub("AI", "AXXXXY")
|
||||
gsub("AI", "AXXXXX")
|
||||
sub(".*AXXXXY", "AI")
|
||||
if (match($0, "^AI") && match($0, ".")) {
|
||||
sub("\\(.*", "", $0)
|
||||
sub("\\.", "::", $0)
|
||||
print $0
|
||||
}
|
||||
}
|
||||
' | sed 's/ //g' | sort | uniq > tmp.in_regression
|
||||
|
||||
grep 'DefSQ.*Method' ../src/script/api/ai/*.hpp.sq | grep -v 'AIError::' | grep -v 'AIAbstractList::Valuate' | grep -v '::GetClassName' | sed 's/^[^,]*, &//g;s/,[^,]*//g' | sort > tmp.in_api
|
||||
|
||||
diff -u tmp.in_regression tmp.in_api | grep -v '^+++' | grep '^+' | sed 's/^+//'
|
||||
|
||||
rm -f tmp.in_regression tmp.in_api
|
||||
|
@ -1,69 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
if ! [ -f ai/regression/run.sh ]; then
|
||||
echo "Make sure you are in the root of OpenTTD before starting this script."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ -f scripts/game_start.scr ]; then
|
||||
mv scripts/game_start.scr scripts/game_start.scr.regression
|
||||
fi
|
||||
|
||||
params=""
|
||||
gdb=""
|
||||
if [ "$1" != "-r" ]; then
|
||||
params="-snull -mnull -vnull:ticks=30000"
|
||||
fi
|
||||
if [ "$1" = "-g" ]; then
|
||||
gdb="gdb --ex run --args "
|
||||
fi
|
||||
|
||||
if [ -d "ai/regression/tst_$1" ]; then
|
||||
tests="ai/regression/tst_$1"
|
||||
elif [ -d "ai/regression/tst_$2" ]; then
|
||||
tests="ai/regression/tst_$2"
|
||||
else
|
||||
tests=ai/regression/tst_*
|
||||
fi
|
||||
|
||||
ret=0
|
||||
for tst in $tests; do
|
||||
echo -n "Running $tst... "
|
||||
|
||||
# Make sure that only one info.nut is present for each test run. Otherwise openttd gets confused.
|
||||
cp ai/regression/regression_info.nut $tst/info.nut
|
||||
|
||||
sav=$tst/test.sav
|
||||
if ! [ -f $sav ]; then
|
||||
sav=ai/regression/empty.sav
|
||||
fi
|
||||
|
||||
if [ -n "$gdb" ]; then
|
||||
$gdb ./openttd -x -c ai/regression/regression.cfg $params -g $sav
|
||||
else
|
||||
./openttd -x -c ai/regression/regression.cfg $params -g $sav -d script=2 -d misc=9 2>&1 | awk '{ gsub("0x(\\(nil\\)|0+)(x0)?", "0x00000000", $0); gsub("^dbg: \\[script\\]", "", $0); gsub("^ ", "ERROR: ", $0); gsub("ERROR: \\[1\\] ", "", $0); gsub("\\[P\\] ", "", $0); print $0; }' | grep -v '^dbg: \[.*\]' > $tst/tmp.regression
|
||||
fi
|
||||
|
||||
if [ -z "$gdb" ]; then
|
||||
res="`diff -ub $tst/result.txt $tst/tmp.regression`"
|
||||
if [ -z "$res" ]; then
|
||||
echo "passed!"
|
||||
else
|
||||
echo "failed! Difference:"
|
||||
echo "$res"
|
||||
ret=1
|
||||
fi
|
||||
fi
|
||||
|
||||
rm $tst/info.nut
|
||||
|
||||
if [ "$1" != "-k" ]; then
|
||||
rm -f $tst/tmp.regression
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -f scripts/game_start.scr.regression ]; then
|
||||
mv scripts/game_start.scr.regression scripts/game_start.scr
|
||||
fi
|
||||
|
||||
exit $ret
|
@ -1,152 +0,0 @@
|
||||
Option Explicit
|
||||
|
||||
' This file is part of OpenTTD.
|
||||
' OpenTTD 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, version 2.
|
||||
' OpenTTD 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 OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Dim FSO
|
||||
Set FSO = CreateObject("Scripting.FileSystemObject")
|
||||
|
||||
Function GetTestList()
|
||||
Dim retests, i, tests, dir
|
||||
Set retests = New RegExp
|
||||
Set GetTestList = CreateObject("Scripting.Dictionary")
|
||||
|
||||
retests.Pattern = "ai/regression/tst_*"
|
||||
retests.Global = True
|
||||
For i = 0 To WScript.Arguments.Count - 1
|
||||
Dim test
|
||||
test = "ai/regression/tst_" & WScript.Arguments.Item(i)
|
||||
If FSO.FolderExists(test) Then
|
||||
retests.Pattern = test
|
||||
Exit For
|
||||
End If
|
||||
Next
|
||||
|
||||
For Each dir In FSO.GetFolder("ai/regression/").SubFolders
|
||||
Dim name
|
||||
name = "ai/regression/" & dir.Name
|
||||
If retests.Test(name) Then
|
||||
GetTestList.Add name, name
|
||||
End If
|
||||
Next
|
||||
End Function
|
||||
|
||||
Function GetParams()
|
||||
GetParams = "-snull -mnull -vnull:ticks=30000"
|
||||
If WScript.Arguments.Count = 0 Then Exit Function
|
||||
If WScript.Arguments.Item(0) <> "-r" Then Exit Function
|
||||
GetParams = ""
|
||||
End Function
|
||||
|
||||
Sub FilterFile(filename)
|
||||
Dim lines, filter, file
|
||||
|
||||
Set file = FSO.OpenTextFile(filename, 1)
|
||||
If Not file.AtEndOfStream Then
|
||||
lines = file.ReadAll
|
||||
End If
|
||||
file.Close
|
||||
|
||||
Set filter = New RegExp
|
||||
filter.Global = True
|
||||
filter.Multiline = True
|
||||
filter.Pattern = "0x(\(nil\)|0+)(x0)?"
|
||||
lines = filter.Replace(lines, "0x00000000")
|
||||
filter.Pattern = "^dbg: \[script\]"
|
||||
lines = filter.Replace(lines, "")
|
||||
filter.Pattern = "^ "
|
||||
lines = filter.Replace(lines, "ERROR: ")
|
||||
filter.Pattern = "ERROR: \[1\] \[P\] "
|
||||
lines = filter.Replace(lines, "")
|
||||
filter.Pattern = "^dbg: .*\r\n"
|
||||
lines = filter.Replace(lines, "")
|
||||
|
||||
Set file = FSO.OpenTextFile(filename, 2)
|
||||
file.Write lines
|
||||
file.Close
|
||||
End Sub
|
||||
|
||||
Function CompareFiles(filename1, filename2)
|
||||
Dim file, lines1, lines2
|
||||
Set file = FSO.OpenTextFile(filename1, 1)
|
||||
If Not file.AtEndOfStream Then
|
||||
lines1 = file.ReadAll
|
||||
End IF
|
||||
file.Close
|
||||
Set file = FSO.OpenTextFile(filename2, 1)
|
||||
If Not file.AtEndOfStream Then
|
||||
lines2 = file.ReadAll
|
||||
End IF
|
||||
file.Close
|
||||
CompareFiles = (lines1 = lines2)
|
||||
End Function
|
||||
|
||||
Function RunTest(test, params, ret)
|
||||
Dim WshShell, oExec, sav, command
|
||||
Set WshShell = CreateObject("WScript.Shell")
|
||||
|
||||
' Make sure that only one info.nut is present for each test run. Otherwise openttd gets confused.
|
||||
FSO.CopyFile "ai/regression/regression_info.nut", test & "/info.nut"
|
||||
|
||||
sav = test & "/test.sav"
|
||||
If Not FSO.FileExists(sav) Then
|
||||
sav = "ai/regression/empty.sav"
|
||||
End If
|
||||
|
||||
command = ".\openttd -x -c ai/regression/regression.cfg " & params & " -g " & sav & " -d script=2 -d misc=9"
|
||||
' 2>&1 must be after >tmp.regression, else stderr is not redirected to the file
|
||||
WshShell.Run "cmd /c " & command & " >"& test & "/tmp.regression 2>&1", 0, True
|
||||
|
||||
FilterFile test & "/tmp.regression"
|
||||
|
||||
If CompareFiles(test & "/result.txt", test & "/tmp.regression") Then
|
||||
RunTest = "passed!"
|
||||
Else
|
||||
RunTest = "failed!"
|
||||
ret = 1
|
||||
End If
|
||||
|
||||
FSO.DeleteFile test & "/info.nut"
|
||||
|
||||
If WScript.Arguments.Count > 0 Then
|
||||
If WScript.Arguments.Item(0) = "-k" Then
|
||||
Exit Function
|
||||
End If
|
||||
End If
|
||||
|
||||
FSO.DeleteFile test & "/tmp.regression"
|
||||
End Function
|
||||
|
||||
On Error Resume Next
|
||||
WScript.StdOut.WriteLine ""
|
||||
If Err.Number <> 0 Then
|
||||
WScript.Echo "This script must be started with cscript."
|
||||
WScript.Quit 1
|
||||
End If
|
||||
On Error Goto 0
|
||||
|
||||
If Not FSO.FileExists("ai/regression/run.vbs") Then
|
||||
WScript.Echo "Make sure you are in the root of OpenTTD before starting this script."
|
||||
WScript.Quit 1
|
||||
End If
|
||||
|
||||
If FSO.FileExists("scripts/game_start.scr") Then
|
||||
FSO.MoveFile "scripts/game_start.scr", "scripts/game_start.scr.regression"
|
||||
End If
|
||||
|
||||
Dim params, test, ret
|
||||
params = GetParams()
|
||||
ret = 0
|
||||
|
||||
For Each test in GetTestList()
|
||||
WScript.StdOut.Write "Running " & test & "... "
|
||||
WScript.StdOut.WriteLine RunTest(test, params, ret)
|
||||
Next
|
||||
|
||||
If FSO.FileExists("scripts/game_start.scr.regression") Then
|
||||
FSO.MoveFile "scripts/game_start.scr.regression", "scripts/game_start.scr"
|
||||
End If
|
||||
|
||||
WScript.Quit ret
|
@ -0,0 +1,145 @@
|
||||
macro(_parse_arguments_with_multi_hack ORIGINAL_COMMAND_LINE)
|
||||
# cmake_parse_arguments() put all the MULTIS in a single variable; you
|
||||
# lose the ability to see for example multiple COMMANDs. To be able to
|
||||
# passthrough multiple MULTIS, we add a marker after every MULTI. This
|
||||
# allows us to reassemble the correct amount again before giving it to
|
||||
# the wrapped command with _reassemble_command_line().
|
||||
|
||||
set(COMMAND_LINE "${ORIGINAL_COMMAND_LINE}")
|
||||
|
||||
foreach(MULTI IN LISTS MULTIS)
|
||||
string(REPLACE "${MULTI}" "${MULTI};:::" COMMAND_LINE "${COMMAND_LINE}")
|
||||
endforeach(MULTI)
|
||||
|
||||
cmake_parse_arguments(PARAM "${OPTIONS}" "${SINGLES}" "${MULTIS}" ${COMMAND_LINE})
|
||||
endmacro()
|
||||
|
||||
macro(_reassemble_command_line)
|
||||
# Reassemble the command line as we original got it.
|
||||
set(NEW_COMMAND_LINE ${PARAM_UNPARSED_ARGUMENTS})
|
||||
|
||||
foreach(OPTION IN LISTS OPTIONS)
|
||||
if (PARAM_${OPTION})
|
||||
list(APPEND NEW_COMMAND_LINE "${OPTION}")
|
||||
endif (PARAM_${OPTION})
|
||||
endforeach(OPTION)
|
||||
|
||||
foreach(SINGLE IN LISTS SINGLES)
|
||||
if (PARAM_${SINGLE})
|
||||
list(APPEND NEW_COMMAND_LINE "${SINGLE}" "${PARAM_${SINGLE}}")
|
||||
endif (PARAM_${SINGLE})
|
||||
endforeach(SINGLE)
|
||||
|
||||
foreach(MULTI IN LISTS MULTIS)
|
||||
if (PARAM_${MULTI})
|
||||
# Replace our special marker with the name of the MULTI again. This
|
||||
# restores for example multiple COMMANDs again.
|
||||
string(REPLACE ":::" "${MULTI}" PARAM_${MULTI} "${PARAM_${MULTI}}")
|
||||
list(APPEND NEW_COMMAND_LINE "${PARAM_${MULTI}}")
|
||||
endif (PARAM_${MULTI})
|
||||
endforeach(MULTI)
|
||||
endmacro()
|
||||
|
||||
# Generated files can be older than their dependencies, causing useless
|
||||
# regenerations. This function replaces each file in OUTPUT with a .timestamp
|
||||
# file, adds a command to touch it and move the original file in BYPRODUCTS,
|
||||
# before calling add_custom_command().
|
||||
#
|
||||
# Note: Any add_custom_target() depending on files in original OUTPUT must use
|
||||
# add_custom_target_timestamp() instead to have the correct dependencies.
|
||||
#
|
||||
# add_custom_command_timestamp(OUTPUT output1 [output2 ...]
|
||||
# COMMAND command1 [ARGS] [args1...]
|
||||
# [COMMAND command2 [ARGS] [args2...] ...]
|
||||
# [MAIN_DEPENDENCY depend]
|
||||
# [DEPENDS [depends...]]
|
||||
# [BYPRODUCTS [files...]]
|
||||
# [IMPLICIT_DEPENDS <lang1> depend1
|
||||
# [<lang2> depend2] ...]
|
||||
# [WORKING_DIRECTORY dir]
|
||||
# [COMMENT comment]
|
||||
# [VERBATIM] [APPEND] [USES_TERMINAL])
|
||||
function(add_custom_command_timestamp)
|
||||
set(OPTIONS VERBATIM APPEND USES_TERMINAL)
|
||||
set(SINGLES MAIN_DEPENDENCY WORKING_DIRECTORY COMMENT)
|
||||
set(MULTIS OUTPUT COMMAND DEPENDS BYPRODUCTS IMPLICIT_DEPENDS)
|
||||
|
||||
_parse_arguments_with_multi_hack("${ARGN}")
|
||||
|
||||
# Create a list of all the OUTPUTs (by removing our magic marker)
|
||||
string(REPLACE ":::;" "" OUTPUTS "${PARAM_OUTPUT}")
|
||||
|
||||
# Reset the OUTPUT and BYPRODUCTS as an empty list (if needed).
|
||||
# Because they are MULTIS, we need to add our special marker here.
|
||||
set(PARAM_OUTPUT ":::")
|
||||
if (NOT PARAM_BYPRODUCTS)
|
||||
set(PARAM_BYPRODUCTS ":::")
|
||||
endif ()
|
||||
|
||||
foreach(OUTPUT IN LISTS OUTPUTS)
|
||||
# For every output, we add a 'cmake -E touch' entry to update the
|
||||
# timestamp on each run.
|
||||
get_filename_component(OUTPUT_FILENAME ${OUTPUT} NAME)
|
||||
string(APPEND PARAM_COMMAND ";:::;${CMAKE_COMMAND};-E;touch;${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_FILENAME}.timestamp")
|
||||
|
||||
# We change the OUTPUT to a '.timestamp' variant, and make the real
|
||||
# output a byproduct.
|
||||
list(APPEND PARAM_OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_FILENAME}.timestamp)
|
||||
list(APPEND PARAM_BYPRODUCTS ${OUTPUT})
|
||||
|
||||
# Mark this file as being a byproduct; we use this again with
|
||||
# add_custom_target_timestamp() to know if we should point to the
|
||||
# '.timestamp' variant or not.
|
||||
set_source_files_properties(${OUTPUT} PROPERTIES BYPRODUCT ${CMAKE_CURRENT_BINARY_DIR}/${OUTPUT_FILENAME}.timestamp)
|
||||
endforeach(OUTPUT)
|
||||
|
||||
# Reassemble and call the wrapped command
|
||||
_reassemble_command_line()
|
||||
add_custom_command(${NEW_COMMAND_LINE})
|
||||
endfunction(add_custom_command_timestamp)
|
||||
|
||||
# Generated files can be older than their dependencies, causing useless
|
||||
# regenerations. This function adds a .timestamp file for each file in DEPENDS
|
||||
# replaced by add_custom_command_timestamp(), before calling add_custom_target().
|
||||
#
|
||||
# add_custom_target_timestamp(Name [ALL] [command1 [args1...]]
|
||||
# [COMMAND command2 [args2...] ...]
|
||||
# [DEPENDS depend depend depend ... ]
|
||||
# [BYPRODUCTS [files...]]
|
||||
# [WORKING_DIRECTORY dir]
|
||||
# [COMMENT comment]
|
||||
# [VERBATIM] [USES_TERMINAL]
|
||||
# [SOURCES src1 [src2...]])
|
||||
function(add_custom_target_timestamp)
|
||||
set(OPTIONS VERBATIM USES_TERMINAL)
|
||||
set(SINGLES WORKING_DIRECTORY COMMENT)
|
||||
set(MULTIS COMMAND DEPENDS BYPRODUCTS SOURCES)
|
||||
# ALL is missing, as the order is important here. It will be picked up
|
||||
# by ${PARAM_UNPARSED_ARGUMENTS} when reassembling the command line.
|
||||
|
||||
_parse_arguments_with_multi_hack("${ARGN}")
|
||||
|
||||
# Create a list of all the DEPENDs (by removing our magic marker)
|
||||
string(REPLACE ":::;" "" DEPENDS "${PARAM_DEPENDS}")
|
||||
|
||||
# Reset the DEPEND as an empty list.
|
||||
# Because it is a MULTI, we need to add our special marker here.
|
||||
set(PARAM_DEPENDS ":::")
|
||||
|
||||
foreach(DEPEND IN LISTS DEPENDS)
|
||||
# Check if the output is produced by add_custom_command_timestamp()
|
||||
get_source_file_property(BYPRODUCT ${DEPEND} BYPRODUCT)
|
||||
|
||||
if (BYPRODUCT STREQUAL "NOTFOUND")
|
||||
# If it is not, just keep it as DEPEND
|
||||
list(APPEND PARAM_DEPENDS "${DEPEND}")
|
||||
else (BYPRODUCT STREQUAL "NOTFOUND")
|
||||
# If it is, the BYPRODUCT property points to the timestamp we want to depend on
|
||||
list(APPEND PARAM_DEPENDS "${BYPRODUCT}")
|
||||
endif (BYPRODUCT STREQUAL "NOTFOUND")
|
||||
endforeach(DEPEND)
|
||||
|
||||
# Reassemble and call the wrapped command
|
||||
_reassemble_command_line()
|
||||
add_custom_target(${NEW_COMMAND_LINE})
|
||||
endfunction(add_custom_target_timestamp)
|
@ -0,0 +1,120 @@
|
||||
# Macro which contains all bits to setup the compile flags correctly.
|
||||
#
|
||||
# compile_flags()
|
||||
#
|
||||
macro(compile_flags)
|
||||
if (MSVC)
|
||||
# Switch to MT (static) instead of MD (dynamic) binary
|
||||
|
||||
# For MSVC two generators are available
|
||||
# - a command line generator (Ninja) using CMAKE_BUILD_TYPE to specify the
|
||||
# configuration of the build tree
|
||||
# - an IDE generator (Visual Studio) using CMAKE_CONFIGURATION_TYPES to
|
||||
# specify all configurations that will be available in the generated solution
|
||||
list(APPEND MSVC_CONFIGS "${CMAKE_BUILD_TYPE}" "${CMAKE_CONFIGURATION_TYPES}")
|
||||
|
||||
# Set usage of static runtime for all configurations
|
||||
foreach(MSVC_CONFIG ${MSVC_CONFIGS})
|
||||
string(TOUPPER "CMAKE_CXX_FLAGS_${MSVC_CONFIG}" MSVC_FLAGS)
|
||||
string(REPLACE "/MD" "/MT" ${MSVC_FLAGS} "${${MSVC_FLAGS}}")
|
||||
endforeach()
|
||||
|
||||
# "If /Zc:rvalueCast is specified, the compiler follows section 5.4 of the
|
||||
# C++11 standard". We need C++11 for the way we use threads.
|
||||
add_compile_options(/Zc:rvalueCast)
|
||||
|
||||
# Add DPI manifest to project; other WIN32 targets get this via ottdres.rc
|
||||
list(APPEND GENERATED_SOURCE_FILES "${CMAKE_SOURCE_DIR}/os/windows/openttd.manifest")
|
||||
endif (MSVC)
|
||||
|
||||
# Add some -D flags for Debug builds. We cannot use add_definitions(), because
|
||||
# it does not appear to support the $<> tags.
|
||||
add_compile_options(
|
||||
"$<$<CONFIG:Debug>:-D_DEBUG>"
|
||||
"$<$<CONFIG:Debug>:-D_FORTIFY_SOURCE=2>"
|
||||
)
|
||||
|
||||
# Prepare a generator that checks if we are not a debug, and don't have asserts
|
||||
# on. We need this later on to set some compile options for stable releases.
|
||||
set(IS_STABLE_RELEASE "$<AND:$<NOT:$<CONFIG:Debug>>,$<NOT:$<BOOL:${OPTION_USE_ASSERTS}>>>")
|
||||
|
||||
if (MSVC)
|
||||
add_compile_options(/W3)
|
||||
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
|
||||
add_compile_options(
|
||||
-W
|
||||
-Wall
|
||||
-Wcast-qual
|
||||
-Wextra
|
||||
-Wsign-compare
|
||||
-Wundef
|
||||
-Wpointer-arith
|
||||
-Wwrite-strings
|
||||
-Wredundant-decls
|
||||
-Wformat-security
|
||||
-Wformat=2
|
||||
-Winit-self
|
||||
-Wnon-virtual-dtor
|
||||
|
||||
# Often parameters are unused, which is fine.
|
||||
-Wno-unused-parameter
|
||||
# We use 'ABCD' multichar for SaveLoad chunks identifiers
|
||||
-Wno-multichar
|
||||
|
||||
# Compilers complains about that we break strict-aliasing.
|
||||
# On most places we don't see how to fix it, and it doesn't
|
||||
# break anything. So disable strict-aliasing to make the
|
||||
# compiler all happy.
|
||||
-fno-strict-aliasing
|
||||
)
|
||||
|
||||
add_compile_options(
|
||||
# When we are a stable release (Release build + USE_ASSERTS not set),
|
||||
# assertations are off, which trigger a lot of warnings. We disable
|
||||
# these warnings for these releases.
|
||||
"$<${IS_STABLE_RELEASE}:-Wno-unused-variable>"
|
||||
"$<${IS_STABLE_RELEASE}:-Wno-unused-but-set-parameter>"
|
||||
"$<${IS_STABLE_RELEASE}:-Wno-unused-but-set-variable>"
|
||||
)
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
include(CheckCXXCompilerFlag)
|
||||
check_cxx_compiler_flag("-flifetime-dse=1" LIFETIME_DSE_FOUND)
|
||||
|
||||
add_compile_options(
|
||||
# GCC 4.2+ automatically assumes that signed overflows do
|
||||
# not occur in signed arithmetics, whereas we are not
|
||||
# sure that they will not happen. It furthermore complains
|
||||
# about its own optimized code in some places.
|
||||
"-fno-strict-overflow"
|
||||
|
||||
# Prevent optimisation supposing enums are in a range specified by the standard
|
||||
# For details, see http://gcc.gnu.org/PR43680
|
||||
"-fno-tree-vrp"
|
||||
|
||||
# -flifetime-dse=2 (default since GCC 6) doesn't play
|
||||
# well with our custom pool item allocator
|
||||
"$<$<BOOL:${LIFETIME_DSE_FOUND}>:-flifetime-dse=1>"
|
||||
)
|
||||
endif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
|
||||
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "Intel")
|
||||
add_compile_options(
|
||||
-Wall
|
||||
# warning #873: function ... ::operator new ... has no corresponding operator delete ...
|
||||
-wd873
|
||||
# warning #1292: unknown attribute "fallthrough"
|
||||
-wd1292
|
||||
# warning #1899: multicharacter character literal (potential portability problem)
|
||||
-wd1899
|
||||
# warning #2160: anonymous union qualifier is ignored
|
||||
-wd2160
|
||||
)
|
||||
else ()
|
||||
message(FATAL_ERROR "No warning flags are set for this compiler yet; please consider creating a Pull Request to add support for this compiler.")
|
||||
endif ()
|
||||
|
||||
if (NOT WIN32)
|
||||
# rdynamic is used to get useful stack traces from crash reports.
|
||||
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -rdynamic")
|
||||
endif (NOT WIN32)
|
||||
endmacro()
|
@ -0,0 +1,50 @@
|
||||
# Macro which contains all bits and pieces to create a single grf file based
|
||||
# on NFO and PNG files.
|
||||
#
|
||||
# create_grf_command()
|
||||
#
|
||||
function(create_grf_command)
|
||||
set(EXTRA_PNG_SOURCE_FILES ${ARGV})
|
||||
|
||||
get_filename_component(GRF_SOURCE_FOLDER_NAME "${CMAKE_CURRENT_SOURCE_DIR}" NAME)
|
||||
get_filename_component(GRF_BINARY_FILE ${CMAKE_CURRENT_SOURCE_DIR}/../${GRF_SOURCE_FOLDER_NAME}.grf ABSOLUTE)
|
||||
file(GLOB_RECURSE GRF_PNG_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.png)
|
||||
file(GLOB_RECURSE GRF_NFO_SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/*.nfo)
|
||||
set(GRF_PNG_SOURCE_FILES ${GRF_PNG_SOURCE_FILES} ${EXTRA_PNG_SOURCE_FILES})
|
||||
|
||||
# Copy over all the PNG files to the correct folder
|
||||
foreach(GRF_PNG_SOURCE_FILE IN LISTS GRF_PNG_SOURCE_FILES)
|
||||
get_filename_component(GRF_PNG_SOURCE_FILE_NAME "${GRF_PNG_SOURCE_FILE}" NAME)
|
||||
set(GRF_PNG_BINARY_FILE "${CMAKE_CURRENT_BINARY_DIR}/sprites/${GRF_PNG_SOURCE_FILE_NAME}")
|
||||
|
||||
add_custom_command(OUTPUT ${GRF_PNG_BINARY_FILE}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy
|
||||
${GRF_PNG_SOURCE_FILE}
|
||||
${GRF_PNG_BINARY_FILE}
|
||||
MAIN_DEPENDENCY ${GRF_PNG_SOURCE_FILE}
|
||||
COMMENT "Copying ${GRF_PNG_SOURCE_FILE_NAME} sprite file"
|
||||
)
|
||||
|
||||
list(APPEND GRF_PNG_BINARY_FILES ${GRF_PNG_BINARY_FILE})
|
||||
endforeach(GRF_PNG_SOURCE_FILE)
|
||||
|
||||
add_custom_command(OUTPUT ${GRF_BINARY_FILE}
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-DGRF_SOURCE_FOLDER=${CMAKE_CURRENT_SOURCE_DIR}
|
||||
-DGRF_BINARY_FILE=${GRF_BINARY_FILE}
|
||||
-DNFORENUM_EXECUTABLE=${NFORENUM_EXECUTABLE}
|
||||
-DGRFCODEC_EXECUTABLE=${GRFCODEC_EXECUTABLE}
|
||||
-P ${CMAKE_SOURCE_DIR}/cmake/scripts/CreateGRF.cmake
|
||||
MAIN_DEPENDENCY ${GRF_NFO_SOURCE_FILES}
|
||||
DEPENDS ${GRF_PNG_BINARY_FILES}
|
||||
${CMAKE_SOURCE_DIR}/cmake/scripts/CreateGRF.cmake
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMENT "Generating ${GRF_SOURCE_FOLDER_NAME}.grf"
|
||||
)
|
||||
|
||||
# For conviance, if you want to only test building the GRF
|
||||
add_custom_target(${GRF_SOURCE_FOLDER_NAME}.grf
|
||||
DEPENDS
|
||||
${GRF_BINARY_FILE}
|
||||
)
|
||||
endfunction()
|
@ -0,0 +1,86 @@
|
||||
# Macro which contains all bits and pieces to create the regression tests.
|
||||
# This creates both a standalone target 'regression', and it integrates with
|
||||
# 'ctest'. The first is prefered, as it is more verbose, and takes care of
|
||||
# dependencies correctly.
|
||||
#
|
||||
# create_regression()
|
||||
#
|
||||
macro(create_regression)
|
||||
# Find all the files in the regression folder; they need to be copied to the
|
||||
# build folder before we can run the regression
|
||||
file(GLOB_RECURSE REGRESSION_SOURCE_FILES ${CMAKE_SOURCE_DIR}/regression/*)
|
||||
foreach(REGRESSION_SOURCE_FILE IN LISTS REGRESSION_SOURCE_FILES)
|
||||
string(REGEX REPLACE "^${CMAKE_SOURCE_DIR}/regression/" "${CMAKE_BINARY_DIR}/ai/" REGRESSION_BINARY_FILE "${REGRESSION_SOURCE_FILE}")
|
||||
string(REGEX REPLACE "^${CMAKE_SOURCE_DIR}/regression/" "" REGRESSION_SOURCE_FILE_NAME "${REGRESSION_SOURCE_FILE}")
|
||||
|
||||
if ("${REGRESSION_SOURCE_FILE_NAME}" STREQUAL "regression.cfg")
|
||||
continue()
|
||||
endif ("${REGRESSION_SOURCE_FILE_NAME}" STREQUAL "regression.cfg")
|
||||
|
||||
add_custom_command(OUTPUT ${REGRESSION_BINARY_FILE}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy
|
||||
${REGRESSION_SOURCE_FILE}
|
||||
${REGRESSION_BINARY_FILE}
|
||||
MAIN_DEPENDENCY ${REGRESSION_SOURCE_FILE}
|
||||
COMMENT "Copying ${REGRESSION_SOURCE_FILE_NAME} regression file"
|
||||
)
|
||||
|
||||
list(APPEND REGRESSION_BINARY_FILES ${REGRESSION_BINARY_FILE})
|
||||
endforeach(REGRESSION_SOURCE_FILE)
|
||||
|
||||
# Copy the regression configuration in a special folder, so all autogenerated
|
||||
# folders end up in the same place after running regression.
|
||||
add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/regression/regression.cfg
|
||||
COMMAND ${CMAKE_COMMAND} -E copy
|
||||
${CMAKE_SOURCE_DIR}/regression/regression.cfg
|
||||
${CMAKE_BINARY_DIR}/regression/regression.cfg
|
||||
MAIN_DEPENDENCY ${CMAKE_SOURCE_DIR}/regression/regression.cfg
|
||||
COMMENT "Copying ${REGRESSION_SOURCE_FILE_NAME} regression file"
|
||||
)
|
||||
list(APPEND REGRESSION_BINARY_FILES ${CMAKE_BINARY_DIR}/regression/regression.cfg)
|
||||
|
||||
# Create a new target which copies all regression files
|
||||
add_custom_target(regression_files
|
||||
ALL # this is needed because 'make test' doesn't resolve dependencies, and otherwise this is never executed
|
||||
DEPENDS
|
||||
${REGRESSION_BINARY_FILES}
|
||||
)
|
||||
|
||||
enable_testing()
|
||||
|
||||
# Find all the tests we have, and create a target for them
|
||||
file(GLOB REGRESSION_TESTS ${CMAKE_SOURCE_DIR}/regression/*)
|
||||
foreach(REGRESSION_TEST IN LISTS REGRESSION_TESTS)
|
||||
get_filename_component(REGRESSION_TEST_NAME "${REGRESSION_TEST}" NAME)
|
||||
|
||||
if ("${REGRESSION_TEST_NAME}" STREQUAL "regression.cfg")
|
||||
continue()
|
||||
endif ("${REGRESSION_TEST_NAME}" STREQUAL "regression.cfg")
|
||||
|
||||
add_custom_target(regression_${REGRESSION_TEST_NAME}
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-DOPENTTD_EXECUTABLE=$<TARGET_FILE:openttd>
|
||||
-DEDITBIN_EXECUTABLE=${EDITBIN_EXECUTABLE}
|
||||
-DREGRESSION_TEST=${REGRESSION_TEST_NAME}
|
||||
-P "${CMAKE_SOURCE_DIR}/cmake/scripts/Regression.cmake"
|
||||
DEPENDS openttd regression_files
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
|
||||
COMMENT "Running regression test ${REGRESSION_TEST_NAME}"
|
||||
)
|
||||
|
||||
# Also make sure that 'make test' runs the regression
|
||||
add_test(NAME regression_${REGRESSION_TEST_NAME}
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-DOPENTTD_EXECUTABLE=$<TARGET_FILE:openttd>
|
||||
-DEDITBIN_EXECUTABLE=${EDITBIN_EXECUTABLE}
|
||||
-DREGRESSION_TEST=${REGRESSION_TEST_NAME}
|
||||
-P "${CMAKE_SOURCE_DIR}/cmake/scripts/Regression.cmake"
|
||||
WORKING_DIRECTORY ${CMAKE_BINARY_DIR})
|
||||
|
||||
list(APPEND REGRESSION_TARGETS regression_${REGRESSION_TEST_NAME})
|
||||
endforeach(REGRESSION_TEST)
|
||||
|
||||
# Create a new target which runs the regression
|
||||
add_custom_target(regression
|
||||
DEPENDS ${REGRESSION_TARGETS})
|
||||
endmacro()
|
@ -0,0 +1,14 @@
|
||||
# Add the definitions to indicate which endian we are building for.
|
||||
#
|
||||
# add_endian_definition()
|
||||
#
|
||||
function(add_endian_definition)
|
||||
include(TestBigEndian)
|
||||
TEST_BIG_ENDIAN(IS_BIG_ENDIAN)
|
||||
|
||||
if (IS_BIG_ENDIAN)
|
||||
add_definitions(-DTTD_ENDIAN=TTD_BIG_ENDIAN)
|
||||
else (IS_BIG_ENDIAN)
|
||||
add_definitions(-DTTD_ENDIAN=TTD_LITTLE_ENDIAN)
|
||||
endif (IS_BIG_ENDIAN)
|
||||
endfunction()
|
@ -0,0 +1,65 @@
|
||||
#[=======================================================================[.rst:
|
||||
FindAllegro
|
||||
-------
|
||||
|
||||
Finds the allegro library.
|
||||
|
||||
Result Variables
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
This will define the following variables:
|
||||
|
||||
``Allegro_FOUND``
|
||||
True if the system has the allegro library.
|
||||
``Allegro_INCLUDE_DIRS``
|
||||
Include directories needed to use allegro.
|
||||
``Allegro_LIBRARIES``
|
||||
Libraries needed to link to allegro.
|
||||
``Allegro_VERSION``
|
||||
The version of the allegro library which was found.
|
||||
|
||||
Cache Variables
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
The following cache variables may also be set:
|
||||
|
||||
``Allegro_INCLUDE_DIR``
|
||||
The directory containing ``allegro.h``.
|
||||
``Allegro_LIBRARY``
|
||||
The path to the allegro library.
|
||||
|
||||
#]=======================================================================]
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_check_modules(PC_Allegro QUIET allegro)
|
||||
|
||||
find_path(Allegro_INCLUDE_DIR
|
||||
NAMES allegro.h
|
||||
PATHS ${PC_Allegro_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
find_library(Allegro_LIBRARY
|
||||
NAMES alleg
|
||||
PATHS ${PC_Allegro_LIBRARY_DIRS}
|
||||
)
|
||||
|
||||
set(Allegro_VERSION ${PC_Allegro_VERSION})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Allegro
|
||||
FOUND_VAR Allegro_FOUND
|
||||
REQUIRED_VARS
|
||||
Allegro_LIBRARY
|
||||
Allegro_INCLUDE_DIR
|
||||
VERSION_VAR Allegro_VERSION
|
||||
)
|
||||
|
||||
if (Allegro_FOUND)
|
||||
set(Allegro_LIBRARIES ${Allegro_LIBRARY})
|
||||
set(Allegro_INCLUDE_DIRS ${Allegro_INCLUDE_DIR})
|
||||
endif ()
|
||||
|
||||
mark_as_advanced(
|
||||
Allegro_INCLUDE_DIR
|
||||
Allegro_LIBRARY
|
||||
)
|
@ -0,0 +1,13 @@
|
||||
# Autodetect editbin. Only useful for MSVC.
|
||||
|
||||
get_filename_component(MSVC_COMPILE_DIRECTORY ${CMAKE_CXX_COMPILER} DIRECTORY)
|
||||
find_program(
|
||||
EDITBIN_EXECUTABLE editbin.exe
|
||||
HINTS ${MSVC_COMPILE_DIRECTORY}
|
||||
)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Editbin
|
||||
FOUND_VAR EDITBIN_FOUND
|
||||
REQUIRED_VARS EDITBIN_EXECUTABLE
|
||||
)
|
@ -0,0 +1,65 @@
|
||||
#[=======================================================================[.rst:
|
||||
FindFluidsynth
|
||||
-------
|
||||
|
||||
Finds the fluidsynth library.
|
||||
|
||||
Result Variables
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
This will define the following variables:
|
||||
|
||||
``Fluidsynth_FOUND``
|
||||
True if the system has the fluidsynth library.
|
||||
``Fluidsynth_INCLUDE_DIRS``
|
||||
Include directories needed to use fluidsynth.
|
||||
``Fluidsynth_LIBRARIES``
|
||||
Libraries needed to link to fluidsynth.
|
||||
``Fluidsynth_VERSION``
|
||||
The version of the fluidsynth library which was found.
|
||||
|
||||
Cache Variables
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
The following cache variables may also be set:
|
||||
|
||||
``Fluidsynth_INCLUDE_DIR``
|
||||
The directory containing ``fluidsynth.h``.
|
||||
``Fluidsynth_LIBRARY``
|
||||
The path to the fluidsynth library.
|
||||
|
||||
#]=======================================================================]
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_check_modules(PC_Fluidsynth QUIET fluidsynth)
|
||||
|
||||
find_path(Fluidsynth_INCLUDE_DIR
|
||||
NAMES fluidsynth.h
|
||||
PATHS ${PC_Fluidsynth_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
find_library(Fluidsynth_LIBRARY
|
||||
NAMES fluidsynth
|
||||
PATHS ${PC_Fluidsynth_LIBRARY_DIRS}
|
||||
)
|
||||
|
||||
set(Fluidsynth_VERSION ${PC_Fluidsynth_VERSION})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Fluidsynth
|
||||
FOUND_VAR Fluidsynth_FOUND
|
||||
REQUIRED_VARS
|
||||
Fluidsynth_LIBRARY
|
||||
Fluidsynth_INCLUDE_DIR
|
||||
VERSION_VAR Fluidsynth_VERSION
|
||||
)
|
||||
|
||||
if (Fluidsynth_FOUND)
|
||||
set(Fluidsynth_LIBRARIES ${Fluidsynth_LIBRARY})
|
||||
set(Fluidsynth_INCLUDE_DIRS ${Fluidsynth_INCLUDE_DIR})
|
||||
endif ()
|
||||
|
||||
mark_as_advanced(
|
||||
Fluidsynth_INCLUDE_DIR
|
||||
Fluidsynth_LIBRARY
|
||||
)
|
@ -0,0 +1,101 @@
|
||||
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
# file Copyright.txt or https://cmake.org/licensing for details.
|
||||
|
||||
#[=======================================================================[.rst:
|
||||
FindFontconfig
|
||||
--------------
|
||||
|
||||
Find Fontconfig headers and library.
|
||||
|
||||
Imported Targets
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
``Fontconfig::Fontconfig``
|
||||
The Fontconfig library, if found.
|
||||
|
||||
Result Variables
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
This will define the following variables in your project:
|
||||
|
||||
``Fontconfig_FOUND``
|
||||
true if (the requested version of) Fontconfig is available.
|
||||
``Fontconfig_VERSION``
|
||||
the version of Fontconfig.
|
||||
``Fontconfig_LIBRARIES``
|
||||
the libraries to link against to use Fontconfig.
|
||||
``Fontconfig_INCLUDE_DIRS``
|
||||
where to find the Fontconfig headers.
|
||||
``Fontconfig_COMPILE_OPTIONS``
|
||||
this should be passed to target_compile_options(), if the
|
||||
target is not used for linking
|
||||
|
||||
#]=======================================================================]
|
||||
|
||||
|
||||
# use pkg-config to get the directories and then use these values
|
||||
# in the FIND_PATH() and FIND_LIBRARY() calls
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_check_modules(PKG_FONTCONFIG QUIET fontconfig)
|
||||
set(Fontconfig_COMPILE_OPTIONS ${PKG_FONTCONFIG_CFLAGS_OTHER})
|
||||
set(Fontconfig_VERSION ${PKG_FONTCONFIG_VERSION})
|
||||
|
||||
find_path( Fontconfig_INCLUDE_DIR
|
||||
NAMES
|
||||
fontconfig/fontconfig.h
|
||||
HINTS
|
||||
${PKG_FONTCONFIG_INCLUDE_DIRS}
|
||||
/usr/X11/include
|
||||
)
|
||||
|
||||
find_library( Fontconfig_LIBRARY
|
||||
NAMES
|
||||
fontconfig
|
||||
PATHS
|
||||
${PKG_FONTCONFIG_LIBRARY_DIRS}
|
||||
)
|
||||
|
||||
if (Fontconfig_INCLUDE_DIR AND NOT Fontconfig_VERSION)
|
||||
file(STRINGS ${Fontconfig_INCLUDE_DIR}/fontconfig/fontconfig.h _contents REGEX "^#define[ \t]+FC_[A-Z]+[ \t]+[0-9]+$")
|
||||
unset(Fontconfig_VERSION)
|
||||
foreach(VPART MAJOR MINOR REVISION)
|
||||
foreach(VLINE ${_contents})
|
||||
if(VLINE MATCHES "^#define[\t ]+FC_${VPART}[\t ]+([0-9]+)$")
|
||||
set(Fontconfig_VERSION_PART "${CMAKE_MATCH_1}")
|
||||
if(Fontconfig_VERSION)
|
||||
string(APPEND Fontconfig_VERSION ".${Fontconfig_VERSION_PART}")
|
||||
else()
|
||||
set(Fontconfig_VERSION "${Fontconfig_VERSION_PART}")
|
||||
endif()
|
||||
endif()
|
||||
endforeach()
|
||||
endforeach()
|
||||
endif ()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Fontconfig
|
||||
FOUND_VAR
|
||||
Fontconfig_FOUND
|
||||
REQUIRED_VARS
|
||||
Fontconfig_LIBRARY
|
||||
Fontconfig_INCLUDE_DIR
|
||||
VERSION_VAR
|
||||
Fontconfig_VERSION
|
||||
)
|
||||
|
||||
|
||||
if(Fontconfig_FOUND AND NOT TARGET Fontconfig::Fontconfig)
|
||||
add_library(Fontconfig::Fontconfig UNKNOWN IMPORTED)
|
||||
set_target_properties(Fontconfig::Fontconfig PROPERTIES
|
||||
IMPORTED_LOCATION "${Fontconfig_LIBRARY}"
|
||||
INTERFACE_COMPILE_OPTIONS "${Fontconfig_COMPILE_OPTIONS}"
|
||||
INTERFACE_INCLUDE_DIRECTORIES "${Fontconfig_INCLUDE_DIR}"
|
||||
)
|
||||
endif()
|
||||
|
||||
mark_as_advanced(Fontconfig_LIBRARY Fontconfig_INCLUDE_DIR)
|
||||
|
||||
if(Fontconfig_FOUND)
|
||||
set(Fontconfig_LIBRARIES ${Fontconfig_LIBRARY})
|
||||
set(Fontconfig_INCLUDE_DIRS ${Fontconfig_INCLUDE_DIR})
|
||||
endif()
|
@ -0,0 +1,13 @@
|
||||
# Autodetect grfcodec and nforenum.
|
||||
#
|
||||
|
||||
find_program(GRFCODEC_EXECUTABLE grfcodec)
|
||||
find_program(NFORENUM_EXECUTABLE nforenum)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(Grfcodec
|
||||
FOUND_VAR GRFCODEC_FOUND
|
||||
REQUIRED_VARS
|
||||
GRFCODEC_EXECUTABLE
|
||||
NFORENUM_EXECUTABLE
|
||||
)
|
@ -0,0 +1,64 @@
|
||||
#[=======================================================================[.rst:
|
||||
FindICU
|
||||
-------
|
||||
|
||||
Finds components of the ICU library.
|
||||
|
||||
Accepted components are: uc, i18n, le, lx, io
|
||||
|
||||
Result Variables
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
This will define the following variables:
|
||||
|
||||
``ICU_FOUND``
|
||||
True if components of ICU library are found.
|
||||
``ICU_VERSION``
|
||||
The version of the ICU library which was found.
|
||||
``ICU_<c>_FOUND``
|
||||
True if the system has the <c> component of ICU library.
|
||||
``ICU_<c>_INCLUDE_DIRS``
|
||||
Include directories needed to use the <c> component of ICU library.
|
||||
``ICU_<c>_LIBRARIES``
|
||||
Libraries needed to link to the <c> component of ICU library.
|
||||
|
||||
#]=======================================================================]
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
|
||||
set(ICU_KNOWN_COMPONENTS "uc" "i18n" "le" "lx" "io")
|
||||
|
||||
foreach(MOD_NAME IN LISTS ICU_FIND_COMPONENTS)
|
||||
if (NOT MOD_NAME IN_LIST ICU_KNOWN_COMPONENTS)
|
||||
message(FATAL_ERROR "Unknown ICU component: ${MOD_NAME}")
|
||||
endif()
|
||||
pkg_check_modules(PC_ICU_${MOD_NAME} QUIET icu-${MOD_NAME})
|
||||
|
||||
# Check the libraries returned by pkg-config really exist.
|
||||
unset(PC_LIBRARIES)
|
||||
foreach(LIBRARY IN LISTS PC_ICU_${MOD_NAME}_LIBRARIES)
|
||||
unset(PC_LIBRARY CACHE)
|
||||
find_library(PC_LIBRARY NAMES ${LIBRARY})
|
||||
if (NOT PC_LIBRARY)
|
||||
unset(PC_ICU_${MOD_NAME}_FOUND)
|
||||
endif()
|
||||
list(APPEND PC_LIBRARIES ${PC_LIBRARY})
|
||||
endforeach()
|
||||
unset(PC_LIBRARY CACHE)
|
||||
|
||||
if (${PC_ICU_${MOD_NAME}_FOUND})
|
||||
set(ICU_COMPONENT_FOUND TRUE)
|
||||
set(ICU_${MOD_NAME}_FOUND TRUE)
|
||||
set(ICU_${MOD_NAME}_LIBRARIES ${PC_LIBRARIES})
|
||||
set(ICU_${MOD_NAME}_INCLUDE_DIRS ${PC_ICU_${MOD_NAME}_INCLUDE_DIRS})
|
||||
set(ICU_VERSION ${PC_ICU_${MOD_NAME}_VERSION})
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(ICU
|
||||
FOUND_VAR ICU_FOUND
|
||||
REQUIRED_VARS ICU_COMPONENT_FOUND
|
||||
VERSION_VAR ICU_VERSION
|
||||
HANDLE_COMPONENTS
|
||||
)
|
@ -0,0 +1,133 @@
|
||||
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||
# file Copyright.txt or https://cmake.org/licensing for details.
|
||||
|
||||
#[=======================================================================[.rst:
|
||||
FindIconv
|
||||
---------
|
||||
|
||||
This module finds the ``iconv()`` POSIX.1 functions on the system.
|
||||
These functions might be provided in the regular C library or externally
|
||||
in the form of an additional library.
|
||||
|
||||
The following variables are provided to indicate iconv support:
|
||||
|
||||
.. variable:: Iconv_FOUND
|
||||
|
||||
Variable indicating if the iconv support was found.
|
||||
|
||||
.. variable:: Iconv_INCLUDE_DIRS
|
||||
|
||||
The directories containing the iconv headers.
|
||||
|
||||
.. variable:: Iconv_LIBRARIES
|
||||
|
||||
The iconv libraries to be linked.
|
||||
|
||||
.. variable:: Iconv_IS_BUILT_IN
|
||||
|
||||
A variable indicating whether iconv support is stemming from the
|
||||
C library or not. Even if the C library provides `iconv()`, the presence of
|
||||
an external `libiconv` implementation might lead to this being false.
|
||||
|
||||
Additionally, the following :prop_tgt:`IMPORTED` target is being provided:
|
||||
|
||||
.. variable:: Iconv::Iconv
|
||||
|
||||
Imported target for using iconv.
|
||||
|
||||
The following cache variables may also be set:
|
||||
|
||||
.. variable:: Iconv_INCLUDE_DIR
|
||||
|
||||
The directory containing the iconv headers.
|
||||
|
||||
.. variable:: Iconv_LIBRARY
|
||||
|
||||
The iconv library (if not implicitly given in the C library).
|
||||
|
||||
.. note::
|
||||
On POSIX platforms, iconv might be part of the C library and the cache
|
||||
variables ``Iconv_INCLUDE_DIR`` and ``Iconv_LIBRARY`` might be empty.
|
||||
|
||||
#]=======================================================================]
|
||||
|
||||
include(CMakePushCheckState)
|
||||
if(CMAKE_C_COMPILER_LOADED)
|
||||
include(CheckCSourceCompiles)
|
||||
elseif(CMAKE_CXX_COMPILER_LOADED)
|
||||
include(CheckCXXSourceCompiles)
|
||||
else()
|
||||
# If neither C nor CXX are loaded, implicit iconv makes no sense.
|
||||
set(Iconv_IS_BUILT_IN FALSE)
|
||||
endif()
|
||||
|
||||
# iconv can only be provided in libc on a POSIX system.
|
||||
# If any cache variable is already set, we'll skip this test.
|
||||
if(NOT DEFINED Iconv_IS_BUILT_IN)
|
||||
if(UNIX AND NOT DEFINED Iconv_INCLUDE_DIR AND NOT DEFINED Iconv_LIBRARY)
|
||||
cmake_push_check_state(RESET)
|
||||
# We always suppress the message here: Otherwise on supported systems
|
||||
# not having iconv in their C library (e.g. those using libiconv)
|
||||
# would always display a confusing "Looking for iconv - not found" message
|
||||
set(CMAKE_FIND_QUIETLY TRUE)
|
||||
# The following code will not work, but it's sufficient to see if it compiles.
|
||||
# Note: libiconv will define the iconv functions as macros, so CheckSymbolExists
|
||||
# will not yield correct results.
|
||||
set(Iconv_IMPLICIT_TEST_CODE
|
||||
"
|
||||
#include <stddef.h>
|
||||
#include <iconv.h>
|
||||
int main() {
|
||||
char *a, *b;
|
||||
size_t i, j;
|
||||
iconv_t ic;
|
||||
ic = iconv_open(\"to\", \"from\");
|
||||
iconv(ic, &a, &i, &b, &j);
|
||||
iconv_close(ic);
|
||||
}
|
||||
"
|
||||
)
|
||||
if(CMAKE_C_COMPILER_LOADED)
|
||||
check_c_source_compiles("${Iconv_IMPLICIT_TEST_CODE}" Iconv_IS_BUILT_IN)
|
||||
else()
|
||||
check_cxx_source_compiles("${Iconv_IMPLICIT_TEST_CODE}" Iconv_IS_BUILT_IN)
|
||||
endif()
|
||||
cmake_pop_check_state()
|
||||
else()
|
||||
set(Iconv_IS_BUILT_IN FALSE)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if(NOT Iconv_IS_BUILT_IN)
|
||||
find_path(Iconv_INCLUDE_DIR
|
||||
NAMES "iconv.h"
|
||||
DOC "iconv include directory")
|
||||
set(Iconv_LIBRARY_NAMES "iconv" "libiconv")
|
||||
else()
|
||||
set(Iconv_INCLUDE_DIR "" CACHE FILEPATH "iconv include directory")
|
||||
set(Iconv_LIBRARY_NAMES "c")
|
||||
endif()
|
||||
|
||||
find_library(Iconv_LIBRARY
|
||||
NAMES ${Iconv_LIBRARY_NAMES}
|
||||
DOC "iconv library (potentially the C library)")
|
||||
|
||||
mark_as_advanced(Iconv_INCLUDE_DIR)
|
||||
mark_as_advanced(Iconv_LIBRARY)
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
if(NOT Iconv_IS_BUILT_IN)
|
||||
find_package_handle_standard_args(Iconv REQUIRED_VARS Iconv_LIBRARY Iconv_INCLUDE_DIR)
|
||||
else()
|
||||
find_package_handle_standard_args(Iconv REQUIRED_VARS Iconv_LIBRARY)
|
||||
endif()
|
||||
|
||||
if(Iconv_FOUND)
|
||||
set(Iconv_INCLUDE_DIRS "${Iconv_INCLUDE_DIR}")
|
||||
set(Iconv_LIBRARIES "${Iconv_LIBRARY}")
|
||||
if(NOT TARGET Iconv::Iconv)
|
||||
add_library(Iconv::Iconv INTERFACE IMPORTED)
|
||||
endif()
|
||||
set_property(TARGET Iconv::Iconv PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${Iconv_INCLUDE_DIRS}")
|
||||
set_property(TARGET Iconv::Iconv PROPERTY INTERFACE_LINK_LIBRARIES "${Iconv_LIBRARIES}")
|
||||
endif()
|
@ -0,0 +1,89 @@
|
||||
#[=======================================================================[.rst:
|
||||
FindLZO
|
||||
-------
|
||||
|
||||
Finds the LZO library.
|
||||
|
||||
Result Variables
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
This will define the following variables:
|
||||
|
||||
``LZO_FOUND``
|
||||
True if the system has the LZO library.
|
||||
``LZO_INCLUDE_DIRS``
|
||||
Include directories needed to use LZO.
|
||||
``LZO_LIBRARIES``
|
||||
Libraries needed to link to LZO.
|
||||
``LZO_VERSION``
|
||||
The version of the LZO library which was found.
|
||||
|
||||
Cache Variables
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
The following cache variables may also be set:
|
||||
|
||||
``LZO_INCLUDE_DIR``
|
||||
The directory containing ``lzo/lzo1x.h``.
|
||||
``LZO_LIBRARY``
|
||||
The path to the LZO library.
|
||||
|
||||
#]=======================================================================]
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_check_modules(PC_LZO QUIET lzo2)
|
||||
|
||||
find_path(LZO_INCLUDE_DIR
|
||||
NAMES lzo/lzo1x.h
|
||||
PATHS ${PC_LZO_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
find_library(LZO_LIBRARY
|
||||
NAMES lzo2
|
||||
PATHS ${PC_LZO_LIBRARY_DIRS}
|
||||
)
|
||||
|
||||
# With vcpkg, the library path should contain both 'debug' and 'optimized'
|
||||
# entries (see target_link_libraries() documentation for more information)
|
||||
#
|
||||
# NOTE: we only patch up when using vcpkg; the same issue might happen
|
||||
# when not using vcpkg, but this is non-trivial to fix, as we have no idea
|
||||
# what the paths are. With vcpkg we do. And we only official support vcpkg
|
||||
# with Windows.
|
||||
#
|
||||
# NOTE: this is based on the assumption that the debug file has the same
|
||||
# name as the optimized file. This is not always the case, but so far
|
||||
# experiences has shown that in those case vcpkg CMake files do the right
|
||||
# thing.
|
||||
if (VCPKG_TOOLCHAIN AND LZO_LIBRARY)
|
||||
if (LZO_LIBRARY MATCHES "/debug/")
|
||||
set(LZO_LIBRARY_DEBUG ${LZO_LIBRARY})
|
||||
string(REPLACE "/debug/lib/" "/lib/" LZO_LIBRARY_RELEASE ${LZO_LIBRARY})
|
||||
else()
|
||||
set(LZO_LIBRARY_RELEASE ${LZO_LIBRARY})
|
||||
string(REPLACE "/lib/" "/debug/lib/" LZO_LIBRARY_DEBUG ${LZO_LIBRARY})
|
||||
endif()
|
||||
include(SelectLibraryConfigurations)
|
||||
select_library_configurations(LZO)
|
||||
endif()
|
||||
|
||||
set(LZO_VERSION ${PC_LZO_VERSION})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(LZO
|
||||
FOUND_VAR LZO_FOUND
|
||||
REQUIRED_VARS
|
||||
LZO_LIBRARY
|
||||
LZO_INCLUDE_DIR
|
||||
VERSION_VAR LZO_VERSION
|
||||
)
|
||||
|
||||
if (LZO_FOUND)
|
||||
set(LZO_LIBRARIES ${LZO_LIBRARY})
|
||||
set(LZO_INCLUDE_DIRS ${LZO_INCLUDE_DIR})
|
||||
endif ()
|
||||
|
||||
mark_as_advanced(
|
||||
LZO_INCLUDE_DIR
|
||||
LZO_LIBRARY
|
||||
)
|
@ -0,0 +1,17 @@
|
||||
# Autodetect if SSE4.1 can be used. If so, the assumption is, so can the other
|
||||
# SSE version (SSE 2.0, SSSE 3.0).
|
||||
|
||||
include(CheckCXXSourceCompiles)
|
||||
set(CMAKE_REQUIRED_FLAGS "")
|
||||
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
|
||||
set(CMAKE_REQUIRED_FLAGS "-msse4.1")
|
||||
endif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" OR CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
|
||||
|
||||
check_cxx_source_compiles("
|
||||
#include <xmmintrin.h>
|
||||
#include <smmintrin.h>
|
||||
#include <tmmintrin.h>
|
||||
int main() { return 0; }"
|
||||
SSE_FOUND
|
||||
)
|
@ -0,0 +1,65 @@
|
||||
#[=======================================================================[.rst:
|
||||
FindXDG_basedir
|
||||
-------
|
||||
|
||||
Finds the xdg-basedir library.
|
||||
|
||||
Result Variables
|
||||
^^^^^^^^^^^^^^^^
|
||||
|
||||
This will define the following variables:
|
||||
|
||||
``XDG_basedir_FOUND``
|
||||
True if the system has the xdg-basedir library.
|
||||
``XDG_basedir_INCLUDE_DIRS``
|
||||
Include directories needed to use xdg-basedir.
|
||||
``XDG_basedir_LIBRARIES``
|
||||
Libraries needed to link to xdg-basedir.
|
||||
``XDG_basedir_VERSION``
|
||||
The version of the xdg-basedir library which was found.
|
||||
|
||||
Cache Variables
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
The following cache variables may also be set:
|
||||
|
||||
``XDG_basedir_INCLUDE_DIR``
|
||||
The directory containing ``xdg-basedir.h``.
|
||||
``XDG_basedir_LIBRARY``
|
||||
The path to the xdg-basedir library.
|
||||
|
||||
#]=======================================================================]
|
||||
|
||||
find_package(PkgConfig QUIET)
|
||||
pkg_check_modules(PC_XDG_basedir QUIET libxdg-basedir)
|
||||
|
||||
find_path(XDG_basedir_INCLUDE_DIR
|
||||
NAMES basedir.h
|
||||
PATHS ${PC_XDG_basedir_INCLUDE_DIRS}
|
||||
)
|
||||
|
||||
find_library(XDG_basedir_LIBRARY
|
||||
NAMES xdg-basedir
|
||||
PATHS ${PC_XDG_basedir_LIBRARY_DIRS}
|
||||
)
|
||||
|
||||
set(XDG_basedir_VERSION ${PC_XDG_basedir_VERSION})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(XDG_basedir
|
||||
FOUND_VAR XDG_basedir_FOUND
|
||||
REQUIRED_VARS
|
||||
XDG_basedir_LIBRARY
|
||||
XDG_basedir_INCLUDE_DIR
|
||||
VERSION_VAR XDG_basedir_VERSION
|
||||
)
|
||||
|
||||
if (XDG_basedir_FOUND)
|
||||
set(XDG_basedir_LIBRARIES ${XDG_basedir_LIBRARY})
|
||||
set(XDG_basedir_INCLUDE_DIRS ${XDG_basedir_INCLUDE_DIR})
|
||||
endif ()
|
||||
|
||||
mark_as_advanced(
|
||||
XDG_basedir_INCLUDE_DIR
|
||||
XDG_basedir_LIBRARY
|
||||
)
|
@ -0,0 +1,18 @@
|
||||
# Autodetect if xaudio2 can be used.
|
||||
|
||||
include(CheckCXXSourceCompiles)
|
||||
set(CMAKE_REQUIRED_FLAGS "")
|
||||
|
||||
check_cxx_source_compiles("
|
||||
#include <windows.h>
|
||||
|
||||
#undef NTDDI_VERSION
|
||||
#undef _WIN32_WINNT
|
||||
|
||||
#define NTDDI_VERSION NTDDI_WIN8
|
||||
#define _WIN32_WINNT _WIN32_WINNT_WIN8
|
||||
|
||||
#include <xaudio2.h>
|
||||
int main() { return 0; }"
|
||||
XAUDIO2_FOUND
|
||||
)
|
@ -0,0 +1,116 @@
|
||||
include(GNUInstallDirs)
|
||||
|
||||
# If requested, use FHS layout; otherwise fall back to a flat layout.
|
||||
if (OPTION_INSTALL_FHS)
|
||||
set(BINARY_DESTINATION_DIR "${CMAKE_INSTALL_BINDIR}")
|
||||
set(DATA_DESTINATION_DIR "${CMAKE_INSTALL_DATADIR}/openttd")
|
||||
set(DOCS_DESTINATION_DIR "${CMAKE_INSTALL_DOCDIR}")
|
||||
set(MAN_DESTINATION_DIR "${CMAKE_INSTALL_MANDIR}")
|
||||
else (OPTION_INSTALL_FHS)
|
||||
set(BINARY_DESTINATION_DIR ".")
|
||||
set(DATA_DESTINATION_DIR ".")
|
||||
set(DOCS_DESTINATION_DIR ".")
|
||||
set(MAN_DESTINATION_DIR ".")
|
||||
endif (OPTION_INSTALL_FHS)
|
||||
|
||||
install(TARGETS openttd
|
||||
RUNTIME
|
||||
DESTINATION ${BINARY_DESTINATION_DIR}
|
||||
COMPONENT Runtime
|
||||
)
|
||||
|
||||
install(DIRECTORY
|
||||
${CMAKE_BINARY_DIR}/lang
|
||||
${CMAKE_BINARY_DIR}/baseset
|
||||
${CMAKE_SOURCE_DIR}/bin/ai
|
||||
${CMAKE_SOURCE_DIR}/bin/game
|
||||
${CMAKE_SOURCE_DIR}/bin/scripts
|
||||
${CMAKE_SOURCE_DIR}/bin/data
|
||||
DESTINATION ${DATA_DESTINATION_DIR}
|
||||
COMPONENT language_files)
|
||||
|
||||
install(FILES
|
||||
${CMAKE_SOURCE_DIR}/COPYING.md
|
||||
${CMAKE_SOURCE_DIR}/README.md
|
||||
${CMAKE_SOURCE_DIR}/changelog.txt
|
||||
${CMAKE_SOURCE_DIR}/docs/multiplayer.md
|
||||
${CMAKE_SOURCE_DIR}/known-bugs.txt
|
||||
${CMAKE_SOURCE_DIR}/jgrpp-changelog.md
|
||||
DESTINATION ${DOCS_DESTINATION_DIR}
|
||||
COMPONENT docs)
|
||||
|
||||
# A Linux manual only makes sense when using FHS. Otherwise it is a very odd
|
||||
# file with little context to what it is.
|
||||
if (OPTION_INSTALL_FHS)
|
||||
install(FILES
|
||||
${CMAKE_SOURCE_DIR}/docs/openttd.6
|
||||
DESTINATION ${MAN_DESTINATION_DIR}/man6
|
||||
COMPONENT manual)
|
||||
endif (OPTION_INSTALL_FHS)
|
||||
|
||||
# TODO -- Media files
|
||||
# TODO -- Menu files
|
||||
|
||||
if (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
|
||||
set(ARCHITECTURE "amd64")
|
||||
else (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
|
||||
string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" ARCHITECTURE)
|
||||
endif (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
|
||||
|
||||
# Windows is a bit more annoying to detect; using the size of void pointer
|
||||
# seems to be the most robust.
|
||||
if (WIN32)
|
||||
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(ARCHITECTURE "win64")
|
||||
else (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
set(ARCHITECTURE "win32")
|
||||
endif (CMAKE_SIZEOF_VOID_P EQUAL 8)
|
||||
endif (WIN32)
|
||||
|
||||
set(CPACK_SYSTEM_NAME "${ARCHITECTURE}")
|
||||
|
||||
set(CPACK_PACKAGE_NAME "openttd")
|
||||
set(CPACK_PACKAGE_VENDOR "OpenTTD")
|
||||
set(CPACK_PACKAGE_DESCRIPTION "OpenTTD")
|
||||
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "OpenTTD")
|
||||
set(CPACK_PACKAGE_HOMEPAGE_URL "https://www.openttd.org/")
|
||||
set(CPACK_PACKAGE_CONTACT "OpenTTD <info@openttd.org>")
|
||||
set(CPACK_PACKAGE_INSTALL_DIRECTORY "OpenTTD")
|
||||
set(CPACK_PACKAGE_CHECKSUM "SHA256")
|
||||
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING.md")
|
||||
set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README.md")
|
||||
set(CPACK_MONOLITHIC_INSTALL YES)
|
||||
set(CPACK_PACKAGE_EXECUTABLES "openttd;OpenTTD")
|
||||
set(CPACK_STRIP_FILES YES)
|
||||
set(CPACK_OUTPUT_FILE_PREFIX "bundles")
|
||||
|
||||
if (APPLE)
|
||||
set(CPACK_GENERATOR "Bundle")
|
||||
include(PackageBundle)
|
||||
|
||||
set(CPACK_PACKAGE_FILE_NAME "openttd-#CPACK_PACKAGE_VERSION#-macosx")
|
||||
elseif (WIN32)
|
||||
set(CPACK_GENERATOR "ZIP")
|
||||
if (OPTION_USE_NSIS)
|
||||
list(APPEND CPACK_GENERATOR "NSIS")
|
||||
include(PackageNSIS)
|
||||
endif (OPTION_USE_NSIS)
|
||||
|
||||
set(CPACK_PACKAGE_FILE_NAME "openttd-#CPACK_PACKAGE_VERSION#-windows-${CPACK_SYSTEM_NAME}")
|
||||
elseif (UNIX)
|
||||
# With FHS, we can create deb/rpm/... Without it, they would be horribly broken
|
||||
# and not work. The other way around is also true; with FHS they are not
|
||||
# usable, and only flat formats work.
|
||||
if (OPTION_INSTALL_FHS)
|
||||
set(CPACK_GENERATOR "DEB")
|
||||
include(PackageDeb)
|
||||
else (OPTION_INSTALL_FHS)
|
||||
set(CPACK_GENERATOR "TXZ")
|
||||
endif (OPTION_INSTALL_FHS)
|
||||
|
||||
set(CPACK_PACKAGE_FILE_NAME "openttd-#CPACK_PACKAGE_VERSION#-linux-${CPACK_SYSTEM_NAME}")
|
||||
else ()
|
||||
message(FATAL_ERROR "Unknown OS found for packaging; please consider creating a Pull Request to add support for this OS.")
|
||||
endif ()
|
||||
|
||||
include(CPack)
|
@ -0,0 +1,18 @@
|
||||
function(link_package NAME)
|
||||
cmake_parse_arguments(LP "ENCOURAGED" "TARGET" "" ${ARGN})
|
||||
|
||||
if (${NAME}_FOUND)
|
||||
string(TOUPPER "${NAME}" UCNAME)
|
||||
add_definitions(-DWITH_${UCNAME})
|
||||
if (LP_TARGET AND TARGET ${LP_TARGET})
|
||||
target_link_libraries(openttd ${LP_TARGET})
|
||||
message(STATUS "${NAME} found -- -DWITH_${UCNAME} -- ${LP_TARGET}")
|
||||
else()
|
||||
include_directories(${${NAME}_INCLUDE_DIRS} ${${NAME}_INCLUDE_DIR})
|
||||
target_link_libraries(openttd ${${NAME}_LIBRARIES} ${${NAME}_LIBRARY})
|
||||
message(STATUS "${NAME} found -- -DWITH_${UCNAME} -- ${${NAME}_INCLUDE_DIRS} ${${NAME}_INCLUDE_DIR} -- ${${NAME}_LIBRARIES} ${${NAME}_LIBRARY}")
|
||||
endif()
|
||||
elseif (LP_ENCOURAGED)
|
||||
message(WARNING "${NAME} not found; compiling OpenTTD without ${NAME} is strongly disencouraged")
|
||||
endif()
|
||||
endfunction()
|
@ -0,0 +1,88 @@
|
||||
include(GNUInstallDirs)
|
||||
|
||||
# Set the options for the directories (personal, shared, global).
|
||||
#
|
||||
# set_directory_options()
|
||||
#
|
||||
function(set_directory_options)
|
||||
if (APPLE)
|
||||
set(DEFAULT_PERSONAL_DIR "Documents/OpenTTD")
|
||||
set(DEFAULT_SHARED_DIR "/Library/Application Support/OpenTTD")
|
||||
set(DEFAULT_GLOBAL_DIR "(not set)")
|
||||
elseif (WIN32)
|
||||
set(DEFAULT_PERSONAL_DIR "OpenTTD")
|
||||
set(DEFAULT_SHARED_DIR "(not set)")
|
||||
set(DEFAULT_GLOBAL_DIR "(not set)")
|
||||
elseif (UNIX)
|
||||
set(DEFAULT_PERSONAL_DIR ".openttd")
|
||||
set(DEFAULT_SHARED_DIR "(not set)")
|
||||
set(DEFAULT_GLOBAL_DIR "${CMAKE_INSTALL_FULL_DATADIR}/openttd")
|
||||
else ()
|
||||
message(FATAL_ERROR "Unknown OS found; please consider creating a Pull Request to add support for this OS.")
|
||||
endif ()
|
||||
|
||||
if (NOT PERSONAL_DIR)
|
||||
set(PERSONAL_DIR "${DEFAULT_PERSONAL_DIR}" CACHE STRING "Personal directory")
|
||||
message(STATUS "Detecting Personal Data directory - ${PERSONAL_DIR}")
|
||||
endif (NOT PERSONAL_DIR)
|
||||
|
||||
if (NOT SHARED_DIR)
|
||||
set(SHARED_DIR "${DEFAULT_SHARED_DIR}" CACHE STRING "Shared directory")
|
||||
message(STATUS "Detecting Shared Data directory - ${SHARED_DIR}")
|
||||
endif (NOT SHARED_DIR)
|
||||
|
||||
if (NOT GLOBAL_DIR)
|
||||
set(GLOBAL_DIR "${DEFAULT_GLOBAL_DIR}" CACHE STRING "Global directory")
|
||||
message(STATUS "Detecting Global Data directory - ${GLOBAL_DIR}")
|
||||
endif (NOT GLOBAL_DIR)
|
||||
endfunction()
|
||||
|
||||
# Set some generic options that influence what is being build.
|
||||
#
|
||||
# set_options()
|
||||
#
|
||||
function(set_options)
|
||||
if (UNIX AND NOT APPLE)
|
||||
set(DEFAULT_OPTION_INSTALL_FHS ON)
|
||||
else (UNIX AND NOT APPLE)
|
||||
set(DEFAULT_OPTION_INSTALL_FHS OFF)
|
||||
endif (UNIX AND NOT APPLE)
|
||||
|
||||
option(OPTION_DEDICATED "Build dedicated server only (no GUI)" OFF)
|
||||
option(OPTION_INSTALL_FHS "Install with Filesstem Hierarchy Standard folders" ${DEFAULT_OPTION_INSTALL_FHS})
|
||||
option(OPTION_USE_ASSERTS "Use assertions; leave enabled for nightlies, betas, and RCs" ON)
|
||||
option(OPTION_USE_THREADS "Use threads" ON)
|
||||
option(OPTION_USE_NSIS "Use NSIS to create windows installer; enable only for stable releases" OFF)
|
||||
endfunction()
|
||||
|
||||
# Show the values of the generic options.
|
||||
#
|
||||
# show_options()
|
||||
#
|
||||
function(show_options)
|
||||
message(STATUS "Option Dedicated - ${OPTION_DEDICATED}")
|
||||
message(STATUS "Option Install FHS - ${OPTION_INSTALL_FHS}")
|
||||
message(STATUS "Option Use assert - ${OPTION_USE_ASSERTS}")
|
||||
message(STATUS "Option Use threads - ${OPTION_USE_THREADS}")
|
||||
message(STATUS "Option Use NSIS - ${OPTION_USE_NSIS}")
|
||||
endfunction()
|
||||
|
||||
# Add the definitions for the options that are selected.
|
||||
#
|
||||
# add_definitions_based_on_options()
|
||||
#
|
||||
function(add_definitions_based_on_options)
|
||||
if (OPTION_DEDICATED)
|
||||
add_definitions(-DDEDICATED)
|
||||
endif (OPTION_DEDICATED)
|
||||
|
||||
if (NOT OPTION_USE_THREADS)
|
||||
add_definitions(-DNO_THREADS)
|
||||
endif (NOT OPTION_USE_THREADS)
|
||||
|
||||
if (OPTION_USE_ASSERTS)
|
||||
add_definitions(-DWITH_ASSERT)
|
||||
else (OPTION_USE_ASSERTS)
|
||||
add_definitions(-DNDEBUG)
|
||||
endif (OPTION_USE_ASSERTS)
|
||||
endfunction()
|
@ -0,0 +1,25 @@
|
||||
string(TIMESTAMP CURRENT_YEAR "%Y")
|
||||
|
||||
set(CPACK_BUNDLE_NAME "OpenTTD")
|
||||
set(CPACK_BUNDLE_ICON "${CMAKE_SOURCE_DIR}/os/macosx/openttd.icns")
|
||||
set(CPACK_BUNDLE_PLIST "${CMAKE_CURRENT_BINARY_DIR}/Info.plist")
|
||||
set(CPACK_BUNDLE_STARTUP_COMMAND "${CMAKE_SOURCE_DIR}/os/macosx/launch.sh")
|
||||
set(CPACK_DMG_BACKGROUND_IMAGE "${CMAKE_SOURCE_DIR}/os/macosx/splash.png")
|
||||
|
||||
# Create a temporary Info.plist.in, where we will fill in the version via
|
||||
# CPackProperties.cmake.in. This because at this point in time the version
|
||||
# is not yet known.
|
||||
configure_file("${CMAKE_SOURCE_DIR}/os/macosx/Info.plist.in" "${CMAKE_CURRENT_BINARY_DIR}/Info.plist.in")
|
||||
set(CPACK_BUNDLE_PLIST_SOURCE "${CMAKE_CURRENT_BINARY_DIR}/Info.plist.in")
|
||||
|
||||
# Delay fixup_bundle() till the install step; this makes sure all executables
|
||||
# exists and it can do its job.
|
||||
install(
|
||||
CODE
|
||||
"
|
||||
include(BundleUtilities)
|
||||
set(BU_CHMOD_BUNDLE_ITEMS TRUE)
|
||||
fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/openttd\" \"\" \"\")
|
||||
"
|
||||
DESTINATION .
|
||||
COMPONENT Runtime)
|
@ -0,0 +1,4 @@
|
||||
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "${ARCHITECTURE}")
|
||||
set(CPACK_DEBIAN_PACKAGE_SECTION "games")
|
||||
# TODO -- Fix depends
|
||||
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.15)")
|
@ -0,0 +1,39 @@
|
||||
set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON)
|
||||
set(CPACK_NSIS_HELP_LINK "${CPACK_PACKAGE_HOMEPAGE_URL}")
|
||||
set(CPACK_NSIS_URL_INFO_ABOUT "${CPACK_PACKAGE_HOMEPAGE_URL}")
|
||||
set(CPACK_NSIS_CONTACT "${CPACK_PACKAGE_CONTACT}")
|
||||
|
||||
# NSIS uses this for the icon in the top left of the installer
|
||||
set(CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/os/windows\\\\nsis-top.bmp")
|
||||
|
||||
# Set other icons and bitmaps for NSIS
|
||||
set(CPACK_NSIS_MUI_ICON "${CMAKE_SOURCE_DIR}/os/windows\\\\openttd.ico")
|
||||
set(CPACK_NSIS_MUI_UNIICON "${CMAKE_SOURCE_DIR}/os/windows\\\\openttd.ico")
|
||||
set(CPACK_NSIS_MUI_WELCOMEFINISHPAGE_BITMAP "${CMAKE_SOURCE_DIR}/os/windows\\\\nsis-welcome.bmp")
|
||||
set(CPACK_NSIS_MUI_UNWELCOMEFINISHPAGE_BITMAP "${CMAKE_SOURCE_DIR}/os/windows\\\\nsis-welcome.bmp")
|
||||
|
||||
# Use the icon of the application
|
||||
set(CPACK_NSIS_INSTALLED_ICON_NAME "openttd.exe")
|
||||
# Tell NSIS the binary will be in the root
|
||||
set(CPACK_NSIS_EXECUTABLES_DIRECTORY ".")
|
||||
|
||||
# Add detail information on the NSIS installer executable. CPack doesn't
|
||||
# support this out of the box, so we use CPACK_NSIS_DEFINES for this.
|
||||
|
||||
# \\\ are needed, because this value is generated in another CPack file,
|
||||
# which is used. So one \ is to escape here, the second to escape in the
|
||||
# CPack file, which we have to escape here (hence: 3 \).
|
||||
set(CPACK_NSIS_DEFINES "
|
||||
; Version Info
|
||||
Var AddWinPrePopulate
|
||||
VIProductVersion \\\"0.0.0.0\\\"
|
||||
VIAddVersionKey \\\"ProductName\\\" \\\"OpenTTD Installer for Windows\\\"
|
||||
VIAddVersionKey \\\"Comments\\\" \\\"Installs OpenTTD \\\${VERSION}\\\"
|
||||
VIAddVersionKey \\\"CompanyName\\\" \\\"OpenTTD Developers\\\"
|
||||
VIAddVersionKey \\\"FileDescription\\\" \\\"Installs OpenTTD \\\${VERSION}\\\"
|
||||
VIAddVersionKey \\\"ProductVersion\\\" \\\"\\\${VERSION}\\\"
|
||||
VIAddVersionKey \\\"InternalName\\\" \\\"InstOpenTTD\\\"
|
||||
VIAddVersionKey \\\"FileVersion\\\" \\\"0.0.0.0\\\"
|
||||
VIAddVersionKey \\\"LegalCopyright\\\" \\\" \\\"
|
||||
"
|
||||
)
|
@ -0,0 +1,63 @@
|
||||
# Add a file to be compiled.
|
||||
#
|
||||
# add_files([file1 ...] CONDITION condition [condition ...])
|
||||
#
|
||||
# CONDITION is a complete statement that can be evaluated with if().
|
||||
# If it evaluates true, the source files will be added; otherwise not.
|
||||
# For example: ADD_IF SDL_FOUND AND Allegro_FOUND
|
||||
#
|
||||
function(add_files)
|
||||
cmake_parse_arguments(PARAM "" "" "CONDITION" ${ARGN})
|
||||
set(PARAM_FILES "${PARAM_UNPARSED_ARGUMENTS}")
|
||||
|
||||
if (PARAM_CONDITION)
|
||||
if (NOT (${PARAM_CONDITION}))
|
||||
return()
|
||||
endif (NOT (${PARAM_CONDITION}))
|
||||
endif (PARAM_CONDITION)
|
||||
|
||||
foreach(FILE IN LISTS PARAM_FILES)
|
||||
target_sources(openttd PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/${FILE})
|
||||
endforeach()
|
||||
endfunction(add_files)
|
||||
|
||||
# This function works around an 'issue' with CMake, where
|
||||
# set_source_files_properties() only works in the scope of the file. We want
|
||||
# to set properties for the source file on a more global level. To solve this,
|
||||
# this function records the flags you want, and a macro adds them in the root
|
||||
# CMakeLists.txt.
|
||||
# See this URL for more information on the issue:
|
||||
# http://cmake.3232098.n2.nabble.com/scope-of-set-source-files-properties-td4766111.html
|
||||
#
|
||||
# set_compile_flags([file1 ...] COMPILE_FLAGS cflag [cflag ...])
|
||||
#
|
||||
function(set_compile_flags)
|
||||
cmake_parse_arguments(PARAM "" "" "COMPILE_FLAGS" ${ARGN})
|
||||
set(PARAM_FILES "${PARAM_UNPARSED_ARGUMENTS}")
|
||||
|
||||
get_property(SOURCE_PROPERTIES GLOBAL PROPERTY source_properties)
|
||||
|
||||
foreach(FILE IN LISTS PARAM_FILES)
|
||||
list(APPEND SOURCE_PROPERTIES "${CMAKE_CURRENT_SOURCE_DIR}/${FILE}::${PARAM_COMPILE_FLAGS}")
|
||||
endforeach()
|
||||
|
||||
set_property(GLOBAL PROPERTY source_properties "${SOURCE_PROPERTIES}")
|
||||
endfunction(set_compile_flags)
|
||||
|
||||
# Call this macro in the same CMakeLists.txt and after add_executable().
|
||||
# This makes sure all the COMPILE_FLAGS of set_compile_flags() are set
|
||||
# correctly.
|
||||
#
|
||||
# process_compile_flags()
|
||||
#
|
||||
function(process_compile_flags)
|
||||
get_property(SOURCE_PROPERTIES GLOBAL PROPERTY source_properties)
|
||||
|
||||
foreach(ENTRY ${SOURCE_PROPERTIES})
|
||||
string(REPLACE "::" ";" ENTRY "${ENTRY}")
|
||||
list(GET ENTRY 0 FILE)
|
||||
list(GET ENTRY 1 PROPERTIES)
|
||||
|
||||
set_source_files_properties(${FILE} PROPERTIES COMPILE_FLAGS ${PROPERTIES})
|
||||
endforeach()
|
||||
endfunction(process_compile_flags)
|
@ -0,0 +1,14 @@
|
||||
# Set static linking if the platform requires it.
|
||||
#
|
||||
# set_static()
|
||||
#
|
||||
function(set_static_if_needed)
|
||||
if (MINGW)
|
||||
# Let exectutables run outside MinGW environment
|
||||
# Force searching static libs
|
||||
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a" PARENT_SCOPE)
|
||||
|
||||
# Force static linking
|
||||
link_libraries(-static -static-libgcc -static-libstdc++)
|
||||
endif()
|
||||
endfunction()
|
@ -0,0 +1,53 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
#
|
||||
# Create a single baseset meta file with the correct translations.
|
||||
#
|
||||
|
||||
set(ARGC 1)
|
||||
set(ARG_READ NO)
|
||||
|
||||
# Read all the arguments given to CMake; we are looking for -- and everything
|
||||
# that follows. Those are our language files.
|
||||
while(ARGC LESS CMAKE_ARGC)
|
||||
set(ARG ${CMAKE_ARGV${ARGC}})
|
||||
|
||||
if (ARG_READ)
|
||||
list(APPEND LANG_SOURCE_FILES "${ARG}")
|
||||
endif (ARG_READ)
|
||||
|
||||
if (ARG STREQUAL "--")
|
||||
set(ARG_READ YES)
|
||||
endif (ARG STREQUAL "--")
|
||||
|
||||
math(EXPR ARGC "${ARGC} + 1")
|
||||
endwhile()
|
||||
|
||||
# Place holder format is @<ini_key>_<str_id>@
|
||||
file(STRINGS "${BASESET_SOURCE_FILE}" PLACE_HOLDER REGEX "^@")
|
||||
string(REGEX REPLACE "@([^_]+).*@" "\\1" INI_KEY "${PLACE_HOLDER}")
|
||||
string(REGEX REPLACE "@[^_]+_(.*)@" "\\1" STR_ID "${PLACE_HOLDER}")
|
||||
string(REGEX REPLACE "@(.*)@" "\\1" PLACE_HOLDER "${PLACE_HOLDER}")
|
||||
|
||||
# Get the translations
|
||||
foreach(LANGFILE IN LISTS LANG_SOURCE_FILES)
|
||||
file(STRINGS "${LANGFILE}" LANGLINES REGEX "^(##isocode|${STR_ID})" ENCODING UTF-8)
|
||||
string(FIND "${LANGLINES}" "${STR_ID}" HAS_STR_ID)
|
||||
if (HAS_STR_ID LESS 0)
|
||||
continue()
|
||||
endif (HAS_STR_ID LESS 0)
|
||||
string(REGEX REPLACE "##isocode ([^;]+).*" "\\1" ISOCODE "${LANGLINES}")
|
||||
if ("${ISOCODE}" STREQUAL "en_GB")
|
||||
string(REGEX REPLACE "[^:]*:(.*)" "${INI_KEY} = \\1" LANGLINES "${LANGLINES}")
|
||||
else()
|
||||
string(REGEX REPLACE "[^:]*:(.*)" "${INI_KEY}.${ISOCODE} = \\1" LANGLINES "${LANGLINES}")
|
||||
endif()
|
||||
list(APPEND ${PLACE_HOLDER} ${LANGLINES})
|
||||
endforeach(LANGFILE)
|
||||
list(SORT ${PLACE_HOLDER})
|
||||
string(REPLACE ";" "\n" ${PLACE_HOLDER} "${${PLACE_HOLDER}}")
|
||||
|
||||
# Get the grf md5
|
||||
file(MD5 ${BASESET_EXTRAGRF_FILE} ORIG_EXTRA_GRF_MD5)
|
||||
|
||||
configure_file(${BASESET_SOURCE_FILE} ${BASESET_BINARY_FILE})
|
@ -0,0 +1,44 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
#
|
||||
# Create a single GRF file based on sprites/<grfname>.nfo and sprites/*.png
|
||||
# files.
|
||||
#
|
||||
|
||||
if (NOT NFORENUM_EXECUTABLE)
|
||||
message(FATAL_ERROR "Script needs NFORENUM_EXECUTABLE defined")
|
||||
endif (NOT NFORENUM_EXECUTABLE)
|
||||
if (NOT GRFCODEC_EXECUTABLE)
|
||||
message(FATAL_ERROR "Script needs GRFCODEC_EXECUTABLE defined")
|
||||
endif (NOT GRFCODEC_EXECUTABLE)
|
||||
if (NOT GRF_SOURCE_FOLDER)
|
||||
message(FATAL_ERROR "Script needs GRF_SOURCE_FOLDER defined")
|
||||
endif (NOT GRF_SOURCE_FOLDER)
|
||||
if (NOT GRF_BINARY_FILE)
|
||||
message(FATAL_ERROR "Script needs GRF_BINARY_FILE defined")
|
||||
endif (NOT GRF_BINARY_FILE)
|
||||
|
||||
get_filename_component(GRF_SOURCE_FOLDER_NAME "${GRF_SOURCE_FOLDER}" NAME)
|
||||
|
||||
file(WRITE sprites/${GRF_SOURCE_FOLDER_NAME}.nfo "")
|
||||
file(READ ${GRF_SOURCE_FOLDER}/${GRF_SOURCE_FOLDER_NAME}.nfo NFO_LINES)
|
||||
# Replace ; with \;, and make a list out of this based on \n
|
||||
string(REPLACE ";" "\\;" NFO_LINES "${NFO_LINES}")
|
||||
string(REPLACE "\n" ";" NFO_LINES "${NFO_LINES}")
|
||||
|
||||
foreach(NFO_LINE IN LISTS NFO_LINES)
|
||||
# Recover the ; that was really in the text (and not a newline)
|
||||
string(REPLACE "\\;" ";" NFO_LINE "${NFO_LINE}")
|
||||
|
||||
if (NFO_LINE MATCHES "^#include")
|
||||
string(REGEX REPLACE "^#include \"(.*)\"$" "\\1" INCLUDE_FILE ${NFO_LINE})
|
||||
file(READ ${GRF_SOURCE_FOLDER}/${INCLUDE_FILE} INCLUDE_LINES)
|
||||
file(APPEND sprites/${GRF_SOURCE_FOLDER_NAME}.nfo "${INCLUDE_LINES}")
|
||||
else (NFO_LINE MATCHES "^#include")
|
||||
file(APPEND sprites/${GRF_SOURCE_FOLDER_NAME}.nfo "${NFO_LINE}\n")
|
||||
endif (NFO_LINE MATCHES "^#include")
|
||||
endforeach(NFO_LINE)
|
||||
|
||||
execute_process(COMMAND ${NFORENUM_EXECUTABLE} -s sprites/${GRF_SOURCE_FOLDER_NAME}.nfo)
|
||||
execute_process(COMMAND ${GRFCODEC_EXECUTABLE} -n -s -e -p1 ${GRF_SOURCE_FOLDER_NAME}.grf)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${GRF_SOURCE_FOLDER_NAME}.grf ${GRF_BINARY_FILE})
|
@ -0,0 +1,140 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
#
|
||||
# Finds the current version of the current folder.
|
||||
#
|
||||
|
||||
find_package(Git QUIET)
|
||||
# ${CMAKE_SOURCE_DIR}/.git may be a directory or a regular file
|
||||
if (GIT_FOUND AND EXISTS "${CMAKE_SOURCE_DIR}/.git")
|
||||
# Make sure LC_ALL is set to something desirable
|
||||
set(SAVED_LC_ALL "$ENV{LC_ALL}")
|
||||
set(ENV{LC_ALL} C)
|
||||
|
||||
# Assume the dir is not modified
|
||||
set(REV_MODIFIED 0)
|
||||
|
||||
# Refresh the index to make sure file stat info is in sync, then look for modifications
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} update-index --refresh
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
OUTPUT_QUIET
|
||||
)
|
||||
|
||||
# See if git tree is modified
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} diff-index HEAD
|
||||
OUTPUT_VARIABLE IS_MODIFIED
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
)
|
||||
if (NOT IS_MODIFIED STREQUAL "")
|
||||
set(REV_MODIFIED 2)
|
||||
endif()
|
||||
|
||||
# Get last commit hash
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --verify HEAD
|
||||
OUTPUT_VARIABLE FULLHASH
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
ERROR_QUIET
|
||||
)
|
||||
set(REV_HASH "${FULLHASH}")
|
||||
|
||||
string(SUBSTRING "${FULLHASH}" 0 10 SHORTHASH)
|
||||
|
||||
# Get the last commit date
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} show -s --pretty=format:%ci HEAD
|
||||
OUTPUT_VARIABLE COMMITDATE
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
)
|
||||
string(REGEX REPLACE "([0-9]+)-([0-9]+)-([0-9]+).*" "\\1\\2\\3" COMMITDATE "${COMMITDATE}")
|
||||
set(REV_ISODATE "${COMMITDATE}")
|
||||
string(SUBSTRING "${REV_ISODATE}" 0 4 REV_YEAR)
|
||||
|
||||
# Get the branch
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} symbolic-ref -q HEAD
|
||||
OUTPUT_VARIABLE BRANCH
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
ERROR_QUIET
|
||||
)
|
||||
string(REGEX REPLACE ".*/" "" BRANCH "${BRANCH}")
|
||||
|
||||
# Get the tag
|
||||
execute_process(COMMAND ${GIT_EXECUTABLE} describe --tags
|
||||
OUTPUT_VARIABLE TAG
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||
ERROR_QUIET
|
||||
)
|
||||
string(REGEX REPLACE "\^0$" "" TAG "${TAG}")
|
||||
|
||||
if (REV_MODIFIED EQUAL 0)
|
||||
set(HASHPREFIX "-g")
|
||||
elseif (REV_MODIFIED EQUAL 2)
|
||||
set(HASHPREFIX "-m")
|
||||
else ()
|
||||
set(HASHPREFIX "-u")
|
||||
endif()
|
||||
|
||||
# Set the version string
|
||||
if (NOT TAG STREQUAL "")
|
||||
set(REV_VERSION "${TAG}")
|
||||
set(REV_ISTAG 1)
|
||||
|
||||
string(REGEX REPLACE "^[0-9.]*$" "" STABLETAG "${TAG}")
|
||||
if (NOT STABLETAG STREQUAL "")
|
||||
set(REV_ISSTABLETAG 1)
|
||||
else ()
|
||||
set(REV_ISSTABLETAG 0)
|
||||
endif ()
|
||||
else ()
|
||||
set(REV_VERSION "${REV_ISODATE}-${BRANCH}${HASHPREFIX}${SHORTHASH}")
|
||||
set(REV_ISTAG 0)
|
||||
set(REV_ISSTABLETAG 0)
|
||||
endif ()
|
||||
|
||||
# Restore LC_ALL
|
||||
set(ENV{LC_ALL} "${SAVED_LC_ALL}")
|
||||
elseif (EXISTS "${CMAKE_SOURCE_DIR}/.ottdrev")
|
||||
file(READ "${CMAKE_SOURCE_DIR}/.ottdrev" OTTDREV)
|
||||
string(REPLACE "\n" "" OTTDREV "${OTTDREV}")
|
||||
string(REPLACE "\t" ";" OTTDREV "${OTTDREV}")
|
||||
list(GET OTTDREV 0 REV_VERSION)
|
||||
list(GET OTTDREV 1 REV_ISODATE)
|
||||
list(GET OTTDREV 2 REV_MODIFIED)
|
||||
list(GET OTTDREV 3 REV_HASH)
|
||||
list(GET OTTDREV 4 REV_ISTAG)
|
||||
list(GET OTTDREV 5 REV_ISSTABLETAG)
|
||||
list(GET OTTDREV 6 REV_YEAR)
|
||||
else ()
|
||||
message(WARNING "No version detected; this build will NOT be network compatible")
|
||||
set(REV_VERSION "norev0000")
|
||||
set(REV_ISODATE "19700101")
|
||||
set(REV_MODIFIED 1)
|
||||
set(REV_HASH "unknown")
|
||||
set(REV_ISTAG 0)
|
||||
set(REV_ISSTABLETAG 0)
|
||||
set(REV_YEAR "1970")
|
||||
endif ()
|
||||
|
||||
message(STATUS "Version string: ${REV_VERSION}")
|
||||
|
||||
if (GENERATE_OTTDREV)
|
||||
message(STATUS "Generating .ottdrev")
|
||||
file(WRITE ${CMAKE_SOURCE_DIR}/.ottdrev "${REV_VERSION}\t${REV_ISODATE}\t${REV_MODIFIED}\t${REV_HASH}\t${REV_ISTAG}\t${REV_ISSTABLETAG}\t${REV_YEAR}\n")
|
||||
else (GENERATE_OTTDREV)
|
||||
message(STATUS "Generating rev.cpp")
|
||||
configure_file("${CMAKE_SOURCE_DIR}/src/rev.cpp.in"
|
||||
"${FIND_VERSION_BINARY_DIR}/rev.cpp")
|
||||
|
||||
if (WIN32)
|
||||
message(STATUS "Generating ottdres.rc")
|
||||
configure_file("${CMAKE_SOURCE_DIR}/src/os/windows/ottdres.rc.in"
|
||||
"${FIND_VERSION_BINARY_DIR}/ottdres.rc")
|
||||
endif (WIN32)
|
||||
|
||||
message(STATUS "Generating CPackProperties.cmake")
|
||||
configure_file("${CMAKE_SOURCE_DIR}/CPackProperties.cmake.in"
|
||||
"${CPACK_BINARY_DIR}/CPackProperties.cmake" @ONLY)
|
||||
endif (GENERATE_OTTDREV)
|
@ -0,0 +1,97 @@
|
||||
cmake_minimum_required(VERSION 3.5)
|
||||
|
||||
#
|
||||
# Runs a single regressoion test
|
||||
#
|
||||
|
||||
if (NOT REGRESSION_TEST)
|
||||
message(FATAL_ERROR "Script needs REGRESSION_TEST defined (tip: use -DREGRESSION_TEST=..)")
|
||||
endif (NOT REGRESSION_TEST)
|
||||
if (NOT OPENTTD_EXECUTABLE)
|
||||
message(FATAL_ERROR "Script needs OPENTTD_EXECUTABLE defined (tip: use -DOPENTTD_EXECUTABLE=..)")
|
||||
endif (NOT OPENTTD_EXECUTABLE)
|
||||
|
||||
if (NOT EXISTS ai/${REGRESSION_TEST}/test.sav)
|
||||
message(FATAL_ERROR "Regression test ${REGRESSION_TEST} does not exist (tip: check regression folder for the correct spelling)")
|
||||
endif ()
|
||||
|
||||
# If editbin is given, copy the executable to a new folder, and change the
|
||||
# subsystem to console. The copy is needed as multiple regressions can run
|
||||
# at the same time.
|
||||
if (EDITBIN_EXECUTABLE)
|
||||
execute_process(COMMAND ${CMAKE_COMMAND} -E copy ${OPENTTD_EXECUTABLE} regression/${REGRESSION_TEST}.exe)
|
||||
set(OPENTTD_EXECUTABLE "regression/${REGRESSION_TEST}.exe")
|
||||
|
||||
execute_process(COMMAND ${EDITBIN_EXECUTABLE} /nologo /subsystem:console ${OPENTTD_EXECUTABLE})
|
||||
endif (EDITBIN_EXECUTABLE)
|
||||
|
||||
# Run the regression test
|
||||
execute_process(COMMAND ${OPENTTD_EXECUTABLE}
|
||||
-x
|
||||
-c regression/regression.cfg
|
||||
-g ai/${REGRESSION_TEST}/test.sav
|
||||
-snull
|
||||
-mnull
|
||||
-vnull:ticks=30000
|
||||
-d script=2
|
||||
-d misc=9
|
||||
OUTPUT_VARIABLE REGRESSION_OUTPUT
|
||||
ERROR_VARIABLE REGRESSION_RESULT
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
ERROR_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
|
||||
if (REGRESSION_OUTPUT)
|
||||
message(FATAL_ERROR "Unexpected output: ${REGRESSION_OUTPUT}")
|
||||
endif (REGRESSION_OUTPUT)
|
||||
|
||||
if (NOT REGRESSION_RESULT)
|
||||
message(FATAL_ERROR "Regression did not output anything; did the compilation fail?")
|
||||
endif (NOT REGRESSION_RESULT)
|
||||
|
||||
# For some reason pointer can be printed as '0x(nil)', '0x0000000000000000', or '0x0x0'
|
||||
string(REPLACE "0x(nil)" "0x00000000" REGRESSION_RESULT "${REGRESSION_RESULT}")
|
||||
string(REPLACE "0x0000000000000000" "0x00000000" REGRESSION_RESULT "${REGRESSION_RESULT}")
|
||||
string(REPLACE "0x0x0" "0x00000000" REGRESSION_RESULT "${REGRESSION_RESULT}")
|
||||
|
||||
# Convert the output to a format that is expected (and more readable) by result.txt
|
||||
string(REPLACE "\ndbg: [script]" "\n" REGRESSION_RESULT "${REGRESSION_RESULT}")
|
||||
string(REPLACE "\n " "\nERROR: " REGRESSION_RESULT "${REGRESSION_RESULT}")
|
||||
string(REPLACE "\nERROR: [1] " "\n" REGRESSION_RESULT "${REGRESSION_RESULT}")
|
||||
string(REPLACE "\n[P] " "\n" REGRESSION_RESULT "${REGRESSION_RESULT}")
|
||||
string(REGEX REPLACE "dbg: ([^\n]*)\n?" "" REGRESSION_RESULT "${REGRESSION_RESULT}")
|
||||
|
||||
# Read the expected result
|
||||
file(READ ai/${REGRESSION_TEST}/result.txt REGRESSION_EXPECTED)
|
||||
|
||||
# Convert the string to a list
|
||||
string(REPLACE "\n" ";" REGRESSION_RESULT "${REGRESSION_RESULT}")
|
||||
string(REPLACE "\n" ";" REGRESSION_EXPECTED "${REGRESSION_EXPECTED}")
|
||||
|
||||
set(ARGC 0)
|
||||
set(ERROR NO)
|
||||
|
||||
list(LENGTH REGRESSION_EXPECTED REGRESSION_EXPECTED_LENGTH)
|
||||
|
||||
# Compare the output
|
||||
foreach(RESULT IN LISTS REGRESSION_RESULT)
|
||||
list(GET REGRESSION_EXPECTED ${ARGC} EXPECTED)
|
||||
|
||||
if (NOT RESULT STREQUAL EXPECTED)
|
||||
message("${ARGC}: - ${EXPECTED}")
|
||||
message("${ARGC}: + ${RESULT}'")
|
||||
set(ERROR YES)
|
||||
endif (NOT RESULT STREQUAL EXPECTED)
|
||||
|
||||
math(EXPR ARGC "${ARGC} + 1")
|
||||
endforeach(RESULT)
|
||||
|
||||
if (NOT REGRESSION_EXPECTED_LENGTH EQUAL ARGC)
|
||||
math(EXPR MISSING "${REGRESSION_EXPECTED_LENGTH} - ${ARGC}")
|
||||
message("(${MISSING} more lines were expected than found)")
|
||||
set(ERROR YES)
|
||||
endif (NOT REGRESSION_EXPECTED_LENGTH EQUAL ARGC)
|
||||
|
||||
if (ERROR)
|
||||
message(FATAL_ERROR "Regression failed")
|
||||
endif (ERROR)
|
@ -1,170 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# This file is part of OpenTTD.
|
||||
# OpenTTD 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, version 2.
|
||||
# OpenTTD 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 OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
check_path_characters() {
|
||||
if [ -n "`echo $ROOT_DIR | grep '[^-_A-Za-z0-9\/\\\.:]'`" ]; then
|
||||
echo "WARNING: The path contains a non-alphanumeric character that might cause"
|
||||
echo " failures in subsequent build stages. Any failures with the build"
|
||||
echo " will most likely be caused by this."
|
||||
fi
|
||||
}
|
||||
|
||||
CONFIGURE_EXECUTABLE="$_"
|
||||
# On *nix systems those two are equal when ./configure is done
|
||||
if [ "$0" != "$CONFIGURE_EXECUTABLE" ]; then
|
||||
# On some systems, when ./configure is triggered from 'make'
|
||||
# the $_ is filled with 'make'. So if that is true, skip 'make'
|
||||
# and use $0 (and hope that is correct ;))
|
||||
if [ -n "`echo $CONFIGURE_EXECUTABLE | grep make`" ]; then
|
||||
CONFIGURE_EXECUTABLE="$0"
|
||||
else
|
||||
CONFIGURE_EXECUTABLE="$CONFIGURE_EXECUTABLE $0"
|
||||
fi
|
||||
fi
|
||||
# Find out where configure is (in what dir)
|
||||
ROOT_DIR="`dirname $0`"
|
||||
# For MSYS/MinGW we want to know the FULL path. This as that path is generated
|
||||
# once you call an outside binary. Having the same path for the rest is needed
|
||||
# for dependency checking.
|
||||
# pwd -W returns said FULL path, but doesn't exist on others so fall back.
|
||||
ROOT_DIR="`cd $ROOT_DIR && (pwd -W 2>/dev/null || pwd 2>/dev/null)`"
|
||||
|
||||
check_path_characters
|
||||
|
||||
# Same here as for the ROOT_DIR above
|
||||
PWD="`pwd -W 2>/dev/null || pwd 2>/dev/null`"
|
||||
PREFIX="$PWD/bin"
|
||||
|
||||
. $ROOT_DIR/config.lib
|
||||
|
||||
# Set default dirs
|
||||
OBJS_DIR="$PWD/objs"
|
||||
BASE_SRC_OBJS_DIR="$OBJS_DIR"
|
||||
LANG_OBJS_DIR="$OBJS_DIR/lang"
|
||||
GRF_OBJS_DIR="$OBJS_DIR/extra_grf"
|
||||
SETTING_OBJS_DIR="$OBJS_DIR/setting"
|
||||
BIN_DIR="$PREFIX"
|
||||
SRC_DIR="$ROOT_DIR/src"
|
||||
LANG_DIR="$SRC_DIR/lang"
|
||||
MEDIA_DIR="$ROOT_DIR/media"
|
||||
SOURCE_LIST="$ROOT_DIR/source.list"
|
||||
|
||||
if [ "$1" = "--reconfig" ] || [ "$1" = "--reconfigure" ]; then
|
||||
if [ ! -f "config.cache" ]; then
|
||||
echo "can't reconfigure, because never configured before"
|
||||
exit 1
|
||||
fi
|
||||
# Make sure we don't lock config.cache
|
||||
cat config.cache | sed 's@\\ @\\\\ @g' > cache.tmp
|
||||
sh cache.tmp
|
||||
RET=$?
|
||||
rm -f cache.tmp
|
||||
exit $RET
|
||||
fi
|
||||
|
||||
set_default
|
||||
detect_params "$@"
|
||||
check_params
|
||||
save_params
|
||||
make_cflags_and_ldflags
|
||||
|
||||
EXE=""
|
||||
if [ "$os" = "MINGW" ] || [ "$os" = "CYGWIN" ] || [ "$os" = "OS2" ]; then
|
||||
EXE=".exe"
|
||||
fi
|
||||
|
||||
TTD="openttd$EXE"
|
||||
STRGEN="strgen$EXE"
|
||||
DEPEND="depend$EXE"
|
||||
SETTINGSGEN="settings_gen$EXE"
|
||||
|
||||
if [ -z "$sort" ]; then
|
||||
PIPE_SORT="sed s@a@a@"
|
||||
else
|
||||
PIPE_SORT="$sort"
|
||||
fi
|
||||
|
||||
if [ ! -f "$LANG_DIR/english.txt" ]; then
|
||||
echo "Languages not found in $LANG_DIR. Can't continue without it."
|
||||
echo "Please make sure the dir exists and contains at least english.txt"
|
||||
fi
|
||||
|
||||
# Read the source.list and process it
|
||||
AWKCOMMAND='
|
||||
{ }
|
||||
/^( *)#end/ { if (deep == skip) { skip -= 1; } deep -= 1; next; }
|
||||
/^( *)#else/ { if (deep == skip) { skip -= 1; } else if (deep - 1 == skip) { skip += 1; } next; }
|
||||
/^( *)#if/ {
|
||||
gsub(" ", "", $0);
|
||||
gsub("^#if ", "", $0);
|
||||
|
||||
if (deep != skip) { deep += 1; next; }
|
||||
|
||||
deep += 1;
|
||||
|
||||
if ($0 == "ALLEGRO" && "'$allegro_config'" == "") { next; }
|
||||
if ($0 == "SDL" && "'$sdl_config'" == "") { next; }
|
||||
if ($0 == "SDL2" && "'$sdl2_config'" == "") { next; }
|
||||
if ($0 == "PNG" && "'$png_config'" == "") { next; }
|
||||
if ($0 == "OSX" && "'$os'" != "OSX") { next; }
|
||||
if ($0 == "OS2" && "'$os'" != "OS2") { next; }
|
||||
if ($0 == "DEDICATED" && "'$enable_dedicated'" != "1") { next; }
|
||||
if ($0 == "AI" && "'$enable_ai'" == "0") { next; }
|
||||
if ($0 == "COCOA" && "'$with_cocoa'" == "0") { next; }
|
||||
if ($0 == "HAIKU" && "'$os'" != "HAIKU") { next; }
|
||||
if ($0 == "WIN32" && "'$os'" != "MINGW" &&
|
||||
"'$os'" != "CYGWIN" && "'$os'" != "MSVC") { next; }
|
||||
if ($0 == "MSVC" && "'$os'" != "MSVC") { next; }
|
||||
if ($0 == "MINGW" && "'$os'" != "MINGW") { next; }
|
||||
if ($0 == "DIRECTMUSIC" && "'$with_direct_music'" == "0") { next; }
|
||||
if ($0 == "FLUIDSYNTH" && "'$fluidsynth'" == "" ) { next; }
|
||||
if ($0 == "USE_XAUDIO2" && "'$with_xaudio2'" == "0") { next; }
|
||||
if ($0 == "USE_THREADS" && "'$with_threads'" == "0") { next; }
|
||||
if ($0 == "USE_SSE" && "'$with_sse'" != "1") { next; }
|
||||
|
||||
skip += 1;
|
||||
|
||||
next;
|
||||
}
|
||||
/^( *)#/ { next }
|
||||
/^$/ { next }
|
||||
/\.h$/ { next }
|
||||
/\.hpp$/ { next }
|
||||
{
|
||||
if (deep == skip) {
|
||||
gsub(" ", "", $0);
|
||||
print $0;
|
||||
}
|
||||
}
|
||||
'
|
||||
|
||||
# Read the source.list and process it
|
||||
# Please escape ALL " within ` because e.g. "" terminates the string in some sh implementations
|
||||
SRCS="`< $ROOT_DIR/source.list tr '\r' '\n' | $awk \"$AWKCOMMAND\" | LC_ALL=C $PIPE_SORT`"
|
||||
|
||||
OBJS_C="` echo \"$SRCS\" | $awk ' { ORS = \" \" } /\.c$/ { gsub(\".c$\", \".o\", $0); print $0; }'`"
|
||||
OBJS_CPP="`echo \"$SRCS\" | $awk ' { ORS = \" \" } /\.cpp$/ { gsub(\".cpp$\", \".o\", $0); print $0; }'`"
|
||||
OBJS_MM="` echo \"$SRCS\" | $awk ' { ORS = \" \" } /\.mm$/ { gsub(\".mm$\", \".o\", $0); print $0; }'`"
|
||||
OBJS_RC="` echo \"$SRCS\" | $awk ' { ORS = \" \" } /\.rc$/ { gsub(\".rc$\", \".o\", $0); print $0; }'`"
|
||||
SRCS="` echo \"$SRCS\" | $awk ' { ORS = \" \" } { print $0; }'`"
|
||||
|
||||
# In makefiles, we always use -u for sort
|
||||
if [ -z "$sort" ]; then
|
||||
sort="sed s@a@a@"
|
||||
else
|
||||
sort="$sort -u"
|
||||
fi
|
||||
|
||||
CONFIGURE_FILES="$ROOT_DIR/configure $ROOT_DIR/config.lib $ROOT_DIR/Makefile.in $ROOT_DIR/Makefile.grf.in $ROOT_DIR/Makefile.lang.in $ROOT_DIR/Makefile.src.in $ROOT_DIR/Makefile.bundle.in $ROOT_DIR/Makefile.setting.in"
|
||||
|
||||
generate_main
|
||||
generate_lang
|
||||
generate_settings
|
||||
generate_grf
|
||||
generate_src
|
||||
|
||||
check_path_characters
|
@ -1,148 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# This file is part of OpenTTD.
|
||||
# OpenTTD 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, version 2.
|
||||
# OpenTTD 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 OpenTTD. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
|
||||
# Arguments given? Show help text.
|
||||
if [ "$#" != "0" ]; then
|
||||
cat <<EOF
|
||||
Usage: ./findversion.sh
|
||||
Finds the current revision and if the code is modified.
|
||||
|
||||
Output: <VERSION>\t<ISODATE>\t<MODIFIED>\t<HASH>
|
||||
VERSION
|
||||
a string describing what version of the code the current checkout is
|
||||
based on.
|
||||
This also includes the commit date, an indication of whether the checkout
|
||||
was modified and which branch was checked out. This value is not
|
||||
guaranteed to be sortable, but is mainly meant for identifying the
|
||||
revision and user display.
|
||||
|
||||
If no revision identifier could be found, this is left empty.
|
||||
ISODATE
|
||||
the commit date of the revision this checkout is based on.
|
||||
The commit date may differ from the author date.
|
||||
This can be used to decide upon the age of the source.
|
||||
|
||||
If no timestamp could be found, this is left empty.
|
||||
MODIFIED
|
||||
Whether (the src directory of) this checkout is modified or not. A
|
||||
value of 0 means not modified, a value of 2 means it was modified.
|
||||
|
||||
A value of 1 means that the modified status is unknown, because this
|
||||
is not an git checkout for example.
|
||||
|
||||
HASH
|
||||
the git revision hash
|
||||
|
||||
By setting the AWK environment variable, a caller can determine which
|
||||
version of "awk" is used. If nothing is set, this script defaults to
|
||||
"awk".
|
||||
EOF
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
# Allow awk to be provided by the caller.
|
||||
if [ -z "$AWK" ]; then
|
||||
AWK=awk
|
||||
fi
|
||||
|
||||
# Find out some dirs
|
||||
cd `dirname "$0"`
|
||||
ROOT_DIR=`pwd`
|
||||
|
||||
# Determine if we are using a modified version
|
||||
# Assume the dir is not modified
|
||||
MODIFIED="0"
|
||||
if [ -d "$ROOT_DIR/.git" ] || [ -f "$ROOT_DIR/.git" ]; then
|
||||
# We are a git checkout
|
||||
# Refresh the index to make sure file stat info is in sync, then look for modifications
|
||||
git update-index --refresh >/dev/null
|
||||
if [ -n "`git diff-index HEAD`" ]; then
|
||||
MODIFIED="2"
|
||||
fi
|
||||
HASH=`LC_ALL=C git rev-parse --verify HEAD 2>/dev/null`
|
||||
SHORTHASH=`echo ${HASH} | cut -c1-10`
|
||||
ISODATE=`LC_ALL=C git show -s --pretty='format:%ci' HEAD | "$AWK" '{ gsub("-", "", $1); print $1 }'`
|
||||
YEAR=`echo ${ISODATE} | cut -c1-4`
|
||||
BRANCH="`git symbolic-ref -q HEAD 2>/dev/null | sed 's@.*/@@'`"
|
||||
TAG="`git describe --tags 2>/dev/null`"
|
||||
|
||||
if [ "$MODIFIED" -eq "0" ]; then
|
||||
hashprefix="-g"
|
||||
elif [ "$MODIFIED" -eq "2" ]; then
|
||||
hashprefix="-m"
|
||||
else
|
||||
hashprefix="-u"
|
||||
fi
|
||||
|
||||
if [ -n "$TAG" ]; then
|
||||
VERSION="${TAG}"
|
||||
ISTAG="1"
|
||||
if [ -n "`echo \"${TAG}\" | grep \"^[0-9.]*$\"`" ]; then
|
||||
ISSTABLETAG="1"
|
||||
else
|
||||
ISSTABLETAG="0"
|
||||
fi
|
||||
else
|
||||
VERSION="${ISODATE}-${BRANCH}${hashprefix}${SHORTHASH}"
|
||||
ISTAG="0"
|
||||
ISSTABLETAG="0"
|
||||
fi
|
||||
elif [ -f "$ROOT_DIR/.ottdrev-vc" ]; then
|
||||
VERSION_DATA="`cat "$ROOT_DIR/.ottdrev-vc" | sed -n -e '1 p;'`"
|
||||
HASH_DATA="`cat "$ROOT_DIR/.ottdrev-vc" | sed -n -e '2 p;'`"
|
||||
VERSION="`echo "$VERSION_DATA" | cut -f 1 -d' '`"
|
||||
ISODATE="`echo "$VERSION_DATA" | cut -f 2 -d' '`"
|
||||
MODIFIED="`echo "$VERSION_DATA" | cut -f 3 -d' '`"
|
||||
HASH="`echo "$VERSION_DATA" | cut -f 4 -d' '`"
|
||||
ISTAG="`echo "$VERSION_DATA" | cut -f 5 -d' '`"
|
||||
ISSTABLETAG="`echo "$VERSION_DATA" | cut -f 6 -d' '`"
|
||||
YEAR="`echo "$VERSION_DATA" | cut -f 7 -d' '`"
|
||||
if [ -z "$ISTAG" ]; then
|
||||
ISTAG="0"
|
||||
fi
|
||||
if [ -z "$ISSTABLETAG" ]; then
|
||||
ISSTABLETAG="0"
|
||||
fi
|
||||
if [ -z "$YEAR" ]; then
|
||||
YEAR=`echo ${ISODATE} | cut -c1-4`
|
||||
fi
|
||||
if [ "$MODIFIED" = "2" ]; then
|
||||
VERSION="`echo "$VERSION" | sed -e 's/M$//'`"
|
||||
fi
|
||||
if ! $ROOT_DIR/version_utils.sh -o; then
|
||||
MODIFIED="1"
|
||||
else
|
||||
CURRENT_HASH="`$ROOT_DIR/version_utils.sh -s`"
|
||||
if [ "$CURRENT_HASH" != "$HASH_DATA" ]; then
|
||||
MODIFIED="2"
|
||||
VERSION="${VERSION}-H`echo "$CURRENT_HASH" | cut -c 1-8`"
|
||||
fi
|
||||
fi
|
||||
elif [ -f "$ROOT_DIR/.ottdrev" ]; then
|
||||
# We are an exported source bundle
|
||||
cat $ROOT_DIR/.ottdrev
|
||||
exit
|
||||
else
|
||||
# We don't know
|
||||
MODIFIED="1"
|
||||
HASH=""
|
||||
SHORTHASH=""
|
||||
BRANCH=""
|
||||
ISODATE=""
|
||||
YEAR=""
|
||||
TAG=""
|
||||
VERSION=""
|
||||
ISTAG="0"
|
||||
ISSTABLETAG="0"
|
||||
fi
|
||||
|
||||
if [ "$MODIFIED" -eq "2" ]; then
|
||||
VERSION="${VERSION}M"
|
||||
fi
|
||||
|
||||
echo "$VERSION $ISODATE $MODIFIED $HASH $ISTAG $ISSTABLETAG $YEAR"
|
@ -0,0 +1,87 @@
|
||||
add_subdirectory(openttd)
|
||||
add_subdirectory(orig_extra)
|
||||
|
||||
set(BASESET_SOURCE_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/orig_dos.obg
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/orig_dos_de.obg
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/orig_win.obg
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/no_music.obm
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/orig_dos.obm
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/orig_tto.obm
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/orig_win.obm
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/no_sound.obs
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/orig_dos.obs
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/orig_win.obs
|
||||
)
|
||||
set(BASESET_OTHER_SOURCE_FILES
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/openttd.grf
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/opntitle.dat
|
||||
${CMAKE_CURRENT_SOURCE_DIR}/orig_extra.grf
|
||||
)
|
||||
|
||||
# Done by the subdirectories, if nforenum / grfcodec is installed
|
||||
if (GRFCODEC_FOUND)
|
||||
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/openttd.grf PROPERTIES GENERATED TRUE)
|
||||
set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/orig_extra.grf PROPERTIES GENERATED TRUE)
|
||||
|
||||
list(APPEND BASESET_BINARY_FILES openttd.grf)
|
||||
list(APPEND BASESET_BINARY_FILES orig_extra.grf)
|
||||
endif (GRFCODEC_FOUND)
|
||||
|
||||
set(BASESET_EXTRAGRF_FILE ${CMAKE_CURRENT_SOURCE_DIR}/orig_extra.grf)
|
||||
|
||||
# Walk over all the baseset files, and generate a command to configure them
|
||||
foreach(BASESET_SOURCE_FILE IN LISTS BASESET_SOURCE_FILES)
|
||||
get_filename_component(BASESET_SOURCE_FILE_NAME "${BASESET_SOURCE_FILE}" NAME)
|
||||
set(BASESET_BINARY_FILE "${CMAKE_BINARY_DIR}/baseset/${BASESET_SOURCE_FILE_NAME}")
|
||||
|
||||
get_target_property(LANG_SOURCE_FILES language_files LANG_SOURCE_FILES)
|
||||
|
||||
add_custom_command_timestamp(OUTPUT ${BASESET_BINARY_FILE}
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-DBASESET_SOURCE_FILE=${BASESET_SOURCE_FILE}
|
||||
-DBASESET_BINARY_FILE=${BASESET_BINARY_FILE}
|
||||
-DBASESET_EXTRAGRF_FILE=${BASESET_EXTRAGRF_FILE}
|
||||
-P ${CMAKE_SOURCE_DIR}/cmake/scripts/Baseset.cmake
|
||||
--
|
||||
${LANG_SOURCE_FILES}
|
||||
MAIN_DEPENDENCY ${BASESET_SOURCE_FILE}
|
||||
DEPENDS ${LANG_SOURCE_FILES}
|
||||
${BASESET_EXTRAGRF_FILE}
|
||||
${CMAKE_SOURCE_DIR}/cmake/scripts/Baseset.cmake
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||
COMMENT "Generating ${BASESET_SOURCE_FILE_NAME} baseset metadata file"
|
||||
)
|
||||
|
||||
list(APPEND BASESET_BINARY_FILES ${BASESET_BINARY_FILE})
|
||||
endforeach(BASESET_SOURCE_FILE)
|
||||
|
||||
# Walk over all the other baseset files, and generate a command to copy them
|
||||
foreach(BASESET_OTHER_SOURCE_FILE IN LISTS BASESET_OTHER_SOURCE_FILES)
|
||||
get_filename_component(BASESET_OTHER_SOURCE_FILE_NAME "${BASESET_OTHER_SOURCE_FILE}" NAME)
|
||||
set(BASESET_OTHER_BINARY_FILE "${CMAKE_BINARY_DIR}/baseset/${BASESET_OTHER_SOURCE_FILE_NAME}")
|
||||
|
||||
add_custom_command(OUTPUT ${BASESET_OTHER_BINARY_FILE}
|
||||
COMMAND ${CMAKE_COMMAND} -E copy
|
||||
${BASESET_OTHER_SOURCE_FILE}
|
||||
${BASESET_OTHER_BINARY_FILE}
|
||||
MAIN_DEPENDENCY ${BASESET_OTHER_SOURCE_FILE}
|
||||
COMMENT "Copying ${BASESET_OTHER_SOURCE_FILE_NAME} baseset file"
|
||||
)
|
||||
|
||||
list(APPEND BASESET_BINARY_FILES ${BASESET_OTHER_BINARY_FILE})
|
||||
endforeach(BASESET_OTHER_SOURCE_FILE)
|
||||
|
||||
# Create a new target which generates all baseset metadata files
|
||||
add_custom_target_timestamp(baseset_files
|
||||
DEPENDS
|
||||
${BASESET_BINARY_FILES}
|
||||
)
|
||||
|
||||
add_library(basesets
|
||||
INTERFACE
|
||||
)
|
||||
add_dependencies(basesets
|
||||
baseset_files
|
||||
)
|
||||
add_library(openttd::basesets ALIAS basesets)
|
@ -0,0 +1,9 @@
|
||||
# In case both NFORenum and GRFCodec are found, generate the GRF.
|
||||
# Otherwise, just use them from the cache (read: git).
|
||||
# This is mainly because not many people have both of these tools installed,
|
||||
# so it is cheaper to cache them in git, and only regenerate when you are
|
||||
# working on it / have the tools installed.
|
||||
if (GRFCODEC_FOUND)
|
||||
include(CreateGrfCommand)
|
||||
create_grf_command()
|
||||
endif (GRFCODEC_FOUND)
|
Before Width: | Height: | Size: 29 KiB After Width: | Height: | Size: 29 KiB |
Before Width: | Height: | Size: 9.3 KiB After Width: | Height: | Size: 9.3 KiB |
Before Width: | Height: | Size: 3.5 KiB After Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 5.4 KiB After Width: | Height: | Size: 5.4 KiB |
Before Width: | Height: | Size: 16 KiB After Width: | Height: | Size: 16 KiB |
Before Width: | Height: | Size: 6.1 KiB After Width: | Height: | Size: 6.1 KiB |
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
Before Width: | Height: | Size: 5.9 KiB After Width: | Height: | Size: 5.9 KiB |
Before Width: | Height: | Size: 1.7 KiB After Width: | Height: | Size: 1.7 KiB |
Before Width: | Height: | Size: 54 KiB After Width: | Height: | Size: 54 KiB |
Before Width: | Height: | Size: 4.7 KiB After Width: | Height: | Size: 4.7 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 26 KiB After Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 2.2 KiB After Width: | Height: | Size: 2.2 KiB |
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.2 KiB |
Before Width: | Height: | Size: 1.3 KiB After Width: | Height: | Size: 1.3 KiB |
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
Before Width: | Height: | Size: 2.6 KiB After Width: | Height: | Size: 2.6 KiB |
Before Width: | Height: | Size: 23 KiB After Width: | Height: | Size: 23 KiB |