1# Copyright (C) 2013-2015 Yubico AB
2#
3# This program is free software: you can redistribute it and/or modify
4# it under the terms of the GNU General Public License as published by
5# the Free Software Foundation, eithe version 3 of the License, or
6# (at your option) any later version.
7#
8# This program is distributed in the hope that it will be useful,
9# but WITHOUT ANY WARRANTY; without even the implied warranty of
10# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11# GNU General Public License for more details.
12#
13# You should have received a copy of the GNU General Public License
14# along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
16AC_INIT([libu2f-host], [1.1.10], [yubico-devel@googlegroups.com])
17AC_CONFIG_MACRO_DIR([m4])
18AC_CONFIG_HEADERS([config.h])
19AC_CONFIG_AUX_DIR([build-aux])
20
21# http://www.gnu.org/s/libtool/manual/html_node/Updating-version-info.html
22AC_SUBST(LT_CURRENT, 1)  # Interfaces removed:    CURRENT++, AGE=0, REVISION=0
23AC_SUBST(LT_AGE, 1)      # Interfaces added:      CURRENT++, AGE++, REVISION=0
24AC_SUBST(LT_REVISION, 10) # No interfaces changed:                   REVISION++
25
26AM_INIT_AUTOMAKE([gnits dist-xz no-dist-gzip std-options -Wall])
27AM_SILENT_RULES([yes])
28
29AC_PROG_CC
30gl_EARLY
31AM_PROG_AR
32LT_INIT([win32-dll])
33
34GTK_DOC_CHECK(1.1)
35AM_MISSING_PROG(HELP2MAN, help2man, $missing_dir)
36AM_MISSING_PROG(HELP2ADOC, help2adoc, $missing_dir)
37
38PKG_CHECK_MODULES([LIBJSON], [json-c], [], [
39  PKG_CHECK_MODULES([LIBJSON], [json])])
40
41# Check for json_object_to_json_string_ext, needed for pretty printing.
42am_save_CFLAGS="$CFLAGS"
43am_save_LIBS="$LIBS"
44CFLAGS="$CFLAGS $LIBJESON_CFLAGS"
45LIBS="$LIBS $LIBJSON_LIBS"
46AC_CHECK_FUNCS([json_object_to_json_string_ext])
47AC_CHECK_FUNCS([json_object_object_get_ex])
48CFLAGS=$am_save_CFLAGS
49LIBS=$am_save_LIBS
50
51PKG_CHECK_MODULES([HIDAPI], [hidapi], [], [
52  PKG_CHECK_MODULES([HIDAPI], [hidapi-hidraw])])
53
54gl_INIT
55
56AC_ARG_ENABLE([gcc-warnings],
57  [AS_HELP_STRING([--enable-gcc-warnings],
58		  [turn on lots of GCC warnings (for developers)])],
59  [case $enableval in
60     yes|no) ;;
61     *)      AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
62   esac
63   gl_gcc_warnings=$enableval],
64  [gl_gcc_warnings=no]
65)
66
67if test "$gl_gcc_warnings" = yes; then
68  nw="$nw -Wsystem-headers"         # Don't let system headers trigger warnings
69  nw="$nw -Wpadded"                 # Struct's arenot padded
70  nw="$nw -Wc++-compat"             # We don't care strongly about C++ compilers
71  nw="$nw -Wtraditional"            # Warns on #elif which we use often
72  nw="$nw -Wtraditional-conversion" # Too many warnings for now
73  nw="$nw -Wconversion"             # Too many warnings for now
74  nw="$nw -Wsuggest-attribute=pure" # Is it worth using attributes?
75  nw="$nw -Wsuggest-attribute=const" # Is it worth using attributes?
76
77  gl_MANYWARN_ALL_GCC([ws])
78  gl_MANYWARN_COMPLEMENT(ws, [$ws], [$nw])
79  for w in $ws; do
80    gl_WARN_ADD([$w])
81  done
82
83  gl_WARN_ADD([-fdiagnostics-show-option])
84fi
85
86AC_SUBST([U2FH_VERSION_MAJOR],
87	 `echo $PACKAGE_VERSION | sed 's/\(.*\)\..*\..*/\1/g'`)
88AC_SUBST([U2FH_VERSION_MINOR],
89	 `echo $PACKAGE_VERSION | sed 's/.*\.\(.*\)\..*/\1/g'`)
90AC_SUBST([U2FH_VERSION_PATCH],
91	 `echo $PACKAGE_VERSION | sed 's/.*\..*\.\(.*\)/\1/g'`)
92AC_SUBST([U2FH_VERSION_NUMBER],
93	 `printf "0x%02x%02x%02x" $U2FH_VERSION_MAJOR \
94		 $U2FH_VERSION_MINOR $U2FH_VERSION_PATCH`)
95
96AC_ARG_WITH([udevrulesdir],
97  AS_HELP_STRING([--with-udevrulesdir=DIR], [Install udev rules into this directory]),
98  [], [])
99AC_SUBST([udevrulesdir], [$with_udevrulesdir])
100
101dnl check for random device
102AC_CACHE_CHECK(for random device, ac_cv_have_dev_random,
103[if test -r "/dev/urandom" ; then
104  ac_cv_have_dev_random=yes; else ac_cv_have_dev_random=no; fi])
105if test "$ac_cv_have_dev_random" = yes; then
106  AC_DEFINE([HAVE_DEV_URANDOM], 1, [Discovered a random device])
107fi
108
109PKG_CHECK_MODULES([UDEV], [udev],
110                  udevrulesfile=70-u2f.rules,
111                  udevrulesfile=""
112                  )
113AC_SUBST([udevrulesfile], [$udevrulesfile])
114
115AC_CONFIG_FILES([
116  Makefile
117  gl/Makefile
118  gtk-doc/Makefile
119  src/Makefile
120  tests/Makefile
121  u2f-host/Makefile
122  u2f-host/u2f-host-version.h
123  u2f-host/u2f-host.pc
124])
125AC_OUTPUT
126
127AC_MSG_NOTICE([summary of build options:
128
129  version:          ${VERSION} shared $LT_CURRENT:$LT_REVISION:$LT_AGE major $U2FH_VERSION_MAJOR minor $U2FH_VERSION_MINOR patch $U2FH_VERSION_PATCH number $U2FH_VERSION_NUMBER
130  Host type:        ${host}
131  Install prefix:   ${prefix}
132  udev rules:       ${with_udevrulesdir:-N/A}
133  udev rulefile:    ${udevrulesfile}
134  Compiler:         ${CC}
135  Shared library:   ${enable_shared}
136  Static library:   ${enable_static}
137  JSON CFLAGS:      $LIBJSON_CFLAGS
138  JSON LIBS:        $LIBJSON_LIBS
139  HIDAPI CFLAGS:    $HIDAPI_CFLAGS
140  HIDAPI LIBS:      $HIDAPI_LIBS
141])
142