File: configure.ac

package info (click to toggle)
wmaker 0.92.0-6.1
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 13,132 kB
  • ctags: 9,342
  • sloc: ansic: 101,113; sh: 9,590; makefile: 1,285; python: 607; perl: 585; cs: 488; lisp: 219
file content (1125 lines) | stat: -rw-r--r-- 27,936 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
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
dnl
dnl Window Maker autoconf input.
dnl
dnl Process with:
dnl               aclocal
dnl               autoheader
dnl               autoconf
dnl               libtoolize --force --automake
dnl               automake -a --gnu --include-deps
dnl
dnl


AC_INIT(src/WindowMaker.h)



AM_INIT_AUTOMAKE(WindowMaker, 0.92.0)

AC_PROG_LIBTOOL

AM_CONFIG_HEADER(src/config.h)


dnl Checks for host/os name
dnl =======================
dnl AC_CANONICAL_HOST -- already done by AC_PROG_LIBTOOL


dnl Checks for programs.
dnl ===================
AC_ISC_POSIX
AC_PROG_CC
dnl AC_PROG_MAKE_SET -- already done by AM_INIT_AUTOMAKE
#AC_PROG_RANLIB
dnl AC_PROG_INSTALL -- already done by AM_INIT_AUTOMAKE
AC_PROG_LN_S
AC_PROG_GCC_TRADITIONAL


dnl the prefix
dnl ==========
dnl
dnl move this earlier in the script... anyone know why this is handled
dnl in such a bizarre way?

test "x$prefix" = xNONE && prefix=$ac_default_prefix
dnl Let make expand exec_prefix.
test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'


_bindir=`eval echo $bindir`
_bindir=`eval echo $_bindir`

_libdir=`eval echo $libdir`
_libdir=`eval echo $_libdir`
lib_search_path="-L$_libdir"

inc_search_path=`eval echo $includedir`
inc_search_path="-I`eval echo $inc_search_path`"


dnl
dnl Check for RedHat bugs
dnl =====================

dnl WM_CHECK_REDCRAP_BUGS($prefix,$_bindir,$_libdir)


dnl
dnl Specify paths to look for libraries and headers
dnl ===============================================
AC_ARG_WITH(libs-from,
[  --with-libs-from        pass compiler flags to look for libraries],
	[lib_search_path="$withval $lib_search_path"])

AC_ARG_WITH(incs-from,
[  --with-incs-from        pass compiler flags to look for header files],
	[inc_search_path="$withval $inc_search_path"])



dnl Checks for library functions.
dnl ============================
dnl not used anywhere
dnl AC_FUNC_MEMCMP  
AC_FUNC_VPRINTF
AC_FUNC_ALLOCA
AC_CHECK_FUNCS(gethostname select poll strerror strcasecmp strncasecmp \
	       setsid atexit mallinfo mkstemp snprintf vsnprintf asprintf \
	       vasprintf)

dnl ripped from samba
dnl 
AC_CACHE_CHECK([for C99 vsnprintf],_cv_HAVE_C99_VSNPRINTF,[
AC_TRY_RUN([
#include <sys/types.h>
#include <stdarg.h>
void foo(const char *format, ...) { 
       va_list ap;
       int len;
       char buf[5];

       va_start(ap, format);
       len = vsnprintf(0, 0, format, ap);
       va_end(ap);
       if (len != 5) exit(1);

       if (snprintf(buf, 3, "hello") != 5 || strcmp(buf, "he") != 0) exit(1);

       exit(0);
}
main() { foo("hello"); }
],
_cv_HAVE_C99_VSNPRINTF=yes,_cv_HAVE_C99_VSNPRINTF=no,_cv_HAVE_C99_VSNPRINTF=cross)])
if test x"$_cv_HAVE_C99_VSNPRINTF" = x"yes"; then
    AC_DEFINE(HAVE_C99_VSNPRINTF, 1, [define if you have vsnprintf with C99 semantics (set by configure)])
fi

dnl Loading of dynamic libraries at runtime
dnl =======================================
DLLIBS=""

AC_CHECK_FUNC(dlopen, [HAVEDL="yes"], 
	AC_CHECK_LIB(dl, dlopen, [DLLIBS="-ldl" HAVEDL="yes"],
			 DLLIBS="" ))

if test "x$HAVEDL" = xyes; then
    AC_CHECK_HEADERS(dlfcn.h)
fi



dnl Check CPP
dnl =========
if test "x$CPP_PATH" = x; then
    AC_PATH_PROG(CPP_PATH, cpp, notfound, 
		$PATH:/lib:/usr/bin:/bin:/usr/lib:/usr/ccs/lib)
fi

