File: configure.ac

package info (click to toggle)
foxeye 0.12.0-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 4,792 kB
  • sloc: ansic: 62,790; sh: 5,155; makefile: 746; yacc: 291; tcl: 239; sed: 16
file content (1007 lines) | stat: -rw-r--r-- 29,002 bytes parent folder | download
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
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ(2.51)
AC_INIT([FoxEye], 0.12.0,, foxeye, [http://foxeye.sf.net])
AM_CONFIG_HEADER(config.h)
AM_INIT_AUTOMAKE

AC_CANONICAL_HOST

dnl Checks for programs.
AC_PROG_MAKE_SET
AC_PROG_INSTALL
AC_PROG_MKDIR_P
AC_PROG_RANLIB
AC_PROG_LN_S
AC_PATH_PROG(BASENAME, basename)
AC_PATH_PROG(BASH, bash)
AC_PATH_PROGS(XGETTEXT, [gxgettext xgettext])

dnl Define systems for some code specifics
case "$host_os" in
    linux* | kfreebsd* | gnu)
	AC_DEFINE(_LINUX, 1, [Define to 1 if on Linux.])
	;;
    freebsd*)
	AC_DEFINE(_FREEBSD, 1, [Define to 1 if on FreeBSD.])
	;;
    openbsd* | netbsd*)
	AC_DEFINE(_OPENBSD, 1, [Define to 1 if on OpenBSD.])
	;;
    hpux)
	AC_DEFINE(_HPUX, 1, [Define to 1 if on HP-UX.])
	;;
    *)
	;;
esac

dnl Some non-standard compiler defaults
if test "x$CC" = x; then
    case "$host_os" in
	bsd*)
	    if test ! "${host_os}" = bsdi2; then
		CC="shlicc"
	    fi
	    ;;
	solaris*)
	    CC="c99"
	    AC_PATH_PROG(GMAKE, gmake)
	    if test -z "$ac_cv_path_GMAKE"; then
		AC_MSG_ERROR([gmake required for compilation of FoxEye.])
	    fi
	    MAKE="$ac_cv_path_GMAKE"
	    FORCE_GMAKE="MAKE = $ac_cv_path_GMAKE"
	    AC_SUBST(FORCE_GMAKE)
	    ;;
	*)
	    ;;
    esac
fi
if test "x$CC" != x; then
    AC_MSG_RESULT(compiler is set to $CC)
fi

dnl Checks for C compiler features
: ${CFLAGS=""}
AC_PROG_CC
AC_PROG_CC_C99
AC_USE_SYSTEM_EXTENSIONS
# AC_PROG_CXX
AC_C_CONST
AC_C_VOLATILE
AC_C_INLINE

dnl Checks for system features to implement optimizations
# AC_C_BIGENDIAN
# AC_CHECK_SIZEOF(int)

ac_default_prefix="${HOME}/${PACKAGE}"
m4_pattern_allow(LIBOBJ)

