File: acinclude.m4

package info (click to toggle)
pgadmin3 1.22.2-5
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 74,488 kB
  • sloc: cpp: 195,064; ansic: 20,444; sh: 5,119; pascal: 1,120; yacc: 927; makefile: 516; lex: 421; xml: 126; perl: 40
file content (953 lines) | stat: -rw-r--r-- 24,887 bytes parent folder | download | duplicates (3)
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
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
#######################################################################
#
# pgAdmin III - PostgreSQL Tools
# 
# Copyright (C) 2002 - 2016, The pgAdmin Development Team
# This software is released under the PostgreSQL Licence
#
# acinclude.m4 - Build system scripts.
#
#######################################################################

#################################
# Check there is a C++ compiler #
#################################

AC_DEFUN([CHECK_CPP_COMPILER],
[
	if test "$ac_cv_prog_cxx_g" = no; then
		AC_MSG_ERROR([could not find a suitable C++ compiler to build pgAdmin])
	fi
])

#################################
# Check this is SUN compiler #
#################################

AC_DEFUN([CHECK_SUN_COMPILER],
[
       $CC -V 2>test.txt
       SUN_STR=`head -1 test.txt |cut -f2 -d" "`
       rm -rf test.txt
       if test "$SUN_STR" = "Sun"; then
	       SUN_CC_COMPILER=yes 
       fi

       $CXX -V 2>test.txt
       SUN_STR=`head -1 test.txt |cut -f2 -d" "`
       rm -rf test.txt
       if test "$SUN_STR" = "Sun"; then
	       SUN_CXX_COMPILER=yes
       fi

])

m4_include([lib-prefix.m4])
m4_include([lib-ld.m4])
m4_include([lib-link.m4])

#############################
# Override wxWidgets version #
#############################
AC_DEFUN([SET_WX_VERSION],
[
	AC_ARG_WITH(wx-version, [  --with-wx-version=<version>	the wxWidgets version in major.minor format (default: 2.8)],
	[
		if test "$withval" = yes; then
			AC_MSG_ERROR([you must specify a version number when using --with-wx-version=<version number>])
		else
			if test -z "$withval"; then
				AC_MSG_ERROR([you must specify a version number when using --with-wx-version=<version number>])
			else
				WX_VERSION="$withval"
			fi
		fi
	],
	[
		WX_VERSION="2.8"
	])
])

####################
# Locate wxWidgets #
####################
AC_DEFUN([LOCATE_WXWIDGETS],
[
	AC_ARG_WITH(wx, [  --with-wx=DIR		root directory for wxWidgets installation],
	[
		if test "$withval" != no
		then
			WX_HOME="$withval"
			if test ! -f "${WX_HOME}/bin/wx-config"
			then
				AC_MSG_ERROR([Could not find your wxWidgets installation in ${WX_HOME}])
			fi

		fi
		WX_CONFIG=${WX_HOME}/bin/wx-config
	], 
	[
		WX_HOME=/usr/local/wx2
		if test ! -f "${WX_HOME}/bin/wx-config"
		then
			WX_HOME=/usr/local
			if test ! -f "${WX_HOME}/bin/wx-config"
			then
				WX_HOME=/usr
				if test ! -f "${WX_HOME}/bin/wx-config"
				then
		    # Search the path
				    AC_PATH_PROGS(WX_CONFIG, wx-config)
		    if test ! -f "${WX_CONFIG}"
				    then
			AC_MSG_ERROR([Could not find your wxWidgets installation. You might need to use the --with-wx=DIR configure option])
		    else
					   WX_HOME=`${WX_CONFIG} --prefix`
		    fi
				fi
			fi
		fi
		WX_CONFIG=${WX_HOME}/bin/wx-config
	])
])

###########################
# Check wxWidgets version #
###########################
AC_DEFUN([CHECK_WXWIDGETS],
[
	AC_MSG_CHECKING(wxWidgets version)
	TMP_WX_VERSION=`${WX_CONFIG} --version=${WX_VERSION} --version 2> /dev/null`
	if test "$TMP_WX_VERSION" = ""
	then
		 AC_MSG_RESULT(failed)
		 AC_MSG_ERROR([The version of wxWidgets required (${WX_VERSION}) is not supported by the installations in ${WX_HOME}.])
	fi
	changequote(<<. >>)dnl
	WX_MAJOR=`expr ${TMP_WX_VERSION} : '\([0-9]*\)'`
	WX_MINOR=`expr ${TMP_WX_VERSION} : '[0-9]*\.\([0-9]*\)'`
	changequote([, ])dnl
	if test "$WX_MAJOR" -lt 2; then
		AC_MSG_ERROR([wxWidgets 2.8.0 or newer is required to build pgAdmin])
	fi
	if test "$WX_MAJOR" -eq 2 && test "$WX_MINOR" -lt 8; then
		AC_MSG_ERROR([wxWidgets 2.8.0 or newer is required to build pgAdmin])
	fi
	AC_MSG_RESULT(ok)
])