dnl
dnl Tell stupid Solaris cpp that the files it will process have C++ like syntax
dnl RedHat 5.x is broken too, so it won't make a symlink from cpp to the
dnl standard locations
dnl
if test "$CPP_PATH" = "/usr/ccs/lib/cpp" -o "$CPP_PATH" = "notfound" ; then
    if test "$GCC" = "yes"; then
	CPP_PATH="gcc -E -x c"
    else 
	if test "$CPP_PATH" = "/usr/ccs/lib/cpp"; then
	    CPP_PATH="$CPP_PATH -B"
	else
	    echo "cpp, the C preprocessor was not found in your system."
  	    echo "Create a symbolic link from it to /lib/cpp and rerun configure"
  	    exit
	fi
    fi
fi
AC_DEFINE_UNQUOTED(CPP_PATH, "$CPP_PATH", [define to the path to cpp])



dnl Checks for header files.
dnl =======================
AC_HEADER_SYS_WAIT
AC_HEADER_TIME
AC_CHECK_HEADERS(fcntl.h limits.h sys/ioctl.h sys/time.h sys/types.h \
		 libintl.h sys/select.h poll.h malloc.h ctype.h string.h \
		 strings.h)



dnl Checks for typedefs, structures, and compiler characteristics.
dnl ==============================================================
AC_DECL_SYS_SIGLIST
AC_C_CONST
#AC_TYPE_SIZE_T
#AC_TYPE_PID_T
AC_TYPE_SIGNAL



dnl Compiler/architecture specific optimizations
dnl ============================================


dnl GCC/as with MMX support
dnl -----------------------

# until we fix it, leave it disabled
asm_support=no
mmx_support=no
if test "$ac_cv_prog_gcc" = yes; then

    # gcc-3.3 or newer complains about some of our stuff without this
    NOSTRICTALIASING="-fno-strict-aliasing"

    AC_CACHE_CHECK(whether gcc supports x86 inline asm,
                   ac_cv_c_inline_asm,
                   [AC_TRY_LINK(,[{int x; asm volatile("movl %%eax, %%ebx\n"::
                          "m" (x),"m" (x),"m" (x),"m" (x),"m" (x),"m" (x),
                          "m" (x),"m" (x),"m" (x),"m" (x),"m" (x),"m" (x));}],
                   ac_cv_c_inline_asm=yes,
                   ac_cv_c_inline_asm=no)])

    if test "x$ac_cv_c_inline_asm" = xyes; then
       AC_DEFINE(ASM_X86, 1, [define if processor is x86 (normally detected by configure)])
       asm_support=yes

       AC_CACHE_CHECK(whether gcc supports MMX(tm) inline asm,
                      ac_cv_c_inline_mmx,
                      [AC_TRY_LINK(,[asm ("movq %mm0, %mm1");],
                      ac_cv_c_inline_mmx=yes,
                      ac_cv_c_inline_mmx=no)])

       if test "x$ac_cv_c_inline_mmx" = xyes; then
          AC_DEFINE(ASM_X86_MMX, 1, [define if processor is x86 with MMX(tm) support (normally autodetected by configure)])
          mmx_support=yes
       fi
    fi
fi
AC_SUBST(NOSTRICTALIASING)


dnl pkg-config
dnl ----------
dnl AC_ARG_VAR(PKGCONFIG, [pkg-config command])
AC_CHECK_PROG(PKGCONFIG, pkg-config, pkg-config) 


dnl gettext
dnl -------


dnl AM_GNU_GETTEXT



INTLIBS=""

AC_CHECK_FUNC(gettext, [HAVEGETTEXT="yes"], 
	AC_CHECK_LIB(intl, gettext, [INTLIBS="-lintl" HAVEGETTEXT="yes"],
			 INTLIBS="" ))

AC_CHECK_PROG(XGETTEXT, xgettext, xgettext)

if test "$XGETTEXT" != ""; then 
    if $XGETTEXT --help 2>&1 | grep illegal >/dev/null ; then
        echo "xgettext isn't GNU version"
        XGETTEXT=""
    fi
fi

if test "$LINGUAS" != ""; then
    if test "$XGETTEXT" != "" -a "$HAVEGETTEXT" != ""; then
        AC_DEFINE(I18N, 1, [Internationalization (I18N) support (set by configure)])
        PO=""
#       if test "$LINGUAS" = ""; then
#   	    ling=` (cd src/po; /bin/ls *.po) `
#    	    for l in $ling; do
#	        lcode=`basename $l .po`
#	        LINGUAS="$LINGUAS $lcode"
#           done
#       fi
        echo "xgettext and gettext() exist; will build i18n support for $LINGUAS"
    else
        LINGUAS=""
        PO=""
        echo "xgettext and libintl.a don't both exist; will not build i18n support"
    fi