if test "$ac_cv_c_inline" != no ; then
    AC_DEFINE(HAVE_INLINE, 1, [Define to 1 if you have working `inline' modifier.])
    AC_SUBST(HAVE_INLINE)
fi

dnl Default linker for the modules
CCLIB="\$(CC)"

dnl Prepare summary
AC_MSG_CACHE_INIT([$PACKAGE_NAME])

dnl Checks for options to CFLAGS
AC_CHECK_LDFLAG(fe_cv_add_wnotrigraphs, -Wno-trigraphs, CPPFLAGS)
AC_CHECK_LDFLAG(fe_cv_add_wnolonglong, -Wno-long-long, CPPFLAGS)
AC_CHECK_LDFLAG(fe_cv_add_wnopointersign, -Wno-pointer-sign, CPPFLAGS)
AC_CHECK_LDFLAG(fe_cv_add_wnounusedparameter, -Wno-unused-parameter, CPPFLAGS)
AC_CHECK_LDFLAG(fe_cv_add_wall, -Wall, CFLAGS)
AC_CHECK_LDFLAG(fe_cv_add_pipe, -pipe, CFLAGS)
AC_CHECK_LDFLAG(fe_cv_add_fshortenums, -fshort-enums, CPPFLAGS)

dnl Do we want debug or optimization?
AC_ARG_ENABLE(debug,
    [  --enable-debug[[=info]]   creates debugging code],
    fe_enable_debug="$enableval", fe_enable_debug="no")
    if test x"$fe_enable_debug" = xno; then
	dnl enable optimization - this is default
	ac_cv_add_optimization=yes
	dnl Adding -S (strip debug) to linker
	AC_CHECK_LDFLAG(fe_cv_add_s, [-Wl,-S], LDFLAGS)
    else
	dnl disable optimization and add extra warnings if it's debug compilation
	if test x"$fe_enable_debug" = xinfo; then
	    ac_cv_add_optimization=yes
	else
	    ac_cv_add_optimization=no
	fi
	AC_CHECK_LDFLAG(fe_cv_add_g, -g, CFLAGS)
	AC_CHECK_LDFLAG(fe_cv_add_wextra, -Wextra, CPPFLAGS)
    fi
if test $ac_cv_add_optimization = yes; then
    dnl Compiler specific options
    case "$CC" in
	c99*)
	    AC_CHECK_LDFLAG(fe_cv_add_erroff, -erroff, CPPFLAGS)
	    AC_CHECK_LDFLAG(fe_cv_add_fast, -fast, CPPFLAGS)
	    fe_save_CC="$CC"
	    CC="c99 -fast"
	    AC_CHECK_LDFLAG(fe_cv_add_xipo, -xipo=2, CPPFLAGS)
	    CC="$fe_save_CC"
	    AC_CHECK_LDFLAG(fe_cv_add_xrestrict, [-xrestrict=%all], CPPFLAGS)
	    AC_CHECK_LDFLAG(fe_cv_add_xinline, [-xinline=%auto], CPPFLAGS)
	    ;;
	*)
	    AC_CHECK_LDFLAG(fe_cv_add_oo, -O2, CFLAGS)
	    dnl GCC 3.x guess wrong about strict aliasing
	    fe_save_CFLAGS="$CFLAGS"
	    CFLAGS="$CFLAGS -Werror"
	    AC_TRY_COMPILE([struct atest {
char *s; };], [struct atest *a;
void **v = (void **)&a;
*v = (void *)a;
], [CFLAGS="$fe_save_CFLAGS"], [CFLAGS="$fe_save_CFLAGS"
		AC_CHECK_LDFLAG(fe_cv_add_fnostrictaliasing, -fno-strict-aliasing, CPPFLAGS)
	    ])

	    ;;
    esac
fi
AC_MSG_CACHE_ADD([Debug support], [$fe_enable_debug])

dnl Need to make static code?
AC_ARG_ENABLE(static,
    [  --enable-static         build static code],
    [ unset fe_cv_static
    if test $enableval = yes; then
        fe_enable_static=yes
    fi], [fe_enable_static=no])

AC_CACHE_CHECK([whether you need static compiling], fe_cv_static,
[  fe_cv_static="$fe_enable_static"
if test "$fe_cv_static" = no; then
    case "$host_os" in
	linux* | kfreebsd* | gnu | freebsd* | openbsd* | netbsd* | darwin*)
	    ;;
	bsd*)
	    AC_MSG_RESULT(BSD/OS, ok)
	    AC_MSG_CHECKING(again for static)
	    if test "${host_os}" = bsdi2; then
		fe_cv_static=yes
	    fi
	    ;;
	solaris* | sunos* | hpux)
	    ;;
	*)
	    # I don't know how to builf modules on other platforms
	    # Will try to run, maybe fall on the start...
	    fe_cv_static=yes
	    ;;
    esac
fi ])

ADD_LC=
MOD_LIBS=
SONAME_KEY=soname
SONAME_PREFIX=
if test "$fe_cv_static" = no; then
    case "$host_os" in
	linux* | kfreebsd* | gnu)
	    CCLIB="${CCLIB} -shared"
	    dnl use -fpic on 32 bit systems and -fPIC on 64 bit systems
	    case "$ac_cv_build" in
		*64*)
		    AC_CHECK_LDFLAG(fe_cv_fpic, [-fPIC], CPPFLAGS)
		    ;;
		*)
		    AC_CHECK_LDFLAG(fe_cv_fpic, [-fpic], CPPFLAGS)
		    ;;
	    esac
	    ;;
	darwin*)
	    CCLIB="${CCLIB} -shared"
	    AC_CHECK_LDFLAG(fe_cv_fpic, [-fPIC], CPPFLAGS)
	    dnl Homebrew installs headers and libs under /usr/local in OS X
	    CPPFLAGS="-I/usr/local/bin ${CPPFLAGS}"
	    MOD_LIBS=-L/usr/local/lib
	    LIBS="${MOD_LIBS} ${LIBS}"
	    SONAME_KEY=install_name
	    SONAME_PREFIX="@rpath/"
	    ;;
	freebsd*)
	    CCLIB="${CCLIB} -shared"
	    CPPFLAGS="-fpic ${CPPFLAGS}"
	    ;;
	openbsd* | netbsd*)
	    CCLIB="${CCLIB} -Wl,-x -Wl,-Bshareable"
	    CPPFLAGS="-fpic ${CPPFLAGS}"
	    ;;
	bsd*)
	    if test ! "${host_os}" = bsdi2; then
		LD="shlicc -r"
	    fi
	    ;;
	solaris*)
#	    LD="ld -G -z text"
	    CCLIB="${CCLIB} -G"
	    CPPFLAGS="-Kpic ${CPPFLAGS}"
	    AC_CHECK_LDFLAG(fe_cv_add_wl_e, [-Wl,-E], LDFLAGS)
	    case "$CC" in
		gcc*)
		    ;;
		*)
		    dnl explicitly add libc to link shared objects
		    ADD_LC="-lc"
		    ;;
	    esac
	    ;;
	sunos*)
	    dnl LD="ld"
	    CPPFLAGS="-fPIC ${CPPFLAGS}"
	    AC_CHECK_LIB(dl,main)
	    ;;
	hpux)
	    CCLIB="${CCLIB} -Wl,-b, -Wl,-E"
	    CPPFLAGS="-fPIC ${CPPFLAGS}"
	    ;;
	*)
	    ;;
    esac
fi
AC_SUBST(ADD_LC)
AC_SUBST(SONAME_KEY)
AC_SUBST(SONAME_PREFIX)
AC_SUBST(MOD_LIBS)

dnl Some substitutions for modules/Makefile.mods
case `eval "${MAKE-make} -v -f NoFile 2>/dev/null"` in
    GNU*)
	MAKE_IS_GNU=true
	;;
    *)
esac
AM_CONDITIONAL([MAKE_IS_GNU], [test x$MAKE_IS_GNU = xtrue])

dnl AM_ICONV uses strange variable ac_t in reports so reset it now
ac_t=
AC_CHECK_ICONV

AC_CHECK_IPV6

dnl Checks for multithreaded heap managers
AC_SEARCH_LIBS(mallocctl, mtmalloc) dnl Sun's MTmalloc
AC_HAVE_LIBRARY(hoard) dnl Not sure if it works that way

dnl Check for libthr presence (it has thread-safe libc functions on FreeBSD)
AC_HAVE_LIBRARY(thr)

dnl Checks for libraries and extensions
AC_SEARCH_LIBS(socket, socket)
AC_SEARCH_LIBS(connect, nsl)
AC_SEARCH_LIBS(getaddrinfo, [dns nsl])
AC_SEARCH_LIBS(inet_ntop, nsl)
AC_SEARCH_LIBS(clock_gettime, rt)

if test "$fe_cv_static" = no; then
    AC_SEARCH_LIBS(dlopen, dl,
	[AC_DEFINE(HAVE_DLOPEN, 1, [Define to 1 if you have the `dlopen' function.])],
	[AC_MSG_WARN([    Sorry, modules are not available now])
	fe_cv_static=yes
    ])
fi
AC_MSG_CACHE_ADD([Static compiling], [$fe_enable_static])

dnl Checks for threads.
AC_SEARCH_LIBS(pthread_cancel, [c_r pthread], [fe_cv_have_pthreads=yes],
    [AC_MSG_ERROR([you cannot compile without threads support.
      Install pthreads library and then run configure again.])
])
AC_CHECK_LDFLAG(fe_cv_add_pthread, -pthread, CFLAGS)

dnl Checks for header files.
AC_HEADER_DIRENT
AC_HEADER_SYS_WAIT
AC_HEADER_TIME
AC_CHECK_HEADERS(unistd.h dlfcn.h crypt.h getopt.h limits.h posix1_lim.h)
AC_CHECK_HEADERS(fcntl.h strings.h stdint.h sys/filio.h thread.h wctype.h)
AC_CHECK_HEADERS(sys/ioctl.h)

dnl Checks for typedefs, structures, and compiler characteristics.
AC_TYPE_PID_T
AC_TYPE_UID_T
# AC_CHECK_MEMBERS([struct sigaction.sa_handler],,,[#include <signal.h>])

if test "$fe_cv_static" = yes; then
    EXTRA_HDR='${top_srcdir}/core/static.h'
    CPPFLAGS="${CPPFLAGS} -DSTATIC"
    LD_MODS="../modules/*/*.o"
    dnl LD="${CC}"
    AC_CHECK_LDFLAG(fe_cv_add_static, [-static], LDFLAGS)
    if test $fe_cv_add_static = no; then
	AC_CHECK_LDFLAG(fe_cv_add_Bstatic, [-Bstatic], LDFLAGS)
    fi
else
    dnl Check for -rdynamic option to LDFLAGS
    AC_CHECK_LDFLAG(fe_cv_add_rdynamic, -rdynamic, LDFLAGS)
    dnl Try to be more strict on dynamic objects
    AC_CHECK_LDFLAG(fe_cv_add_O1, [-Wl,-O1], LDFLAGS)
    AC_CHECK_LDFLAG(fe_cv_add_z_defs, [-Wl,-z,defs], LDFLAGS)
fi
AM_CONDITIONAL([STATICBUILD], [test x$fe_cv_static = xyes])

dnl Checks for library functions.
AC_CHECK_FUNCS(rename sigaction strncasecmp towlower)

AC_CACHE_CHECK([whether you need libcrypt], ac_cv_need_libcrypt,
[
    ac_cv_have_crypt=yes
    AC_TRY_LINK([], [crypt ("","");], [ac_cv_need_libcrypt=no],
	[save_LIBS="${LIBS}"
	LIBS="-lcrypt ${LIBS}"
	AC_TRY_LINK([], [crypt ("","");], [ac_cv_need_libcrypt=yes],
	    [ac_cv_need_libcrypt=no
	    ac_cv_have_crypt=no
	])
	LIBS="${save_LIBS}"
    ])
])
if test "$ac_cv_have_crypt" = no; then
    AC_MSG_ERROR([you have no encryption library but need it for password save.])
fi
if test "$ac_cv_need_libcrypt" = yes; then
    LIBS="-lcrypt ${LIBS}"
fi

AC_REPLACE_FUNCS(strcasecmp)

AC_CHECK_FUNC(rwlock_init, [AC_DEFINE(HAVE_RWLOCK_INIT)
    AC_CHECK_LDFLAG(fe_cv_add_mt, -mt, CFLAGS)],
    [AC_CHECK_FUNCS(pthread_rwlock_init)
])
if test "$ac_cv_func_rwlock_init" = no -a "$ac_cv_func_pthread_rwlock_init" = no
then
    AC_REPLACE_FUNCS(rwlock_init)
fi

GENDATE="`LC_TIME=C date +'%B %Y'`"
AC_SUBST(GENDATE)
AC_DEFINE_UNQUOTED(COMPILETIME, "`LC_TIME=C date`", [The compilation time string.])

AC_SUBST(CCLIB)
AC_SUBST(LD_MODS)
AC_SUBST(BASENAME)
AC_SUBST(EXTRA_HDR)
AC_SUBST(MODLIBS)
AC_SUBST(STATICLIBS)

AM_GNU_GETTEXT
AC_MSG_CACHE_ADD([Use included libintl], [$USE_INCLUDED_LIBINTL])

AC_SYS_LONG_FILE_NAMES

AC_CHECK_LIBIDN

AC_CONFIG_FILES(Makefile \
        doc/Makefile \
        help/Makefile \
        scripts/Makefile \
	tree/Makefile \
        modules/Makefile \
	modules/Makefile.mods \
        core/Makefile \
	core/init.h \
	intl/Makefile \
	ui/Makefile \
	po/Makefile.in \
	doc/foxeye.1 \
	foxeye.pc)

dnl We have to include -lnsl on Solaris, use results from main tests
if test "$ac_cv_search_inet_ntop" != no; then :
  if test "$ac_cv_search_inet_ntop" != "none required"; then
    MODLIBS="MODLIBS_irc_ctcp=\"$ac_cv_search_inet_ntop\" ${MODLIBS}"
  fi
fi

AC_ARG_WITH([rusnet],
    [AS_HELP_STRING([--with-rusnet],
		    [compile ircd optimized for RusNet @<:@default=no@:>@])],
    [if test x$withval = xyes; then
	AC_DEFINE([RUSNET_COMPILE], [1],
		  [Define to 1 to compile ircd-rusnet module for using in RusNet IRC network])
	AC_MSG_CACHE_ADD([RusNet ircd support module], [yes])
    else
	AC_MSG_CACHE_ADD([RusNet ircd support module], [no])
    fi
])

AC_C_BIGENDIAN
dnl Check if we have liblua so we can compile the module
AC_CHECK_PROGS(ac_have_luaconfig, [lua-config lua-config50 lua-config51], no)

if test "$ac_have_luaconfig" = no; then
dnl    AC_HAVE_LIBRARY(lua)
    AC_CHECK_PROGS(ac_have_pkgconfig, [pkg-config], no)
    if test "$ac_have_pkgconfig" = no; then
	AC_HAVE_LIBRARY(lua, [AC_DEFINE(HAVE_LIBLUA)
	    LUA_LIBS=-llua], [LUA_LIBS=
	])
    else
	AC_MSG_CHECKING(for lua config)
	for lualibver in lua lua53 lua5.3 lua-5.3 lua52 lua5.2 lua-5.2 lua51 lua5.1 lua-5.1 lua50 lua5.0 lua-5.0; do
		if $ac_have_pkgconfig --exists $lualibver 2>/dev/null; then
		    LUA_INCLUDES="`$ac_have_pkgconfig --cflags $lualibver`"
		    if test "$fe_cv_static" = yes; then
			LUA_LIBS="`$ac_have_pkgconfig --libs --static $lualibver`"
		    else
			LUA_LIBS="`$ac_have_pkgconfig --libs $lualibver`"
		    fi
		    AC_MSG_RESULT($lualibver: $LUA_LIBS)
		    AC_DEFINE(HAVE_LIBLUA)
		    break
		fi
	done
	if test -z "$LUA_LIBS"; then
	    AC_MSG_RESULT(none found)
	else
	    ac_cv_lib_lua=yes
	fi
    fi
else
    AC_DEFINE([HAVE_LIBLUA], 1, [Define to 1 if you have the `lua' library.])
    LUA_INCLUDES="`$ac_have_luaconfig --include`"
    LUA_LIBS="`$ac_have_luaconfig --libs`"
    ac_cv_lib_lua=yes
fi

if test -n "${LUA_INCLUDES}"; then
    CPPFLAGS="${LUA_INCLUDES} ${CPPFLAGS}"
fi

if test -n "${LUA_LIBS}"; then
    if test "$fe_cv_static" = yes; then
	STATICLIBS="${LUA_LIBS} ${STATICLIBS}"
    else
	dnl add rpath in any case
	case "$LUA_LIBS" in
	    *-L*)
		fe_cv_lua_rpath=" `echo $LUA_LIBS | sed -e 's/.*-L/-R/' -e 's/ .*$//'`"
		;;
	    *)
		fe_cv_lua_rpath=
		;;
	esac
	MODLIBS="MODLIBS_lua=\"${LUA_LIBS}${fe_cv_lua_rpath}\" ${MODLIBS}"
    fi
fi

if test x$ac_cv_lib_lua != xno; then
    AC_MSG_CHECKING([for version 5.1 of liblua])
    AC_TRY_COMPILE([#include <lauxlib.h>], [luaL_Reg *A;],
	[AC_DEFINE(HAVE_LIBLUA51, 1, [Define to 1 if you have the Lua version 5.1 or above.])
	AC_MSG_RESULT(yes)], [AC_MSG_RESULT(no)])
fi
AC_MSG_CACHE_ADD([Lua language support], [${ac_cv_lib_lua:-no}])

dnl OpenSSL support from configure.in for rusnet-ircd-1.5, reworked

fe_save_LIBS="$LIBS"
fe_save_LDFLAGS="$LDFLAGS"
fe_save_CFLAGS="$CFLAGS"
USE_OPENSSL=no
LIBS="-lcrypto -lssl $LIBS"
openssl_libpath=
openssl_include=

AC_ARG_WITH(openssl,
    AC_HELP_STRING([--with-openssl=PATH], [Specify path to OpenSSL installation]), [
    fe_openssl_path=$withval], [
    fe_openssl_path=auto])

dnl Search for OpenSSL library
case $fe_openssl_path in
no)
    # Disable OpenSSL
    ;;

auto)
    # Autodetect
    AC_MSG_CHECKING(for OpenSSL libraries in default paths)
    AC_LINK_IFELSE([AC_LANG_CALL([], [SSL_library_init])], [
	AC_MSG_RESULT(found)
	# Found in default paths
	USE_OPENSSL=yes
    ], [
      AC_LINK_IFELSE([AC_LANG_CALL([], [OPENSSL_init_ssl])], [
	AC_MSG_RESULT(found)
	# Found OpenSSL 1.1 in default paths
	USE_OPENSSL=yes
      ], [
	AC_MSG_RESULT(no)
	# Search for it
	for tryssl_dir in	/usr/local/ssl /usr /usr/local /usr/local/share \
				/usr/local/openssl /usr/lib/openssl /usr/lib/ssl \
				/usr/pkg /opt /opt/openssl
	do
	    test -d "$tryssl_dir/." || continue
	    if test -d "${tryssl_dir}/lib"; then
		openssl_libpath="${tryssl_dir}/lib"
	    else
		openssl_libpath="${tryssl_dir}"
	    fi
	    LDFLAGS="-L${openssl_libpath} ${fe_save_LDFLAGS}"
	    if test -d "${tryssl_dir}/include"; then
		openssl_include="${tryssl_dir}/include"
	    else
		openssl_include="${tryssl_dir}"
	    fi
	    # Now check if it links
	    unset ac_cv_lib_ssl_SSL_library_init
	    AC_MSG_CHECKING(for OpenSSL libraries in $tryssl_dir)
	    AC_LINK_IFELSE([AC_LANG_CALL([], [SSL_library_init])], [
		AC_MSG_RESULT(found)
		USE_OPENSSL=yes
		break
	    ], [
	      AC_LINK_IFELSE([AC_LANG_CALL([], [OPENSSL_init_ssl])], [
		AC_MSG_RESULT(found)
		USE_OPENSSL=yes
		break
	      ], [
		AC_MSG_RESULT(no)
		openssl_include=
	    ])])
	done
    ])])
    dnl at this point if $USE_OPENSSL isn't "yes" then it's not found
    if test x$USE_OPENSSL != xyes; then
	AC_MSG_WARN(could not find OpenSSL libcrypto: see config.log for details)
	openssl_libpath=
    fi
    ;;

yes)
    # Try to enforce link
    AC_MSG_CHECKING(for OpenSSL libraries in default paths)
    AC_LINK_IFELSE([AC_LANG_CALL([], [SSL_library_init])], [
	AC_MSG_RESULT(found)
	USE_OPENSSL=yes
    ], [
      AC_LINK_IFELSE([AC_LANG_CALL([], [OPENSSL_init_ssl])], [
	AC_MSG_RESULT(found)
	USE_OPENSSL=yes
      ], [
	AC_MSG_RESULT(no)
	AC_MSG_FAILURE(couldn't find OpenSSL)
    ])])
    ;;

*)
    # Try to find it in the given path
    case "$fe_openssl_path" in
    # Relative paths
    ./*|../*)
	fe_openssl_path="`pwd`/$fe_openssl_path"
	;;
    esac
    if test -d "$fe_openssl_path/lib"; then
	openssl_libpath="$fe_openssl_path/lib"
    else
	openssl_libpath="$fe_openssl_path"
    fi
    LDFLAGS="-L${openssl_libpath} ${fe_save_LDFLAGS}"
    if test -d "$fe_openssl_path/include"; then
	openssl_include="$fe_openssl_path/include"
    else
	openssl_include="$fe_openssl_path"
    fi

    # Now check if it links
    AC_MSG_CHECKING(for OpenSSL libraries in $openssl_libpath)
    AC_LINK_IFELSE([AC_LANG_CALL([], [SSL_library_init])], [
	AC_MSG_RESULT(found)
	USE_OPENSSL=yes
    ], [
      AC_LINK_IFELSE([AC_LANG_CALL([], [OPENSSL_init_ssl])], [
	AC_MSG_RESULT(found)
	USE_OPENSSL=yes
      ], [
	AC_MSG_RESULT(no)
	AC_MSG_FAILURE(couldn't find OpenSSL)
    ])])
    ;;
esac
dnl -- end of OpenSSL search

if test x$USE_OPENSSL = xyes; then
    dnl Check for OpenSSL headers
    AC_CHECK_HEADER([openssl/ssl.h], [], [
	if test -z "$openssl_include"; then
	    AC_MSG_FAILURE(couldn't find OpenSSL)
	else
	    OPENSSL_CFLAGS="-I$openssl_include"
	    CFLAGS="${OPENSSL_CFLAGS} ${CFLAGS}"
	    AC_MSG_CHECKING(in $openssl_include)
	    unset ac_cv_header_openssl_ssl_h
	    AC_CHECK_HEADER([openssl/ssl.h], [], [
		AC_MSG_FAILURE(couldn't find OpenSSL)
	    ])
	fi
    ])

    dnl Determine OpenSSL header version
    AC_MSG_CHECKING(OpenSSL header version)
    AC_RUN_IFELSE([
	AC_LANG_SOURCE([[
#include <stdio.h>
#include <string.h>
#include <openssl/opensslv.h>
#define DATA "conftest.sslincver"
int main(void) {
        FILE *fd;
        int rc;

        fd = fopen(DATA,"w");
        if(fd == NULL)
                exit(1);
        if ((rc = fprintf(fd ,"%lx (%s)\n", OPENSSL_VERSION_NUMBER, OPENSSL_VERSION_TEXT)) <0)
                exit(1);
        exit(0);
}
    ]])], [
	ssl_header_ver=`cat conftest.sslincver`
	AC_MSG_RESULT($ssl_header_ver)
    ], [
	AC_MSG_RESULT(not found)
	AC_MSG_ERROR(OpenSSL version header not found.)
    ], [
	AC_MSG_WARN(cross compiling: not checking)
    ])

    dnl Determine OpenSSL library version
    AC_MSG_CHECKING(OpenSSL library version)
    AC_RUN_IFELSE([
	AC_LANG_SOURCE([[
#include <stdio.h>
#include <string.h>
#include <openssl/opensslv.h>
#include <openssl/crypto.h>
#define DATA "conftest.ssllibver"
int main(void) {
        FILE *fd;
        int rc;

        fd = fopen(DATA,"w");
        if(fd == NULL)
                exit(1);

        if ((rc = fprintf(fd ,"%lx (%s)\n", SSLeay(), SSLeay_version(SSLEAY_VERSION))) <0)
                exit(1);

        exit(0);
}
    ]])], [
	ssl_library_ver=`cat conftest.ssllibver`
	AC_MSG_RESULT($ssl_library_ver)
    ], [
	AC_MSG_RESULT(not found)
	AC_MSG_ERROR(OpenSSL library not found.)
    ], [
	AC_MSG_WARN(cross compiling: not checking)
    ])

    dnl Sanity check OpenSSL headers
    AC_MSG_CHECKING(whether OpenSSL headers match the library)
    AC_RUN_IFELSE([
	AC_LANG_SOURCE([[
#include <string.h>
#include <openssl/opensslv.h>
#include <openssl/crypto.h>
int main(void) { exit(SSLeay() == OPENSSL_VERSION_NUMBER ? 0 : 1); }
    ]])], [
	AC_MSG_RESULT(yes)
    ], [
	AC_MSG_RESULT(no)
	AC_MSG_FAILURE(your OpenSSL headers do NOT match your library)
    ], [
	AC_MSG_WARN(cross compiling: not checking)
    ])

    AC_DEFINE([USE_OPENSSL], [1], [Define if openssl package must be used for compilation/linking.])

    dnl update LIBS for the module
    openssl_libs="-lssl -lcrypto"
    if test -n "$openssl_libpath"; then
	openssl_libs="$openssl_libs -L$openssl_libpath -R$openssl_libpath"
    fi
    if test "$fe_cv_static" = yes; then
	STATICLIBS="${openssl_libs} ${STATICLIBS}"
    else
	MODLIBS="MODLIBS_ssl=\"${openssl_libs}\" ${MODLIBS}"
    fi
fi

LIBS="$fe_save_LIBS"
CFLAGS="$fe_save_CFLAGS"
LDFLAGS="$fe_save_LDFLAGS"

if test -n "$OPENSSL_CFLAGS"; then
    CPPFLAGS="$OPENSSL_CFLAGS $CPPFLAGS"
fi
AC_MSG_CACHE_ADD([OpenSSL support], [$USE_OPENSSL])
# End of OpenSSL
dnl Checks for Tcl.
AC_ARG_WITH(tcl,
    [  --with-tcl[[=PATH]]       where the root of Tcl is installed],
    [  fe_tcl_with="$withval"
    ], [fe_tcl_with=yes
    ])

if test ! "x$fe_tcl_includes" = x; then
    unset fe_cv_have_tcl
fi

AC_CACHE_VAL(fe_cv_have_tcl,
[# check for Tcl config script first
 AC_MSG_CHECKING(for Tcl config)
 if test "$fe_tcl_with" = no; then
  AC_MSG_RESULT([not requested])
  fe_cv_have_tcl="have_tcl=no"
 else
  if test "$fe_tcl_with" = yes; then
    fe_tcl_with=
  fi
  fe_tcl_libs=no TCL_LIB_SPEC=no TCL_INCLUDE_SPEC=no
  tcl_config_dirs="$fe_tcl_with $prefix/lib/tcl* /usr/lib/tcl* /usr/local/lib/tcl*"
  for dir in $tcl_config_dirs; do
    if test -f $dir/tclConfig.sh; then
	. $dir/tclConfig.sh
	AC_MSG_CHECKING([$dir/tclConfig.sh])
	if test x"$TCL_LIB_SPEC" = xno || test x"$TCL_INCLUDE_SPEC" = xno; then
	    dnl malformed config
	    TCL_LIB_SPEC=no TCL_INCLUDE_SPEC=no
	    AC_MSG_RESULT([invalid])
	    continue
	fi
	AC_MSG_RESULT([fine])
	fe_tcl_libs="$TCL_LIB_SPEC $TCL_DL_LIBS"
	fe_tcl_includes="$TCL_INCLUDE_SPEC"
	break
    fi
  done
  if test x"$fe_tcl_libs" != xno; then
    fe_cv_have_tcl="have_tcl=yes \
	fe_tcl_includes=\"$fe_tcl_includes\" fe_tcl_libs=\"$fe_tcl_libs\""
  else
    dnl check for default then...
    AC_MSG_RESULT([none working])
    AC_MSG_CHECKING([for Tcl headers])
    fe_tcl_save_LIBS="${LIBS}"
    dnl finding includes - default first, then paths
    LIBS="${LIBS} -ltcl"
    AC_TRY_LINK([#include <tcl.h>], [Tcl_Interp *interp;

Tcl_AppendElement(interp, NULL);
], [fe_cv_have_tcl="have_tcl=yes fe_tcl_includes=default fe_tcl_libs=\"-ltcl\""
	AC_MSG_RESULT([defaults])],
	[# not found, now try to find...
        AC_TRY_CPP([#include <tcl.h>], [fe_tcl_includes=default
	    fe_try_incs="<tcl.h>"],
            [fe_tcl_includes=no
		tcl_incdirs="$fe_tcl_with/include $prefix/include \
		$prefix/tcl/include /usr/local/include /usr/local/include/tcl* \
		/usr/local/pkgs/tcl/include /usr/include/tcl"
	    tcl_incdir=
	    AC_FIND_FILE(tcl.h, $tcl_incdirs, tcl_incdir)
	    if test x"$tcl_incdir" != x; then
		fe_tcl_includes="-I$tcl_incdir"
		fe_try_incs="\"$tcl_incdir/tcl.h\""
	    fi
        ])
	if test "$fe_tcl_includes" == no; then
	    AC_MSG_RESULT([not found])
	else
	    fe_tcl_incdir=`echo $fe_tcl_includes|sed s/-I//`
	    AC_MSG_RESULT($fe_tcl_incdir)
	    AC_MSG_CHECKING([for Tcl libraries])
	    dnl header possibly found, trying library
	    fe_tcl_libs=none
	    tcl_libdirs="default ${fe_tcl_with}/lib $prefix/lib \
		$prefix/tcl/lib /usr/local/lib /usr/local/lib/tcl \
		/usr/local/pkgs/tcl/lib /usr/lib /usr/lib/tcl*"
	    for dir in $tcl_libdirs; do
		if test $dir = default; then
		    tcl_library=tcl
		    tcl_lddir=
		else
		    try="ls -1 $dir/libtcl*.so*"
		    if test "x`eval $try 2>/dev/null`" = "x"; then
			continue
		    fi
		    tcl_library=`eval $try | tail -1 | sed -e 's/^.*lib//' -e 's/\.so.*$//'`
		    if test "$fe_cv_static" = yes; then
			tcl_lddir="-L$dir "
		    else
			tcl_lddir="-R$dir -L$dir "
		    fi
		fi
		LIBS="${fe_tcl_save_LIBS} ${tcl_lddir}-l${tcl_library}"
		AC_TRY_LINK([#include $fe_try_incs], [Tcl_Interp *interp;

Tcl_AppendElement(interp, NULL);
], [fe_tcl_libs="${tcl_lddir}-l${tcl_library}"
		    fe_cv_have_tcl="have_tcl=yes fe_tcl_libs=\"$fe_tcl_libs\" \
		    fe_tcl_includes=\"$fe_tcl_includes\""], [
		    dnl try -lm for it, it could want it
		    LIBS="$LIBS -lm"
		    AC_TRY_LINK([#include $fe_try_incs], [Tcl_Interp *interp;

Tcl_AppendElement(interp, NULL);
], [fe_tcl_libs="${tcl_lddir}-l${tcl_library} -lm"
			fe_cv_have_tcl="have_tcl=yes fe_tcl_libs=\"$fe_tcl_libs\" \
			fe_tcl_includes=\"$fe_tcl_includes\""], [
			dnl also try -ldl for it, it could want it too
			LIBS="$LIBS -ldl"
			AC_TRY_LINK([#include $fe_try_incs], [Tcl_Interp *interp;

Tcl_AppendElement(interp, NULL);
], [fe_tcl_libs="${tcl_lddir}-l${tcl_library} -lm -ldl"
			    fe_cv_have_tcl="have_tcl=yes fe_tcl_libs=\"$fe_tcl_libs\" \
			    fe_tcl_includes=\"$fe_tcl_includes\""
		])])])
		if test "$fe_tcl_libs" != none; then
		    dnl library found
		    break
		fi
	    done
	    AC_MSG_RESULT([$fe_tcl_libs])
	fi
	if test "$fe_tcl_includes" = no || test "$fe_tcl_libs" = none; then
	    fe_cv_have_tcl="have_tcl=no"
	fi
    ])
    LIBS="${fe_tcl_save_LIBS}"
  fi
 fi
])
eval "$fe_cv_have_tcl"