#####################
# Locate libxml	#
#####################
AC_DEFUN([LOCATE_LIBXML2],
[
	AC_ARG_WITH(libxml2, [  --with-libxml2=DIR	root directory for libxml2 installation],
	[
	  if test "$withval" != no
	  then
		 XML2_HOME="$withval"
		 if test ! -f "${XML2_HOME}/bin/xml2-config"
		 then
			AC_MSG_ERROR([Could not find your libxml2 installation in ${XML2_HOME}])
		 fi
	  fi
	  XML2_CONFIG=${XML2_HOME}/bin/xml2-config
   ],
   [
	  XML2_HOME=/usr/local
	  if test ! -f "${XML2_HOME}/bin/xml2-config"
	  then

		  XML2_HOME=/usr
		  if test ! -f "${XML2_HOME}/bin/xml2-config"
		  then
			  XML2_HOME=/mingw
			  if test ! -f "${XML2_HOME}/bin/xml2-config"
			  then
		  # Search the path
				  AC_PATH_PROGS(XML2_CONFIG, xml2-config)
		  if test ! -f "${XML2_CONFIG}"
				  then
		      AC_MSG_ERROR([Could not find your libxml2 installation. You might need to use the --with-libxml2=DIR configure option])
		  else
					  XML2_HOME=`${XML2_CONFIG} --prefix`
		  fi
			  fi
		  fi
	  fi
	  XML2_CONFIG=${XML2_HOME}/bin/xml2-config
   ])
])

#########################
# Check libxml2 version #
#########################
AC_DEFUN([CHECK_LIBXML2],
[
	AC_MSG_CHECKING(libxml2 version)
	XML2_VERSION=`${XML2_CONFIG} --version`
	changequote(<<. >>)dnl
	XML2_MAJOR=`expr ${XML2_VERSION} : '\([0-9]*\)'`
	XML2_MINOR=`expr ${XML2_VERSION} : '[0-9]*\.\([0-9]*\)'`
	XML2_REVISION=`expr ${XML2_VERSION} : '[0-9]*\.[0-9]*\.\([0-9]*\)'`
	changequote([, ])dnl
	if test "$XML2_MAJOR" -lt 2; then
		AC_MSG_ERROR([libxml2 2.6.18 or newer is required to build pgAdmin])
	fi
	if test "$XML2_MAJOR" -eq 2 && test "$XML2_MINOR" -lt 6; then
		AC_MSG_ERROR([libxml2 2.6.18 or newer is required to build pgAdmin])
	fi
	if test "$XML2_MAJOR" -eq 2 && test "$XML2_MINOR" -eq 6 && test "$XML2_REVISION" -lt 18; then
		AC_MSG_ERROR([libxml2 2.6.18 or newer is required to build pgAdmin])
	fi
	AC_MSG_RESULT(ok)
])


#####################
# Locate libxslt    #
#####################
AC_DEFUN([LOCATE_LIBXSLT],
[
	AC_ARG_WITH(libxslt, [  --with-libxslt=DIR	root directory for libxslt installation],
	[
	  if test "$withval" != no
	  then
		 XSLT_HOME="$withval"
		 if test ! -f "${XSLT_HOME}/bin/xslt-config"
		 then
			AC_MSG_ERROR([Could not find your libxslt installation in ${XSLT_HOME}])
		 fi
	  fi
	  XSLT_CONFIG=${XSLT_HOME}/bin/xslt-config
   ],
   [
	  XSLT_HOME=/usr/local
	  if test ! -f "${XSLT_HOME}/bin/xslt-config"
	  then

		  XSLT_HOME=/usr
		  if test ! -f "${XSLT_HOME}/bin/xslt-config"
		  then
			  XSLT_HOME=/mingw
			  if test ! -f "${XSLT_HOME}/bin/xslt-config"
			  then
		  # Search the path
				  AC_PATH_PROGS(XSLT_CONFIG, xslt-config)
		  if test ! -f "${XSLT_CONFIG}"
				  then
		      AC_MSG_ERROR([Could not find your libxslt installation. You might need to use the --with-libxslt=DIR configure option])
		  else
					  XSLT_HOME=`${XSLT_CONFIG} --prefix`
		  fi
			  fi
		  fi
	  fi
	  XSLT_CONFIG=${XSLT_HOME}/bin/xslt-config
   ])
])

