~ubuntu-branches/ubuntu/gutsy/audacity/gutsy-backports

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
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
dnl
dnl audacity configure.in script
dnl
dnl Joshua Haberman
dnl Dominic Mazzoni
dnl


dnl TODO:
dnl
dnl automatically choose whether or not to make some libs
dnl based on:
dnl
dnl AC_CHECK_LIB(z, compress2, build_libz=false, build_libz=true)
dnl AM_CONDITIONAL(BUILD_LIBZ, test $build_libz = true)
dnl
dnl

dnl Process this file with autoconf to produce a configure script.

dnl Require autoconf >= 2.50 (unfortunately 2.13 is standard)
AC_PREREQ(2.50)

dnl Init autoconf
AC_INIT

dnl Check for existence of Audacity.h
AC_CONFIG_SRCDIR([src/Audacity.h])

dnl Checks for programs.
AC_PROG_CC
AC_PROG_GCC_TRADITIONAL
AC_LANG([C++])
AC_PROG_CXX
AC_PROG_CXXCPP
AC_PROG_INSTALL

dnl extra variables
AC_SUBST(BUILDLIBS)
AC_SUBST(EXTRAOBJS)
AC_SUBST(OPTOBJS)
AC_SUBST(CDEPEND)
AC_SUBST(AFTERBUILD)
AC_SUBST(INSTALL_PREFIX)
AC_SUBST(CONFIGHEADER)
AC_SUBST(PRECOMP_CFLAGS)
AC_SUBST(EXTRATARGETS)

dnl allow the user to specify options to configure that change the
dnl name "audacity" anywhere it appears in a pathname.  This allows
dnl multiple versions of Audacity to be installed concurrently
dnl without collision

AC_ARG_PROGRAM
AC_SUBST(AUDACITY_NAME)

dnl autoconf's program_transform_name is set to spit out a sed expression --
dnl however it's "helpfully" already escaped for make.  Since we want to use
dnl it in shell and not make, we have to unescape this: this translates into
dnl turning two dollar signs into one.
dnl
dnl I feign at this monstrosity, but no one depends on this particular
dnl feature but me, as Debian package maintainer, so no one else should
dnl need to worry about understanding it...
program_transform_name=`echo $program_transform_name | sed 's/\\$\\$/$/'`
AUDACITY_NAME=`echo audacity | sed $program_transform_name`

if [[ "$AUDACITY_NAME" = "audacity" ]] ; then
    AC_DEFINE(AUDACITY_NAME, "audacity",
        [define if Audacity is being installed under a name other than "audacity",
         so it can find the files it needs at runtime])
else
    AC_DEFINE_UNQUOTED(AUDACITY_NAME, "$AUDACITY_NAME")
fi

dnl
dnl Make the install prefix available to the program so that it
dnl knows where to look for help files, plug-ins, etc.
dnl

AC_PREFIX_DEFAULT(/usr/local)
if [[ $prefix = "NONE" ]] ; then
	AC_DEFINE(INSTALL_PREFIX, "/usr/local",
        [define as prefix where Audacity is installed])
else
	AC_DEFINE_UNQUOTED(INSTALL_PREFIX, "$prefix")
fi

dnl
dnl Required sublibraries
dnl

BUILDLIBS="$BUILDLIBS expat/expat.a"
EXTRAOBJS="$EXTRAOBJS ../lib-src/expat/expat.a"
CXXFLAGS="$CXXFLAGS -I../lib-src/expat"

dnl TODO enable/disable allegro
BUILDLIBS="$BUILDLIBS allegro/allegro.a"
EXTRAOBJS="$EXTRAOBJS ../lib-src/allegro/allegro.a"
CXXFLAGS="$CXXFLAGS -I../lib-src/allegro"

dnl
dnl Optional sublibraries
dnl

dnl For each sublibrary, check to see if the source to this
dnl library is in the lib-src directory (where it's provided
dnl for convenience if you get Audacity through CVS).

AC_CHECK_FILE(lib-src/libmad/frame.h,
              default_libmad="yes",
              default_libmad="system")

AC_CHECK_FILE(lib-src/libvorbis/include/vorbis/vorbisenc.h,
              default_vorbis="yes",
              default_vorbis="system")