else
    	INTLIBS=""
	MOFILES=""
	WPMOFILES=""
	PO=""
fi


dnl The Tower of Babel
dnl ==================

dnl List of supported locales
dnl -------------------------
supported_locales="be bg bs ca cs da de el es et fi fr gl hr hu it ja ko ms nl no pl pt ro ru sk sv tr zh_CN zh_TW"
supported_wprefs_locales="bg ca cs de es et fi fr hr hu it ja ko pt ru sk zh_CN zh_TW"
supported_wings_locales="bg ca cs de fr sk"

for lang in $LINGUAS; do
	ok=0
	for l in $supported_locales; do
		if test "$l" = "$lang"; then
			ok=1
			break
		fi
	done
	if test "$ok" = 1; then
		MOFILES="$MOFILES $lang.mo"
	else
		echo "Locale $lang is not supported."
	fi
	ok=0
	for l in $supported_wprefs_locales; do
		if test "$l" = "$lang"; then
			ok=1
			break
		fi
	done
	if test "$ok" = 1; then
		WPMOFILES="$WPMOFILES $lang.mo"
	fi
	ok=0
	for l in $supported_wings_locales; do
		if test "$l" = "$lang"; then
			ok=1
			break
		fi
	done
	if test "$ok" = 1; then
		WINGSMOFILES="$WINGSMOFILES $lang.mo"
	fi
done


dnl Kanji Characters support
dnl ========================

case $host_os in
	freebsd*)
		AC_CHECK_LIB(xpg4, setlocale, [LIBS="$LIBS -lxpg4"]);;
	*)
	;;
esac



dnl Added by Oliver - Support for NLSDIR option,   Hi Oliver!
dnl ===========================================
AC_ARG_WITH(nlsdir, 
	[  --with-nlsdir=PATH      specify where the locale stuff should go ])


if test "x$NLSDIR" = "x"; then
	if test "x$with_nlsdir" != "x"; then
		NLSDIR=$with_nlsdir
	else
		NLSDIR='$(prefix)/lib/locale'
	fi
fi



AC_SUBST(DLLIBS)
AC_SUBST(INTLIBS)
AC_SUBST(NLSDIR)
AC_SUBST(MOFILES)
AC_SUBST(WPMOFILES)
AC_SUBST(WINGSMOFILES)
AC_SUBST(supported_locales)



dnl Support for various hint things
dnl ===============================

dnl vdesktop_on="no"

dnl AC_ARG_ENABLE(vdesktop,
dnl  [  --enable-vdesktop       enable virtual desktop],
dnl  [if test x$enableval = xyes; then
dnl    AC_DEFINE(VIRTUAL_DESKTOP, 1, [define if you want virtual desktop support])
dnl    vdesktop_on=yes
dnl  fi])


dnl
dnl Disable some stuff that are duplicated in kde
dnl ---------------------------------------------
AC_ARG_ENABLE(lite,
  [  --enable-lite           disable some stuff (dont use it) ],
  [if test x$enableval = xyes; then
        LITE=yes
	AC_DEFINE(LITE, 1, [define if you want the 'lite' version])
        AC_SUBST(LITE)
  fi])



dnl
dnl Networking stuff
dnl

NETLIBS=""

AC_CHECK_FUNC(connect,,
	AC_CHECK_LIB(socket, connect, NETLIBS="$NETLIBS -lsocket"))

AC_CHECK_FUNC(gethostbyname,,
	AC_CHECK_LIB(nsl, gethostbyname, NETLIBS="$NETLIBS -lnsl"))

AC_CHECK_FUNC(inet_aton, AC_DEFINE(HAVE_INET_ATON, 1, [define if you have then inet_aton function (set by configure)]),
     for lib in resolv socket inet bsd; do
	AC_CHECK_LIB($lib, inet_aton, [AC_DEFINE(HAVE_INET_ATON)
	             NETLIBS="$NETLIBS -l$lib"; break],, $NETLIBS)
     done)

AC_SUBST(NETLIBS)


dnl ===========================================
dnl 		Stuff that uses X
dnl ===========================================

AC_PATH_XTRA

if test $no_x; then
    AC_MSG_ERROR([The path for the X11 files not found!
Make sure you have X and it's headers and libraries (the -devel packages
in Linux) installed.])
fi

X_LIBRARY_PATH=$x_libraries

XCFLAGS="$X_CFLAGS"

XLFLAGS="$X_LIBS"

XLIBS="-lX11 $X_EXTRA_LIBS"


lib_search_path="$lib_search_path $XLFLAGS"
inc_search_path="$inc_search_path $XCFLAGS"


AC_SUBST(X_LIBRARY_PATH)