#####################
# Locate PostgreSQL #
#####################
AC_DEFUN([LOCATE_POSTGRESQL],
[
	AC_ARG_WITH(pgsql, [  --with-pgsql=DIR	root directory for PostgreSQL installation],
	[
		if test "$withval" != no
		then
			PG_HOME="$withval"
			if test ! -f "${PG_HOME}/bin/pg_config"
			then
				AC_MSG_ERROR([Could not find your PostgreSQL installation in ${PG_HOME}])
			fi

		fi
		PG_CONFIG=${PG_HOME}/bin/pg_config
	],
	[
		PG_HOME=/usr/local/pgsql
		if test ! -f "${PG_HOME}/bin/pg_config"
		then
			PG_HOME=/usr/local
			if test ! -f "${PG_HOME}/bin/pg_config"
			then
				PG_HOME=/usr
				if test ! -f "${PG_HOME}/bin/pg_config"
				then
				    # Search the path
					AC_PATH_PROGS(PG_CONFIG, pg_config)
				    if test ! -f "${PG_CONFIG}"
				    then
					    AC_MSG_ERROR([Could not find your PostgreSQL installation. You might need to use the --with-pgsql=DIR configure option])
					else
					    PG_HOME=`${PG_CONFIG} --bindir | sed "s/\/bin$//"`
					fi
				fi
			fi
		fi
		PG_CONFIG=${PG_HOME}/bin/pg_config
	])
])

#################
# Locate Sphinx #
#################
AC_DEFUN([LOCATE_SPHINX],
[
        AC_ARG_WITH(sphinx-build, [  --with-sphinx-build=FILE sphinx-build executable to build the docs with],
        [
                if test "$withval" != no
                then
                        SPHINX_BUILD="$withval"
                        if test ! -f "${SPHINX_BUILD}"
                        then
                                AC_MSG_ERROR([Could not find your sphinx-build executable ${SPHINX_BUILD}])
                        fi

                fi
        ],
        [
                SPHINX_BUILD=/usr/local/bin/sphinx-build
                if test ! -f "${SPHINX_BUILD}"
                then
                        SPHINX_BUILD=/usr/bin/sphinx-build
                        if test ! -f "${SPHINX_BUILD}"
                        then
                                # Search the path
				SPHINX_BUILD=""
                                AC_PATH_PROGS(SPHINX_BUILD, sphinx-build sphinx-build-2.7 sphinx-build-2.6, "")
                                if test ! -f "${SPHINX_BUILD}"
                                then
                                        AC_MSG_WARN([Could not find your sphinx-build executable. You might need to use the --with-sphinx-build=FILE configure option])
                                fi
                        fi
                fi
        ])
])
AC_SUBST(SPHINX_BUILD)

########################################
# Enable Database Designer in pgAdmin3 #
########################################
AC_DEFUN([ENABLE_DATABASEDESIGNER],
[
	AC_ARG_ENABLE(databasedesigner, [  --enable-databasedesigner	build the database designer of pgAdmin3],
	[
		if test "$enableval" = yes
		then
			HAVE_DATABASEDESIGNER=yes
		else
			HAVE_DATABASEDESIGNER=no
		fi
	],
	[
		HAVE_DATABASEDESIGNER=no
	])
])
AC_SUBST(HAVE_DATABASEDESIGNER)

###########################
# Debug build of pgAdmin3 #
###########################
AC_DEFUN([ENABLE_DEBUG],
[
	AC_ARG_ENABLE(debug, [  --enable-debug	build a debug version of pgAdmin3],
	[
		if test "$enableval" = yes
		then
			BUILD_DEBUG=yes
		else
			BUILD_DEBUG=no
		fi
	],
	[
		BUILD_DEBUG=no
	])
])
AC_SUBST(BUILD_DEBUG)

############################
# Static build of pgAdmin3 #
############################
AC_DEFUN([ENABLE_STATIC],
[
	AC_ARG_ENABLE(static, [  --enable-static	build a statically linked version of pgAdmin3],
	[
		if test "$enableval" = yes
		then
			BUILD_STATIC=yes
			WX_STATIC="--static=yes"
		else
			BUILD_STATIC=no
			WX_STATIC="--static=no"
		fi
	],
	[
		BUILD_STATIC=no
		WX_STATIC="--static=no"
	])
])