AC_CHECK_FILE(lib-src/libid3tag/frame.h,
              default_libid3tag="yes",
              default_libid3tag="system")

AC_CHECK_FILE(lib-src/libsndfile/src/sndfile.h.in,
              default_libsndfile="local",
              default_libsndfile="system")

AC_CHECK_FILE(lib-src/libsamplerate/src/samplerate.h,
              default_libsamplerate="local",
              default_libsamplerate="system")

AC_CHECK_FILE(lib-src/libresample/include/libresample.h,
              default_libresample="yes",
              default_libresample="no")

AC_CHECK_FILE(lib-src/libflac/include/FLAC/format.h,
              default_libflac="local",
              default_libflac="system")

dnl If any of the optional sublibraries was not found in lib-src,
dnl we assume the user wants to use a system library.  If the
dnl library isn't installed, though, disable this library by
dnl default.

if [[ "$default_libmad" = "system" ]] ; then
	AC_CHECK_HEADER(mad.h, , default_libmad="no")
fi

if [[ "$default_vorbis" = "system" ]] ; then
	AC_CHECK_HEADER(vorbis/vorbisenc.h, , default_vorbis="no")
fi

if [[ "$default_libid3tag" = "system" ]] ; then
	AC_CHECK_HEADER(id3tag.h, , default_libid3tag="no")
fi

if [[ "$default_libflac" = "system" ]] ; then
	AC_CHECK_HEADER(FLAC/format.h, , default_libflac="no")
fi

dnl options

AC_ARG_WITH(libmad,
	[AC_HELP_STRING([--with-libmad],
      [use libmad for mp3 decoding support])],
	use_libmad=$withval,
	use_libmad=$default_libmad)

AC_ARG_WITH(vorbis,
	[AC_HELP_STRING([--with-vorbis],
		[enable ogg vorbis support])],
	use_vorbis=$withval,
	use_vorbis=$default_vorbis)

AC_ARG_WITH(id3tag,
	[AC_HELP_STRING([--with-id3tag],
		[use libid3tag for mp3 id3 tag support])],
	use_libid3tag=$withval,
	use_libid3tag=$default_libid3tag)

AC_ARG_WITH(libsndfile,
	[AC_HELP_STRING([--with-libsndfile],
		[which libsndfile to use: [local system]])],
	use_libsndfile=$withval,
	use_libsndfile=$default_libsndfile)

AC_ARG_WITH(libresample,
	[AC_HELP_STRING([--with-libresample],
		[use libresample: [yes no]])],
	use_libresample=$withval,
	use_libresample=$default_libresample)

AC_ARG_WITH(libsamplerate,
	[AC_HELP_STRING([--with-libsamplerate],
		[use libsamplerate (instead of libresample): [local system none]])],
	use_libsamplerate=$withval,
	use_libsamplerate="default")

AC_ARG_WITH(libflac,
	[AC_HELP_STRING([--with-libflac [local system none]],
		[enable FLAC support [default=none]])],
	use_libflac=$withval,
	use_libflac="no")

AC_ARG_WITH(ladspa,
	[AC_HELP_STRING([--with-ladspa],
		[compile with ladspa plug-in support [default=yes]])],
	use_ladspa=$withval,
	use_ladspa="default")

AC_ARG_WITH(nyquist,
	[AC_HELP_STRING([--with-nyquist],
		[compile with Nyquist support [default=yes]])],
	use_nyquist=$withval,
	use_nyquist="yes")

AC_ARG_WITH(portmixer,
	[AC_HELP_STRING([--with-portmixer],
		[compile with PortMixer [default=yes]])],
	use_portmixer=$withval,
	use_portmixer="yes")

AC_ARG_WITH(portaudio,
	[AC_HELP_STRING([--with-portaudio],
		[which version of PortAudio to use (=[v18,v19]) [default=v18]])],
	use_portaudio=$withval,
	use_portaudio="v18")

AC_ARG_WITH(soundtouch,
	[AC_HELP_STRING([--with-soundtouch],
		[compile with SoundTouch [default=yes]])],
	use_soundtouch=$withval,
	use_soundtouch="yes")

