aboutsummaryrefslogtreecommitdiff
path: root/common
diff options
context:
space:
mode:
authorBryan Jurish <mukau@users.sourceforge.net>2009-04-26 22:36:09 +0000
committerBryan Jurish <mukau@users.sourceforge.net>2009-04-26 22:36:09 +0000
commit0eeb1dc9455f8976a988e218bec446fdba5574fe (patch)
treec21eeee24f3c4573a85a003eccb8df2e4fa517e4 /common
parentf37557d096b3bdf15a962d382df5f03b34516202 (diff)
+ yet more quoted-command-line-macro hell
svn path=/trunk/externals/moocow/; revision=11161
Diffstat (limited to 'common')
-rw-r--r--common/m4/ax_hack_cflags.m475
-rw-r--r--common/m4/ax_pd_external.m467
2 files changed, 129 insertions, 13 deletions
diff --git a/common/m4/ax_hack_cflags.m4 b/common/m4/ax_hack_cflags.m4
new file mode 100644
index 0000000..7e735a8
--- /dev/null
+++ b/common/m4/ax_hack_cflags.m4
@@ -0,0 +1,75 @@
+#-*- Mode: autoconf -*-
+#
+# SYNOPSIS
+#
+# AX_DISTRIBUTE_CFLAGS([$FLAGS], [cppflagsVar], [cflagsVar])
+# + distributes $FLAGS among $cppflagsVar and $cflagsVar
+#
+# AX_SAFE_CFLAGS([$FLAGS], [safeVar], [unsafeVar]).
+# + distributes $FLAGS among $safeVar and $unsafeVar
+#
+# LAST MODIFICATION
+#
+# Sun, 26 Apr 2009 23:53:21 +0200
+#
+# COPYLEFT
+#
+# Copyright (c) 2009 Bryan Jurish <moocow@ling.uni-potsdam.de>
+#
+# Copying and distribution of this file, with or without
+# modification, are permitted in any medium without royalty provided
+# the copyright notice and this notice are preserved.
+
+
+# AX_DISTRIBUTE_CFLAGS($FLAGS, CPPFLAGS, CFLAGS)
+# + distribute $FLAGS between $CPPFLAGS and $CFLAGS
+AC_DEFUN([AX_DISTRIBUTE_CFLAGS],
+[
+ ##vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
+ ## BEGIN AX_DISTRIBUTE_CFLAGS
+ axdf_cppflags=
+ axdf_cflags=
+
+ for axdf_flag in $1
+ do
+ case "$axdf_flag" in
+ -undef|-nostdinc*|-I*|-D*|-U*|-E|-P|-C)
+ axdf_cppflags="$axdf_cppflags $axdf_flag"
+ ;;
+ *)
+ axdf_cflags="$axdf_cflags $axdf_flag"
+ ;;
+ esac
+ done
+
+ test x$2 != x && $2="$$2 $axdf_cppflags"
+ test x$3 != x && $3="$$3 $axdf_cflags"
+
+ ## END AX_DISTRIBUTE_CFLAGS
+ ##^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+])
+
+# AX_SAFE_CFLAGS($FLAGS, SAFE, UNSAFE)
+# + distribute $FLAGS between $SAFE and $UNSAFE
+AC_DEFUN([AX_SAFE_CFLAGS],
+[
+ ##vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
+ ## BEGIN AX_SAFE_CFLAGS
+ axsf_safe=
+ axsf_unsafe=
+
+ for axsf_flag in $1
+ do
+ axsf_flag_tmp=`echo $axsf_flag | sed -e 's/[[ '\''\"\(\)]]//g'`
+ if test "${axsf_flag_tmp}" = "${axsf_flag}"; then
+ axsf_safe="$axsf_safe $axsf_flag"
+ else
+ axsf_unsafe="$axsf_unsafe $axsf_flag"
+ fi
+ done
+
+ test x$2 != x && $2="$$2 $axsf_safe"
+ test x$3 != x && $3="$$3 $axsf_unsafe"
+ ## END AX_SAFE_CFLAGS
+ ##^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+])
diff --git a/common/m4/ax_pd_external.m4 b/common/m4/ax_pd_external.m4
index 5218936..25864ee 100644
--- a/common/m4/ax_pd_external.m4
+++ b/common/m4/ax_pd_external.m4
@@ -1,15 +1,19 @@
+#-*- Mode: autoconf -*-
#
# SYNOPSIS
#
-# TODO: AX_PD_EXTERNAL()
+# AX_PD_EARLY() ##-- call this early on
+# AX_PD_EXTERNAL() ##-- call this soon-ish
+# AX_PD_LATE() ##-- call this after running your own tests
#
# DESCRIPTION
#
-# This macro provides tests, options, & flags for building a Pd
-# external.
+# The AX_PD_EXTERNAL macro provides tests, options, & flags for
+# building a Pd external.
#
-# User flags (should already be set at call time)
-# UCFLAGS, UCPPFLAGS, ULDFLAGS
+# CAVEATS:
+#
+# You should call AX_PD_EARLY() before calling AC_PROG_CC()
#
# Pd directories
# AC_ARG_WITH(pd-dir) : default: "\${prefix}/pd"
@@ -50,6 +54,12 @@
# PDEXT : platform-specific external extension (without leading ".")
# LIBS : additional libs required for building pd externals (win32 only)
#
+# Flag parsing:
+# CFLAGS : has CPPFLAGS filtered out
+# CPPFLAGS : has CFLAGS appended and unsafe flags filtered out
+# EXTRA_CPPFLAGS : gets "unsafe" user CPPFLAGS appended (quotes etc.)
+# AM_CPPFLAGS : gets \${EXTRA_CPPFLAGS} appended (make-side)
+#
# EXEEXT hacks:
# AC_SUBST(pd_buildext)
#
@@ -67,17 +77,13 @@
# modification, are permitted in any medium without royalty provided
# the copyright notice and this notice are preserved.
+##==============================================================================
AC_DEFUN([AX_PD_EXTERNAL],
[
##vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
## prerequisites
AC_PREREQ(2.5)
- ##-- save user's CFLAGS,CPPFLAGS (do this before calling AX_PD_EXTERNAL!)
- #test -z "$UCPPFLAGS" && UCPPFLAGS="$CPPFLAGS"
- #test -z "$UCFLAGS" && UCFLAGS="$CFLAGS"
- #test -z "$ULDFLAGS" && ULDFLAGS="$LDFLAGS"
-
##-- Programs, prefix
AC_PROG_CC
AC_PROG_INSTALL
@@ -371,11 +377,46 @@ AC_DEFUN([AX_PD_EXTERNAL],
AC_SUBST(PDEXT_OFLAGS)
AC_SUBST(PDEXT_WFLAGS)
- ##-- add defaults to user flags
+ ## END platform-dependent variables
+ ##^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+])
+
+##==============================================================================
+AC_DEFUN([AX_PD_EARLY],
+[
+ ##-- parse user's CFLAGS,CPPFLAGS
+ dnl AC_MSG_NOTICE([parsing user *FLAGS])
+ dnl AC_MSG_NOTICE([(input) CFLAGS=$CFLAGS])
+ dnl AC_MSG_NOTICE([(input) CPPFLAGS=$CPPFLAGS])
+
+ AX_DISTRIBUTE_CFLAGS([$CFLAGS],CPPFLAGS,cflags)
+ AX_SAFE_CFLAGS([$CPPFLAGS],cppflags,EXTRA_CPPFLAGS)
+ CFLAGS="$cflags"
+ CPPFLAGS="$cppflags"
+
+ dnl AC_MSG_NOTICE([(output) CFLAGS=$CFLAGS])
+ dnl AC_MSG_NOTICE([(output) CPPFLAGS=$CPPFLAGS])
+ dnl AC_MSG_NOTICE([(output) EXTRA_CPPFLAGS=$EXTRA_CPPFLAGS])
+ AM_CPPFLAGS="\${EXTRA_CPPFLAGS}"
+ AC_SUBST(EXTRA_CPPFLAGS)
+ AC_SUBST(AM_CPPFLAGS)
+
+ ##-- save (hacked) user's CFLAGS,CPPFLAGS
+ UCPPFLAGS="$CPPFLAGS"
+ UCFLAGS="$CFLAGS"
+ ULDFLAGS="$LDFLAGS"
+])
+
+##==============================================================================
+AC_DEFUN([AX_PD_LATE],
+[
+ ##-- add platform defaults to user flags
CPPFLAGS="$UCPPFLAGS $PDEXT_IFLAGS $PDEXT_DFLAGS"
CFLAGS="$UCFLAGS $PDEXT_OFLAGS $PDEXT_AFLAGS $PDEXT_WFLAGS"
LDFLAGS="$ULDFLAGS $PDEXT_LFLAGS"
- ## END platform-dependent variables
- ##^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ AC_MSG_NOTICE([set CPPFLAGS="$CPPFLAGS"])
+ AC_MSG_NOTICE([set EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS"])
+ AC_MSG_NOTICE([set CFLAGS="$CFLAGS])
+ AC_MSG_NOTICE([set LDFLAGS="$LDFLAGS"])
])