aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authortobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>2008-09-09 12:50:50 +0000
committertobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c>2008-09-09 12:50:50 +0000
commit5e1dd23ad5ed2fe8b0a618a9f9e10eac1694fe2b (patch)
treefb59afccbff16075ac39b00fe5d81340a2612741
parentf3e8cb5a09ada2c74292047f2fad4fd47a01b99a (diff)
downloadusdx-5e1dd23ad5ed2fe8b0a618a9f9e10eac1694fe2b.tar.gz
usdx-5e1dd23ad5ed2fe8b0a618a9f9e10eac1694fe2b.tar.xz
usdx-5e1dd23ad5ed2fe8b0a618a9f9e10eac1694fe2b.zip
- better conformance of Makefiles to GNU coding standards
- bindir/prefix, etc. can be changed anytime make is performed and is not hardcoded on configure time anymore - paths are written to the intermediate paths.inc file (instead of config-xyz.inc) - binary is not stripped anymore - fpc.m4 rewrite - additional options like heaptrace, range-checks - noexecstack workaround - some more changes - configure.ac helper functions moved to ax_ectract_version.m4 and pkg_config_utils.m4 - some icons moved from artwork to icons git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1351 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to '')
-rw-r--r--Makefile.in186
-rw-r--r--configure.ac197
-rw-r--r--dists/autogen/m4/ax_extract_version.m454
-rw-r--r--dists/autogen/m4/fpc.m4351
-rw-r--r--dists/autogen/m4/macosx_version.m431
-rw-r--r--dists/autogen/m4/pkg_config_utils.m4190
-rw-r--r--icons/ultrastardx-icon.svg (renamed from artwork/usdx_icon.svg)0
-rw-r--r--src/Makefile.in171
-rw-r--r--src/base/UPlatformLinux.pas5
-rw-r--r--src/config.inc.in6
10 files changed, 758 insertions, 433 deletions
diff --git a/Makefile.in b/Makefile.in
index f48fba24..334a5bc7 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -4,6 +4,7 @@
#################################################
@SET_MAKE@
+SHELL = /bin/sh
#################################################
# Standard definitions
@@ -13,6 +14,7 @@ prefix ?= @prefix@
exec_prefix ?= @exec_prefix@
bindir ?= @bindir@
datarootdir ?= @datarootdir@
+datadir ?= @datadir@
libdir ?= @libdir@
docdir ?= @docdir@
pdfdir ?= @pdfdir@
@@ -35,11 +37,9 @@ RM ?= rm -f
RM_REC ?= $(RM) -r
# install tool
-INSTALL ?= @INSTALL@
-INSTALL_DATA ?= @INSTALL_DATA@
-
-# installation path
-INSTALL_DATADIR ?= @INSTALL_DATADIR@
+INSTALL ?= @INSTALL@
+INSTALL_DATA ?= @INSTALL_DATA@
+INSTALL_PROGRAM ?= @INSTALL_DATA@
#################################################
# General package configuration
@@ -56,10 +56,12 @@ USDX_TARNAME := @PACKAGE_TARNAME@
USDX_SRC_DIR := $(top_srcdir)/src
USDX_GAME_DIR := $(top_srcdir)/game
USDX_TOOLS_DIR := $(top_srcdir)/tools
+USDX_BUILD_DIR := $(top_srcdir)/build
USDX_LIB_DIR := $(USDX_SRC_DIR)/lib
-USDX_BUILD_DIR := $(USDX_SRC_DIR)/build
-AUTOGEN_DIR := $(top_srcdir)/dists/autogen
+INSTALL_DATADIR := $(datadir)/$(USDX_PACKAGE_NAME)
+
+AUTOGEN_DIR := $(srcdir)/dists/autogen
#################################################
# Binary name
@@ -89,10 +91,30 @@ endif
# general targets
#################################################
+##
+# IMPORTANT:
+# Always assure that this Makefile still works with the -jN
+# parameter set. This is important as Gentoo uses parallel
+# make (-j2) by default.
+# If parallel execution is enabled you cannot rely on a
+# specific order the prerequisites are build.
+#
+# Example:
+# target: dependency dependant
+#
+# will first build "dependency" and "dependant" afterwards with a
+# sequential execution (-j1). With parallel execution "dependant"
+# might be started before "dependency" is finished and make will
+# crash.
+#
+# If it is not possible, add the virtual .NOTPARALLEL target.
+# This will disable parallel execution for ALL targets.
+##
+
BUILD_TARGETS = all debug release rebuild build
.PHONY: $(BUILD_TARGETS)
$(BUILD_TARGETS): all-deps
- $(MAKE) -C src $@
+ $(MAKE) -C $(USDX_SRC_DIR) $@
.PHONY: all-deps
all-deps:
@@ -105,7 +127,7 @@ clean: clean-src clean-deps
.PHONY: clean-src
clean-src:
- $(MAKE) -C src clean
+ $(MAKE) -C $(USDX_SRC_DIR) clean
.PHONY: clean-deps
clean-deps:
@@ -123,43 +145,37 @@ clean-game:
-rmdir $(USDX_GAME_DIR)/playlists
-rmdir $(USDX_GAME_DIR)/songs
+# just clean the game build data but no dependencies (libs, tools, ...)
.PHONY: mostlyclean
mostlyclean: clean-src
.PHONY: distclean
-distclean: clean clean-game tidy
- $(RM_REC) config.log config.status aclocal.m4 autom4te.cache
+distclean: clean clean-game
+ $(RM) config.log config.status aclocal.m4
+ $(RM_REC) autom4te.cache
$(RM) $(USDX_SRC_DIR)/config.inc
- $(RM) Makefile $(USDX_SRC_DIR)/Makefile $(PROJECTM_CWRAPPER_DIR)/Makefile
-
-# remove Mac OS X apllication bundle and disk image
-.PHONY: clean-macosx
-clean-macosx: clean-macosx-app clean-macosx-dmg
-
-.PHONY: clean-macosx-app
-clean-macosx-app:
- $(RM) -r UltraStarDeluxe.app
+ $(RM) $(srcdir)/Makefile $(USDX_SRC_DIR)/Makefile $(PROJECTM_CWRAPPER_DIR)/Makefile
-.PHONY: clean-macosx-dmg
-clean-macosx-dmg:
- $(RM) UltraStarDeluxe.dmg
+.PHONY: maintainer-clean
+maintainer-clean: distclean
# remove temporary and backup files
.PHONY: tidy
tidy:
# FPC stuff
- find . -name "*.compiled" | xargs $(RM)
+ find $(srcdir) -name "*.compiled" | xargs $(RM)
# Delphi stuff
- find . -name "__history" | xargs $(RM_REC)
- find . -name "*.identcache" -o -name "*.dcu" | xargs $(RM)
+ find $(srcdir) -name "__history" | xargs $(RM_REC)
+ find $(srcdir) -name "*.identcache" -o -name "*.dcu" | xargs $(RM)
# Backup files
- find . -name "*~" -o -name "*.bak" -o -name "*.orig" | xargs $(RM)
+ find $(srcdir) -name "*~" -o -name "*.bak" -o -name "*.orig" | xargs $(RM)
+
#################################################
# auto-update
#################################################
-Makefile: Makefile.in $(USDX_SRC_DIR)/Makefile.in $(USDX_SRC_DIR)/config.inc.in $(PROJECTM_CWRAPPER_DIR)/Makefile.in config.status
+Makefile: $(srcdir)/Makefile.in $(USDX_SRC_DIR)/Makefile.in $(USDX_SRC_DIR)/config.inc.in $(PROJECTM_CWRAPPER_DIR)/Makefile.in config.status
@echo "-----------------------------------"
@echo "Performing reconfiguration..."
./config.status
@@ -176,46 +192,74 @@ reconf:
# install/uninstall
#################################################
+##
+# For information on directory and install conventions see
+# "info autoconf", Section 4.8.2. Installation Directory Variables
+# Section 4.8.1, 4.8.3 and 4.8.4
+# Notes:
+# - "make install" must not rebuild, so do not depend on all.
+# - use the DESTDIR variable as prefix for installation directories,
+# otherwise Gentoo will not be able to install as it uses a sandbox.
+##
+
.PHONY: install
-install: all
- $(MAKE) install-all
+install: install-all
@echo "--------------------------------"
@echo "$(USDX_PACKAGE_NAME) installed."
@echo "Start with: $(bindir)/$(USDX_BIN_NAME)"
@echo "--------------------------------"
+# strip binaries during install
+install-strip:
+ $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' \
+ install
+
.PHONY: install-all
-install-all: install-data install-exec
+install-all: install-exec install-data
+
+.PHONY: install-exec
+install-exec:
+ $(MKDIR) "$(DESTDIR)$(bindir)"
+ $(INSTALL_PROGRAM) "$(USDX_BIN)" "$(DESTDIR)$(bindir)"
.PHONY: install-data
install-data:
- $(MAKE) RECURSIVE_SRC_DIR="artwork" RECURSIVE_DST_DIR="$(INSTALL_DATADIR)/artwork" install-data-recursive
- $(MAKE) RECURSIVE_SRC_DIR="$(USDX_GAME_DIR)/languages" RECURSIVE_DST_DIR="$(INSTALL_DATADIR)/languages" install-data-recursive
- $(MAKE) RECURSIVE_SRC_DIR="$(USDX_GAME_DIR)/sounds" RECURSIVE_DST_DIR="$(INSTALL_DATADIR)/sounds" install-data-recursive
- $(MAKE) RECURSIVE_SRC_DIR="$(USDX_GAME_DIR)/themes" RECURSIVE_DST_DIR="$(INSTALL_DATADIR)/themes" install-data-recursive
- $(MAKE) RECURSIVE_SRC_DIR="$(USDX_GAME_DIR)/resources" RECURSIVE_DST_DIR="$(INSTALL_DATADIR)/resources" install-data-recursive
- $(INSTALL_DATA) "COPYING.txt" "$(INSTALL_DATADIR)"
+ $(MAKE) RECURSIVE_SRC_DIR="artwork" \
+ RECURSIVE_DST_DIR="$(DESTDIR)$(INSTALL_DATADIR)/artwork" \
+ install-data-recursive
+ $(MAKE) RECURSIVE_SRC_DIR="$(USDX_GAME_DIR)/languages" \
+ RECURSIVE_DST_DIR="$(DESTDIR)$(INSTALL_DATADIR)/languages" \
+ install-data-recursive
+ $(MAKE) RECURSIVE_SRC_DIR="$(USDX_GAME_DIR)/sounds" \
+ RECURSIVE_DST_DIR="$(DESTDIR)$(INSTALL_DATADIR)/sounds" \
+ install-data-recursive
+ $(MAKE) RECURSIVE_SRC_DIR="$(USDX_GAME_DIR)/themes" \
+ RECURSIVE_DST_DIR="$(DESTDIR)$(INSTALL_DATADIR)/themes" \
+ install-data-recursive
+ $(MAKE) RECURSIVE_SRC_DIR="$(USDX_GAME_DIR)/resources" \
+ RECURSIVE_DST_DIR="$(DESTDIR)$(INSTALL_DATADIR)/resources" \
+ install-data-recursive
+ $(INSTALL_DATA) "COPYING.txt" "$(DESTDIR)$(INSTALL_DATADIR)/COPYING.txt"
.PHONY: install-data-recursive
install-data-recursive:
+# Note: the project contains filesnames with whitespace
$(MKDIR) "$(RECURSIVE_DST_DIR)"
@for file in "$(RECURSIVE_SRC_DIR)"/*; do \
if test -f "$$file"; then \
- echo $(INSTALL_DATA) "$$file" "$(RECURSIVE_DST_DIR)"; \
- $(INSTALL_DATA) "$$file" "$(RECURSIVE_DST_DIR)"; \
+ filename=`basename "$$file"`; \
+ echo "$(INSTALL_DATA) \"$$file\" \"$(RECURSIVE_DST_DIR)/$$filename\""; \
+ $(INSTALL_DATA) "$$file" "$(RECURSIVE_DST_DIR)/$$filename" || exit 1; \
fi; \
if test -d "$$file"; then \
subdir="$$file"; \
subdirname=`basename "$$subdir"`; \
- $(MAKE) RECURSIVE_SRC_DIR="$$subdir" RECURSIVE_DST_DIR="$(RECURSIVE_DST_DIR)/$$subdirname" install-data-recursive; \
+ $(MAKE) RECURSIVE_SRC_DIR="$$subdir" \
+ RECURSIVE_DST_DIR="$(RECURSIVE_DST_DIR)/$$subdirname" \
+ install-data-recursive || exit 1; \
fi; \
done
-.PHONY: install-exec
-install-exec:
- $(MKDIR) "$(bindir)"
- $(INSTALL) "$(USDX_BIN)" "$(bindir)"
-
.PHONY: uninstall
uninstall: uninstall-all
@@ -224,31 +268,41 @@ uninstall-all: uninstall-data uninstall-exec
.PHONY: uninstall-data
uninstall-data:
- $(RM_REC) "$(INSTALL_DATADIR)/artwork"
- $(RM_REC) "$(INSTALL_DATADIR)/languages"
- $(RM_REC) "$(INSTALL_DATADIR)/sounds"
- $(RM_REC) "$(INSTALL_DATADIR)/themes"
- $(RM_REC) "$(INSTALL_DATADIR)/resources"
- $(RM) "$(INSTALL_DATADIR)/COPYING.txt"
- -rmdir "$(INSTALL_DATADIR)"
+ $(RM_REC) "$(DESTDIR)$(INSTALL_DATADIR)/artwork"
+ $(RM_REC) "$(DESTDIR)$(INSTALL_DATADIR)/languages"
+ $(RM_REC) "$(DESTDIR)$(INSTALL_DATADIR)/sounds"
+ $(RM_REC) "$(DESTDIR)$(INSTALL_DATADIR)/themes"
+ $(RM_REC) "$(DESTDIR)$(INSTALL_DATADIR)/resources"
+ $(RM) "$(DESTDIR)$(INSTALL_DATADIR)/COPYING.txt"
+ -rmdir "$(DESTDIR)$(INSTALL_DATADIR)"
.PHONY: uninstall-exec
uninstall-exec:
- $(RM) "$(bindir)/$(USDX_BIN_NAME)"
+ $(RM) "$(DESTDIR)$(bindir)/$(USDX_BIN_NAME)"
#################################################
# Distributable source-package (TODO)
#################################################
-disttmpdir ?= disttmp
+#disttmpdir := $(USDX_PACKAGE_NAME)-$(USDX_VERSION)-src
+disttmpdir := $(USDX_PACKAGE_NAME)-1.1_alpha-src
+# choose all files in SVN that are not deleted
+svn-files := svn status -v | grep -v "^[?D]" | cut -c8- | tr -s " " | cut -f5- -d" "
.PHONY: dist
dist:
-# $(MKDIR) $(disttmpdir)
-# cp -R . $(disttmpdir)
-# $(MAKE) -C $(disttmpdir)/src distclean
-# tar cvzf $(USDX_TARNAME)-$(USDX_VERSION).tar.gz $(disttmpdir)
-# $(RM_REC) $(disttmpdir)
+ @$(svn-files) | while read FILE; do \
+ if test -d "$$FILE"; then \
+ echo "MKDIR: $(disttmpdir)/$$FILE"; \
+ $(MKDIR) "$(disttmpdir)/$$FILE" || exit 1; \
+ else \
+ echo "COPY: $$FILE"; \
+ cp "$$FILE" "$(disttmpdir)/$$FILE" || exit 1; \
+ fi; \
+ done
+ tar cvf $(disttmpdir).tar $(disttmpdir)
+ gzip $(disttmpdir).tar
+ $(RM_REC) $(disttmpdir)
#################################################
# Debian package
@@ -266,7 +320,7 @@ deb: all
$(MKDIR) $(debpkgdir)
$(MKDIR) $(debpkgtmpdir)/DEBIAN
- $(MAKE) prefix=$(debpkgtmpdir)/$(prefix) install
+ $(MAKE) DESTDIR=$(debpkgtmpdir)/ install-all
$(INSTALL_DATA) $(debpkgdir)/$(debpkgprefix).control $(debpkgtmpdir)/DEBIAN/control
@@ -381,3 +435,15 @@ macosx-dmg: macosx-standalone-app
$(HDIUTIL) detach /Volumes/UltraStarDeluxe
$(HDIUTIL) convert UltraStarDeluxe.sparseimage -format UDBZ -o UltraStarDeluxe.dmg
$(RM) UltraStarDeluxe.sparseimage
+
+# remove Mac OS X apllication bundle and disk image
+.PHONY: clean-macosx
+clean-macosx: clean-macosx-app clean-macosx-dmg
+
+.PHONY: clean-macosx-app
+clean-macosx-app:
+ $(RM_REC) UltraStarDeluxe.app
+
+.PHONY: clean-macosx-dmg
+clean-macosx-dmg:
+ $(RM) UltraStarDeluxe.dmg
diff --git a/configure.ac b/configure.ac
index 18d7e957..2a0bc83a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -6,6 +6,10 @@
# Execute "dists/autogen/autogen.sh" or "make reconf"
# to create the configure script.
#
+# Helper macros have been separated to
+# ax_extract_version.m4 (AX_EXTRACT_VERSION)
+# pkg_config_utils.m4 (PKG_VALUE, PKG_VERSION, PKG_HAVE)
+#
# Require autoconf >= 2.61
AC_PREREQ(2.61)
@@ -30,12 +34,6 @@ AC_CONFIG_AUX_DIR(dists/autogen)
# show features and packages in one list
AC_PRESERVE_HELP_ORDER
-# set INSTALL_DATADIR to the expanded dataroot sub-directory for USDX.
-# Pascal is not able to handle shell-variables like ${prefix} that is
-# why we expand here.
-INSTALL_DATADIR_UNEXP="$datadir/$PACKAGE_NAME"
-AC_DEFINE_DIR(INSTALL_DATADIR, INSTALL_DATADIR_UNEXP)
-
# -----------------------------------------
# find tools
# -----------------------------------------
@@ -58,13 +56,6 @@ AC_PROG_GREP
# macro declarations
# -----------------------------------------
-# AC_TRIM(STRING)
-# removes surrounding whitespace
-# -------------------------------------------
-AC_DEFUN([AC_TRIM],
-[echo "[$1]" | $SED 's/^[[ \t]]*//' | $SED 's/[[ \t]]*$//'
-])
-
# AC_SUBST_DEFINE(DEFINE_SUFFIX, IS_DEFINED)
# used to enable/disable pascal defines
AC_DEFUN([AC_SUBST_DEFINE],
@@ -77,170 +68,6 @@ AC_DEFUN([AC_SUBST_DEFINE],
AC_SUBST(DEFINE_[$1])
])
-# AC_SPLIT_VERSION(VARIABLE_PREFIX, VERSION)
-# Splits version number ("major.minor.release") into its components.
-# Sets
-# [$VARIABLE_PREFIX]_VERSION_MAJOR
-# [$VARIABLE_PREFIX]_VERSION_MINOR
-# [$VARIABLE_PREFIX]_VERSION_RELEASE
-# This function calls
-# AC_SUBST([$VARIABLE_PREFIX]_VERSION_type] for each type
-AC_DEFUN([AC_SPLIT_VERSION],
-[
- version=[$2]
-
- # strip leading non-numeric tokens
- # (necessary for some ffmpeg-packages in ubuntu)
- # example: 0d.51.1.0 -> 51.1.0
- version=`echo $version | $SED 's/^[[^.]]*[[^0-9.]][[^.]]*\.//'`
-
- # replace "." and "-" with " " and ignore trailing tokens.
- # 1.23.4-r2 will be splitted to [maj=1, min=23, rel=4].
- # In addition we delete every character which is not 0-9.
- # 1.3a4-r32 will be [maj=1, min=34, rel=32].
- read major minor release ignore <<eof
- `echo $version | tr '.-' ' ' | $SED 's/[[^0-9\ ]].*//'`
-eof
- # Note: Do NOT indent the eof-delimiter
- # We use a here-document (<<< here-strings not POSIX compatible)
-
- # strip preceding 0s and set unset version-parts to 0
- [$1][_VERSION_MAJOR]=$(($major))
- [$1][_VERSION_MINOR]=$(($minor))
- [$1][_VERSION_RELEASE]=$(($release))
- # integer representation: MMMmmmrrr (M:major,m:minor,r:release)
- # can be used if pkg-config's comparison fails
- [$1][_VERSION_INT]=$(($[$1][_VERSION_MAJOR]*1000000+$[$1][_VERSION_MINOR]*1000+$[$1][_VERSION_RELEASE]))
-
- AC_SUBST([$1][_VERSION_MAJOR])
- AC_SUBST([$1][_VERSION_MINOR])
- AC_SUBST([$1][_VERSION_RELEASE])
- AC_SUBST([$1][_VERSION_INT])
-])
-
-# PKG_VALUE(VARIABLE_PREFIX, POSTFIX, COMMAND, MODULE, HELP-STRING)
-# -----------------------------------------------------
-AC_DEFUN([PKG_VALUE],
-[
- AC_ARG_VAR([$1]_[$2], [$5, overriding pkg-config])
- # check if variable was defined by the user
- if test -z "$[$1]_[$2]"; then
- # if not, get it from pkg-config
- if test x$[$1][_HAVE] = xyes; then
- PKG_CHECK_EXISTS([$4],
- [[$1]_[$2]=`$PKG_CONFIG --[$3] --silence-errors "$4"`],
- [# print error message and quit
- err_msg=`$PKG_CONFIG --errors-to-stdout --print-errors "$4"`
- AC_MSG_ERROR(
-[
-
-$err_msg
-
-If --with-[$1]=nocheck is defined the environment variable
-[$1]_[$2]
-must be set to avoid the need to call pkg-config.
-
-See the pkg-config man page for more details.
-])
-
- ])
- fi
- fi
- AC_SUBST([$1]_[$2])
-])
-
-# PKG_VERSION(VARIABLE_PREFIX, MODULE)
-# Checks version of a package
-# Parameters:
-# - VARIABLE_PREFIX: the prefix for the variables storing information about the package.
-# - MODULE: package name according to pkg-config
-# Sets:
-# [$VARIABLE_PREFIX]_VERSION # full version string (format: "major.minor.release")
-# [$VARIABLE_PREFIX]_VERSION_MAJOR # major version number
-# [$VARIABLE_PREFIX]_VERSION_MINOR # minor version number
-# [$VARIABLE_PREFIX]_VERSION_RELEASE # release version number
-# [$VARIABLE_PREFIX]_VERSION_INT # integer representation: MMMmmmrrr (M:major,m:minor,r:release)
-AC_DEFUN([PKG_VERSION],
-[
- if test x$[$1][_HAVE] = xyes; then
- AC_MSG_CHECKING([version of $1])
- PKG_VALUE([$1], [VERSION], [modversion], [$2], [version of $1])
- AC_MSG_RESULT(@<:@$[$1][_VERSION]@:>@)
- else
- [$1][_VERSION]="0.0.0"
- fi
- AC_SPLIT_VERSION([$1], $[$1][_VERSION])
-])
-
-# PKG_HAVE(VARIABLE_PREFIX, MODULE, [REQUIRED])
-# Checks with pkg-config if a package exists and retrieves information
-# about it.
-# Parameters:
-# - VARIABLE_PREFIX: the prefix for the variables storing information about the package.
-# - MODULE: package name according to pkg-config
-# - REQUIRED: if true, the configure-script is aborted if the package was not found
-# Uses:
-# with_[$VARIABLE_PREFIX]: whether and how the package should be checked for
-# "check": check for the package but do not abort if it does not exist (default)
-# "no": do not check for the package (sets _HAVE to "no" and _VERSION to "0.0.0")
-# "yes": check for the package and abort if it does not exist
-# "nocheck": do not check for the package (sets _HAVE to "yes")
-# Sets:
-# [$VARIABLE_PREFIX]_HAVE # package is available (values: "yes"|"no")
-# [$VARIABLE_PREFIX]_LIBS # linker flags (e.g. -Lmylibdir -lmylib)
-# [$VARIABLE_PREFIX]_LIBDIRS # library dirs (e.g. -Lmylibdir)
-AC_DEFUN([PKG_HAVE],
-[
- have_lib="no"
- AC_MSG_CHECKING([for $2])
- if test x"$with_[$1]" = xnocheck; then
- # do not call pkg-config, use user settings
- have_lib="yes"
- elif test x"$with_[$1]" != xno; then
- # check if package exists
- PKG_CHECK_EXISTS([$2], [
- have_lib="yes"
- [$1][_LIBS]=`$PKG_CONFIG --libs --silence-errors "$2"`
- [$1][_LIBDIRS]=`$PKG_CONFIG --libs-only-L --silence-errors "$2"`
- [$1][_LIBDIRS]=`AC_TRIM($[$1][_LIBDIRS])`
- # add library directories to LIBS (ignore *_LIBS for now)
- if test -n "$[$1][_LIBDIRS]"; then
- LIBS="$LIBS $[$1][_LIBDIRS]"
- fi
- ])
- fi
- if test x$have_lib = xyes; then
- [$1][_HAVE]="yes"
- if test -n "$[$1][_LIBDIRS]"; then
- # show additional lib-dirs
- AC_MSG_RESULT(yes [(]$[$1][_LIBDIRS][)])
- else
- AC_MSG_RESULT(yes)
- fi
- else
- [$1][_HAVE]="no"
- AC_MSG_RESULT(no)
-
- # check if package is required
- if test x$3 = xyes -o x"$with_[$1]" = xyes ; then
- # print error message and quit
- err_msg=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"`
- AC_MSG_ERROR(
-[
-
-$err_msg
-
-Alternatively, you may set --with-[$1]=nocheck and the environment
-variables [$1]_[[...]] (see configure --help)
-to appropriate values to avoid the need to call pkg-config.
-
-See the pkg-config man page for more details.
-])
- fi
- fi
-])
-
-
# -----------------------------------------
# define switches
# -----------------------------------------
@@ -279,6 +106,12 @@ if [[ x$enable_global != x -o x$enable_local != x ]]; then
sleep 2
fi
+AC_ARG_ENABLE(debug,
+ [AS_HELP_STRING([--enable-debug],
+ [Enable debug build @<:@default=no@:>@])],
+ [test $enableval = "yes" && ENABLE_DEBUG="yes"], [])
+AC_SUBST(ENABLE_DEBUG)
+
# -----------------------------------------
# check for compilers
# -----------------------------------------
@@ -288,9 +121,6 @@ AC_CANONICAL_HOST
# find and test the freepascal compiler
# sets PFLAGS, FPC_VERSION, FPC_DEBUG, etc.
AC_PROG_FPC
-# FPC_VERSION is already defined by FPC, use
-# PPC as prefix instead.
-AC_SPLIT_VERSION(PPC, $FPC_VERSION)
# find and test the C compiler (for C-libs and wrappers)
AC_PROG_CC
@@ -316,11 +146,8 @@ fi
# check for OS
# -----------------------------------------
-if [[ x$FPC_PLATFORM = xdarwin ]]; then
- AC_MSG_CHECKING([for Mac OS X version])
- MACOSX_VERSION=`sw_vers -productVersion`
- AC_SPLIT_VERSION(MACOSX, $MACOSX_VERSION)
- AC_MSG_RESULT(@<:@$MACOSX_VERSION@:>@)
+if test x$FPC_PLATFORM = xdarwin; then
+ AC_MACOSX_VERSION
fi
# -----------------------------------------
diff --git a/dists/autogen/m4/ax_extract_version.m4 b/dists/autogen/m4/ax_extract_version.m4
new file mode 100644
index 00000000..e9501f69
--- /dev/null
+++ b/dists/autogen/m4/ax_extract_version.m4
@@ -0,0 +1,54 @@
+# This file is part of UltraStar Deluxe
+# Created by the UltraStar Deluxe Team
+
+# SYNOPSIS
+#
+# AX_EXTRACT_VERSION(VARIABLE_PREFIX, VERSION)
+#
+# DESCRIPTION
+#
+# Splits a version number ("major.minor.release") into its components.
+# The resulting components of the version are guaranteed to be
+# numeric. All non-numeric chars are removed.
+#
+# Sets
+# [$VARIABLE_PREFIX]_VERSION_MAJOR
+# [$VARIABLE_PREFIX]_VERSION_MINOR
+# [$VARIABLE_PREFIX]_VERSION_RELEASE
+#
+# This function calls
+# AC_SUBST([$VARIABLE_PREFIX]_VERSION_type] for each type
+
+AC_DEFUN([AX_EXTRACT_VERSION],
+[
+ version=[$2]
+
+ # strip leading non-numeric tokens
+ # (necessary for some ffmpeg-packages in ubuntu)
+ # example: 0d.51.1.0 -> 51.1.0
+ version=`echo $version | sed 's/^[[^.]]*[[^0-9.]][[^.]]*\.//'`
+
+ # replace "." and "-" with " " and ignore trailing tokens.
+ # 1.23.4-r2 will be splitted to [maj=1, min=23, rel=4].
+ # In addition we delete everything after the first character
+ # which is not 0-9.
+ # 1.3a4-r32 will be [maj=1, min=3, rel=0].
+ read major minor release ignore <<eof
+ `echo $version | tr '.-' ' ' | sed 's/[[^0-9\ ]].*//'`
+eof
+ # Note: Do NOT indent the eof-delimiter
+ # We use a here-document (<<< here-strings not POSIX compatible)
+
+ # strip preceding 0s and set unset version-parts to 0
+ [$1][_VERSION_MAJOR]=$(($major))
+ [$1][_VERSION_MINOR]=$(($minor))
+ [$1][_VERSION_RELEASE]=$(($release))
+ # integer representation: MMMmmmrrr (M:major,m:minor,r:release)
+ # can be used if pkg-config's comparison fails
+ [$1][_VERSION_INT]=$(($[$1][_VERSION_MAJOR]*1000000+$[$1][_VERSION_MINOR]*1000+$[$1][_VERSION_RELEASE]))
+
+ AC_SUBST([$1][_VERSION_MAJOR])
+ AC_SUBST([$1][_VERSION_MINOR])
+ AC_SUBST([$1][_VERSION_RELEASE])
+ AC_SUBST([$1][_VERSION_INT])
+])
diff --git a/dists/autogen/m4/fpc.m4 b/dists/autogen/m4/fpc.m4
index 896c53d2..217fddc8 100644
--- a/dists/autogen/m4/fpc.m4
+++ b/dists/autogen/m4/fpc.m4
@@ -1,176 +1,271 @@
-dnl ** Version 1.1 of file is part of the LGPLed
-dnl ** J Sound System (http://jss.sourceforge.net)
-dnl **
-dnl ** Checks for Free Pascal Compiler by Matti "ccr/TNSP" Hamalainen
-dnl ** (C) Copyright 2000-2001 Tecnic Software productions (TNSP)
-dnl **
-dnl ** Versions
-dnl ** --------
-dnl ** 1.0 - Created
-dnl **
-dnl ** 1.1 - Added stuff to enable unix -> win32
-dnl ** cross compilation.
-dnl **
-dnl ** 1.x - A few fixes (by the UltraStar Deluxe Team)
-dnl **
+# Based on fpc.m4 Version 1.1 provided with
+# J Sound System (http://jss.sourceforge.net)
+#
+# Originally written by
+# Matti "ccr/TNSP" Hamalainen
+# (C) Copyright 2000-2001 Tecnic Software productions (TNSP)
+#
+# Mostly rewritten by
+# UltraStar Deluxe Team
-AC_DEFUN([AC_PROG_FPC], [
+# SYNOPSIS
+#
+# AC_PROG_FPC
+#
+# DESCRIPTION
+#
+# Checks for Free Pascal Compiler
+#
+# Sets:
+# PPC : fpc command
+# FPCMAKE : fpcmake command
+#
+# PFLAGS : flags passed to fpc (overwrite default)
+# PFLAGS_BASE : base flags (release + debug)
+# PFLAGS_EXTRA : additional flags (appended to default PFLAGS)
+# PFLAGS_DEBUG : flags used in debug build
+# PFLAGS_RELEASE : flags used in release build
+#
+# Note:
+# all PFLAGS/PFLAGS_XYZ vars are set to $(PFLAGS_XYZ_DEFAULT)
+# if not set by the user, so the Makefile can assign default
+# values to them.
+#
+# FPC_VERSION : fpc version string, e.g. 2.3.1
+# FPC_VERSION_MAJOR : major version (here 2)
+# FPC_VERSION_MINOR : minor version (here 3)
+# FPC_VERSION_RELEASE: release version (here 1)
+#
+# FPC_PLATFORM : platform of the target (linux/darwin/win32/...)
+# FPC_PROCESSOR : processor of the target, (i386/...)
+# FPC_CPLATFORM : platform of the compiler host, (linux/darwin/win32/...)
+# FPC_CPROCESSOR : processor of the compiler host, (i386/...)
+# FPC_TARGET : FPC_PROCESSOR-FPC_PLATFORM (e.g. i386-linux)
+#
+# FPC_PREFIX : prefix of fpc install path, (default: /usr)
+# FPC_BASE_PATH : $FPC_PREFIX/lib/fpc/$FPC_VERSION
+# FPC_UNIT_PATH : $FPC_BASE_PATH/units/$FPC_TARGET
+#
+# See "fpc -i" for a list of supported platforms and processors
-AC_ARG_VAR(PFLAGS, [Free Pascal Compiler flags (replaces all other flags)])
-AC_ARG_VAR(PFLAGS_DEBUG, [Free Pascal Compiler debug flags @<:@-gl -Coi -Xs- -vew -dDEBUG_MODE@:>@])
-AC_ARG_VAR(PFLAGS_RELEASE, [Free Pascal Compiler release flags @<:@-O2 -Xs -vew@:>@])
-AC_ARG_VAR(PFLAGS_EXTRA, [Free Pascal Compiler additional flags])
+AC_DEFUN([AC_PROG_FPC], [
-dnl set DEBUG/RELEASE flags to default-values if unset
+##
+# User PFLAGS
+##
-dnl - Do not use -dDEBUG because this will enable range-checks that will fail with USDX.
-dnl - Disable -Xs which is defined in fpc.cfg (TODO: is this necessary?).
-dnl - For FPC we have to use DEBUG_MODE instead of DEBUG to enable the apps debug-mode
-dnl because DEBUG enables some additional compiler-flags in fpc.cfg too
-PFLAGS_DEBUG=${PFLAGS_DEBUG-"-gl -Xs- -vew -dDEBUG_MODE"}
-dnl -dRELEASE works too but we define our own settings
-PFLAGS_RELEASE=${PFLAGS_RELEASE-"-O2 -Xs -vew"}
+AC_ARG_VAR(PFLAGS, [Free Pascal Compiler flags (replaces all other flags)])
+AC_ARG_VAR(PFLAGS_BASE, [Free Pascal Compiler base flags, e.g. -Si])
+AC_ARG_VAR(PFLAGS_DEBUG, [Free Pascal Compiler debug flags, e.g. -gl])
+AC_ARG_VAR(PFLAGS_RELEASE, [Free Pascal Compiler release flags, e.g. -O2])
+AC_ARG_VAR(PFLAGS_EXTRA, [Free Pascal Compiler additional flags])
+##
+# Compiler options
+##
AC_ARG_ENABLE(dummy_fpc1,[
Free Pascal Compiler specific options:])
+# fpc path
AC_ARG_WITH(fpc,
[AS_HELP_STRING([--with-fpc=DIR],
[Directory of the FPC executable @<:@PATH@:>@])],
[PPC_PATH=$withval], [])
-FPC_DEBUG="no"
-
-AC_ARG_ENABLE(release,
- [AS_HELP_STRING([--enable-release],
- [Enable FPC release options @<:@default=yes@:>@])],
- [test $enableval = "no" && FPC_DEBUG="yes"], [])
-
-AC_ARG_ENABLE(debug,
- [AS_HELP_STRING([--enable-debug],
- [Enable FPC debug options (= --disable-release) @<:@default=no@:>@])],
- [test $enableval = "yes" && FPC_DEBUG="yes"], [])
-
-AC_ARG_ENABLE(profile,
- [AS_HELP_STRING([--enable-profile],
- [Enable FPC profiling options @<:@default=no@:>@])],
- [PFLAGS_EXTRA="$PFLAGS_EXTRA -pg"], [])
-
-
-dnl ** set PFLAGS depending on whether it is already set by the user
-dnl Note: the user's PFLAGS must *follow* this script's flags
-dnl to enable the user to overwrite the settings.
-if test x${PFLAGS+assigned} = x; then
-dnl PFLAGS not set by the user
- if test x$FPC_DEBUG = xyes; then
- PFLAGS="$PFLAGS_DEBUG"
- PFLAGS_MAKE="[\$](PFLAGS_DEBUG)"
- else
- PFLAGS="$PFLAGS_RELEASE"
- PFLAGS_MAKE="[\$](PFLAGS_RELEASE)"
- fi
-else
-dnl PFLAGS set by the user, just add additional flags
- PFLAGS="$PFLAGS"
- PFLAGS_MAKE="$PFLAGS"
-fi
+# verbose
+AC_ARG_ENABLE(verbose,
+ [AS_HELP_STRING([--disable-verbose],
+ [Disable verbose compiler output @<:@default=no@:>@])],
+ [test x$enableval = xno && PFLAGS_EXTRA="$PFLAGS_EXTRA -v0Bew"], [])
+
+# gprof
+AC_ARG_ENABLE(gprof,
+ [AS_HELP_STRING([--enable-gprof],
+ [Enable profiling with gprof @<:@default=no@:>@])],
+ [test x$enableval = xyes && PFLAGS_EXTRA="$PFLAGS_EXTRA -pg"], [])
+
+# valgrind
+AC_ARG_ENABLE(valgrind,
+ [AS_HELP_STRING([--enable-valgrind],
+ [Enable debugging with valgrind @<:@default=no@:>@])],
+ [test x$enableval = xyes && PFLAGS_EXTRA="$PFLAGS_EXTRA -pv"], [])
-dnl ** find compiler executable
+# heaptrace
+AC_ARG_ENABLE(heaptrace,
+ [AS_HELP_STRING([--enable-heaptrace],
+ [Enable heaptrace (memory corruption detection) @<:@default=no@:>@])],
+ [test x$enableval = xyes && PFLAGS_EXTRA="$PFLAGS_EXTRA -gh"], [])
-PPC_CHECK_PROGS="fpc FPC ppc386 ppc PPC386 ppos2"
+# range-checks
+AC_ARG_ENABLE(rangechecks,
+ [AS_HELP_STRING([--enable-rangechecks],
+ [Enables range-checks @<:@default=no@:>@])],
+ [test x$enableval = xyes && PFLAGS_EXTRA="$PFLAGS_EXTRA -Crtoi"], [])
+
+# allow execstack (see noexecstack compiler check below)
+AC_ARG_ENABLE(noexecstack,
+ [AS_HELP_STRING([--disable-noexecstack],
+ [Allow executable stacks @<:@default=no@:>@])],
+ [], [enable_noexecstack="yes"])
+
+###
+# Find compiler executable
+###
+
+PPC_CHECK_PROGS="fpc FPC ppc386 ppc PPC386"
if test -z "$PPC_PATH"; then
- PPC_PATH=$PATH
- AC_CHECK_PROGS(PPC, $PPC_CHECK_PROGS)
- AC_CHECK_PROGS(FPCMAKE, [fpcmake])
+ PPC_PATH=$PATH
+ AC_CHECK_PROGS(PPC, $PPC_CHECK_PROGS)
+ AC_CHECK_PROGS(FPCMAKE, [fpcmake])
else
- AC_PATH_PROGS(PPC, $PPC_CHECK_PROGS, [], $PPC_PATH)
- AC_PATH_PROGS(FPCMAKE, [fpcmake], [], $PPC_PATH)
+ AC_PATH_PROGS(PPC, $PPC_CHECK_PROGS, [], $PPC_PATH)
+ AC_PATH_PROGS(FPCMAKE, [fpcmake], [], $PPC_PATH)
fi
if test -z "$PPC"; then
- AC_MSG_ERROR([no Free Pascal Compiler found in $PPC_PATH])
+ AC_MSG_ERROR([no Free Pascal Compiler found in $PPC_PATH])
fi
if test -z "$FPCMAKE"; then
- AC_MSG_ERROR([fpcmake not found in $PPC_PATH])
+ AC_MSG_ERROR([fpcmake not found in $PPC_PATH])
fi
-AC_PROG_FPC_WORKS
-AC_PROG_FPC_LINKS
+###
+# Get the FPC compiler info
+###
-dnl *** Get the FPC version and some paths
+AC_MSG_CHECKING([version of fpc])
FPC_VERSION=`${PPC} -iV`
+AX_EXTRACT_VERSION(FPC, $FPC_VERSION)
+AC_SUBST(FPC_VERSION)
+AC_MSG_RESULT([@<:@$FPC_VERSION@:>@])
+
FPC_PLATFORM=`${PPC} -iTO`
FPC_PROCESSOR=`${PPC} -iTP`
+FPC_CPLATFORM=`${PPC} -iSO`
+FPC_CPROCESSOR=`${PPC} -iSP`
-if test "x$prefix" != xNONE; then
- FPC_PREFIX=$prefix
-else
- FPC_PREFIX=$ac_default_prefix
-fi
-FPC_BASE_PATH="${FPC_PREFIX}/lib/fpc/${FPC_VERSION}"
-FPC_UNIT_PATH="${FPC_BASE_PATH}/units/${FPC_PLATFORM}"
+FPC_TARGET=${FPC_PROCESSOR}-${FPC_PLATFORM}
-AC_SUBST(PFLAGS)
-AC_SUBST(PFLAGS_MAKE)
-AC_SUBST(PFLAGS_EXTRA)
-AC_SUBST(PFLAGS_DEBUG)
-AC_SUBST(PFLAGS_RELEASE)
-AC_SUBST(FPC_VERSION)
AC_SUBST(FPC_PLATFORM)
AC_SUBST(FPC_PROCESSOR)
+AC_SUBST(FPC_CPLATFORM)
+AC_SUBST(FPC_CPROCESSOR)
+AC_SUBST(FPC_TARGET)
+
+###
+# Get paths
+###
+
+if test "x$prefix" != xNONE; then
+ FPC_PREFIX=$prefix
+else
+ FPC_PREFIX=$ac_default_prefix
+fi
+
+FPC_BASE_PATH="${FPC_PREFIX}/lib/fpc/${FPC_VERSION}"
+FPC_UNIT_PATH="${FPC_BASE_PATH}/units/${FPC_TARGET}"
AC_SUBST(FPC_PREFIX)
AC_SUBST(FPC_BASE_PATH)
AC_SUBST(FPC_UNIT_PATH)
-])
-PFLAGS_TEST="$PFLAGS $PFLAGS_EXTRA"
+###
+# Compiler checks
+###
-dnl ***
-dnl *** Check if FPC works and can compile a program
-dnl ***
-AC_DEFUN([AC_PROG_FPC_WORKS],
-[AC_CACHE_CHECK([whether the Free Pascal Compiler ($PPC $PFLAGS_TEST) works], ac_cv_prog_ppc_works,
-[
-rm -f conftest*
-echo "program foo; begin writeln; end." > conftest.pp
-${PPC} ${PFLAGS_TEST} conftest.pp >> config.log
+SIMPLE_PROGRAM="program foo; begin writeln; end."
-if test -f conftest || test -f conftest.exe; then
-dnl *** It works!
- ac_cv_prog_ppc_works="yes"
-
-else
- ac_cv_prog_ppc_works="no"
-fi
-rm -f conftest*
-dnl AC_MSG_RESULT($ac_cv_prog_ppc_works)
+# Check if FPC works and can compile a program
+AC_CACHE_CHECK([whether the Free Pascal Compiler works], ac_cv_prog_ppc_works,
+[
+ AC_PROG_FPC_CHECK([ac_cv_prog_ppc_works], [], [$SIMPLE_PROGRAM])
+])
if test x$ac_cv_prog_ppc_works = xno; then
- AC_MSG_ERROR([installation or configuration problem: Cannot create executables.])
+ AC_MSG_ERROR([installation or configuration problem: Cannot create executables.])
fi
-])])
-
-dnl ***
-dnl *** Check if FPC can link with standard libraries
-dnl ***
-AC_DEFUN([AC_PROG_FPC_LINKS],
-[AC_CACHE_CHECK([whether the Free Pascal Compiler ($PPC $PFLAGS_TEST) can link], ac_cv_prog_ppc_works,
+# Check if FPC can link with standard libraries
+AC_CACHE_CHECK([whether the Free Pascal Compiler can link], ac_cv_prog_ppc_links,
[
-rm -f conftest*
-echo "program foo; uses crt; begin writeln; end." > conftest.pp
-${PPC} ${PFLAGS_TEST} conftest.pp >> config.log
-if test -f conftest || test -f conftest.exe; then
- ac_cv_prog_ppc_links="yes"
-else
- ac_cv_prog_ppc_links="no"
-fi
-rm -f conftest*
-AC_MSG_RESULT($ac_cv_prog_ppc_links)
+ AC_PROG_FPC_CHECK([ac_cv_prog_ppc_links], [],
+ [program foo; uses crt; begin writeln; end.]
+ )
+])
if test x$ac_cv_prog_ppc_links = xno; then
- AC_MSG_ERROR([installation or configuration problem: Cannot link with some standard libraries.])
+ AC_MSG_ERROR([installation or configuration problem: Cannot link with some standard libraries.])
fi
-])])
+# Check whether FPC's linker knows "-z noexecstack"
+# FPC does not set the NX-flag on stack memory. Binaries generated with FPC
+# might crash on platforms that require the stack to be non-executable.
+# So we will try to find a workaround here.
+# See http://bugs.freepascal.org/view.php?id=11563
+
+AC_CACHE_CHECK([whether FPC supports -k"-z noexecstack"], ac_cv_prog_ppc_noexecstack,
+[
+ AC_PROG_FPC_CHECK([ac_cv_prog_ppc_noexecstack], [-k"-z noexecstack"], [$SIMPLE_PROGRAM])
+])
+if test x$enable_noexecstack = xyes; then
+ if test x$ac_cv_prog_ppc_noexecstack = xyes; then
+ PFLAGS_EXTRA="$PFLAGS_EXTRA -k\"-z noexecstack\""
+ fi
+fi
+
+# Finally substitute PFLAGS
+
+# set unset PFLAGS_XYZ vars to $(PFLAGS_XYZ_DEFAULT)
+# so the Makefile can define default values to it.
+true ${PFLAGS:=\$(PFLAGS_DEFAULT)}
+true ${PFLAGS_BASE:=\$(PFLAGS_BASE_DEFAULT)}
+true ${PFLAGS_EXTRA:=\$(PFLAGS_EXTRA_DEFAULT)}
+true ${PFLAGS_DEBUG:=\$(PFLAGS_DEBUG_DEFAULT)}
+true ${PFLAGS_RELEASE:=\$(PFLAGS_RELEASE_DEFAULT)}
+
+AC_SUBST(PFLAGS)
+AC_SUBST(PFLAGS_BASE)
+AC_SUBST(PFLAGS_EXTRA)
+AC_SUBST(PFLAGS_DEBUG)
+AC_SUBST(PFLAGS_RELEASE)
+
+])
+
+#######################################
+# Helper functions
+#######################################
+
+# SYNOPSIS
+#
+# AC_PROG_FPC_CHECK(RESULT, FPC_FLAGS, CODE)
+#
+# DESCRIPTION
+#
+# Checks if FPC is able to compile CODE with FPC_FLAGS.
+# The result ("yes" on success, "no" otherwise) is
+# stored in [$RESULT]
+#
+# Parameters:
+# RESULT: Name of result variable
+# FPC_FLAGS: Flags passed to FPC
+# CODE:
+
+AC_DEFUN([AC_PROG_FPC_CHECK],
+[
+ # create test file
+ rm -f conftest*
+ echo "[$3]" > conftest.pp
+
+ # compile test file
+ ${PPC} [$2] conftest.pp >> config.log 2>&1
+
+ # check if test file was compiled
+ if test -f conftest || test -f conftest.exe; then
+ [$1]="yes"
+ else
+ [$1]="no"
+ fi
+
+ # remove test file
+ rm -f conftest*
+])
diff --git a/dists/autogen/m4/macosx_version.m4 b/dists/autogen/m4/macosx_version.m4
new file mode 100644
index 00000000..508dc775
--- /dev/null
+++ b/dists/autogen/m4/macosx_version.m4
@@ -0,0 +1,31 @@
+# This file is part of UltraStar Deluxe
+# Created by the UltraStar Deluxe Team
+
+# SYNOPSIS
+#
+# AC_MACOSX_VERSION
+#
+# DESCRIPTION
+#
+# Determines the Mac OS X and Darwin version.
+#
+# +----------+---------+
+# | Mac OS X | Darwin |
+# +----------+---------+
+# | 10.4 | 8 |
+# | 10.5 | 9 |
+# +----------+---------+
+
+AC_DEFUN([AC_MACOSX_VERSION],
+[
+ AC_MSG_CHECKING([for Mac OS X version])
+ MACOSX_VERSION=`sw_vers -productVersion`
+ AX_EXTRACT_VERSION(MACOSX, $MACOSX_VERSION)
+ AC_MSG_RESULT(@<:@$MACOSX_VERSION@:>@)
+ AC_SUBST(MACOSX_VERSION)
+
+ AC_MSG_CHECKING([for Darwin version])
+ DARWIN_VERSION=`uname -r | cut -f1 -d.`
+ AC_MSG_RESULT(@<:@$DARWIN_VERSION@:>@)
+ AC_SUBST(DARWIN_VERSION)
+]) \ No newline at end of file
diff --git a/dists/autogen/m4/pkg_config_utils.m4 b/dists/autogen/m4/pkg_config_utils.m4
new file mode 100644
index 00000000..903e0fc9
--- /dev/null
+++ b/dists/autogen/m4/pkg_config_utils.m4
@@ -0,0 +1,190 @@
+# This file is part of UltraStar Deluxe
+# Created by the UltraStar Deluxe Team
+
+
+# OVERVIEW
+#
+# PKG_VALUE(VARIABLE_PREFIX, POSTFIX, COMMAND, MODULE, HELP-STRING)
+# PKG_VERSION(VARIABLE_PREFIX, MODULE)
+# PKG_HAVE(VARIABLE_PREFIX, MODULE, [REQUIRED])
+# AX_TRIM(STRING)
+
+# SYNOPSIS
+#
+# PKG_VALUE(VARIABLE_PREFIX, POSTFIX, COMMAND, MODULE, HELP-STRING)
+#
+# DESCRIPTION
+#
+# Calls pkg-config with a given command and stores the result.
+# If the variable was already defined by the user or the package
+# is not present on the system ([$VARIABLE_PREFIX]_HAVE <> yes)
+# pkg-config will not be executed and the old value remains.
+# In addition the variable will be shown on "./configure --help"
+# described by a given help-string.
+#
+# Parameters:
+# - VARIABLE_PREFIX: the prefix for the variables storing
+# information about the package.
+# - POSTFIX: [$VARIABLE_PREFIX]_[$POSTFIX] will contain the value
+# - COMMAND: a pkg-config command, e.g. "variable=prefix"
+# - MODULE: the package pkg-config will retrieve info from
+# - HELP-STRING: description of the variable
+#
+# Sets:
+# [$VARIABLE_PREFIX]_[$POSTFIX] # value (AC_SUBST)
+
+AC_DEFUN([PKG_VALUE],
+[
+ AC_ARG_VAR([$1]_[$2], [$5, overriding pkg-config])
+ # check if variable was defined by the user
+ if test -z "$[$1]_[$2]"; then
+ # if not, get it from pkg-config
+ if test x$[$1][_HAVE] = xyes; then
+ PKG_CHECK_EXISTS([$4],
+ [[$1]_[$2]=`$PKG_CONFIG --[$3] --silence-errors "$4"`],
+ [# print error message and quit
+ err_msg=`$PKG_CONFIG --errors-to-stdout --print-errors "$4"`
+ AC_MSG_ERROR(
+[
+
+$err_msg
+
+If --with-[$1]=nocheck is defined the environment variable
+[$1]_[$2]
+must be set to avoid the need to call pkg-config.
+
+See the pkg-config man page for more details.
+])
+
+ ])
+ fi
+ fi
+ AC_SUBST([$1]_[$2])
+])
+
+# SYNOPSIS
+#
+# PKG_VERSION(VARIABLE_PREFIX, MODULE)
+#
+# DESCRIPTION
+#
+# Retrieves the version of a package
+#
+# Parameters:
+# - VARIABLE_PREFIX: the prefix for the variables storing
+# information about the package.
+# - MODULE: package name according to pkg-config
+#
+# Sets:
+# [$VARIABLE_PREFIX]_VERSION # full version string
+# # (format: "major.minor.release")
+#
+# [$VARIABLE_PREFIX]_VERSION_MAJOR # major version number
+# [$VARIABLE_PREFIX]_VERSION_MINOR # minor version number
+# [$VARIABLE_PREFIX]_VERSION_RELEASE # release version number
+#
+# [$VARIABLE_PREFIX]_VERSION_INT # integer representation:
+# # MMMmmmrrr (M:major,m:minor,r:release)
+
+AC_DEFUN([PKG_VERSION],
+[
+ if test x$[$1][_HAVE] = xyes; then
+ AC_MSG_CHECKING([version of $1])
+ PKG_VALUE([$1], [VERSION], [modversion], [$2], [version of $1])
+ AC_MSG_RESULT(@<:@$[$1][_VERSION]@:>@)
+ else
+ [$1][_VERSION]="0.0.0"
+ fi
+ AX_EXTRACT_VERSION([$1], $[$1][_VERSION])
+])
+
+
+# SYNOPSIS
+#
+# AX_TRIM(STRING)
+#
+# DESCRIPTION
+#
+# Removes surrounding whitespace
+
+AC_DEFUN([AX_TRIM],
+[
+ echo "[$1]" | $SED 's/^[[ \t]]*//' | $SED 's/[[ \t]]*$//'
+])
+
+# SYNOPSIS
+#
+# PKG_HAVE(VARIABLE_PREFIX, MODULE, [REQUIRED])
+#
+# DESCRIPTION
+#
+# Checks with pkg-config if a package exists and retrieves
+# information about it.
+#
+# Parameters:
+# - VARIABLE_PREFIX: the prefix for the variables storing information about the package.
+# - MODULE: package name according to pkg-config
+# - REQUIRED: if true, the configure-script is aborted if the package was not found
+#
+# Uses:
+# with_[$VARIABLE_PREFIX]: whether and how the package should be checked for
+# "check": check for the package but do not abort if it does not exist (default)
+# "no": do not check for the package (sets _HAVE to "no" and _VERSION to "0.0.0")
+# "yes": check for the package and abort if it does not exist
+# "nocheck": do not check for the package (sets _HAVE to "yes")
+#
+# Sets:
+# [$VARIABLE_PREFIX]_HAVE # package is available (values: "yes"|"no")
+# [$VARIABLE_PREFIX]_LIBS # linker flags (e.g. -Lmylibdir -lmylib)
+# [$VARIABLE_PREFIX]_LIBDIRS # library dirs (e.g. -Lmylibdir)
+
+AC_DEFUN([PKG_HAVE],
+[
+ have_lib="no"
+ AC_MSG_CHECKING([for $2])
+ if test x"$with_[$1]" = xnocheck; then
+ # do not call pkg-config, use user settings
+ have_lib="yes"
+ elif test x"$with_[$1]" != xno; then
+ # check if package exists
+ PKG_CHECK_EXISTS([$2], [
+ have_lib="yes"
+ [$1][_LIBS]=`$PKG_CONFIG --libs --silence-errors "$2"`
+ [$1][_LIBDIRS]=`$PKG_CONFIG --libs-only-L --silence-errors "$2"`
+ [$1][_LIBDIRS]=`AX_TRIM($[$1][_LIBDIRS])`
+ # add library directories to LIBS (ignore *_LIBS for now)
+ if test -n "$[$1][_LIBDIRS]"; then
+ LIBS="$LIBS $[$1][_LIBDIRS]"
+ fi
+ ])
+ fi
+ if test x$have_lib = xyes; then
+ [$1][_HAVE]="yes"
+ if test -n "$[$1][_LIBDIRS]"; then
+ # show additional lib-dirs
+ AC_MSG_RESULT(yes [(]$[$1][_LIBDIRS][)])
+ else
+ AC_MSG_RESULT(yes)
+ fi
+ else
+ [$1][_HAVE]="no"
+ AC_MSG_RESULT(no)
+
+ # check if package is required
+ if test x$3 = xyes -o x"$with_[$1]" = xyes ; then
+ # print error message and quit
+ err_msg=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"`
+ AC_MSG_ERROR(
+[
+
+$err_msg
+
+Alternatively, you may set --with-[$1]=nocheck and the environment
+variables [$1]_[[...]] (see configure --help)
+to appropriate values to avoid the need to call pkg-config.
+
+See the pkg-config man page for more details.
+])
+ fi
+ fi
+])
diff --git a/artwork/usdx_icon.svg b/icons/ultrastardx-icon.svg
index 49719bba..49719bba 100644
--- a/artwork/usdx_icon.svg
+++ b/icons/ultrastardx-icon.svg
diff --git a/src/Makefile.in b/src/Makefile.in
index 8bdbca40..534fe73f 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -4,11 +4,16 @@
#################################################
@SET_MAKE@
+SHELL = /bin/sh
#################################################
# Standard definitions
#################################################
+prefix ?= @prefix@
+exec_prefix ?= @exec_prefix@
+datarootdir ?= @datarootdir@
+datadir ?= @datadir@
# project root-dir (directory of configure script)
top_srcdir ?= @top_srcdir@
# project src-dir (directory of the current Makefile)
@@ -27,6 +32,14 @@ RM ?= rm -f
RM_REC ?= $(RM) -r
#################################################
+# General package configuration
+#################################################
+
+USDX_PACKAGE_NAME := @PACKAGE_NAME@
+USDX_VERSION := @PACKAGE_VERSION@
+USDX_TARNAME := @PACKAGE_TARNAME@
+
+#################################################
# USDX Paths
#################################################
@@ -36,6 +49,8 @@ USDX_TOOLS_DIR := $(top_srcdir)/tools
USDX_BUILD_DIR := $(top_srcdir)/build
USDX_LIB_DIR := $(USDX_SRC_DIR)/lib
+INSTALL_DATADIR := $(datadir)/$(USDX_PACKAGE_NAME)
+
#################################################
# RC -> resource.inc
#################################################
@@ -67,13 +82,54 @@ PCUNIT_FLAGS := -FU$(PCUNIT_DIR)
# Directories added to the includes path
PINC_FLAGS := -Fi$(USDX_LIB_DIR)/JEDI-SDL/SDL/Pas
-PFLAGS_BASE ?= -S2gi -vB
-PFLAGS_EXTRA ?= @PFLAGS_EXTRA@
+##
+# PFLAGS
+##
+
+# Defined on debug mode
+ENABLE_DEBUG := @ENABLE_DEBUG@
+
+# Note:
+# - PFLAGS/PFLAGS_* defaults to $(PFLAGS_XYZ_DEFAULT) if not set by the user
+# - if PFLAGS is defined, PFLAGS_* will be ignored on "make all"
+PFLAGS ?= @PFLAGS@
+PFLAGS_BASE ?= @PFLAGS_BASE@
PFLAGS_DEBUG ?= @PFLAGS_DEBUG@
PFLAGS_RELEASE ?= @PFLAGS_RELEASE@
-# user-flags (specified with configure) must be last in
-# list to overwrite defaults (e.g. the "-"-option: -Xs-).
-PFLAGS ?= $(PFLAGS_BASE) @PFLAGS_MAKE@ $(PFLAGS_EXTRA)
+
+# Do not overwrite, just add extra flags
+PFLAGS_EXTRA += @PFLAGS_EXTRA@
+
+# Default PFLAGS, used if PFLAGS/PFLAGS_* was not set by the user
+# - Do not use -dDEBUG because it will enable unwanted features
+# - Do not strip executable (-Xs, set by fpc.cfg) to be GNU make conformant
+# - Use DEBUG_MODE instead of DEBUG to avoid enabling the fpc.cfg DEBUG preset
+# - The flag -vB appends the full path to filenames
+# - Note that fpc.cfg already defines -vinw, so add -v0 first
+# - The stack check (-Ct) might not work with enabled threading
+# - Do we need -Coi?
+PFLAGS_BASE_DEFAULT := -Si -Sg- -Sc- -v0Binwe
+PFLAGS_DEBUG_DEFAULT := -Xs- -g -gl -dDEBUG_MODE
+PFLAGS_RELEASE_DEFAULT := -Xs- -O2
+PFLAGS_EXTRA_DEFAULT :=
+
+# Debug/Release mode flags
+# Note that flags will overwrite previously specified flags,
+# e.g. "-vinwe -vi-" is the same as "-vnwe"
+PFLAGS_DEBUG_ALL := $(PFLAGS_BASE) $(PFLAGS_DEBUG) $(PFLAGS_EXTRA)
+PFLAGS_RELEASE_ALL := $(PFLAGS_BASE) $(PFLAGS_RELEASE) $(PFLAGS_EXTRA)
+
+# Choose default PFLAGS, depending on debug mode.
+# Only used if PFLAGS was not set by the user.
+ifdef ENABLE_DEBUG
+PFLAGS_DEFAULT := $(PFLAGS_DEBUG_ALL)
+else
+PFLAGS_DEFAULT := $(PFLAGS_RELEASE_ALL)
+endif
+
+###
+# linker and library settings
+###
LIBS ?= @LIBS@
LDFLAGS ?= @LDFLAGS@
@@ -82,6 +138,8 @@ ifneq ($(linkflags),)
PLINKFLAGS := -k"$(linkflags)"
endif
+PFLAGS_ALL = $(PFLAGS) $(PDEFINES) $(PLINKFLAGS) $(PINC_FLAGS) $(PUNIT_FLAGS) $(PCUNIT_FLAGS)
+
#################################################
# USDX project config
#################################################
@@ -98,7 +156,7 @@ USDX_BIN := $(USDX_GAME_DIR)/$(USDX_BIN_NAME)
PROJECTM_CWRAPPER_DIR := $(USDX_LIB_DIR)/projectM/cwrapper
PROJECTM_CWRAPPER_LIB := $(PROJECTM_CWRAPPER_DIR)/libprojectM-cwrapper.a
-USE_PROJECTM_CWRAPPER = @USE_PROJECTM_CWRAPPER@
+USE_PROJECTM_CWRAPPER := @USE_PROJECTM_CWRAPPER@
#################################################
# Static libs
@@ -113,69 +171,76 @@ endif
# general targets
#################################################
-INC_FILES = $(shell find . -name "*.inc")
-PAS_FILES = $(shell find . -name "*.pas" -o -name "*.pp")
-BIN_DEPS =
-
.PHONY: all
-all: rebuild
-
-# one shot debug build
-.PHONY: debug
-debug: PFLAGS := $(PFLAGS_BASE) $(PFLAGS_DEBUG) $(PFLAGS_EXTRA)
-debug: rebuild
-
-# one shot release build
-.PHONY: release
-release: PFLAGS := $(PFLAGS_BASE) $(PFLAGS_RELEASE) $(PFLAGS_EXTRA)
-release: rebuild
-
-# build, but always clean old data before compiling.
-# FPC does not reliably recognize changes in .inc-files, static libs
-# (and maybe even conditional .pas) dependencies. This might result
-# in corrupted builds and renders debugging difficult.
-# Clean if any (%) file changed.
+all: build
+
+# One shot debug build (always rebuild)
+# Note: we cannot set PFLAGS and call build directly,
+# as target specific flags are not passed at recursive
+# make calls. So call debug-build first.
+.PHONY: debug debug-build
+debug: clean_obj
+ $(MAKE) debug-build
+
+debug-build: PFLAGS := $(PFLAGS_DEBUG_ALL)
+debug-build: build
+
+# One shot release build (always rebuild)
+# Note: we cannot set PFLAGS and call build directly,
+# as target specific flags are not passed at recursive
+# make calls. So call release-build first.
+.PHONY: release release-build
+release: clean_obj
+ $(MAKE) release-build
+
+release-build: PFLAGS := $(PFLAGS_RELEASE_ALL)
+release-build: build
+
+# Always rebuild, even if no file changed.
.PHONY: rebuild
-rebuild: CLEANON_PATTERN := %
-rebuild: $(USDX_BIN)
-
-# Use FPC to determine if the sources have to be rebuild.
-# This does not work if an .inc or a static lib (e.g. .a) changed so we will
-# manually clean in these cases. FPC might even miss some changes in
-# .pas files so we prefer the rebuild target.
-# Clean if an inc-file (%.inc) or static lib (%.a) changed.
+rebuild: clean_obj
+ $(MAKE) build
+
+# Build if files changed. Always clean old data before compiling.
+# FPC does not reliably recognize changes, neither in .pas,
+# .inc-files nor static libs (.a/.o). This might result in corrupted
+# builds and renders debugging difficult (because FPC uses outdated
+# .ppu/.o data of files that have been changed).
.PHONY: build
-build: CLEANON_PATTERN := %.inc %.a
build: $(USDX_BIN)
#################################################
# build
#################################################
-# After expansion of the expression, check_clean will
-# contain the first changed prerequisite ($?) that matches
-# CLEANON_PATTERN. It is used to check if any prerequisite of CLEANON_PATTERN
-# type changed (we just return the first word to avoid spaces in
-# the result that might crash "test x$(check_clean)").
-check_clean = $(firstword $(filter $(CLEANON_PATTERN), $?))
+SRC_FILES = $(shell find $(srcdir) -name "*.inc" -o -name "*.pas" -o -name "*.pp")
+
+# To conform to the GNU Coding Standards, INSTALL_DATADIR is
+# not hardcoded so $prefix and $datadir can be changed at any
+# execution of this Makefile.
+# Paths cannot be passed to fpc via -d as with gcc's -D parameter.
+# We use an intermediate file instead.
+# See [info autoconf], "19.5 How Do I `#define' Installation Directories?"
+.PHONY: paths.inc
+paths.inc:
+ echo "INSTALL_DATADIR = '$(INSTALL_DATADIR)';" >$@
-$(USDX_BIN): $(RESOURCE_FILE) $(USDX_PROJ) $(STATIC_LIBS) $(INC_FILES) $(PAS_FILES)
+# check if any src-file changed and rebuild
+$(USDX_BIN): $(RESOURCE_FILE) $(USDX_PROJ) $(STATIC_LIBS) $(INC_FILES) $(PAS_FILES) paths.inc
@echo "==================================="
@echo "Changed files:"
@echo "$?"
@echo "==================================="
+ @echo "-----------------------------------"
+ @echo "Clean old object data..."
+
+ $(MAKE) clean_obj
-# Checks if a rebuild is required.
-# This is the case if any file matching $CLEANON_PATTERN changed.
- @if test x$(check_clean) != x; then \
- echo "-----------------------------------"; \
- echo "Clean objects..."; \
- $(MAKE) clean_obj; \
- echo "-----------------------------------"; \
- fi
+ @echo "-----------------------------------"
$(MKDIR) "$(PCUNIT_DIR)"
- $(PPC) $(strip $(PFLAGS) $(PDEFINES) $(PLINKFLAGS) $(PINC_FLAGS) $(PUNIT_FLAGS) $(PCUNIT_FLAGS)) -o$@ $(USDX_PROJ)
+ $(MAKE) paths.inc
+ $(PPC) $(strip $(PFLAGS_ALL)) -o$@ $(USDX_PROJ)
#################################################
# Resource-file
@@ -191,6 +256,7 @@ $(RESOURCE_FILE): $(RC_FILE)
.PHONY: clean
clean: clean_obj clean_res
+ $(RM) paths.inc
.PHONY: clean_res
clean_res:
@@ -199,7 +265,6 @@ clean_res:
.PHONY: clean_obj
clean_obj: clean_bin
$(RM_REC) "$(PCUNIT_DIR)"
- -rmdir "$(USDX_BUILD_DIR)"
.PHONY: clean_bin
clean_bin:
diff --git a/src/base/UPlatformLinux.pas b/src/base/UPlatformLinux.pas
index 3227e4f8..9095b192 100644
--- a/src/base/UPlatformLinux.pas
+++ b/src/base/UPlatformLinux.pas
@@ -41,6 +41,9 @@ uses
SysUtils,
ULog;
+const
+ {$I paths.inc}
+
procedure TPlatformLinux.Init;
begin
inherited Init();
@@ -54,7 +57,7 @@ end;
* reside in the directory of the executable.
* - It is global if the game was installed (e.g. to /usr/bin) and
* the resources are in a separate folder (e.g. /usr/share/ultrastardx)
- * which name is stored in the INSTALL_DATADIR constant in config-linux.inc.
+ * which name is stored in the INSTALL_DATADIR constant in paths.inc.
*
* Sets UseLocalDirs to true if the game is executed locally, false otherwise.
*}
diff --git a/src/config.inc.in b/src/config.inc.in
index 870c35fd..004f8413 100644
--- a/src/config.inc.in
+++ b/src/config.inc.in
@@ -3,12 +3,6 @@
* @configure_input@
*****************************************************************}
-{* Paths *}
-
-{$IFDEF IncludeConstants}
- INSTALL_DATADIR = '@INSTALL_DATADIR@';
-{$ENDIF}
-
{* Libraries *}
{$@DEFINE_HAVE_FFMPEG@ HaveFFmpeg}