#################################
# Override the OSX architecture #
#################################
AC_DEFUN([SETUP_ARCH_I386],
[
	AC_ARG_WITH(arch-i386, [  --with-arch-i386	include an i386 image in an OS X Universal build],
	[
		if test "$withval" = "yes"
		then
			OSX_ARCH="$OSX_ARCH -arch i386"
		fi
	])
])
AC_DEFUN([SETUP_ARCH_X86_64],
[	AC_ARG_WITH(arch-x86_64, [  --with-arch-x86_64	include an x86_64 image in an OS X Universal build],
	[
		if test "$withval" = "yes"
		then
			OSX_ARCH="$OSX_ARCH -arch x86_64"
		fi
	])
])
AC_DEFUN([SETUP_ARCH_PPC],
[	AC_ARG_WITH(arch-ppc, [  --with-arch-ppc	include a PPC image in an OS X Universal build],
	[
		if test "$withval" = "yes"
		then
			OSX_ARCH="$OSX_ARCH -arch ppc"
		fi
	])
])
AC_DEFUN([SETUP_ARCH_PPC64],
[	AC_ARG_WITH(arch-ppc64, [  --with-arch-ppc64	include a PPC64 image in an OS X Universal build],
	[
		if test "$withval" = "yes"
		then
			OSX_ARCH="$OSX_ARCH -arch ppc64"
		fi
	])
])

##########################
# Build a Mac App Bundle #
##########################
AC_DEFUN([ENABLE_APPBUNDLE],
[
	AC_ARG_ENABLE(appbundle, [  --enable-appbundle	Build a Mac OS X appbundle],
	[
		if test "$enableval" = yes
		then
			BUILD_APPBUNDLE=yes
			prefix=$(pwd)/tmp
			bundledir="$(pwd)/pgAdmin3.app"
			bindir="$bundledir/Contents/MacOS"
			datadir="$bundledir/Contents/SharedSupport"
			AC_SUBST(bundledir)
		else
			BUILD_APPBUNDLE=no
		fi
	],
	[
		BUILD_APPBUNDLE=no
	])
])