AC_ARG_WITH(help,
	[AC_HELP_STRING([--with-help],
		[Make the help file "audacity-1.2-help.htb" [default=yes]])],
	use_help=$withval,
	use_help="yes")

if [[ "$use_soundtouch" = "yes" ]] ; then
	AC_DEFINE(USE_SOUNDTOUCH, 1,	
	[Define if SoundTouch support should be enabled])
	CXXFLAGS="-I../lib-src/soundtouch/include $CXXFLAGS"
	BUILDLIBS="$BUILDLIBS soundtouch/source/SoundTouch/.libs/libSoundTouch.a"		
	EXTRAOBJS="$EXTRAOBJS ../lib-src/soundtouch/source/SoundTouch/.libs/libSoundTouch.a"		

   if test ! -f "lib-src/soundtouch/Makefile"; then
		echo "--- Configuring soundtouch";
		AC_CONFIG_SUBDIRS([[lib-src/soundtouch]])
   fi
fi

if [[ "$use_portmixer" = "yes" ]] && [[ "$use_portaudio" = "v19" ]] ; then
	echo "*** PortAudio v19 does not work with PortMixer (at least not yet)"
	use_portmixer="no"
fi

if [[ "$use_portmixer" = "yes" ]] ; then
	AC_DEFINE(USE_PORTMIXER, 1,	
	[Define if PortMixer support should be enabled])
	CXXFLAGS="-I../lib-src/portmixer/px_common $CXXFLAGS"
fi

if [[ "$use_nyquist" = "yes" ]] ; then
	AC_DEFINE(USE_NYQUIST, 1,	
	[Define if Nyquist support should be enabled])

	BUILDLIBS="$BUILDLIBS libnyquist/libnyquist.a"
	CXXFLAGS="$CXXFLAGS -I../lib-src/libnyquist/nyx"
	OPTOBJS="$OPTOBJS \$(OBJDIR)/effects/nyquist/Nyquist.o"
	OPTOBJS="$OPTOBJS \$(OBJDIR)/effects/nyquist/LoadNyquist.o"
	EXTRAOBJS="$EXTRAOBJS ../lib-src/libnyquist/libnyquist.a"
fi

if [[ "$use_libsndfile" = "no" ]] ; then
	   AC_MSG_ERROR([*** Audacity requires libsndfile 1.0.0 or higher to compile.  You must choose either --with-libsndfile=local or --with-libsndfile=system])
fi

if [[ "$use_libsndfile" = "local" ]] ; then
	BUILDLIBS="$BUILDLIBS libsndfile/src/.libs/libsndfile.a"
	EXTRAOBJS="$EXTRAOBJS ../lib-src/libsndfile/src/.libs/libsndfile.a"
	CXXFLAGS="$CXXFLAGS -I../lib-src/libsndfile/src"

   if test ! -f "lib-src/libsndfile/Makefile"; then
		echo "--- Configuring libsndfile";
		AC_CONFIG_SUBDIRS([[lib-src/libsndfile]])
   fi
fi