if test "$have_tcl" != no; then
    AC_DEFINE(HAVE_TCL, 1, [Define to 1 if you have the Tcl interpreter library.])
    if test "$fe_tcl_includes" != default; then
	CPPFLAGS="${fe_tcl_includes} ${CPPFLAGS}"
    fi
    if test "$fe_cv_static" = yes; then
	STATICLIBS="${fe_tcl_libs} ${STATICLIBS}"
    else
	MODLIBS="MODLIBS_tcl=\"${fe_tcl_libs}\" ${MODLIBS}"
    fi
    dnl now i want check for tcl version
    fe_tcl_save_LIBS="${LIBS}"
    fe_tcl_save_LDFLAGS="${LDFLAGS}"
    LDFLAGS=
    LIBS="$fe_tcl_libs $LIBS"
    try_lib=`echo $fe_tcl_libs | sed -e 's/^.*-ltcl/tcl/' -e 's/ .*//'`
    AC_SEARCH_LIBS(Tcl_CreateObjCommand, [$try_lib], [
	AC_DEFINE(HAVE_TCL8X, 1, [Define to 1 if you have the Tcl version 8.0 or above.])
    ])
    dnl check for multithreaded tcl
    AC_SEARCH_LIBS(Tcl_MutexFinalize, [$try_lib], [
	AC_DEFINE(HAVE_TCL_MULTITHREAD, 1, [Define to 1 if your Tcl interpreter supports mutexes.])
    ])
    dnl check for some functions (8.1+)
    AC_CHECK_FUNCS(Tcl_SetSystemEncoding)
    AC_CHECK_FUNCS(Tcl_EvalObjv)
    LIBS="${fe_tcl_save_LIBS}"
    LDFLAGS="${fe_tcl_save_LDFLAGS}"