#########################################
# Check for libpq libraries and headers #
#########################################
AC_DEFUN([SETUP_POSTGRESQL],
[
	if test -n "${PG_HOME}"
	then
	    PG_LIB=`${PG_CONFIG} --libdir`
		
		PGSQL_OLD_LDFLAGS="$LDFLAGS"
		PGSQL_OLD_CPPFLAGS="$CPPFLAGS"

		AC_LANG_SAVE    
		AC_LANG_C	       
		AC_CHECK_LIB(ssl, SSL_library_init, [LIB_SSL=yes], [LIB_SSL=no])
		AC_LANG_RESTORE	 

		AC_LANG_SAVE    
		AC_LANG_C	       
		AC_CHECK_LIB(krb5, krb5_sendauth, [LIB_KRB5=yes], [LIB_KRB5=no])
		AC_LANG_RESTORE	 


		# Solaris/Mac need -lssl for this test
		case "${host}" in
			*solaris* | *-apple-darwin*)
		if test "$LIB_SSL" = "yes"
				then
					LDFLAGS="$LDFLAGS -L${PG_LIB} -lssl"
				else
					LDFLAGS="$LDFLAGS -L${PG_LIB}"
				fi
				;;
			*)
				LDFLAGS="$LDFLAGS -L${PG_LIB}"
				;;
		esac

		
		# Check for PQexec (basic sanity check!)
		if test "$BUILD_STATIC" = "yes"
		then
			AC_MSG_CHECKING(for PQexec in libpq.a)
			if test "$(nm ${PG_LIB}/libpq.a | grep -c PQexec)" -gt 0
			then
				AC_MSG_RESULT(present)
				PG_LIBPQ="yes" 
			else    
				AC_MSG_RESULT(not present)
				PG_LIBPQ="no"
			fi	      
		else			    
			AC_LANG_SAVE    
			AC_LANG_C	       
			AC_CHECK_LIB(pq, PQexec, [PG_LIBPQ=yes], [PG_LIBPQ=no])
			AC_LANG_RESTORE	 
		fi

		# Check for PQconninfoParse
		if test "$BUILD_STATIC" = "yes"
		then
			AC_MSG_CHECKING(for PQconninfoParse in libpq.a)
			if test "$(nm ${PG_LIB}/libpq.a | grep -c PQconninfoParse)" -gt 0
			then
				AC_MSG_RESULT(present)
				HAVE_CONNINFO_PARSE="yes"
			else
				AC_MSG_RESULT(not present)
				HAVE_CONNINFO_PARSE="no"
			fi
		else
			AC_LANG_SAVE
			AC_LANG_C
			AC_CHECK_LIB(pq, PQconninfoParse, [HAVE_CONNINFO_PARSE=yes], [HAVE_CONNINFO_PARSE=no])
			AC_LANG_RESTORE
		fi

		AC_LANG_SAVE
		AC_LANG_C

		if test "$LIB_SSL" = "yes"
		then
		# Check for SSL support
		if test "$BUILD_STATIC" = "yes"
		then
			AC_MSG_CHECKING(for SSL_connect in libpq.a)
			if test "$(nm ${PG_LIB}/libpq.a | grep -c SSL_connect)" -gt 0
			then
				AC_MSG_RESULT(present)
				PG_SSL="yes"
			else   
				AC_MSG_RESULT(not present)
				PG_SSL="no"
			fi
		else
			if test "$build_cpu-$build_vendor" = "powerpc-apple" -o "$build_cpu-$build_vendor" = "i386-apple" -o "$build_cpu-$build_vendor" = "i686-apple"
			then
				AC_MSG_CHECKING(for SSL_connect in -lpq)
				if test "$(otool -L ${PG_LIB}/libpq.?.dylib | grep -c libssl)" -gt 0
				then
					AC_MSG_RESULT(present)
					PG_SSL="yes"
				else
					AC_MSG_RESULT(not present)
					PG_SSL="no"
				fi
			else
				AC_CHECK_LIB(pq, SSL_connect, [PG_SSL=yes], [PG_SSL=no], "-lssl")
			fi
		fi
		else
			PG_SSL="no"
		fi

		if test "$LIB_KRB5" = "yes"
		then
		# Check for Kerberos support

				LDFLAGS="$LDFLAGS -lkrb5"

		if test "$BUILD_STATIC" = "yes"
		then
			AC_MSG_CHECKING(for krb5_free_principal in libpq.a)
			if test "$(nm ${PG_LIB}/libpq.a | grep -c krb5_free_principal)" -gt 0
			then
				AC_MSG_RESULT(present)
				PG_KRB5="yes"
			else
				AC_MSG_RESULT(not present)
				PG_KRB5="no"
			fi
		else
			if test "$build_cpu-$build_vendor" = "powerpc-apple" -o "$build_cpu-$build_vendor" = "i386-apple" -o "$build_cpu-$build_vendor" = "i686-apple"
			then
				AC_MSG_CHECKING(for krb5_free_principle in -lpq)
				if test "$(otool -L ${PG_LIB}/libpq.?.dylib | grep -c libkrb5)" -gt 0
				then
					AC_MSG_RESULT(present)
					PG_KRB5="yes"
				else
					AC_MSG_RESULT(not present)
					PG_KRB5="no"
				fi
			else
				AC_CHECK_LIB(pq, krb5_free_principal, [PG_KRB5=yes], [PG_KRB5=no])
			fi
		fi
		else
			PG_KRB5="no"
		fi

		AC_LANG_RESTORE

		PG_INCLUDE=`${PG_CONFIG} --includedir` 
		PG_SVRINCLUDE=`${PG_CONFIG} --includedir-server`
		PG_PKGINCLUDE=`${PG_CONFIG} --pkgincludedir`
		CPPFLAGS="$CPPFLAGS -I${PG_INCLUDE} -I${PG_SVRINCLUDE} -I${PG_PKGINCLUDE}"
	
		PG_VERSION=`${PG_CONFIG} --version`

		if test "$build_os" = "mingw32"
		then
			CRYPTO_LIB=""
		else
			CRYPTO_LIB="-lcrypto"
		fi
		
		if test "$BUILD_STATIC" = "yes"
		then
			if test "$build_cpu-$build_vendor" = "powerpc-apple" -o "$build_cpu-$build_vendor" = "i386-apple" -o "$build_cpu-$build_vendor" = "i686-apple"
			then
				CRYPT_LIB=""
			else
				CRYPT_LIB="-lcrypt"
			fi

			if test "$PG_SSL" = "yes"
			then
				LIBS="${PG_LIB}/libpq.a $CRYPT_LIB $LIBS -lssl $CRYPTO_LIB"
			else
				LIBS="${PG_LIB}/libpq.a $CRYPT_LIB $LIBS $CRYPTO_LIB"
			fi

			if test "$PG_KRB5" = "yes"
			then
				LIBS="$LIBS -lkrb5"
			fi
		else
			if test "$PG_SSL" = "yes"
			then
				LIBS="$LIBS -L${PG_LIB} -lpq"
			else
				LIBS="$LIBS -L${PG_LIB} $CRYPTO_LIB -lpq"
			fi
		fi

		AC_LANG_SAVE
		AC_LANG_C
		AC_CHECK_HEADER(libpq-fe.h, [PG_LIBPQFE=yes], [PG_LIBPQFE=no])
		AC_LANG_RESTORE

		if test "$PG_LIBPQ" = "yes"
		then
			AC_MSG_CHECKING(PostgreSQL in ${PG_HOME})
			AC_MSG_RESULT(ok)
		else
			AC_MSG_CHECKING(PostgreSQL in ${PG_HOME})
			AC_MSG_RESULT(failed)
			LDFLAGS="$PGSQL_OLD_LDFLAGS"
			CPPFLAGS="$PGSQL_OLD_CPPFLAGS"
			AC_MSG_ERROR([you must specify a valid PostgreSQL 8.4+ installation with --with-pgsql=DIR])
		fi

		if test "$PG_SSL" = "yes"
		then
			CPPFLAGS="$CPPFLAGS -DPG_SSL"
		fi
		if test "$HAVE_CONNINFO_PARSE" = "yes"
		then
			CPPFLAGS="$CPPFLAGS -DHAVE_CONNINFO_PARSE"
		fi
		if test "$HAVE_DATABASEDESIGNER" = "yes"
		then
			CPPFLAGS="$CPPFLAGS -DDATABASEDESIGNER"
		fi

		# Avoid linking with things we don't need. Really this is a hack
		# to prevent png2c linking with libpq with gcc on non-OSX OSs
		if test "$SUN_CC_COMPILER" != "yes"
		then
			case "${host}" in
				*-apple-darwin*)
					;;
				*solaris*)
					LDFLAGS="$LDFLAGS"
					;;
				*)
					LDFLAGS="$LDFLAGS -Wl,-as-needed"
					;;
			esac
		fi
	fi
])
AC_SUBST(PG_CONFIG)