dnl Decide which locale function to use, setlocale() or _Xsetlocale()
dnl by MANOME Tomonori 
dnl ===========================================
use_locale=yes
AC_ARG_ENABLE(locale, 
[  --disable-locale        disable use of X locale support],
		use_locale=no)

if test "$use_locale" = yes; then
	AC_CHECK_LIB(X11, _Xsetlocale,
		AC_DEFINE(X_LOCALE, 1, [define if you want support for X window's X_LOCALE (set by configure)]),,
		$XLFLAGS $XLIBS)
fi


dnl Check whether XInternAtoms() exist
dnl ==================================
AC_CHECK_LIB(X11, XInternAtoms, 
             AC_DEFINE(HAVE_XINTERNATOMS, 1, [define if your X server has XInternAtoms() (set by configure)]),,
             $XLFLAGS $XLIBS)

dnl Check whether XConvertCase() exist
dnl ==================================
AC_CHECK_LIB(X11, XConvertCase, 
             AC_DEFINE(HAVE_XCONVERTCASE, 1, [define if your X server has XConvertCase() (set by configure)]),,
             $XLFLAGS $XLIBS)


dnl XKB keyboard language status
dnl ============================
AC_ARG_ENABLE(modelock,
[  --enable-modelock       XKB keyboard language status support],
		AC_DEFINE(XKB_MODELOCK, 1, [whether XKB language MODELOCK should be enabled]))



dnl Shape support
dnl =============
shape=yes
AC_ARG_ENABLE(shape, 
[  --disable-shape         disable shaped window extension support],
		shape=$enableval, shape=yes)

added_xext=no

if test "$shape" = yes; then
	AC_CHECK_LIB(Xext, XShapeSelectInput, [XLIBS="-lXext $XLIBS"
		added_xext=yes
		AC_DEFINE(SHAPE, 1, [define if you want support for shaped windows (set by configure)])], 
		shape=no, $XLFLAGS $XLIBS)
fi


dnl Xft2 antialiased font support
dnl =============================

xft=yes
XFTLIBS=""

if test "x$PKGCONFIG" != x -a "`$PKGCONFIG xft; echo $?`" = 0; then
        XFTCONFIG="$PKGCONFIG xft"
        pkgconfig_xft=yes
else
        AC_CHECK_PROG(XFTCONFIG, xft-config, xft-config)
fi

AC_MSG_CHECKING([for the Xft2 library])

if test "x$XFTCONFIG" != x; then
        XFTLIBS=`$XFTCONFIG --libs`
        XFTFLAGS=`$XFTCONFIG --cflags`
        AC_MSG_RESULT([found])
else
        AC_MSG_RESULT([not found])
        echo
        echo "ERROR!!! libXft2 is not installed or could not be found."
        echo "         Xft2 is a requirement for building Window Maker."
        echo "         Please install it (along with fontconfig) before continuing."
        echo
        exit 1
fi

minXFT="2.1.0"
goodxft="no"

dnl
dnl The macro below will use $XFTFLAGS (defined above) to find Xft.h
dnl
WM_CHECK_XFT_VERSION($minXFT, goodxft=yes, goodxft=no)

if test "$goodxft" = no; then
        echo
        echo "ERROR!!! libXft on this system is an old version."
        echo "         Please consider upgrading to at least version ${minXFT}."
        echo
        exit 1
fi

AC_SUBST(XFTFLAGS)
AC_SUBST(XFTLIBS)


dnl XINERAMA support
dnl ================
xinerama=no
AC_ARG_ENABLE(xinerama,
[  --enable-xinerama       enable Xinerama extension support],
		xinerama=$enableval, xinerama=no)

if test "$xinerama" = yes; then
	AC_CHECK_LIB(Xinerama, XineramaQueryScreens, 
                [XLIBS="-lXinerama $XLIBS"
                xfxine=yes],
		xfxine=no, $XLFLAGS $XLIBS)

	AC_CHECK_LIB(Xext, XineramaGetInfo,
                [sunxine=yes
                ], sunxine=no, $XLFLAGS $XLIBS)

	if test "$xfxine" = yes; then
		xine=1
	fi

	if test "$sunxine" = yes; then
	    xine=1
	    AC_DEFINE(SOLARIS_XINERAMA, 1, 
		[define if you want support for the XINERAMA extension and are in Solaris (set by configure)])
	fi

	if test "$xine" = 1; then
	    AC_DEFINE(XINERAMA, 1, 
		[define if you want support for the XINERAMA extension (set by configure)])
	fi
fi



dnl MIT-SHM support
dnl ===============
shm=yes
AC_ARG_ENABLE(shm,
[  --disable-shm           disable usage of MIT-SHM extension],
		shm=$enableval, shm=yes)

if test "$shm" = yes; then
	AC_CHECK_LIB(Xext, XShmAttach, ok=yes, ok=no, $XLFLAGS $XLIBS)

	if test "$ok" = yes; then
	AC_CHECK_FUNC(shmget, ok=yes, ok=no)
	fi

	if test "$ok" = yes; then
		if test "$added_xext" = no; then
			XLIBS="-lXext $XLIBS"
		fi
                AC_DEFINE(XSHM, 1, [define if X's shared memory extension is available (set by configure)])
	fi
fi


dnl R6 Style Session Management Support
dnl ===================================

#
#
#AC_DEFINE(R6SM)
#AC_SUBST(XSMPLIBS)
#


dnl ==============================================
dnl         Graphic Format Libraries
dnl ==============================================





dnl XPM Support
dnl ===========
xpm=yes
AC_ARG_ENABLE(xpm, 
[  --disable-xpm           disable use of XPM pixmaps through libXpm],
	xpm=$enableval, xpm=yes)

if test "$xpm" = yes; then
    WM_CHECK_LIB(Xpm, XpmCreatePixmapFromData, [$XLFLAGS $XLIBS])

    if test "x$ac_cv_lib_Xpm_XpmCreatePixmapFromData" = xyes; then
        WM_CHECK_HEADER(X11/xpm.h)
	if test "x$ac_cv_header_X11_xpm_h" = xyes; then
		GFXLIBS="$GFXLIBS -lXpm"
		supported_gfx="XPM"
		AC_DEFINE(USE_XPM, 1, [define if XPM libraries are available (set by configure)])
	else
		supported_gfx="builtin-XPM"
	fi
    fi
fi

# for wmlib
AC_SUBST(XCFLAGS)
# for test
AC_SUBST(XLFLAGS)
AC_SUBST(XLIBS)

AC_SUBST(X_EXTRA_LIBS)

dnl ===============================================
dnl 		End of stuff that uses X
dnl ===============================================



dnl PNG Support
dnl ===========
png=yes
AC_ARG_ENABLE(png, 
[  --disable-png           disable PNG support through libpng],
	png=$enableval, png=yes, png=no)


if test "$png" = yes ; then
    WM_CHECK_LIB(png, png_get_valid, [-lz -lm])

    if test "x$ac_cv_lib_png_png_get_valid" = xyes; then
    	WM_CHECK_HEADER(png.h)
	if test "x$ac_cv_header_png_h" = xyes; then
	    GFXLIBS="$GFXLIBS -lpng -lz" 
	    supported_gfx="$supported_gfx PNG"
            AC_DEFINE(USE_PNG, 1, [define if PNG libraries are available (set by configure)])
	fi
    fi
fi


dnl JPEG Support
dnl ============
jpeg=yes
ljpeg=""
AC_ARG_ENABLE(jpeg,
[  --disable-jpeg          disable JPEG support through libjpeg],
	jpeg=$enableval, jpeg=yes, jpeg=no)

if test "$jpeg" = yes; then
    WM_CHECK_LIB(jpeg, jpeg_destroy_compress)

    if test "x$ac_cv_lib_jpeg_jpeg_destroy_compress" = xyes; then

    	ljpeg="-ljpeg"

	WM_CHECK_HEADER(jpeglib.h)
	if test "x$ac_cv_header_jpeglib_h" = xyes; then
	    GFXLIBS="$GFXLIBS -ljpeg"
	    supported_gfx="$supported_gfx JPEG"
            AC_DEFINE(USE_JPEG, 1, [define if JPEG libraries are available (set by configure)])
	fi
    fi
fi


dnl GIF Support
dnl ============
gif=yes
AC_ARG_ENABLE(gif,
[  --disable-gif           disable GIF support through libgif or libungif],
	gif=$enableval, gif=yes, gif=no)

if test "$gif" = yes; then
    my_libname=""
    WM_CHECK_LIB(ungif, DGifOpenFileName, [$XLFLAGS $XLIBS])
    if test "x$ac_cv_lib_ungif_DGifOpenFileName" = xyes; then
        my_libname=-lungif
    fi
dnl
dnl libungif is the same thing as libgif for all practical purposes.
dnl
    if test "x$my_libname" = x; then
        WM_CHECK_LIB(gif, DGifOpenFileName, [$XLFLAGS $XLIBS])
        if test "x$ac_cv_lib_gif_DGifOpenFileName" = xyes; then
            my_libname=-lgif
        fi
    fi

    if test "$my_libname" != x; then
	WM_CHECK_HEADER(gif_lib.h)
	if test "x$ac_cv_header_gif_lib_h" = xyes; then
	    GFXLIBS="$GFXLIBS $my_libname"
	    supported_gfx="$supported_gfx GIF"
            AC_DEFINE(USE_GIF, 1, [define if GIF libraries are available (set by configure)])
	fi
    fi
fi



dnl TIFF Support
dnl ============
AC_ARG_ENABLE(tiff, 
[  --disable-tiff          disable use of TIFF images through libtiff],
	tif=$enableval, tif=yes, tif=no)

#
# TIFF can optionally have JPEG and/or zlib support. Must find out
# when they are supported so that correct library flags are passed during
# detection and linkage
#
#
# By default use xpm icons if tiff is not found.
ICONEXT="xpm"
#

if test "$tif" = yes; then
    my_libname=""
    WM_CHECK_LIB(tiff, TIFFGetVersion, [-lm])
    if test "x$ac_cv_lib_tiff_TIFFGetVersion" = xyes; then
    	my_libname="-ltiff"
    fi
dnl
dnl Retry with zlib
dnl
    unset ac_cv_lib_tiff_TIFFGetVersion
    if test "x$my_libname" = x; then
    	WM_CHECK_LIB(tiff, TIFFGetVersion, [$ljpeg -lz -lm])
	if test "x$ac_cv_lib_tiff_TIFFGetVersion" = xyes; then
	    my_libname="-ltiff -lz"
	fi
    fi

    if test "x$my_libname" = x; then
	WM_CHECK_LIB(tiff34, TIFFGetVersion, [$ljpeg -lm])
	if test "x$ac_cv_lib_tiff34_TIFFGetVersion" = xyes; then
	    my_libname="-ltiff34"
	fi
    fi


    if test "x$my_libname" != x; then
	WM_CHECK_HEADER(tiffio.h)
	if test "x$ac_cv_header_tiffio_h" = xyes; then
	    GFXLIBS="$my_libname $GFXLIBS"
	    ICONEXT="tiff"
            supported_gfx="$supported_gfx TIFF"
            AC_DEFINE(USE_TIFF, 1, [define if TIFF libraries are available (set by configure)])	    
	fi
    fi
fi

LIBRARY_SEARCH_PATH="$lib_search_path"
HEADER_SEARCH_PATH="$inc_search_path"

AC_SUBST(LIBRARY_SEARCH_PATH)
AC_SUBST(HEADER_SEARCH_PATH)


AC_SUBST(GFXLIBS)
AC_SUBST(ICONEXT)


dnl ==============================================
dnl         End of Graphic Format Libraries
dnl ==============================================


dnl
dnl stdlib.h is checked here, because of conflict in jpeglib.h
AC_CHECK_HEADERS(stdlib.h)

# AC_PREFIX_PROGRAM(wmaker)

dnl Support for PIXMAPDIR option
dnl ============================
AC_ARG_WITH(pixmapdir,
[  --with-pixmapdir=PATH   specify where pixmaps are located [DATADIR/pixmaps]])

if test "x$with_pixmapdir" != "x"; then
	pixmapdir=$with_pixmapdir
else
	pixmapdir=`eval echo ${datadir}/pixmaps`
fi

AC_DEFINE_UNQUOTED(PIXMAPDIR, "$pixmapdir", [define an extra path for pixmaps (set by configure)])

pkgdatadir=`eval echo $datadir`
AC_DEFINE_UNQUOTED(PKGDATADIR, "$pkgdatadir/WindowMaker", [where shared data is stored (defined by configure)])

_sysconfdir=`eval echo $sysconfdir`
AC_DEFINE_UNQUOTED(SYSCONFDIR, "$_sysconfdir", [where the configuration is stored (defined by configure)])


dnl Support for GNUSTEP_LOCAL_ROOT, for WPrefs.app
dnl ==============================================

AC_ARG_WITH(appspath,
[  --with-gnustepdir=PATH  specify the directory for GNUstep applications])

appspath=$with_gnustepdir

if test "x$appspath$GNUSTEP_LOCAL_ROOT" = "x"; then
    wprefs_base_dir=${prefix}
    wprefs_datadir="${datadir}/WPrefs"
    wprefs_bindir="${bindir}"
else
    gnustepdir=$appspath

    if test "x$GNUSTEP_LOCAL_ROOT" != "x" ; then
	gnustepdir=`echo "$GNUSTEP_LOCAL_ROOT" | sed -e "s|^${prefix}|prefix|"`
	gnustepdir=`echo $gnustepdir | sed -e 's|^prefix|${prefix}|'`
    fi

    wprefs_base_dir=$gnustepdir/Applications
    wprefs_datadir=$wprefs_base_dir/WPrefs.app
    wprefs_bindir=$wprefs_base_dir/WPrefs.app
fi

AC_SUBST(wprefs_datadir)
AC_SUBST(wprefs_bindir)


dnl Enable User Defined Menu thing
dnl ==================================
AC_ARG_ENABLE(usermenu,
[  --enable-usermenu       user defined menus for applications
],
if test "$enableval" = yes; then
	AC_DEFINE(USER_MENU, 1, [define if you want user defined menus for applications])
fi
)


dnl
dnl Nicolai:  Program tests for Documentation Section
dnl =================================================
dnl DOCTYPES=""
dnl AC_CHECK_PROG(MAKEINFO, makeinfo, makeinfo, ,$PATH)
dnl if test "x$MAKEINFO" != "x" ; then
dnl       DOCTYPES="$DOCTYPES info_doc"
dnl fi
dnl AC_CHECK_PROG(TEX, tex, tex, ,$PATH)
dnl if test "x$TEX" != "x" ; then
dnl       DOCTYPES="$DOCTYPES dvi_doc"
dnl fi
dnl AC_CHECK_PROG(DVIPS, dvips, dvips, ,$PATH)
dnl if test "x$DVIPS" != "x" ; then
dnl       DOCTYPES="$DOCTYPES ps_doc"
dnl fi
dnl AC_CHECK_PROG(PERL, perl, perl, ,$PATH)
dnl if test "x$PERL" != "x" ; then
dnl       DOCTYPES="$DOCTYPES html_doc"
dnl fi
dnl AC_PATH_PROG(PERL_PATH, perl, perl, ,$PATH)
dnl AC_CHECK_PROG(TEXI2HTML, texi2html, texi2html, ,$PATH)
  
dnl AC_SUBST(DOCTYPES)

AC_OUTPUT(Makefile po/Makefile util/Makefile test/Makefile \
	WINGs/Makefile WINGs/WINGs/Makefile WINGs/Documentation/Makefile \
	WINGs/Examples/Makefile WINGs/Resources/Makefile WINGs/Tests/Makefile \
	WINGs/Extras/Makefile WINGs/po/Makefile \
	wmlib/Makefile wrlib/Makefile wrlib/tests/Makefile \
	src/Makefile src/wconfig.h \
	doc/Makefile doc/sk/Makefile \
	WindowMaker/Makefile WindowMaker/Backgrounds/Makefile \
	WindowMaker/Defaults/Makefile WindowMaker/IconSets/Makefile \
	WindowMaker/Icons/Makefile WindowMaker/Pixmaps/Makefile \
	WindowMaker/Styles/Makefile WindowMaker/Themes/Makefile \
	WPrefs.app/Makefile WPrefs.app/tiff/Makefile WPrefs.app/xpm/Makefile \
	WPrefs.app/po/Makefile \
	contrib/Makefile contrib/WindowMaker.spec )
#	plugins/Makefile plugins/libwmfun/Makefile)



dnl
dnl Output some helpful data for compiling wraster and WINGs/WUtil apps
dnl ===================================================================
dnl

dnl echo "WFLAGS=\"$LIBPL_INC_PATH -I$prefix/include\"" > WINGs-flags
dnl echo "WLIBS=\"-L$exec_prefix/lib -lWINGs -lwraster $LIBPL_LIBS $GFXLIBS -lm\""\
dnl 	| sed -e 's|\$(prefix)|'"$prefix|" >> WINGs-flags

dnl The #lp# and #rp# stuff below is a hack because [ and ] get lost when
dnl parsed by m4

cat <<EOF >get-wraster-flags
#!/bin/sh

WCFLAGS="$inc_search_path"
WLFLAGS="$lib_search_path"
WLIBS="-lwraster $GFXLIBS $XLIBS -lm"

usage="Usage: get-wraster-flags #lp#--cflags#rp# #lp#--ldflags#rp# #lp#--libs#rp#"

if test \$# -eq 0; then
      echo "\${usage}" 1>&2
      exit 1
fi

while test \$# -gt 0; do
  case \$1 in
    --cflags)
	echo \$WCFLAGS
        ;;
    --ldflags|--lflags)
	echo \$WLFLAGS
        ;;
    --libs)
	echo \$WLIBS
        ;;
    *)
    	echo "\${usage}" 1>&2
    	exit 1
      	;;
  esac
  shift