fi
AC_MSG_CACHE_ADD([Tcl language support], [${have_tcl:-failed}])

dnl Zlib support from configure.in for irc-2.10.1

AC_MSG_CHECKING(for zlib package)
AC_ARG_WITH(zlib, [  --with-zlib[[=ZDIR]]      checks for zlib(default); enables compressed links])
if test "x$withval" = xno; then
  no_zlib=yes
else
fe_zlib_prefix=$with_zlib
AC_CACHE_VAL(fe_cv_path_zlib,
[no_zlib=yes
no_zlib_include=yes
no_zlib_library=yes
AC_PREPROC_IFELSE([AC_LANG_SOURCE([[#include <zlib.h>]])],[no_zlib_include=
fe_zlib_include=],[for fe_dir in "$fe_zlib_include" \
                     `test -z "$fe_zlib_prefix" || echo "$fe_zlib_prefix/include"` \
                     `echo "$fe_zlib_library" | sed s/lib/include/` \
                     /usr/include /usr/local/include /usr/unsupported/include \
                     /usr/share/include /usr/local/share/include /include \
                     /usr/zlib/include /usr/local/zlib/include \
                     /usr/include/zlib /usr/local/include/zlib \
                     /usr/unsupported/include/zlib /usr/share/include/zlib \
                     /usr/local/share/include/zlib /include/zlib \
                     /usr/zlib/include/zlib /usr/local/zlib/include/zlib; \
  do
    if test -r "$fe_dir/zlib.h"; then
      no_zlib_include=
      fe_zlib_include=$fe_dir
      break
    fi
  done
])
fe_save_LIBS="$LIBS"
LIBS="-lz $LIBS"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[inflate()]])],[no_zlib_library=
fe_zlib_library=
LIBS="$fe_save_LIBS"],[LIBS="$fe_save_LIBS"
for fe_dir in "$fe_zlib_library" \
                    `test -z "$fe_zlib_prefix" || echo "$fe_zlib_prefix/lib"` \
                    `echo "$fe_zlib_include" | sed s/include/lib/` \
                    /usr/lib /usr/local/lib /usr/unsupported/lib \
                    /usr/share/lib /usr/local/share/lib /lib /usr/zlib/lib \
                    /usr/local/zlib/lib /usr/lib/zlib /usr/local/lib/zlib \
                    /usr/unsupported/lib/zlib /usr/share/lib/zlib \
                    /usr/local/share/lib/zlib /lib/zlib \
                    /usr/zlib/lib/zlib /usr/local/zlib/lib/zlib; \
do
  for fe_extension in a so sl; do
    if test -r $fe_dir/libz.$fe_extension; then
      no_zlib_library=
      fe_zlib_library=$fe_dir
      break 2
    fi
  done
done
])
if test "x$no_zlib_include" = x && test "x$no_zlib_library" = x; then
  no_zlib=
fi
if test "$no_zlib" = yes; then
  fe_cv_path_zlib="no_zlib=yes"
else
  fe_cv_path_zlib="no_zlib= fe_zlib_include=$fe_zlib_include fe_zlib_library=$fe_zlib_library"
fi])
  eval "$fe_cv_path_zlib"
fi
if test "$no_zlib" = yes; then
  AC_MSG_RESULT(no)
  AC_MSG_CACHE_ADD([ZLib support], [no])
else
  AC_DEFINE([HAVE_ZLIB], [1], [Define if zlib package must be used for compilation/linking.])
  if test "x$fe_zlib_library" = x; then
    fe_zlib_library_message="found by the linker"
    ZLIB_LIBRARY=-lz
  else
    fe_zlib_library_message="in $fe_zlib_library"
    ZLIB_LIBRARY=-L$fe_zlib_library
    if test ! "$fe_cv_solaris_2" = no; then
      ZLIB_LIBRARY="$ZLIB_LIBRARY -R$fe_zlib_library"
    fi
    ZLIB_LIBRARY="$ZLIB_LIBRARY -lz"
  fi
  if test "$fe_cv_static" = yes; then
    STATICLIBS="${ZLIB_LIBRARY} ${STATICLIBS}"
  else
    MODLIBS="MODLIBS_ziplink=\"${ZLIB_LIBRARY}\" ${MODLIBS}"
  fi
  if test "x$fe_zlib_include" = x; then
    fe_zlib_include_message="found by the compiler"
  else
    fe_zlib_include_message="in $fe_zlib_include"
    CPPFLAGS="-I$fe_zlib_include ${CPPFLAGS}"
  fi
  AC_MSG_RESULT([])
  AC_MSG_RESULT([  library $fe_zlib_library_message])
  AC_MSG_RESULT([  header $fe_zlib_include_message])
  AC_MSG_CACHE_ADD([ZLib support], [yes])
fi

if test x"$MODLIBS" = x; then
    MODLIBS=true
fi

dnl strip -fPIE from LDFLAGS and CFLAGS, Linux hardening pushes it everywhere
LIB_LDFLAGS=`echo "$LDFLAGS" | sed s/-fPIE//g | sed s/-pie//g`
CFLAGS=`echo "$CFLAGS" | sed s/-fPIE/-fPIC/g`
AC_SUBST(LIB_LDFLAGS)

AC_OUTPUT

AC_MSG_CACHE_DISPLAY