#######################################################
# Check for extended libpq functions in EnterpriseDB  #
#######################################################
AC_DEFUN([CHECK_EDB_LIBPQ],
[
	if test "$BUILD_STATIC" = "yes"
	then
		AC_MSG_CHECKING(for PQgetOutResult in libpq.a)
		if test "$(nm ${PG_LIB}/libpq.a | grep -c PQgetOutResult)" -gt 0
		then
			AC_MSG_RESULT(present)
			EDB_LIBPQ="yes"
		else
			AC_MSG_RESULT(not present)
			EDB_LIBPQ="no"
		fi
	else
		AC_LANG_SAVE
		AC_LANG_C
		AC_CHECK_LIB(pq, PQgetOutResult, [EDB_LIBPQ=yes], [EDB_LIBPQ=no])
		AC_LANG_RESTORE
	fi
])
AC_SUBST(EDB_LIBPQ)

################################################
# Check for wxWidgets libraries and headers	#
################################################
AC_DEFUN([SETUP_WXWIDGETS],
[
	if test -n "${WX_HOME}"
	then
		LDFLAGS="$LDFLAGS -L${WX_HOME}/lib"
		WX_OLD_LDFLAGS="$LDFLAGS"
		WX_OLD_CPPFLAGS="$CPPFLAGS"
	
		if test "$BUILD_DEBUG" = yes
		then
			WX_NEW_CPPFLAGS=`${WX_CONFIG} --cppflags --unicode=yes --debug=yes --version=${WX_VERSION} 2> /dev/null`
			CPPFLAGS="$CPPFLAGS $WX_NEW_CPPFLAGS"
			CFLAGS=`echo $CFLAGS | sed -e "s/-O2/-O0/g"`
			CXXFLAGS=`echo $CXXFLAGS | sed -e "s/-O2/-O0/g"`
			
			pgadmin3_LDADD=`${WX_CONFIG} ${WX_STATIC} --libs std,stc,aui --unicode=yes --debug=yes --version=${WX_VERSION} 2> /dev/null`
			pgsTest_LDADD=`${WX_CONFIG} ${WX_STATIC} --libs base,core,xml --unicode=yes --debug=yes --version=${WX_VERSION} 2> /dev/null`
			pgScript_LDADD=`${WX_CONFIG} ${WX_STATIC} --libs base,core,xml --unicode=yes --debug=yes --version=${WX_VERSION} 2> /dev/null`
		else
			WX_NEW_CPPFLAGS=`${WX_CONFIG} --cppflags --unicode=yes --debug=no --version=${WX_VERSION} 2> /dev/null`
			CPPFLAGS="$CPPFLAGS $WX_NEW_CPPFLAGS -DEMBED_XRC"
			CFLAGS=`echo $CFLAGS | sed -e "s/-g //g"`
			CXXFLAGS=`echo $CXXFLAGS | sed -e "s/-g //g"`
		
			pgadmin3_LDADD=`${WX_CONFIG} ${WX_STATIC} --libs std,stc,aui --unicode=yes --debug=no --version=${WX_VERSION} 2> /dev/null`
			pgsTest_LDADD=`${WX_CONFIG} ${WX_STATIC} --libs base,core,xml --unicode=yes --debug=no --version=${WX_VERSION} 2> /dev/null`
			pgScript_LDADD=`${WX_CONFIG} ${WX_STATIC} --libs base,core,xml --unicode=yes --debug=no --version=${WX_VERSION} 2> /dev/null`
		fi

		AC_MSG_CHECKING(wxWidgets in ${WX_HOME})
		if test "$WX_NEW_CPPFLAGS" = "" -o "$pgadmin3_LDADD" = ""
		then
			AC_MSG_RESULT(failed)
			AC_MSG_ERROR([Your wxWidgets installation cannot support pgAdmin in the selected configuration. This may be because it was configured without the --enable-unicode option, or the combination of dynamic/static linking and debug/non-debug libraries selected did not match any installed wxWidgets libraries.])
		else
			AC_MSG_RESULT(ok)
		fi

		case "${host}" in
			*-apple-darwin*)

				# Use the default arch if none is specified.
				if test "$OSX_ARCH" = ""
				then
					OSX_ARCH="-arch `uname -p`"
				fi

				LDFLAGS="$LDFLAGS -headerpad_max_install_names"
				CPPFLAGS="$CPPFLAGS $OSX_ARCH" 

				# Strip any existing arch flags from LDFLAGS and add the desired ones
				# This is required as wxWidgets 2.8 (but not 2.9) includes the arch flags
				# in it's --libs output.
				pgadmin3_LDADD=`echo $pgadmin3_LDADD | sed -e "s/-arch ppc//g" -e "s/-arch i386//g" -e "s/-arch x86_64//g" -e "s/-arch ppc64//g"` 
				pgadmin3_LDADD="$pgadmin3_LDADD $OSX_ARCH"
				pgsTest_LDADD=`echo $pgsTest_LDADD | sed -e "s/-arch ppc//g" -e "s/-arch i386//g" -e "s/-arch x86_64//g" -e "s/-arch ppc64//g"`
				pgsTest_LDADD="$pgsTest_LDADD $OSX_ARCH"
				pgScript_LDADD=`echo $pgScript_LDADD | sed -e "s/-arch ppc//g" -e "s/-arch i386//g" -e "s/-arch x86_64//g" -e "s/-arch ppc64//g"`
				pgScript_LDADD="$pgScript_LDADD $OSX_ARCH"
				png2c_LDADD="$OSX_ARCH"

				;;
			*solaris*)
				LDFLAGS="$LDFLAGS -lnsl"
				;;
			*)
				;;
		esac
	fi
])
AC_SUBST(WX_CONFIG)
AC_SUBST(pgadmin3_LDADD)
AC_SUBST(pgsTest_LDADD)
AC_SUBST(pgScript_LDADD)
AC_SUBST(png2c_LDADD)