done


EOF

cat <<EOF > wrlib/wrlib.pc
Name: wrlib
Description: Image manipulation and conversion library
Version: $VERSION
Libs: $lib_search_path -lwraster $GFXLIBS $XLIBS -lm
Cflags: $inc_search_path
EOF

cat <<EOF >get-wings-flags
#!/bin/sh

WCFLAGS="$inc_search_path"
WLFLAGS="$lib_search_path"
WLIBS="-lWINGs -lwraster $GFXLIBS $XFTLIBS $XLIBS -lm $NETLIBS $INTLIBS"

usage="Usage: get-wings-flags #lp#--cflags#rp# #lp#--ldflags#rp# #lp#--libs#rp#"

if test \$# -eq 0; then
      echo "\${usage}" 1>&2
      exit 1
fi

while test \$# -gt 0; do
  case \$1 in
    --cflags)
	echo \$WCFLAGS
        ;;
    --ldflags|--lflags)
	echo \$WLFLAGS
        ;;
    --libs)
	echo \$WLIBS
        ;;
    *)
    	echo "\${usage}" 1>&2
    	exit 1
      	;;
  esac
  shift
done


EOF

cat <<EOF > WINGs/WINGs.pc
Name: WINGs
Description: Small widget set with the NeXTStep(TM) look and feel
Version: $VERSION
Requires: wrlib
Libs: $lib_search_path -lWINGs $XFTLIBS $XLIBS -lm $NETLIBS $INTLIBS
Cflags: $inc_search_path
EOF