if [[ "$use_libsndfile" = "system" ]] ; then
	dnl libsndfile -- we need at least version 1.0
	dnl PKG_CHECK_MODULES(SNDFILE, sndfile >= 1.0.0,
	dnl if found...
	dnl LIBS="$LIBS $SNDFILE_LIBS" CPPFLAGS="$CPPFLAGS $SNDFILE_CFLAGS",

	LIBS="$LIBS -lsndfile"	
fi

if [[ "$use_libsamplerate" = "yes" ]] ; then
	use_libsamplerate=$default_libsamplerate;
	use_libresample="no"
fi

if [[ "$use_libsamplerate" = "local" ]] ; then
	use_libresample="no"
fi

if [[ "$use_libsamplerate" = "system" ]] ; then
	use_libresample="no"
fi

if [[ "$use_libsamplerate" = "default" ]] ; then
	use_libsamplerate=$default_libsamplerate
fi

if [[ "$use_libresample" = "yes" ]] ; then
	use_libsamplerate="none";
	BUILDLIBS="$BUILDLIBS libresample/libresample.a"
	EXTRAOBJS="$EXTRAOBJS ../lib-src/libresample/libresample.a"
	CXXFLAGS="$CXXFLAGS -I../lib-src/libresample/include"
	AC_DEFINE(USE_LIBRESAMPLE, 1,
		[Define if libresample support should be enabled])

   if test ! -f "lib-src/libresample/Makefile"; then
		echo "--- Configuring libresample";
		AC_CONFIG_SUBDIRS([[lib-src/libresample]])
   fi
fi

if [[ "$use_libsamplerate" = "local" ]] ; then
	BUILDLIBS="$BUILDLIBS libsamplerate/src/.libs/libsamplerate.a"
	EXTRAOBJS="$EXTRAOBJS ../lib-src/libsamplerate/src/.libs/libsamplerate.a"
	CXXFLAGS="$CXXFLAGS -I../lib-src/libsamplerate/src"
	AC_DEFINE(USE_LIBSAMPLERATE, 1,
		[Define if libsamplerate support should be enabled])

   if test ! -f "lib-src/libsamplerate/Makefile"; then
		echo "--- Configuring libsamplerate";
		AC_CONFIG_SUBDIRS([[lib-src/libsamplerate]])
   fi
fi

if [[ "$use_libsamplerate" = "system" ]] ; then
	LIBS="$LIBS -lsamplerate"	
	AC_DEFINE(USE_LIBSAMPLERATE, 1,
		[Define if libsamplerate support should be enabled])
fi

if [[ "$use_libmad" = "yes" ]] ; then

	AC_DEFINE(USE_LIBMAD, 1,
		[Define if mp3 support is implemented with the libmad library])
	AC_DEFINE(MP3SUPPORT, 1,
      [Define if mp3 support is implemented])

	EXTRAOBJS="$EXTRAOBJS ../lib-src/libmad/.libs/libmad.a"
	BUILDLIBS="$BUILDLIBS libmad/.libs/libmad.a"
	CXXFLAGS="$CXXFLAGS -I../lib-src/libmad"
	CDEPEND="$CDEPEND ../lib-src/libmad/mad.h"

   if test ! -f "lib-src/libmad/Makefile"; then
		echo "--- Configuring libmad";
		AC_CONFIG_SUBDIRS([[lib-src/libmad]])
   fi
fi

if [[ "$use_libmad" = "system" ]] ; then

   AC_CHECK_LIB(mad, mad_decoder_init, true, dnl here true is just a nop
	   AC_MSG_ERROR([*** libmad not found.  Run configure --without-libmad to disable it.]))

   AC_CHECK_HEADER(mad.h, ,
		AC_MSG_ERROR([*** libmad headers not found.  Run configure --without-libmad to disable it.]))	

   dnl make sure libmad is at least version 0.14.2b
   AC_TRY_RUN([
#include <mad.h>
int main() {
#if MAD_VERSION_MAJOR == 0  && MAD_VERSION_MINOR <= 13
   return 1; /* <= 0.13, too old */
#elsif MAD_VERSION_MAJOR == 0  &&  MAD_VERSION_MINOR == 14  &&  MAD_VERSION_PATCH < 2
   return 1; /* 0.14.0 <= x < 0.14.2, too old */
#else
   return 0;
#endif
}], true, dnl success
    AC_MSG_ERROR([*** Please update your version of libmad to at least 0.14.2b]))
	
	AC_DEFINE(USE_LIBMAD, 1,
		[Define if mp3 support is implemented with the libmad library])
	AC_DEFINE(MP3SUPPORT, 1,
      [Define if mp3 support is implemented])

	LIBS="$LIBS -lmad"
fi

if [[ $use_vorbis = "yes" ]] ; then

	EXTRAOBJS="$EXTRAOBJS ../lib-src/libvorbis/lib/.libs/libvorbisenc.a"
	EXTRAOBJS="$EXTRAOBJS ../lib-src/libvorbis/lib/.libs/libvorbisfile.a"
	EXTRAOBJS="$EXTRAOBJS ../lib-src/libvorbis/lib/.libs/libvorbis.a"
	EXTRAOBJS="$EXTRAOBJS ../lib-src/libogg/src/.libs/libogg.a"
	BUILDLIBS="$BUILDLIBS libvorbis/lib/.libs/libvorbisenc.a"
	BUILDLIBS="$BUILDLIBS libvorbis/lib/.libs/libvorbisfile.a"
	BUILDLIBS="$BUILDLIBS libvorbis/lib/.libs/libvorbis.a"
	BUILDLIBS="$BUILDLIBS libogg/src/.libs/libogg.a"

	CXXFLAGS="$CXXFLAGS -I../lib-src/libogg/include"
	CXXFLAGS="$CXXFLAGS -I../lib-src/libvorbis/include"

	AC_DEFINE(USE_LIBVORBIS, 1,
		[Define if the ogg vorbis decoding library is present])

   if test ! -f "lib-src/libogg/Makefile"; then
		echo "--- Configuring libogg";
		AC_CONFIG_SUBDIRS([[lib-src/libogg]])
   fi

   if test ! -f "lib-src/libvorbis/Makefile"; then
		echo "--- Configuring libvorbis";
		AC_CONFIG_SUBDIRS([[lib-src/libvorbis]])
   fi
fi

if [[ $use_vorbis = "system" ]] ; then

   dnl check for both headers and libraries
   
   AC_CHECK_LIB(vorbisfile, vorbis_bitrate_addblock, true, dnl here true is just a nop
	   AC_MSG_ERROR([*** Ogg Vorbis libraries not found or they are too old. (>= 1.0-rc3 required). Run configure --without-vorbis to disable it.]),
	   -lvorbis -logg) dnl auxiliary library that -lvorbisfile needs

   AC_CHECK_HEADER(vorbis/vorbisfile.h, ,
		AC_MSG_ERROR([*** Ogg Vorbis headers not found.  Run configure --without-vorbis to disable it]))

	LIBS="$LIBS -lvorbisenc -lvorbisfile -lvorbis -logg"
	AC_DEFINE(USE_LIBVORBIS, 1,
		[Define if the ogg vorbis decoding library is present])
fi

if [[ $use_libid3tag = "yes" ]] ; then
	EXTRAOBJS="$EXTRAOBJS ../lib-src/libid3tag/.libs/libid3tag.a"
	BUILDLIBS="$BUILDLIBS libid3tag/.libs/libid3tag.a"
	CPPFLAGS="$CPPFLAGS -I../lib-src/libid3tag"
		
	AC_DEFINE(USE_LIBID3TAG, 1,
      [Define if libid3tag is present])

   if test ! -f "lib-src/libid3tag/Makefile"; then
		echo "--- Configuring libid3tag";
		AC_CONFIG_SUBDIRS([[lib-src/libid3tag]])
   fi
fi

if [[ $use_libid3tag = "system" ]] ; then
   AC_CHECK_LIB(id3tag, id3_file_open, true, dnl here true is just a nop
	   AC_MSG_ERROR([*** libid3tag not found.  Run configure --without-id3tag to disable it.]),
	   -lz) dnl auxiliary library that -lid3tag needs

   AC_CHECK_HEADER(id3tag.h, ,
		AC_MSG_ERROR([*** libid3tag headers not found.  Run configure --without-id3tag to disable it.]))
	
	AC_DEFINE(USE_LIBID3TAG, 1,
      [Define if libid3tag is present])

	LIBS="$LIBS -lid3tag"

fi

if [[ $use_libflac = "local" ]] ; then
   EXTRAOBJS="$EXTRAOBJS ../lib-src/libflac/src/libFLAC/.libs/libFLAC.a"
   EXTRAOBJS="$EXTRAOBJS ../lib-src/libflac/src/libFLAC++/.libs/libFLAC++.a"
   BUILDLIBS="$BUILDLIBS libflac/src/libFLAC/.libs/libFLAC.a"
   BUILDLIBS="$BUILDLIBS libflac/src/libFLAC++/.libs/libFLAC++.a"
   CXXFLAGS="$CXXFLAGS -I../lib-src/libflac/include"

   AC_DEFINE(USE_LIBFLAC, 1,
      [Define if the FLAC library is present])

   if test ! -f "lib-src/libflac/Makefile"; then
		echo "--- Configuring libflac";
		AC_CONFIG_SUBDIRS([[lib-src/libflac]])
   fi
fi

if [[ $use_libflac = "system" ]] ; then
   AC_CHECK_LIB(FLAC, FLAC__format_sample_rate_is_valid, true, dnl here true is just a nop
	   AC_MSG_ERROR([*** FLAC libraries not found or they are too old. Run configure --without-libflac to disable it.]),
	   -lFLAC++) dnl auxiliary library that -lFLAC needs

   AC_CHECK_HEADER(FLAC/format.h, ,
		AC_MSG_ERROR([*** FLAC headers not found.  Run configure --without-libflac to disable it]))

   AC_CHECK_HEADER(FLAC++/all.h, ,
		AC_MSG_ERROR([*** FLAC++ headers not found.  Run configure --without-libflac to disable it]))

   LIBS="$LIBS -lFLAC -lFLAC++"
   AC_DEFINE(USE_LIBFLAC, 1,
      [Define if the FLAC library is present])
fi

dnl if [[ $use_help = "yes" ]] ; then
dnl   enable help
dnl fi

dnl --- look for "ZIP"

AC_PATH_PROG(ZIP, zip, no)
if [[ $ZIP = "no" ]] ; then
        AC_MSG_ERROR("Could not find zip - needed to create the help file");

	dnl TODO

   dnl make non-fatal - i.e. just don't build help
fi

dnl --- check for required libraries ---

dnl wxWindows -- we assume that if wx-config is found, wxWindows is successfully installed.
AC_PATH_PROG(WX_CONFIG, wx-config, no, $PATH:/usr/local/bin )
if [[ "$WX_CONFIG" = "no" ]] ; then
	AC_MSG_ERROR("Could not find wx-config: is wxWindows installed? is wx-config in your path?")
fi
LIBS="$LIBS `$WX_CONFIG --libs`"
CPPFLAGS="$CPPFLAGS `$WX_CONFIG --cxxflags`"


AC_CANONICAL_HOST

dnl PortAudio configuration

if [[ "$use_portaudio" = "v19" ]] ; then
	AC_DEFINE(USE_PORTAUDIO_V19, 1,
		[Define if PortAudio v19 is being used (instead of v18)])

	BUILDLIBS="$BUILDLIBS portaudio-v19/lib/libportaudio.a"
	EXTRAOBJS="$EXTRAOBJS ../lib-src/portaudio-v19/lib/libportaudio.a"
	CXXFLAGS="-I../lib-src/portaudio-v19/pa_common $CXXFLAGS"

	dnl Quick and dirty code to link with ALSA and Jack libs
	dnl if necessary...

	AC_CHECK_LIB(asound, snd_pcm_open, have_alsa=yes, have_alsa=no)
	AC_CHECK_LIB(jack, jack_client_new, have_jack=yes, have_jack=no)

	if [[ $have_jack = "yes" ]] ; then
		LIBS="$LIBS -ljack"
	fi

   if [[ $have_alsa = "yes" ]] ; then
		LIBS="$LIBS -lasound"
	fi

	if [[ "$use_ladspa" = "default" ]] ; then
		use_ladspa="yes";
	fi

	AC_CONFIG_SUBDIRS([[lib-src/portaudio-v19]])

else

	CXXFLAGS="-I../lib-src/portaudio/pa_common $CXXFLAGS"

	case "${host_os}" in
	  darwin* | rhapsody*)
		dnl Mac OS X configuration

		CONFIGHEADER="configunix.h"

		dnl CoreAudio

		CXXFLAGS="-I../mac $CXXFLAGS"

		BUILDLIBS="$BUILDLIBS portaudio/pa_mac_core/portaudio.a"
		EXTRAOBJS="$EXTRAOBJS ../lib-src/portaudio/pa_mac_core/portaudio.a"

	   if [[ "$use_portmixer" = "yes" ]] ; then
			BUILDLIBS="$BUILDLIBS portmixer/px_mac_core/portmixer.a"
			EXTRAOBJS="$EXTRAOBJS ../lib-src/portmixer/px_mac_core/portmixer.a"		
	   fi

		LIBS="-framework AudioUnit -framework AudioToolbox $LIBS"
		LIBS="-framework CoreAudio $LIBS -lz"

		EXTRATARGETS="../Audacity.app"

		if [[ "$use_ladspa" = "default" ]] ; then
			use_ladspa="yes";
		fi

		dnl VST
		
		OPTOBJS="$OPTOBJS \$(OBJDIR)/effects/VST/LoadVSTMac.o"
		OPTOBJS="$OPTOBJS \$(OBJDIR)/effects/VST/VSTEffect.o"

	;;

	cygwin*)
 	dnl Windows/CygWin configuration
 	
 	BUILDLIBS="$BUILDLIBS portaudio/pa_win_wmme/portaudio.a"
 	EXTRAOBJS="$EXTRAOBJS ../lib-src/portaudio/pa_win_wmme/portaudio.a"
 	LIBS="$LIBS -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32 -lwsock32 -lwinmm"
	LIBS="$LIBS -Wl,--subsystem,windows"
 	CONFIGHEADER="configwin.h"
 
    if [[ "$use_portmixer" = "yes" ]] ; then
 		BUILDLIBS="$BUILDLIBS portmixer/px_win_wmme/portmixer.a"
 		EXTRAOBJS="$EXTRAOBJS ../lib-src/portmixer/px_win_wmme/portmixer.a Audacity.coff"
    fi
 
 	if [[ "$use_ladspa" = "default" ]] ; then
 		use_ladspa="yes";
 	fi
 
 	AC_DEFINE(__CYGWIN__,1,[We're using cygwin])
 	AC_DEFINE(_FILE_OFFSET_BITS,32,[Placeholder for large file support])
 
 	AFTERBUILD=""
	;;

	  *)
		dnl Unix OSS configuration

		CONFIGHEADER="configunix.h"

		BUILDLIBS="$BUILDLIBS portaudio/pa_unix_oss/portaudio.a"
		EXTRAOBJS="$EXTRAOBJS ../lib-src/portaudio/pa_unix_oss/portaudio.a"

	   if [[ "$use_portmixer" = "yes" ]] ; then
			BUILDLIBS="$BUILDLIBS portmixer/px_unix_oss/portmixer.a"
			EXTRAOBJS="$EXTRAOBJS ../lib-src/portmixer/px_unix_oss/portmixer.a"		
	   fi

		if [[ "$use_ladspa" = "default" ]] ; then
			use_ladspa="yes";
		fi

		AFTERBUILD=""

	esac
fi

use_precomp="no"

case "$host_os" in
	darwin* | rhapsody*)
		AC_MSG_WARN([[Not using native lrint() and lrintf() because they are missing on 10.1.]])

		cc_version=`$CC --version | head -1`
		if echo "$cc_version" | grep "3\." >/dev/null ; then
		   echo "checking for gcc 3.x... yes"
		   gcc3="yes"
		   echo "Enabling precompiled headers"
		   use_precomp="yes"
		else
		   echo "checking for gcc 3.x... no"
		   gcc3="no"
		fi

		echo "Enabling prebinding"
		LIBS="$LIBS -prebind"

		;;
	*)
      dnl For all other Unix systems, we want to check for lrint/lrintf
		AC_C99_FUNC_LRINT
		AC_C99_FUNC_LRINTF
		;;
	esac