#########################
# Setup libxml2 headers #
#########################
AC_DEFUN([SETUP_LIBXML2],
[
	if test -n "${XML2_HOME}"
	then
		XML2_CFLAGS=`${XML2_CONFIG} --cflags`
		XML2_LIBS=`${XML2_CONFIG} --libs`
		AC_MSG_CHECKING(libxml2 in ${XML2_HOME})
		if test "${XML2_CFLAGS}" = "" -o "${XML2_LIBS}" = ""
		then
			AC_MSG_RESULT(failed)
			AC_MSG_ERROR([Your libxml2 installation does not appear to be complete])
		else
			AC_MSG_RESULT(ok)
			CPPFLAGS="$CPPFLAGS $XML2_CFLAGS"
			pgadmin3_LDADD="${pgadmin3_LDADD} $XML2_LIBS"
		fi
	fi
])
AC_SUBST(XML2_CONFIG)
AC_SUBST(pgadmin3_LDADD)
	
#########################
# Setup libxslt headers #
#########################
AC_DEFUN([SETUP_LIBXSLT],
[
	if test -n "${XSLT_HOME}"
	then
		XSLT_CFLAGS=`${XSLT_CONFIG} --cflags`
		XSLT_LIBS=`${XSLT_CONFIG} --libs`
		AC_MSG_CHECKING(libxslt in ${XSLT_HOME})
		if test "${XSLT_CFLAGS}" = "" -o "${XSLT_LIBS}" = ""
		then
			AC_MSG_RESULT(failed)
			AC_MSG_ERROR([Your libxslt installation does not appear to be complete])
		else
			AC_MSG_RESULT(ok)
			CPPFLAGS="$CPPFLAGS $XSLT_CFLAGS"
			pgadmin3_LDADD="${pgadmin3_LDADD} $XSLT_LIBS"
		fi
	fi
])
AC_SUBST(XSLT_CONFIG)
AC_SUBST(pgadmin3_LDADD)

