File: ax_pd_external.m4

package info (click to toggle)
pd-flite 0.02.3-3
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 524 kB
  • ctags: 63
  • sloc: sh: 787; ansic: 166; makefile: 27
file content (451 lines) | stat: -rw-r--r-- 13,223 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
#-*- Mode: autoconf -*-
#
# SYNOPSIS
#
#   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
#
#   The AX_PD_EXTERNAL macro provides tests, options, & flags for
#   building a Pd external.
#
# CAVEATS:
#   
#   You should call AX_PD_EARLY() before calling AC_PROG_CC()
#
# Pd directories
#   AC_ARG_WITH(pd-dir)     : default: "\${prefix}/pd"
#   AC_ARG_WITH(pd-include) : sets PDEXT_IFLAGS, AM_IFLAGS
#   AC_ARG_WITH(pd-extdir)  : default $pddir/externs
#   AC_SUBST(pddir)
#   AC_SUBST(pddocdir)
#   AC_SUBST(pdextdir)
#    + aliases: pdexternsdir, pdexecdir
#
# Header tests:
#   AC_CHECK_HEADER(m_pd.h)
#
# Object Externals vs. multi-object libraries:
#   AC_ARG_ENABLE(object-externals, ...) ##-- set shell var want_object_externals
#   AC_DEFINE(WANT_OBJECT_EXTERNALS,...)
#   AM_CONDITIONAL(WANT_OBJECT_EXTERNALS)
#
# Debugging
#   AC_ARG_ENABLE(debug)
#   AC_DEFINE(ENABLE_DEBUG)
#   AC_SUBST(ENABLE_DEBUG)
#
# Build time:
#   AC_DEFINE_UNQUOTED(PACKAGE_BUILD_DATE)
#   AC_DEFINE_UNQUOTED(PACKAGE_BUILD_USER)
#
# Versioning
#   AC_SUBST(PACKAGE_VERSION,PACKAGE_NAME,BUGREPORT)
#
# Platform-dependent flags (shell vars and AC_SUBST)
#   LD            : linker
#   PDEXT_LFLAGS  : linker flags, appended to LDFLAGS
#   PDEXT_AFLAGS  : compiler flags for alpha, appended to CFLAGS
#   PDEXT_OFLAGS  : compiler optimization flags, appended to CFLAGS
#   PDEXT_DFLAGS  : preprocessor flags, appended to CPPFLAGS
#   PDEXT_WFLAGS  : compiler warning flags, appended to CFLAGS (gcc only)
#   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)
#   
#
#
# LAST MODIFICATION
#
#   Sat, 14 Feb 2009 10:06:12 +0100
#
# 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.

