Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

klish / configure.ac @ 1a733d28

History | View | Annotate | Download (19.9 KB)

1
#                                               -*- Autoconf -*-
2
# Process this file with autoconf to produce a configure script.
3
m4_define([MAJOR_VERSION], 1)
4
m4_define([MINOR_VERSION], 7)
5
m4_define([MICRO_VERSION], 0)
6

    
7
AC_PREREQ(2.59)
8
AC_INIT([klish],
9
        [MAJOR_VERSION.MINOR_VERSION.MICRO_VERSION],
10
        [serj.kalichev at gmail dot com])
11

    
12
AC_CONFIG_AUX_DIR(aux_scripts)
13
AC_CONFIG_MACRO_DIR([m4])
14

    
15
# Values for SONAME. See -version-info for details.
16
AC_SUBST(SONAME_CURRENT, 1)
17
AC_SUBST(SONAME_REVISION, 0)
18
AC_SUBST(SONAME_AGE, 0)
19

    
20
# Check for system extensions (_POSIX_THREAD_SEMANTICS for Solaris)
21
AC_USE_SYSTEM_EXTENSIONS
22

    
23
# Checks for programs.
24
AC_PROG_CC
25
AC_LIBTOOL_WIN32_DLL
26
AC_PROG_LIBTOOL
27

    
28
AC_CONFIG_HEADERS([config.h])
29
AM_INIT_AUTOMAKE(subdir-objects)
30
AM_PROG_CC_C_O
31

    
32
# Dir for libc replacements
33
AC_CONFIG_LIBOBJ_DIR([libc])
34

    
35
# needed to handle 64-bit architecture
36
AC_CHECK_SIZEOF(int)
37
AC_CHECK_SIZEOF(long)
38
AC_CHECK_SIZEOF(size_t)
39

    
40
#########################################
41
# See if linker supports version scripts
42
#########################################
43
# Check if LD supports linker scripts,
44
# and define automake conditional HAVE_LD_VERSION_SCRIPT if so.
45
AC_ARG_ENABLE([ld-version-script],
46
              AS_HELP_STRING([--enable-ld-version-script],
47
                             [enable linker version script (default is enabled when possible)]),
48
                             [have_ld_version_script=$enableval], [])
49
if test -z "$have_ld_version_script"; then
50
    AC_MSG_CHECKING([if LD -Wl,--version-script works])
51
    save_LDFLAGS="$LDFLAGS"
52
    LDFLAGS="$LDFLAGS -Wl,--version-script=conftest.map"
53
    cat > conftest.map <<EOF
54
VERS_1 {
55
    global: sym;
56
};
57

    
58
VERS_2 {
59
    global: sym;
60
} VERS_1;
61
EOF
62
    AC_LINK_IFELSE([AC_LANG_SOURCE([int main() { return 0; }])],
63
                   [have_ld_version_script=yes], [have_ld_version_script=no])
64
    rm -f conftest.map
65
    LDFLAGS="$save_LDFLAGS"
66
    AC_MSG_RESULT($have_ld_version_script)
67
fi
68
AM_CONDITIONAL(HAVE_LD_VERSION_SCRIPT, test "$have_ld_version_script" = "yes")
69

    
70
################################
71
# Deal with debugging options
72
################################
73
AC_ARG_ENABLE(debug,
74
              [AS_HELP_STRING([--enable-debug],
75
                              [Turn on debugging including asserts [default=no]])],
76
              [],
77
              [enable_debug=no])
78
AM_CONDITIONAL(DEBUG,test x$enable_debug = xyes)
79

    
80
################################
81
# Check for Lua support
82
################################
83
AC_ARG_WITH(lua,
84
            [AS_HELP_STRING([--with-lua=DIR],
85
                            [Build Lua ACTION plugin [default=no]])],
86
            [use_lua=$withval],
87
            [use_lua=no])
88
AM_CONDITIONAL(WITH_LUA,test x$use_lua != xno)
89

    
90
if test x$use_lua != xno; then
91
    if test x$use_lua != xyes; then
92
        CPPFLAGS="${CPPFLAGS} -I$use_lua/include"
93
	LDFLAGS="${LDFLAGS} -L$use_lua/lib"
94
    fi
95
    LUA_VERSION="5.1"
96
    AX_LUA_HEADERS()
97
    AX_LUA_LIBS()
98
fi
99

    
100
################################
101
# Check for the roxml library
102
################################
103
AC_ARG_WITH(libroxml,
104
            [AS_HELP_STRING([--with-libroxml=DIR],
105
                            [Use roxml as the XML parser implementation [default=no]])],
106
            [use_roxml=$withval],
107
            [use_roxml=no])
108

    
109
AC_ARG_WITH(libexpat,
110
            [AS_HELP_STRING([--with-libexpat=DIR],
111
                            [Use expat as the XML parser implementation [default=no]])],
112
            [use_expat=$withval],
113
            [use_expat=no])
114

    
115
AC_ARG_WITH(libxml2,
116
            [AS_HELP_STRING([--with-libxml2=DIR],
117
                            [Use libxml2 as the XML parser implementation [default=no]])],
118
            [use_libxml2=$withval],
119
            [use_libxml2=no])
120

    
121
# select the default xml backend
122
sel_xml_backends=""
123
xml_backend=""
124
found_xml_backend=""
125
count_xml_backends=0
126
if test "x$use_libxml2" != "xno"; then
127
    sel_xml_backends="$sel_xml_backends libxml2"
128
    xml_backend="libxml2"
129
    count_xml_backends=$((count_xml_backends + 1))
130
fi
131

    
132
if test "x$use_roxml" != "xno"; then
133
    sel_xml_backends="$sel_xml_backends roxml"
134
    xml_backend="roxml"
135
    count_xml_backends=$((count_xml_backends + 1))
136
fi
137

    
138
if test "x$use_expat" != "xno"; then
139
    sel_xml_backends="$sel_xml_backends expat"
140
    xml_backend="expat"
141
    count_xml_backends=$((count_xml_backends + 1))
142
fi
143

    
144
if test $count_xml_backends -gt 1; then
145
    AC_MSG_WARN([Multiple XML backend has been selected ($sel_xml_backends). I choose $xml_backend])
146
fi
147

    
148
if test "x$xml_backend" = "x"; then
149
    xml_backend="auto"
150
    AC_MSG_WARN([No XML backend has been selected: auto check])
151
fi
152

    
153
case x$xml_backend in
154
    xroxml)
155
        use_libxml2="no"
156
        use_expat="no"
157
        ;;
158
    xlibxml2)
159
        use_roxml="no"
160
        use_expat="no"
161
        ;;
162
    xexpat)
163
        use_libxml2="no"
164
        use_roxml="no"
165
        ;;
166
esac
167

    
168
XML_LDFLAGS=""
169
XML_CFLAGS=""
170
XML_LIBS=""
171

    
172
if test "$xml_backend" = "expat" -o "$xml_backend" = "auto"; then
173
    if test "$xml_backend" = "auto"; then
174
        # on auto select, we try to detect the library
175
        use_expat="yes"
176
    fi
177
    case x$use_expat in
178
      xyes)
179
        # we choose to NOT rely on pkg-config on this one. Instead, we
180
        # check for the library and the header file - that should be
181
        # enough.
182
        AC_CHECK_HEADER([expat.h],
183
                        [expat_h_found=yes],
184
                        [expat_h_found=no],
185
                        [/* force include check */])
186
        if test "x$expat_h_found" != "xyes"; then
187
            AC_CHECK_HEADER([bsdxml.h],
188
                            [expat_h_found=yes],
189
                            [expat_h_found=no],
190
                            [/* force include check */])
191
            if test "x$expat_h_found" != "xyes"; then
192
                if test "$xml_backend" = "auto"; then
193
                    AC_MSG_WARN([cannot find <expat.h> header file])
194
                else
195
                    AC_MSG_ERROR([cannot find <expat.h> header file])
196
                fi
197
            fi
198
        fi
199
        XML_CFLAGS=""
200

    
201
        AC_CHECK_LIB([expat],
202
                     [XML_ParserCreate],
203
                     [expat_lib_found=yes],
204
                     [expat_lib_found=no],
205
                     [])
206
        if test "x$expat_lib_found" != "xyes"; then
207
            AC_CHECK_LIB([bsdxml],
208
                         [XML_ParserCreate],
209
                         [expat_lib_found=yes],
210
                         [expat_lib_found=no],
211
                         [])
212
            if test "x$expat_lib_found" != "xno"; then
213
                XML_LIBS="-lbsdxml"
214
                AC_DEFINE([HAVE_LIB_BSDXML],
215
                          [],
216
                          [libbsdxml-based XML backend])
217
            else
218
                if test "$xml_backend" = "auto"; then
219
                    AC_MSG_WARN([cannot find expat library])
220
                else
221
                    AC_MSG_ERROR([cannot find expat library])
222
                fi
223
            fi
224
        else
225
            XML_LIBS="-lexpat"
226
        fi
227
        XML_LDFLAGS=""
228

    
229
        AC_DEFINE([HAVE_LIB_EXPAT],
230
                  [],
231
                  [libexpat-based XML backend])
232
        xml_backend="found"
233
        found_xml_backend="expat"
234
        ;;
235
      *)
236
        # this is probably broken. We consider that the user supplied path is
237
        # a non-standard path. But we're not going to check anything.
238
        AC_MSG_WARN([--with-expat=DIR is probably broken, just trying])
239
        XML_LDFLAGS="-L${use_expat}/lib"
240
        XML_CFLAGS="-I${use_expat}/include"
241
        XML_LIBS="-lexpat"
242
        AC_MSG_CHECKING([for expat support])
243
        AC_MSG_RESULT([yes])
244
        AC_MSG_NOTICE([headers for expat hopefully in ${use_expat}/include])
245
        AC_MSG_NOTICE([library expat hopefully in ${use_expat}/lib])
246
        AC_DEFINE([HAVE_LIB_EXPAT],
247
                  [],
248
                  [expat-based XML backend])
249
        xml_backend="found"
250
        found_xml_backend="expat"
251
        ;;
252
    esac
253
else
254
    AC_MSG_CHECKING([for libexpat support])
255
    AC_MSG_RESULT([no])
256
fi
257

    
258
if test "$xml_backend" = "roxml" -o "$xml_backend" = "auto"; then
259
    if test "$xml_backend" = "auto"; then
260
        # on auto select, we try to detect the library
261
        use_roxml="yes"
262
    fi
263
    case x$use_roxml in
264
      xyes)
265
        # we choose to NOT rely on pkg-config on this one. We may do it as
266
        # libroxml provides a .pc file but some environment (both cross-compile
267
        # or native environment) may lack this support. The good thing is that
268
        # it doesn't add much complexity to the configure.ac file (and we
269
        # may move these tests to another m4 file later).
270

    
271
        # the header is installed in the standard path
272
        AC_CHECK_HEADER([roxml.h],
273
                        [roxml_h_found=yes],
274
                        [roxml_h_found=no],
275
                        [/* force include check */])
276
        if test "x$roxml_h_found" != "xyes"; then
277
            if test "$xml_backend" = "auto"; then
278
                AC_MSG_WARN([cannot find <roxml.h> header file])
279
            else
280
                AC_MSG_ERROR([cannot find <roxml.h> header file])
281
            fi
282
        fi
283
        XML_CFLAGS=""
284

    
285
        # the library is installed in the standard path
286
        AC_CHECK_LIB([roxml],
287
                     [roxml_load_doc],
288
                     [roxml_lib_found=yes],
289
                     [roxml_lib_found=no],
290
                     [])
291
        if test "x$roxml_lib_found" != "xyes"; then
292
            if test "$xml_backend" = "auto"; then
293
                AC_MSG_WARN([cannot find roxml library])
294
            else
295
                AC_MSG_ERROR([cannot find roxml library])
296
            fi
297
        fi
298
        XML_LDFLAGS=""
299
        XML_LIBS="-lroxml"
300

    
301
        AC_DEFINE([HAVE_LIB_ROXML],
302
                  [],
303
                  [libroxml-based XML backend])
304
        xml_backend="found"
305
        found_xml_backend="roxml"
306
        ;;
307

    
308
      *)
309
        # first, we check if we're not looking for an alternate include
310
        # directory -for example, if the user feeds the script with the
311
        # option --with-roxml=/usr/local
312
        # NOTE: we search for include/roxml.h and inc/roxml.h to defeat
313
        # the caching algorithm of the configure script. If someone knows
314
        # a better way, please do not hesitate
315
        roxml_CFLAGS="$CFLAGS"
316
        CFLAGS="$CFLAGS -I${use_roxml}"
317
        AC_CHECK_HEADER([include/roxml.h],
318
                        [roxml_h_found=yes],
319
                        [roxml_h_found=no],
320
                        [/* force include check */])
321
        if test "x$roxml_h_found" = "xno"; then
322
            # the directory might be a source directory, so check
323
            # if the include file is to be found here
324
            AC_CHECK_HEADER([inc/roxml.h],
325
                            [roxml_h_found=yes],
326
                            [roxml_h_found=no],
327
                            [/* force include check */])
328
            if test "x$roxml_h_found" = "xno"; then
329
                if test "$xml_backend" = "auto"; then
330
                    AC_MSG_WARN([cannot find <roxml.h> header file])
331
                else
332
                    AC_MSG_ERROR([cannot find <roxml.h> header file])
333
                fi
334
            fi
335
            XML_CFLAGS="-I${use_roxml}/inc"
336
            AC_MSG_NOTICE([header file <roxml.h> found in ${use_roxml}/inc])
337
        else
338
            XML_CFLAGS="-I${use_roxml}/include"
339
            AC_MSG_NOTICE([header file <roxml.h> found in ${use_roxml}/include])
340
        fi
341
        CFLAGS="$roxml_CFLAGS"
342

    
343
        # we're doing both previous checks, but we are trying to find a library
344
        # now, so the check themselves are a bit different
345
        # NOTE: we search for roxml_load_doc and roxml_close to defeat
346
        # the caching algorithm of the configure script. If someone knows
347
        # a better way, please do not hesitate.
348
        roxml_LDFLAGS="$LDFLAGS"
349
        LDFLAGS="$LDFLAGS -L${use_roxml}/lib"
350
        AC_CHECK_LIB([roxml],
351
                     [roxml_load_doc],
352
                     [roxml_lib_found=yes],
353
                     [roxml_lib_found=no],
354
                     [])
355
        LDFLAGS=$roxml_LDFLAGS
356
        if test "x$roxml_lib_found" = "xno"; then
357
            LDFLAGS="$LDFLAGS -L${use_roxml}"
358
            AC_CHECK_LIB([roxml],
359
                         [roxml_close],
360
                         [roxml_lib_found=yes],
361
                         [roxml_lib_found=no],
362
                         [])
363
            LDFLAGS=$roxml_LDFLAGS
364
            if test "x$roxml_lib_found" = "xno"; then
365
                if test "$xml_backend" = "auto"; then
366
                    AC_MSG_WARN([cannot find roxml library])
367
                else
368
                    AC_MSG_ERROR([cannot find roxml library])
369
                fi
370
            fi
371
            XML_LDFLAGS="-L${use_roxml}"
372
            XML_LIBS="-lroxml"
373
            AC_MSG_NOTICE([library libroxml found in ${use_roxml}])
374
        else
375
            XML_LDFLAGS="-L${use_roxml}/lib"
376
            XML_LIBS="-lroxml"
377
            AC_MSG_NOTICE([library libroxml found in ${use_roxml}/lib])
378
        fi
379

    
380
        AC_DEFINE([HAVE_LIB_ROXML],
381
                  [],
382
                  [libroxml-based XML backend])
383
        xml_backend="found"
384
        found_xml_backend="roxml"
385
        ;;
386
    esac
387
else
388
    AC_MSG_CHECKING([for libroxml support])
389
    AC_MSG_RESULT([no])
390
fi
391

    
392
if test "$xml_backend" = "libxml2" -o "$xml_backend" = "auto"; then
393
    if test "$xml_backend" = "auto"; then
394
        # on auto select, we try to detect the library
395
        use_libxml2="yes"
396
    fi
397
    case x$use_libxml2 in
398
      xyes)
399
        # I would love to avoid using pkg-config (which may not be available on
400
        # some compilation environment) but doing so really add a lot of
401
        # complexity to the system, as the headers don't lie in a standard
402
        # directory (they lie in a subdirectory of a standard include directory;
403
        # not the same thing for configure scripts).
404
        XML_CFLAGS="`pkg-config libxml-2.0 --cflags`"
405
        XML_LDFLAGS="`pkg-config libxml-2.0 --libs-only-L`"
406
        XML_LIBS="`pkg-config libxml-2.0 --libs-only-l`"
407
        AC_CHECK_LIB([xml2],
408
                     [xmlNewDoc],
409
                     [libxml2_lib_found=yes],
410
                     [libxml2_lib_found=no],
411
                     [-lz])
412
        if test "x$libxml2_lib_found" != "xyes"; then
413
            if test "$xml_backend" = "auto"; then
414
                AC_MSG_WARN([cannot find libxml2 library])
415
            else
416
                AC_MSG_ERROR([cannot find libxml2 library])
417
            fi
418
        fi
419

    
420
        # the header file is installed in a subdirectory of one of the standard
421
        # include directory. This might prove to be a problem if the cross-
422
        # compile environment is not complete enough (i.e. if it misses
423
        # pkg-config, or if pkg-config returns wrong values). In most cases, the
424
        # environment is likely to be OK so we will never hit any issue.
425
        xml2_CFLAGS="$CFLAGS"
426
        CFLAGS="$CFLAGS $XML_CFLAGS"
427
        AC_CHECK_HEADER([libxml/tree.h],
428
                        [libxml2_h_found=yes],
429
                        [libxml2_h_found=no],
430
                        [/* force include check */])
431
        CFLAGS="$xml2_CFLAGS"
432
        if test "x$libxml2_h_found" != "xyes"; then
433
            if test "$xml_backend" = "auto"; then
434
                AC_MSG_WARN([cannot find libxml2 headers])
435
            else
436
                AC_MSG_ERROR([cannot find libxml2 headers])
437
            fi
438
        fi
439

    
440
        AC_DEFINE([HAVE_LIB_LIBXML2],
441
                  [],
442
                  [libxml2-based XML backend])
443
        xml_backend="found"
444
        found_xml_backend="libxml2"
445
        ;;
446
      *)
447
        # this is probably broken. We consider that the user supplied path is
448
        # a non-standard path. But we're not going to check anything.
449
        AC_MSG_WARN([--with-libxml2=DIR is probably broken, just trying])
450
        XML_LDFLAGS="-L${use_libxml2}/lib"
451
        XML_CFLAGS="-I${use_libxml2}/include/libxml2"
452
        XML_LIBS="-lxml2"
453
        AC_MSG_CHECKING([for libxml2 support])
454
        AC_MSG_RESULT([yes])
455
        AC_MSG_NOTICE([headers for libxml2 hopefully in ${use_libxml2}/include/libxml2])
456
        AC_MSG_NOTICE([library libxml2 hopefully in ${use_libxml2}/lib])
457
        AC_DEFINE([HAVE_LIB_LIBXML2],
458
                  [],
459
                  [libxml2-based XML backend])
460
        xml_backend="found"
461
        found_xml_backend="libxml2"
462
        ;;
463
    esac
464
else
465
    # not selected? We print a small message
466
    AC_MSG_CHECKING([for libxml2 support])
467
    AC_MSG_RESULT([no])
468
fi
469

    
470
if test "$xml_backend" != "found"; then
471
    AC_MSG_ERROR([Failed to find a suitable XML backend])
472
fi
473

    
474
if test $count_xml_backends -eq 0; then
475
    AC_MSG_NOTICE([I found a suitable XML backend: $found_xml_backend])
476
fi
477

    
478
AC_SUBST(XML_LIBS)
479
AC_SUBST(XML_LDFLAGS)
480
AC_SUBST(XML_CFLAGS)
481

    
482
################################
483
# Search for network functions (like connect())
484
################################
485
AC_SEARCH_LIBS([socket], [socket])
486

    
487
################################
488
# Check for regex.h
489
################################
490
AC_CHECK_HEADERS(regex.h, [],
491
    AC_MSG_ERROR([regex.h not found: regular expressions are not supported]))
492

    
493
################################
494
# Internal getopt()
495
################################
496
AC_ARG_WITH(internal-getopt,
497
            [AS_HELP_STRING([--with-internal-getopt],
498
            [Use internal implementation of getopt [default=no]])],
499
            [],
500
            [with_internal_getopt=no])
501

    
502
if test x$with_internal_getopt != xno; then
503
    AC_DEFINE([WITH_INTERNAL_GETOPT], [1], [Use internal getopt() implementation])
504
    AC_LIBOBJ([getopt])
505
    AC_MSG_WARN([Use internal implementation of getopt() and getopt_long()])
506
else
507
    AC_CHECK_HEADERS(getopt.h, [found_getopt_h=yes],
508
        AC_MSG_WARN([getopt.h not found: only short parameters can be used on command line]))
509
fi
510

    
511
AC_MSG_CHECKING([for getopt_long()])
512
if test x$with_internal_getopt = xyes -o x$found_getopt_h = xyes; then
513
    AC_DEFINE([HAVE_GETOPT_LONG], [1], [getopt_long() function])
514
    AC_MSG_RESULT([yes])
515
else
516
    AC_MSG_RESULT([no])
517
fi
518

    
519
################################
520
# Check for locale.h
521
################################
522
AC_CHECK_HEADERS(locale.h, [],
523
    AC_MSG_WARN([locale.h not found: the locales is not supported]))
524

    
525
################################
526
# Check for CODESET within nl_langinfo
527
################################
528
AC_DEFUN([AM_LANGINFO_CODESET],
529
[
530
  AC_CACHE_CHECK([for nl_langinfo and CODESET], [am_cv_langinfo_codeset],
531
    [AC_TRY_LINK([#include <langinfo.h>],
532
      [char* cs = nl_langinfo(CODESET); return !cs;],
533
      [am_cv_langinfo_codeset=yes],
534
      [am_cv_langinfo_codeset=no])
535
    ])
536
  if test $am_cv_langinfo_codeset = yes; then
537
    AC_DEFINE([HAVE_LANGINFO_CODESET], [1],
538
      [Define if you have <langinfo.h> and nl_langinfo(CODESET).])
539
  fi
540
])
541
AM_LANGINFO_CODESET
542

    
543
################################
544
# Check for pwd.h and grp.h
545
################################
546
AC_CHECK_HEADERS(pwd.h, [],
547
    AC_MSG_WARN([pwd.h not found: the pwd operations is not supported]))
548
AC_CHECK_HEADERS(grp.h, [],
549
    AC_MSG_WARN([grp.h not found: the grp operations is not supported]))
550

    
551
################################
552
# Check for chroot
553
################################
554
AC_CHECK_FUNCS(chroot, [],
555
    AC_MSG_WARN([chroot() not found: the choot is not supported]))
556

    
557
################################
558
# Check for dlopen
559
################################
560
CLISH_PLUGIN_BUILTIN_LIST=
561
CLISH_PLUGIN_BUILTIN_DEFS=
562
CLISH_PLUGIN_BUILTIN_LIBS=
563

    
564
AC_DEFUN([AC_PLUGIN_BUILTIN],
565
[
566
  CLISH_PLUGIN_BUILTIN_LIBS="$CLISH_PLUGIN_BUILTIN_LIBS clish_plugin_$1.la"
567
  CLISH_PLUGIN_BUILTIN_DEFS="$CLISH_PLUGIN_BUILTIN_DEFS CLISH_PLUGIN_INIT($1);"
568
  CLISH_PLUGIN_BUILTIN_LIST="$CLISH_PLUGIN_BUILTIN_LIST { \"$1\", clish_plugin_$1_init },"
569
])
570

    
571
AC_CHECK_HEADERS(dlfcn.h, [
572
        AC_SEARCH_LIBS([dlopen], [dl dld], [], [
573
          AC_MSG_ERROR([unable to find the dlopen() function])
574
        ])
575
    ],[
576
          AC_MSG_WARN([dlfcn.h not found: the dl operations is not supported])
577
          AC_PLUGIN_BUILTIN([clish])
578
          if test x$use_lua != xno; then
579
            AC_PLUGIN_BUILTIN([lua])
580
          fi
581
    ])
582

    
583
AC_SUBST([CLISH_PLUGIN_BUILTIN_LIST])
584
AC_SUBST([CLISH_PLUGIN_BUILTIN_DEFS])
585
AC_SUBST([CLISH_PLUGIN_BUILTIN_LIBS])
586
AC_CONFIG_FILES([clish/plugin_builtin.c])
587

    
588
AC_CONFIG_FILES([Makefile])
589
AC_OUTPUT