#################
# Setup libssh2 #
#################

sinclude(acinclude-ssh2.m4)


#########################
# Configuration summary #
#########################
AC_DEFUN([SUMMARY],
[
	# Print a configuration summary
	echo
	echo "PostgreSQL directory:			$PG_HOME"
	echo "PostgreSQL pg_config binary:		$PG_CONFIG"
	echo "PostgreSQL version:			$PG_VERSION"
	echo
	if test "$HAVE_CONNINFO_PARSE" = yes
	then
		echo "PostgreSQL PQconninfoParse support:     Present"
	else
		echo "PostgreSQL PQconninfoParse support:     Missing"
	fi
	if test "$PG_SSL" = yes
	then
		echo "PostgreSQL SSL support:			Present"
	else
		echo "PostgreSQL SSL support:			Missing"
	fi
	echo
	echo "wxWidgets directory:			$WX_HOME"
	echo "wxWidgets wx-config binary:		$WX_CONFIG"
	echo "wxWidgets version:			wxWidgets "`$WX_CONFIG --version --version=$WX_VERSION`
	echo
	echo "libxml2 directory:			$XML2_HOME"
	echo "libxml2 xml2-config binary:		$XML2_CONFIG"
	echo "libxml2 version:			libxml2 "`$XML2_CONFIG --version`
	echo
	echo "libxslt directory:			$XSLT_HOME"
	echo "libxslt xslt-config binary:		$XSLT_CONFIG"
	echo "libxslt version:			libxslt "`$XSLT_CONFIG --version`
	echo
	if test "$HAVE_DATABASEDESIGNER" = yes
	then
		echo "Building Database Designer:		Yes"
	else
		echo "Building Database Designer:		No"
	fi
	echo
	if test "$BUILD_SSH_TUNNEL" = yes
	then
		echo "Building SSH Tunnel:			Yes"
		if test "$ac_cv_libssl" = yes
		then
			echo "Crypto library:				OpenSSL"
		else test "$ac_cv_libgcrypt" = yes
			echo "Crypto library:				libgcrypt"
		fi
		if test "$ac_cv_libz" = yes
		then
			echo "libz compression:			yes"
		else
			echo "libz compression:			no"
		fi
	else
		echo "Building SSH Tunnel:			No"
	fi
	echo
	if test "$BUILD_DEBUG" = yes
	then
		echo "Building a debug version of pgAdmin:	Yes"
	else
		echo "Building a debug version of pgAdmin:	No"
	fi
	if test "$BUILD_STATIC" = yes
	then
		echo "Statically linking pgAdmin:		Yes"
	else
		echo "Statically linking pgAdmin:		No"
	fi
	if test "$BUILD_APPBUNDLE" = yes
	then
		echo "Building a Mac OS X appbundle:		Yes"
	else
		echo "Building a Mac OS X appbundle:		No"
	fi
	echo
        if test "$SPHINX_BUILD" = ""
        then
                echo "sphinx-build executable:                <not found>"
        else
                echo "sphinx-build executable:                ${SPHINX_BUILD}"
        fi
	echo
	echo "pgAdmin configuration is now complete. You can now compile and"
	echo "install pgAdmin using 'make; make install'."
	echo
])