##==============================================================================
AC_DEFUN([AX_PD_EXTERNAL],
[
 ##vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
 ## prerequisites
 AC_PREREQ(2.5)

 ##-- Programs, prefix
 AC_PROG_CC
 AC_PROG_INSTALL
 AC_PROG_LN_S
 dnl AC_PREFIX_DEFAULT(/usr/local)

 ##-- use libtool (but don't build static libraries)
 ##  + in Makefile.am, do:
 ##    pdexterns_LTLIBRARIES = ext1.la ...
 ##    ext1_la_SOURCES = ...
 ##    ext1_la_LDFLAGS = -module
 ##  + still unclear how to get *.$(PDEXT) targets built from *.la
 dnl AC_DISABLE_STATIC
 dnl AC_LIBTOOL_DLOPEN
 dnl AC_PROG_LIBTOOL

 dnl ----- maintainer mode
 dnl  + enables "maintainer mode" only with ./configure --enable-maintainer-mode
 dnl    - causes make __never__ to invoke 'config/missing' (i.e. any autotools)
 dnl    - basically a hack to avoid version mismatches in autoconf, automake, etc.
 dnl      for autobuilds from SVN
 dnl  + maintainer should call ./configure --enable-maintainer-mode, and must keep
 dnl    SVN sources consistent
 dnl AM_MAINTAINER_MODE
 dnl /---- maintainer mode

 ## /prerequisites
 ##^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

 ##vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
 ## versioning
 AC_SUBST(PACKAGE_VERSION)
 AC_SUBST(PACKAGE_NAME)
 AC_SUBST(BUGREPORT)
 ## /versioning
 ##^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

 ##vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
 ## hack EXEEXT (alternative to using libtool)
 AC_MSG_CHECKING([how to hack automake EXEEXT conventions])
 case "${am__api_version}" in
  1.[[0-4]]*)
    AC_MSG_RESULT([automake v${ap__api_version}: on install])
    pd_buildext=""
    ;;
  *)
    AC_MSG_RESULT([automake v${am__api_version}: on build])
    pd_buildext="\$(EXEEXT)"
    ;;
 esac
 AC_SUBST(pd_buildext)
 ## /hack EXEEXT
 ##^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

 ##vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
 ## pd-directory/ies
 AC_ARG_WITH(pd-dir,
	AC_HELP_STRING([--with-pd-dir=DIR], [Pd base directory (default=PREFIX/pd)]),
	[pddir="$withval"],
	[pddir="\${prefix}/pd"])
 AC_SUBST(pddir)

 ##-- pdincludedir
 AC_ARG_WITH(pd-include,
	AC_HELP_STRING([--with-pd-include=DIR], [Pd include directory (default=NONE)]),
	[pdincludedir="$withval"],
	[pdincludedir=""])
 if test -n "$pdincludedir" ; then
  PDEXT_IFLAGS="$PDEXT_IFLAGS -I$pdincludedir"
 fi
 AC_SUBST(pdincludedir)

 ##-- pdextdir
 AC_ARG_WITH(pd-extdir,
	AC_HELP_STRING([--with-pd-extdir=DIR], [Directory for Pd externals (default=PDDIR/externs)]),
	[pdextdir="$withval"],
	[pdextdir="$pddir/externs"])
 AC_SUBST(pdextdir)

 ##-- pdextdir: aliases
 pdexternsdir="$pdextdir"
 pdexecdir="$pdextdir"
 AC_SUBST(pdexternsdir)
 AC_SUBST(pdexecdir)

 # Nowadays the help files usually are installed besides the class files
 pddocdir="${pdextdir}"
 AC_SUBST(pddocdir)

 ## pd-directory/ies
 ##^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

 ##vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
 ## single-object-externals?
 AC_ARG_ENABLE(object-externals,
	AC_HELP_STRING([--enable-object-externals], [Whether to build single-object externals (default=no)]),
	[want_object_externals="$enableval"],
	[want_object_externals="no"])

 AC_MSG_CHECKING([whether to build single-object externals])
 if test "$want_object_externals" != "no" ; then
  ##-- single-objects
  AC_MSG_RESULT(yes)
  AC_DEFINE(WANT_OBJECT_EXTERNALS,1,
     [Define this if you are building single-object externals])
 else
  ##-- multi-lib only
  AC_MSG_RESULT(no)
 fi

 ##-- add automake conditional for object externals
 AM_CONDITIONAL(WANT_OBJECT_EXTERNALS, [test "$want_object_externals" != "no"])
 ##
 ## single-object-externals?
 ##^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^


 ##vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
 ## check: m_pd.h
 CPPFLAGS="$CPPFLAGS $PDEXT_IFLAGS"
 AC_CHECK_HEADER(m_pd.h,[],
	AC_MSG_ERROR([could not find Pd header file 'm_pd.h' - bailing out]),
	[/* nonempty includes: compile only */])
 ##^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

 ##vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
 ## debugging
 AC_MSG_CHECKING([whether to build a debug version])
 AC_ARG_ENABLE([debug],
	AC_HELP_STRING([--enable-debug],[build debug version (default=no)]))
 if test "$enable_debug" = "yes" ; then
  AC_MSG_RESULT(yes)
  ENABLE_DEBUG="yes"
 else
  AC_MSG_RESULT(no)
  ENABLE_DEBUG="no"
 fi
 AC_SUBST(ENABLE_DEBUG)
 ## debugging
 ##^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

 ##vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
 ## warning flags, gcc
 if test "$GCC" = "yes"; then
   AC_MSG_CHECKING([whether to set default gcc warning flags])
   case "$UCFLAGS" in
     *-W*)
       AC_MSG_RESULT(no)
       ;;
     *)
       AC_MSG_RESULT(yes)
       PDEXT_WFLAGS="$WFLAGS -Wall -Winline -W -Wno-unused"
       ;;
   esac
 fi
 ## warning flags, gcc
 ##^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

 ##vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
 ## compiled
 if test -n "$SOURCE_DATE_EPOCH"; then
   AC_DEFINE_UNQUOTED(PACKAGE_BUILD_DATE,  "`LC_ALL=C date --utc --date="@$SOURCE_DATE_EPOCH"`",   [Date this package was configured])
 else
   AC_DEFINE_UNQUOTED(PACKAGE_BUILD_DATE,  "`date`",   [Date this package was configured])
 fi
 AC_DEFINE_UNQUOTED(PACKAGE_BUILD_USER,  "$USER",    [User who configured this package])
 ## /compiled
 ##^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

 ##vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
 ## BEGIN platform-dependent variables
 ##

 ##-- Defaults
 LD=ld

 ##----------- `uname -m`: machine hardware name
 AC_MSG_CHECKING([target machine])
 uname_m="`uname -m`"

 ##-- alpha
 if test "$uname_m" = alpha; 
 then
  AC_MSG_RESULT(alpha)
  PDEXT_AFLAGS="-mieee -mcpu=ev56"; 
 else
  AC_MSG_RESULT([$uname_m])
 fi

 ##----------- `uname -s`: kernel name
 AC_MSG_CHECKING([target system])
 uname_s="`uname -s`"

 case "$uname_s" in
   Linux)
     AC_MSG_RESULT(linux)
     ;;
   Darwin)
     AC_MSG_RESULT(darwin)
     ;;
   MINGW32_NT-*)
     ##-- build farm: `uname -s` = MINGW32_NT-5.1
     AC_MSG_RESULT(win32)
     uname_s="MINGW32_NT" ##-- normalize
     ;;
   IRIX64)
     AC_MSG_RESULT(irix64)
     ;;
   IRIX32)
     AC_MSG_RESULT(irix32)
     ;;
   *)
     AC_MSG_RESULT([$uname_s])
     AC_MSG_WARN([Unknown kernel type "$uname_s" defaults to "Linux"])
     uname_s="Linux"
     ;;
  esac

 ##-- Linux
 if test "$uname_s" = "Linux"
 then
  PDEXT_LFLAGS="-Wl,-export-dynamic -shared"
  if test "$ENABLE_DEBUG" = "no" -a -z "$UCFLAGS"; then
    ##-- only set OFLAGS if user CFLAGS are empty
    PDEXT_OFLAGS="-O2 -pipe" 
  elif test "$ENABLE_DEBUG" = "yes"; then
    PDEXT_OFLAGS="-g"
  fi
  PDEXT_OFLAGS="$PDEXT_OFLAGS -fPIC"
  PDEXT_DFLAGS="$PDEXT_DFLAGS -DPIC"
  PDEXT=pd_linux
 fi

 ##-- MacOSX (darwin)
 if test "$uname_s" = "Darwin"
 then
  LD=cc
  PDEXT_LFLAGS="-bundle -undefined suppress  -flat_namespace"
  PDEXT_DFLAGS="-DMACOSX"
  if test "$ENABLE_DEBUG" = "no" -a -z "$UCFLAGS"; then
    ##-- only set OFLAGS if user CFLAGS are empty
    PDEXT_OFLAGS="-O2"
  elif test "$ENABLE_DEBUG" = "yes"; then
    PDEXT_OFLAGS="-g"
  fi
  PDEXT=pd_darwin
 fi

 ##-- irix64
 if test "$uname_s" = "IRIX64"
 then
  PDEXT_LFLAGS="-n32 -DUNIX -DIRIX -DN32 -woff 1080,1064,1185 \
	-OPT:roundoff=3 -OPT:IEEE_arithmetic=3 -OPT:cray_ivdep=true \
	-shared -rdata_shared"
  PDEXT=pd_irix6
 fi

 ##-- irix32
 if test "$uname_s" = "IRIX32"
 then
  PDEXT_LFLAGS="-o32 -DUNIX -DIRIX -O2 -shared -rdata_shared"
  PDEXT=pd_irix5
 fi

 ##-- win32 via minGW/MSYS
 ##   + courtesy of pd-extended build system, SVN externals/Makefile
 if test "$uname_s" = "MINGW32_NT";  #MINGW32_NT-5.1
 then
  PDEXT_DFLAGS="\
	-D'O_NONBLOCK=1' -D'srand48(n)=srand((n))' \
        -D'drand48()=((double)rand()/RAND_MAX)' -D'bzero(p,n)=memset(p,0,n)' \
	"
  PDEXT_LFLAGS="-shared -L${pddir}/bin -L${pddir}/obj"
  PDEXT_CFLAGS="-mms-bitfields -DMSW -DNT"
  LIBS="$LIBS -lpd -lwsock32 -lpthreadGC2 -lkernel32 -luser32 -lgdi32 -lregex"
  if test "$ENABLE_DEBUG" = "no" -a -z "$UCFLAGS"; then
    ##-- only set OFLAGS if user CFLAGS are empty
    PDEXT_OFLAGS="-O2"
  elif test "$ENABLE_DEBUG" = "yes"; then
    PDEXT_OFLAGS="-g"
  fi
  PDEXT=dll
 fi

 ##----------- report pd extension
 AC_MSG_NOTICE([will use pd extension ".$PDEXT" for pd externals])

 EXT=$PDEXT

 ##----------- substitute
 AC_SUBST(LD)
 AC_SUBST(PDEXT)
 AC_SUBST(PDEXT_AFLAGS)
 AC_SUBST(PDEXT_DFLAGS)
 AC_SUBST(PDEXT_IFLAGS)
 AC_SUBST(PDEXT_LFLAGS)
 AC_SUBST(PDEXT_OFLAGS)
 AC_SUBST(PDEXT_WFLAGS)

 ## END platform-dependent variables
 ##^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
])