dnl Precompiled header support (currently only for gcc 3.3 on Mac OS X)
if [[ "$use_precomp" = "yes" ]] ; then
   CDEPEND="${CDEPEND} AudacityHeaders.h.gch"
   PRECOMP_CFLAGS="-include AudacityHeaders.h"
fi

dnl Special configuration for LADSPA on Mac OS X
if [[ "$use_ladspa" = "yes" ]] ; then
   case "$host_os" in
      darwin* | rhapsody*)

      EXTRAOBJS="$EXTRAOBJS ../lib-src/dlcompat/libdl.a"
      BUILDLIBS="$BUILDLIBS dlcompat/libdl.a"
      CXXFLAGS="$CXXFLAGS -I../lib-src/dlcompat"
      if test ! -f "lib-src/dlcompat/Makefile"; then
         echo "--- Configuring dlcompat";
         AC_CONFIG_SUBDIRS([[lib-src/dlcompat]])
      fi		

      ;;
   *)
      ;;
   esac
fi

if [[ "$use_ladspa" = "yes" ]] ; then
   OPTOBJS="$OPTOBJS \$(OBJDIR)/effects/ladspa/LoadLadspa.o"
   OPTOBJS="$OPTOBJS \$(OBJDIR)/effects/ladspa/LadspaEffect.o"

   AC_DEFINE(USE_LADSPA, 1,
             [Define if LADSPA plug-ins are enabled])
fi

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_SIZE_T

dnl Checks for library functions.

case "${host_os}" in
 	cygwin*)
 		AC_CONFIG_HEADER(src/configwin.h:src/configtemplate.h)
 		;;
 	*)
 		AC_CONFIG_HEADER(src/configunix.h:src/configtemplate.h)
 		;;
esac

AC_CONFIG_FILES([Makefile src/Makefile lib-src/Makefile \
					  lib-src/allegro/Makefile lib-src/expat/Makefile \
					  lib-src/libnyquist/Makefile \
					  locale/Makefile tests/Makefile])

AC_OUTPUT

echo ""
echo "Finished configure:"

if [[ $use_libsndfile = "system" ]] ; then
	echo "  with    libsndfile=system";
fi

if [[ $use_libresample = "yes" ]] ; then
	echo "  with    libresample";
elif [[ $use_libsamplerate = "system" ]] ; then
	echo "  with    libsamplerate=system";
elif [[ $use_libsamplerate = "local" ]] ; then
	echo "  with    libsamplerate";
else
	echo "  without any resampling support";
fi

if [[ $use_libid3tag = "yes" ]] ; then
	echo "  with    libid3tag";
else
	if [[ $use_libid3tag = "system" ]] ; then
		echo "  with    libid3tag (system)";
	else
		echo "  without libid3tag";	
	fi