cat <<EOF >get-wutil-flags
#!/bin/sh

WCFLAGS="-I`eval echo ${includedir}`"
WLFLAGS="-L${_libdir}"
WLIBS="-lWUtil $NETLIBS $INTLIBS"

usage="Usage: get-wutil-flags #lp#--cflags#rp# #lp#--ldflags#rp# #lp#--libs#rp#"

if test \$# -eq 0; then
      echo "\${usage}" 1>&2
      exit 1
fi

while test \$# -gt 0; do
  case \$1 in
    --cflags)
	echo \$WCFLAGS
        ;;
    --ldflags|--lflags)
	echo \$WLFLAGS
        ;;
    --libs)
	echo \$WLIBS
        ;;
    *)
    	echo "\${usage}" 1>&2
    	exit 1
      	;;
  esac
  shift
done


EOF

cat <<EOF > wmlib/wmlib.pc
Name: wmlib
Description: FIXME: What do I write here?
Version: $VERSION
Requires: wrlib
Libs: $lib_search_path -lWUtil $NETLIBS $INTLIBS
Cflags: $inc_search_path
EOF

sed 's/#lp#/[/g' get-wraster-flags | sed 's/#rp#/]/g' > wrlib/get-wraster-flags
sed 's/#lp#/[/g' get-wings-flags | sed 's/#rp#/]/g' > WINGs/get-wings-flags
sed 's/#lp#/[/g' get-wutil-flags | sed 's/#rp#/]/g' > WINGs/get-wutil-flags