##==============================================================================
AC_DEFUN([AX_PD_EARLY],
[
 ##-- parse user's CFLAGS,CPPFLAGS
 AC_MSG_NOTICE([pre-processing user CFLAGS...])
 AC_MSG_NOTICE([got   CFLAGS="$CFLAGS"])
 AC_MSG_NOTICE([got CPPFLAGS="$CPPFLAGS"])

 cflags=
 cppflags=
 AX_DISTRIBUTE_CFLAGS([$CFLAGS],CPPFLAGS,cflags)
 AX_SAFE_CFLAGS([$CPPFLAGS],cppflags,EXTRA_CPPFLAGS)
 CFLAGS="$cflags"
 CPPFLAGS="$cppflags"

 ##-- trim whitespace
 CFLAGS=`echo $CFLAGS`
 CPPFLAGS=`echo $CPPFLAGS`
 EXTRA_CPPFLAGS=`echo $EXTRA_CPPFLAGS`
 #LDFLAGS=`echo $LDFLAGS`

 AC_MSG_NOTICE([setting distributed CFLAGS...])
 AC_MSG_NOTICE([set       CPPFLAGS="$CPPFLAGS"])
 AC_MSG_NOTICE([set EXTRA_CPPFLAGS="$EXTRA_CPPFLAGS"])
 AC_MSG_NOTICE([set         CFLAGS="$CFLAGS"])
 #AM_CPPFLAGS="\${EXTRA_CPPFLAGS}"
 AC_SUBST(EXTRA_CPPFLAGS)
 dnl 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="$CPPFLAGS $PDEXT_IFLAGS $PDEXT_DFLAGS"
 CFLAGS="$CFLAGS $PDEXT_OFLAGS $PDEXT_AFLAGS $PDEXT_WFLAGS"
 LDFLAGS="$LDFLAGS $PDEXT_LFLAGS" 

 ##-- ... and re-hack
 cflags=
 cppflags=
 AX_DISTRIBUTE_CFLAGS([$CFLAGS],CPPFLAGS,cflags)
 AX_SAFE_CFLAGS([$CPPFLAGS],cppflags,EXTRA_CPPFLAGS)
 CFLAGS="$cflags"
 CPPFLAGS="$cppflags"

 ##-- trim whitespace
 CFLAGS=`echo $CFLAGS`
 CPPFLAGS=`echo $CPPFLAGS`
 EXTRA_CPPFLAGS=`echo $EXTRA_CPPFLAGS`
 LDFLAGS=`echo $LDFLAGS`

 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"])
])