diff options
author | tobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2008-04-22 15:34:31 +0000 |
---|---|---|
committer | tobigun <tobigun@b956fd51-792f-4845-bead-9b4dfca2ff2c> | 2008-04-22 15:34:31 +0000 |
commit | 69892748d7d18851c9cd7c49b351bbf86d2e2325 (patch) | |
tree | 0f404ff64eb9c04cdb6bfa0d6bf3964cd14ef6fc /Game/Code/m4 | |
parent | aa3fcb3f5241731357fdc4b78817c37b36ee8fe7 (diff) | |
download | usdx-69892748d7d18851c9cd7c49b351bbf86d2e2325.tar.gz usdx-69892748d7d18851c9cd7c49b351bbf86d2e2325.tar.xz usdx-69892748d7d18851c9cd7c49b351bbf86d2e2325.zip |
New Makefile:
- no need to edit config-linux.inc for non-standard installation
- "make release", "make debug" targets, so reconfiguring with --enable/disable-debug is not necessary anymore
- linkerflags (environment variables LDFLAGS and LIBS) (e.g. from pkg-config) like "-Lpath" or "-Wl,-rpath,'path'" are passed to fpc
- some cleanup
git-svn-id: svn://svn.code.sf.net/p/ultrastardx/svn/trunk@1028 b956fd51-792f-4845-bead-9b4dfca2ff2c
Diffstat (limited to 'Game/Code/m4')
-rw-r--r-- | Game/Code/m4/fpc.m4 | 106 |
1 files changed, 64 insertions, 42 deletions
diff --git a/Game/Code/m4/fpc.m4 b/Game/Code/m4/fpc.m4 index 51ebfc63..e2b0cfbc 100644 --- a/Game/Code/m4/fpc.m4 +++ b/Game/Code/m4/fpc.m4 @@ -16,77 +16,93 @@ dnl ** AC_DEFUN([AC_PROG_FPC], [ -AC_ARG_VAR(PFLAGS, [Free Pascal Compiler flags]) +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]) + +dnl set DEBUG/RELEASE flags to default-values if unset + +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 -Cit -Xs- -vew -dDEBUG_MODE"} +dnl -dRELEASE works too but we define our own settings +PFLAGS_RELEASE=${PFLAGS_RELEASE-"-O2 -Xs -vew"} + AC_ARG_ENABLE(dummy_fpc1,[ Free Pascal Compiler specific options:]) AC_ARG_WITH(fpc, - [AS_HELP_STRING([--with-fpc], + [AS_HELP_STRING([--with-fpc=DIR], [Directory of the FPC executable @<:@PATH@:>@])], [PPC_PATH=$withval], []) FPC_DEBUG="no" -AC_ARG_ENABLE(debug, - [AS_HELP_STRING([--enable-debug], - [Enable FPC debug options @<:@default=no@:>@])], - [FPC_DEBUG="yes"], []) - - AC_ARG_ENABLE(release, [AS_HELP_STRING([--enable-release], - [Enable FPC release options (same as --enable-debug=no)])], - [FPC_DEBUG="no"], []) - -dnl do not use -dDEBUG because this will enable range-checks -dnl that will fail with USDX. -dnl we have to disable -Xs which is defined in fpc.cfg. -AC_ARG_WITH(debug-flags, - [AS_HELP_STRING([--with-debug-flags], - [FPC debug flags @<:@-gl -Coi -Xs- -vew@:>@])], - [PFLAGS_DEBUG="$withval"], - [PFLAGS_DEBUG="-gl -Cit -Xs- -vew"]) + [Enable FPC release options @<:@default=yes@:>@])], + [test $enableval = "no" && FPC_DEBUG="yes"], []) -dnl -dRELEASE works too but we define our own settings -AC_ARG_WITH(release-flags, - [AS_HELP_STRING([--with-release-flags], - [FPC release flags @<:@-O2 -Xs -vew@:>@])], - [PFLAGS_RELEASE="$withval"], - [PFLAGS_RELEASE="-O2 -Xs -vew"]) - -dnl the user's PFLAGS must *follow* this script's flags -dnl to enable the user to overwrite the settings. -if test x$FPC_DEBUG = xyes; then - PFLAGS="$PFLAGS_DEBUG $PFLAGS" -else - PFLAGS="$PFLAGS_RELEASE $PFLAGS" -fi +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])], - [PFLAGS="-pg $PFLAGS"], []) + [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 + +dnl ** find compiler executable PPC_CHECK_PROGS="fpc FPC ppc386 ppc PPC386 ppos2" if test -z "$PPC_PATH"; then 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) fi if test -z "$PPC"; then 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]) +fi AC_PROG_FPC_WORKS AC_PROG_FPC_LINKS dnl *** Get the FPC version and some paths -FPC_VERSION=`${PPC} ${PFLAGS} -iV` -FPC_PLATFORM=`${PPC} ${PFLAGS} -iTO` -FPC_PROCESSOR=`${PPC} ${PFLAGS} -iTP` +FPC_VERSION=`${PPC} -iV` +FPC_PLATFORM=`${PPC} -iTO` +FPC_PROCESSOR=`${PPC} -iTP` + if test "x$prefix" != xNONE; then FPC_PREFIX=$prefix else @@ -94,27 +110,33 @@ else fi FPC_BASE_PATH="${FPC_PREFIX}/lib/fpc/${FPC_VERSION}" FPC_UNIT_PATH="${FPC_BASE_PATH}/units/${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_PREFIX) AC_SUBST(FPC_BASE_PATH) AC_SUBST(FPC_UNIT_PATH) ]) +PFLAGS_TEST="$PFLAGS $PFLAGS_EXTRA" 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) works], ac_cv_prog_ppc_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} conftest.pp >> config.log +${PPC} ${PFLAGS_TEST} conftest.pp >> config.log if test -f conftest || test -f conftest.exe; then dnl *** It works! @@ -135,11 +157,11 @@ 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) can link], ac_cv_prog_ppc_works, +[AC_CACHE_CHECK([whether the Free Pascal Compiler ($PPC $PFLAGS_TEST) can link], ac_cv_prog_ppc_works, [ rm -f conftest* echo "program foo; uses crt; begin writeln; end." > conftest.pp -${PPC} ${PFLAGS} conftest.pp >> config.log +${PPC} ${PFLAGS_TEST} conftest.pp >> config.log if test -f conftest || test -f conftest.exe; then ac_cv_prog_ppc_links="yes" else |