fi

if [[ $use_libmad = "yes" ]] ; then
	echo "  with    libmad";
else
	if [[ $use_libmad = "system" ]] ; then
		echo "  with    libmad (system)";
	else
		echo "  without libmad";	
	fi
fi

if [[ $use_ladspa = "yes" ]] ; then
	echo "  with    LADSPA plug-ins";
else
	echo "  without LADSPA plug-ins";
fi

if [[ "$use_nyquist" = "yes" ]] ; then
	echo "  with    Nyquist plug-ins";
else
	echo "  without Nyquist plug-ins";
fi

if [[ $use_vorbis = "yes" ]] ; then	
	echo "  with    vorbis";
else
	if [[ $use_vorbis = "system" ]] ; then
		echo "  with    vorbis (system)";
	else
		echo "  without libvorbis";	
	fi
fi

dnl if [[ $use_libflac = "local" ]] ; then	
dnl 	echo "  with    libflac";
dnl else
dnl 	if [[ $use_libflac = "system" ]] ; then
dnl 		echo "  with    libflac (system)";
dnl 	else
dnl 		echo "  without libflac";	
dnl 	fi
dnl fi

if [[ "$use_portmixer" = "yes" ]] ; then
	echo "  with    portmixer";
else
	echo "  without portmixer";
fi

if [[ "$use_portaudio" = "v19" ]] ; then
	echo "  with    portaudio v19  (not yet compatible with portmixer)";
else
	echo "  with    portaudio v18";
fi

if [[ "$use_soundtouch" = "yes" ]] ; then
	echo "  with    soundtouch";
else
	echo "  without soundtouch";
fi

if [[ $use_help = "yes" ]] ; then
	echo "  with    help";
else
	echo "  without help";
fi

echo "prefix=$prefix";

if [[ "$use_portaudio" = "v19" ]] ; then
	echo ""
	echo "Note: portaudio v19 supports ALSA and Jack, but may be less stable."
else
	echo ""
	echo "Note: portaudio v18 only supports OSS.  If your system supports"
	echo "ALSA, you may want to reconfigure --with-portaudio=v19, though"
	echo "portaudio v19 is newer and possibly less stable."
fi


echo ""
echo "Run 'configure --help' for an explanation of these options,"
echo "otherwise run 'make' to build Audacity."