chmod 755 wrlib/get-wraster-flags WINGs/get-wings-flags WINGs/get-wutil-flags

rm -f get-wraster-flags get-wings-flags get-wutil-flags


dnl
dnl Spit out the configuration
dnl ==========================

supported_gfx="$supported_gfx builtin-PPM"

if test "x$MOFILES" = "x"; then
	mof=None
else
	mof=`echo $MOFILES`
fi

if test "x$MOFILES" = "x"; then
	languages=None
else
	languages=`echo $MOFILES | sed 's/.mo//g'`
fi

echo
echo "Window Maker was configured as follows:"
echo
echo "Installation path prefix            : $prefix"
echo "Installation path for binaries      : $_bindir"
echo "Installation path for WPrefs.app    : $wprefs_base_dir" | sed -e 's|\${prefix}|'"$prefix|"
echo "Supported graphic format libraries  : $supported_gfx"
echo "Use assembly routines for wrlib     : $asm_support"
echo "Use inline MMX(tm) x86 assembly     : $mmx_support"
echo "Antialiased text support in WINGs   : $xft"
echo "Xinerama extension support          : $xinerama"
dnl echo "Virtual desktop support             : $vdesktop_on"
echo "Translated message files to install : $mof"
dnl echo "Supported languages beside English  : $languages"
if test "x$MOFILES" != "x"; then
	echo "Installation path for translations  : $NLSDIR" | sed -e 's|\$(prefix)|'"$prefix|"
fi
echo

dnl WM_PRINT_REDCRAP_BUG_STATUS

if test "x$ac_cv_header_jpeglib_h" != xyes; then
echo "WARNING   WARNING   WARNING   WARNING   WARNING   WARNING   WARNING"
echo
echo "JPEG support will not be included because the JPEG library is"
echo "not installed correctly or was not found. Background images"
echo "from themes will not display as they usually are JPEG files."
echo
echo "To fix, download and install the jpeg library and/or make sure you"
echo "installed all jpeg related packages, SPECIALLY the development packages"
echo "like jpeg-devel (if you use some prepackaged version of libjpeg)."
echo
echo "WARNING   WARNING   WARNING   WARNING   WARNING   WARNING   WARNING"
fi


dnl This is for Emacs.  I'm lazy, I know... (nicolai)
dnl ================================================
dnl Local Variables:
dnl compile-command: "autoconf"
dnl End: