root/trunk/configure.ac

Revision 1080, 12.4 KB (checked in by alonbl, 2 months ago)

Handle svn checkout detection correctly when srcdir is different

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
Line 
1dnl -*- mode: m4; -*-
2
3AC_PREREQ(2.60)
4
5define([PACKAGE_VERSION_MAJOR], [0])
6define([PACKAGE_VERSION_MINOR], [6])
7define([PACKAGE_VERSION_FIX], [15])
8
9AC_INIT([openct],[PACKAGE_VERSION_MAJOR.PACKAGE_VERSION_MINOR.PACKAGE_VERSION_FIX-svn])
10AC_CONFIG_AUX_DIR([.])
11AC_CONFIG_HEADERS([config.h])
12AC_CONFIG_MACRO_DIR([m4])
13AM_INIT_AUTOMAKE([${PACKAGE_NAME}], [${PACKAGE_VERSION}])
14
15OPENCT_VERSION_MAJOR="PACKAGE_VERSION_MAJOR"
16OPENCT_VERSION_MINOR="PACKAGE_VERSION_MINOR"
17OPENCT_VERSION_FIX="PACKAGE_VERSION_FIX"
18
19# LT Version numbers, remember to change them just *before* a release.
20#   (Code changed:                      REVISION++)
21#   (Oldest interface removed:          OLDEST++)
22#   (Interfaces added:                  CURRENT++, REVISION=0)
23OPENCT_LT_CURRENT="1"
24OPENCT_LT_OLDEST="1"
25OPENCT_LT_REVISION="0"
26OPENCT_LT_AGE="$((${OPENCT_LT_CURRENT}-${OPENCT_LT_OLDEST}))"
27
28AC_CONFIG_SRCDIR(src/ifd/ifdhandler.c)
29
30AC_CANONICAL_HOST
31
32# ct_socket_getcreds::SO_PEERCRED
33AC_GNU_SOURCE   
34
35AC_PROG_CC
36PKG_PROG_PKG_CONFIG
37AC_C_BIGENDIAN
38
39AC_MSG_CHECKING([svn checkout])
40if test -e "${srcdir}/packaged"; then
41        svn_checkout="no"
42else
43        svn_checkout="yes"
44fi
45AC_MSG_RESULT([${svn_checkout}])
46
47dnl Check for some target-specific stuff
48case "${host}" in
49        *-*-hpux*)
50                CPPFLAGS="${CPPFLAGS} -D_HPUX_SOURCE -D_XOPEN_SOURCE_EXTENDED"
51        ;;
52        *-*-solaris*)
53                CPPFLAGS="${CPPFLAGS} -I/usr/local/include"
54                LDFLAGS="${LDFLAGS} -L/usr/local/lib -R/usr/local/lib"
55                need_dash_r="1"
56        ;;
57        *-*-sunos4*)
58                CPPFLAGS="${CPPFLAGS} -DSUNOS4"
59        ;;
60        *-*-aix*)
61                CPPFLAGS="${CPPFLAGS} -I/usr/local/include"
62                LDFLAGS="${LDFLAGS} -L/usr/local/lib"
63                if test "${LD}" != "gcc" -a -z "${blibpath}"; then
64                        blibpath="/usr/lib:/lib:/usr/local/lib"
65                fi
66        ;;
67        *-*-osf*)
68                CPPFLAGS="${CPPFLAGS} -D_POSIX_PII_SOCKET"
69        ;;
70        *-*-darwin*)
71                LIBS="${LIBS} -Wl,-framework,CoreFoundation"
72                if test "${GCC}" = "yes"; then
73                        CFLAGS="${CFLAGS} -no-cpp-precomp"
74                fi
75        ;;
76esac
77
78usrlibdir="/usr/lib${libdir##*/lib}"
79usrsbindir="/usr/sbin${libdir##*/sbin}"
80
81full_sysconfdir=`eval eval eval eval eval echo "${sysconfdir}" | sed "s#NONE#${prefix}#" | sed "s#NONE#${ac_default_prefix}#"`
82full_localstatedir=`eval eval eval eval eval echo "${localstatedir}" | sed "s#NONE#${prefix}#" | sed "s#NONE#${ac_default_prefix}#"`
83
84AC_ARG_ENABLE(
85        [strict],
86        [AS_HELP_STRING([--enable-strict],[enable strict compile mode @<:@disabled@:>@])],
87        ,
88        [enable_strict="no"]
89)
90
91AC_ARG_ENABLE(
92        [pedantic],
93        [AS_HELP_STRING([--enable-pedantic],[enable pedantic compile mode @<:@disabled@:>@])],
94        ,
95        [enable_pedantic="no"]
96)
97
98AC_ARG_ENABLE(
99        [doc],
100        [AS_HELP_STRING([--enable-doc],[enable installation of documents @<:@disabled@:>@])],
101        ,
102        [enable_doc="no"]
103)
104
105AC_ARG_ENABLE(
106        [api-doc],
107        [AS_HELP_STRING([--enable-api-doc],[enable generation and installation of api documents @<:@disabled@:>@])],
108        ,
109        [enable_api_doc="no"]
110)
111
112AC_ARG_ENABLE(
113        [pcsc],
114        [AS_HELP_STRING([--enable-pcsc],[enable pcsc support @<:@disabled@:>@])],
115        ,
116        [enable_pcsc="no"]
117)
118
119AC_ARG_ENABLE(
120        [usb],
121        [AS_HELP_STRING([--enable-usb],[enable usb support @<:@disabled@:>@])],
122        ,
123        [enable_usb="no"]
124)
125
126AC_ARG_ENABLE(
127        [debug],
128        [AS_HELP_STRING([--enable-debug],[enable debug messages @<:@disabled@:>@])],
129        [test "${enableval}" = "yes" && AC_DEFINE([DEBUG], [1], [Enable debug messages.])]
130)
131
132AC_ARG_ENABLE(
133        [sunray],
134        [AS_HELP_STRING([--enable-sunray],[enable sunray support @<:@disabled@:>@])],
135        [test "${enableval}" = "yes" && AC_DEFINE([sunray], [1], [Enable sunray support.])]
136)
137
138AC_ARG_ENABLE(
139        [sunrayclient],
140        [AS_HELP_STRING([--enable-sunrayclient],[enable sunray client support @<:@disabled@:>@])],
141        [test "${enableval}" = "yes" && AC_DEFINE(sunrayclient, 1, [Enable sunray client support.])]
142)
143
144AC_ARG_ENABLE(
145        [non-privileged],
146        [AS_HELP_STRING([--enable-non-privileged],[enable non privileged mode @<:@disabled@:>@])],
147        [test "${enableval}" = "no" && ENABLE_NON_PRIVILEGED="#"],
148        [ENABLE_NON_PRIVILEGED="#"]
149)
150
151AC_ARG_WITH(
152        [bundle],
153        [AS_HELP_STRING([--with-bundle=PATH],[install bundle file for pcsc-lite to PATH @<:@not installed@:>@])],
154        [
155                if test "${withval}" = "yes"; then
156                        bundledir="\$(libdir)"
157                else
158                        bundledir="${withval}"
159                fi
160        ],
161        [bundledir=""]
162)
163
164AC_ARG_WITH(
165        [udev],
166        [AS_HELP_STRING([--with-udev=PATH],[install udev files into PATH @<:@not installed@:>@])],
167        [
168                if test "${withval}" = "yes"; then
169                        udevdir="\$(libdir)/udev"
170                else
171                        udevdir="${withval}"
172                fi
173        ],
174        [udevdir=""]
175)
176
177AC_ARG_WITH(
178        [hotplug],
179        [AS_HELP_STRING([--with-hotplug=PATH],[install hotplug files into PATH @<:@not installed@:>@])],
180        [
181                if test "${withval}" = "yes"; then
182                        hotplugdir="\$(sysconfdir)/hotplug/usb"
183                else
184                        hotplugdir="${withval}"
185                fi
186        ],
187        [hotplugdir=""]
188)
189
190AC_ARG_WITH(
191        [ifddir],
192        [AS_HELP_STRING([--with-ifddir],[ifd directory @<:@/usr/lib/ifd@:>@])],
193        [ifddir="${withval}"],
194        [ifddir="${usrlibdir}/ifd"]
195)
196
197AC_ARG_WITH(
198        [apidocdir],
199        [AS_HELP_STRING([--with-apidocdir],[put API documents at this directory @<:@HTMLDIR/api@:>@])],
200        [apidocdir="${with_apidocdir}"],
201        [apidocdir="\$(htmldir)/api"]
202)
203
204AC_ARG_WITH(
205        [daemon-user],
206        [AS_HELP_STRING([--with-daemon-user=USER],[use this user for daemon @<:@openctd@:>@])],
207        [daemon_user="${withval}"],
208        [daemon_user="openctd"]
209)
210
211AC_ARG_WITH(
212        [daemon-groups],
213        [AS_HELP_STRING([--with-daemon-groups=GROUPS],[use these comma separated group list for daemon @<:@usb@:>@])],
214        [daemon_groups="${withval}"],
215        [daemon_groups="usb"]
216)
217
218dnl Checks for programs.
219AC_PROG_CPP
220AC_PROG_INSTALL
221AC_PROG_LN_S
222AC_PROG_MKDIR_P
223AC_PROG_SED
224AC_PROG_MAKE_SET
225
226AM_PROG_CC_C_O
227
228dnl Add libtool support.
229ifdef(
230        [LT_INIT],
231        [
232                LT_INIT
233        ],
234        [
235                AC_PROG_LIBTOOL
236        ]
237)
238
239AC_CHECK_PROGS([DOXYGEN],[doxygen])
240test "${enable_api_doc}" = "yes" -a -z "${DOXYGEN}" && AC_MSG_ERROR([doxygen is required for api doc])
241
242dnl These required for svn checkout
243AC_ARG_VAR([XSLTPROC], [xsltproc utility])
244AC_ARG_VAR([SVN], [subversion utility])
245AC_ARG_VAR([WGET], [wget utility])
246AC_ARG_VAR([WGET_OPTS], [wget options])
247AC_ARG_VAR([TR], [tr utility])
248AC_CHECK_PROGS([XSLTPROC],[xsltproc])
249AC_CHECK_PROGS([SVN],[svn])
250AC_CHECK_PROGS([WGET],[wget])
251AC_CHECK_PROGS([TR],[tr])
252test -z "${WGET_OPTS}" && WGET_OPTS="-nv"
253
254dnl svn checkout dependencies
255if test "${svn_checkout}" = "yes"; then
256        AC_MSG_CHECKING([XSLTPROC requirement])
257        if test -n "${XSLTPROC}"; then
258                AC_MSG_RESULT([ok])
259        else
260                if test "${enable_doc}" = "yes"; then
261                        AC_MSG_ERROR([Missing XSLTPROC svn build with doc])
262                else
263                        AC_MSG_WARN(["make dist" will not work])
264                fi
265        fi
266
267        AC_MSG_CHECKING([svn doc build dependencies])
268        if test -n "${SVN}" -a -n "${TR}" -a -n "${WGET}"; then
269                AC_MSG_RESULT([ok])
270        else
271                if test "${enable_doc}" = "yes"; then
272                        AC_MSG_ERROR([Missing SVN, TR or WGET for svn doc build])
273                else
274                        AC_MSG_WARN(["make dist" will not work])
275                fi
276        fi
277fi
278
279dnl Checks for header files.
280AC_HEADER_STDC
281AC_HEADER_SYS_WAIT
282AC_CHECK_HEADERS([ \
283        errno.h fcntl.h malloc.h stdlib.h string.h \
284        strings.h sys/time.h unistd.h getopt.h \
285        dlfcn.h sys/poll.h
286])
287
288dnl Checks for typedefs, structures, and compiler characteristics.
289AC_C_CONST
290AC_TYPE_UID_T
291AC_TYPE_SIZE_T
292AC_HEADER_TIME
293
294dnl Checks for library functions.
295AC_FUNC_ERROR_AT_LINE
296AC_FUNC_STAT
297AC_FUNC_VPRINTF
298AC_CHECK_FUNCS([gettimeofday daemon])
299
300dnl C Compiler features
301AC_C_INLINE
302
303dnl See if socket() is found from libsocket
304AC_CHECK_LIB(
305        [socket],
306        [socket],
307        [
308                LIBS="${LIBS} -lsocket"
309                AC_CHECK_LIB(
310                        [resolv],
311                        [res_query],
312                        [LIBS="${LIBS} -lresolv"]
313                )
314        ]
315)
316
317AC_ARG_VAR([LTLIB_CFLAGS], [C compiler flags for libltdl])
318AC_ARG_VAR([LTLIB_LIBS], [linker flags for libltdl])
319if test -z "${LTLIB_LIBS}"; then
320        AC_CHECK_LIB(
321                [ltdl],
322                [lt_dlopen],
323                [LTLIB_LIBS="-lltdl"],
324                [AC_MSG_ERROR([ltdl not found, please install libltdl and/or libtool])]
325        )
326fi
327saved_CFLAGS="${CFLAGS}"
328CFLAGS="${CFLAGS} ${LTLIB_CFLAGS}"
329AC_CHECK_HEADER(
330        [ltdl.h],
331        ,
332        [AC_MSG_ERROR([ltdl.h not found, please install libltdl and/or libtool])]
333)
334CFLAGS="${saved_CFLAGS}"
335
336AC_MSG_CHECKING([struct sockaddr_storage::ss_family])
337AC_COMPILE_IFELSE(
338        [AC_LANG_PROGRAM(
339                [[
340#include <sys/types.h>
341#include <sys/socket.h>
342                ]],
343                [[
344struct sockaddr_storage s;
345s.ss_family = 1;
346                ]]
347        )],
348        [AC_MSG_RESULT([ok])],
349        [AC_TRY_COMPILE(
350                [
351#include <sys/types.h>
352#include <sys/socket.h>
353                ],
354                [
355struct sockaddr_storage s;
356s.__ss_family = 1;
357                ],
358                [
359                        AC_MSG_RESULT([hack])
360                        AC_DEFINE_UNQUOTED([ss_family], [__ss_family], [sockaddr_storage.ss_family wrapper])
361                ],
362                [AC_MSG_ERROR([Invalid struct sockaddr_storage])]
363        )]
364)
365
366dnl see if poll() is found from libpoll
367AC_CHECK_LIB([poll], [poll], [LIBS="$LIBS -lpoll"])
368
369if test "${enable_usb}" = "yes"; then
370        PKG_CHECK_MODULES(
371                [LIBUSB],
372                [libusb],
373                [AC_DEFINE([ENABLE_LIBUSB], [1], [Have libusb libraries and header files])],
374                [AC_MSG_ERROR([Cannot detect libusb])]
375        )
376fi
377
378if test "${enable_pcsc}" = "yes"; then
379        case "$host" in
380                *-*-darwin*)
381                        if test -z "$PCSC_LIBS" -a -z "$PCSC_LIBS"; then
382                                PCSC_MSG=yes
383                                PCSC_CFLAGS=""
384                                PCSC_LIBS="-Wl,-framework,PCSC"
385                        fi
386                ;;
387                *)
388                        PKG_CHECK_MODULES(
389                                [PCSC],
390                                [libpcsclite],
391                                ,
392                                [AC_MSG_ERROR([Cannot locate pcsc-lite])]
393                        )
394                ;;
395        esac
396fi
397
398if test "${enable_usb}" = "yes"; then
399        OPTIONAL_LIBUSB_CFLAGS="${LIBUSB_CFLAGS}"
400        OPTIONAL_LIBUSB_LIBS="${LIBUSB_LIBS}"
401fi
402
403AC_DEFINE_UNQUOTED([OPENCT_CONF_PATH], ["${full_sysconfdir}/openct.conf"], [default config file for libopenct])
404AC_DEFINE_UNQUOTED([OPENCT_MODULES_PATH], ["${ifddir}"], [modules path for libopenct])
405OPENCT_SOCKET_PATH="${full_localstatedir}/run/openct"
406AC_DEFINE_UNQUOTED([OPENCT_SOCKET_PATH], ["${OPENCT_SOCKET_PATH}"], [socket path for libopenct])
407AC_DEFINE_UNQUOTED([OPENCT_IFDHANDLER_PATH], ["${usrsbindir}/ifdhandler"], [ifdhandler path for libopenct])
408
409AC_CREATE_STDINT_H([src/include/openct/types.h])
410
411if test "${enable_pedantic}" = "yes"; then
412        enable_strict="yes";
413        CFLAGS="${CFLAGS} -pedantic"
414fi
415if test "${enable_strict}" = "yes"; then
416        CFLAGS="${CFLAGS} -Wall -Wextra"
417fi
418
419pkgconfigdir="\$(libdir)/pkgconfig"
420openctincludedir="\$(includedir)/openct"
421
422AC_SUBST([pkgconfigdir])
423AC_SUBST([openctincludedir])
424AC_SUBST([apidocdir])
425AC_SUBST([bundledir])
426AC_SUBST([ifddir])
427AC_SUBST([udevdir])
428AC_SUBST([hotplugdir])
429AC_SUBST([daemon_user])
430AC_SUBST([daemon_groups])
431AC_SUBST([OPENCT_VERSION_MAJOR])
432AC_SUBST([OPENCT_VERSION_MINOR])
433AC_SUBST([OPENCT_VERSION_FIX])
434AC_SUBST([OPENCT_LT_CURRENT])
435AC_SUBST([OPENCT_LT_REVISION])
436AC_SUBST([OPENCT_LT_AGE])
437AC_SUBST([OPENCT_LT_OLDEST])
438AC_SUBST([OPTIONAL_LIBUSB_CFLAGS])
439AC_SUBST([OPTIONAL_LIBUSB_LIBS])
440AC_SUBST([OPENCT_SOCKET_PATH])
441AC_SUBST([ENABLE_NON_PRIVILEGED])
442
443AM_CONDITIONAL([SVN_CHECKOUT], [test "${svn_checkout}" = "yes"])
444AM_CONDITIONAL([ENABLE_DOC], [test "${enable_doc}" = "yes"])
445AM_CONDITIONAL([ENABLE_API_DOC], [test "${enable_api_doc}" = "yes"])
446AM_CONDITIONAL([ENABLE_BUNDLES], [test -n "${bundledir}"])
447AM_CONDITIONAL([ENABLE_UDEV], [test -n "${udevdir}"])
448AM_CONDITIONAL([ENABLE_HOTPLUG], [test -n "${hotplugdir}"])
449AM_CONDITIONAL([ENABLE_PCSC], [test "${enable_pcsc}" = "yes"])
450
451AC_CONFIG_FILES([
452        Makefile
453        doc/Makefile
454        doc/doxygen.conf
455        doc/nonpersistent/Makefile
456        etc/Makefile
457        macos/Makefile
458        src/Makefile
459        src/ct/Makefile
460        src/ct/libopenct.pc
461        src/ctapi/Makefile
462        src/ifd/Makefile
463        src/include/Makefile
464        src/include/openct/Makefile
465        src/pcsc/Makefile
466        src/tools/Makefile
467        src/tools/openct-tool.1
468])
469AC_OUTPUT
470
471cat <<EOF
472
473OpenCT has been configured with the following options:
474
475
476Version:                 ${PACKAGE_VERSION}
477Libraries:               $(eval eval eval echo "${libdir}")
478
479doc support:             ${enable_doc}
480api doc support:         ${enable_api_doc}
481usb support:             ${enable_usb}
482pcsc support:            ${enable_pcsc}
483non-privileged support:  ${ENABLE_NON_PRIVILEGED}
484
485Host:                    ${host}
486Compiler:                ${CC}
487Preprocessor flags:      ${CPPFLAGS}
488Compiler flags:          ${CFLAGS}
489Linker flags:            ${LDFLAGS}
490Libraries:               ${LIBS}
491
492LIBUSB_CFLAGS:           ${LIBUSB_CFLAGS}
493LIBUSB_LIBS:             ${LIBUSB_LIBS}
494PCSC_CFLAGS:             ${PCSC_CFLAGS}
495PCSC_LIBS:               ${PCSC_LIBS}
496
497bundledir:               ${bundledir}
498ifddir:                  ${ifddir}
499udevdir:                 ${udevdir}
500hotplugdir:              ${hotplugdir}
501
502daemon user:             ${daemon_user}
503daemon groups:           ${daemon_groups}
504
505EOF
506
507# Only Linux uses libusb
508case "${host}" in
509*-*-linux*)
510        if test "${enable_usb}" != "yes"; then
511
512        cat <<EOF
513
514Without libusb coldplugging will work in basic way,
515To use usb devices, your hotplugging needs to be
516configured and you need to plug in any device
517after the system has started (i.e. the init script ran)
518
519EOF
520
521        fi
522;;
523esac
Note: See TracBrowser for help on using the browser.