a947e804a61af0c2609ccb0087e83360526b8a45
[rtl-433.git] / configure.ac
1 AC_INIT([librtlsdr],
2         m4_esyscmd([./git-version-gen .tarball-version]),
3         [osmocom-sdr@lists.osmocom.org])
4
5 AM_INIT_AUTOMAKE([dist-bzip2])
6
7 dnl kernel style compile messages
8 m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
9
10 dnl checks for programs
11 AC_PROG_MAKE_SET
12 AC_PROG_CC
13 AC_PROG_INSTALL
14 LT_INIT
15 AC_PROG_LIBTOOL
16
17 PKG_CHECK_MODULES(LIBUSB, libusb-1.0 >= 1.0)
18 LIBS="$LIBS $LIBUSB_LIBS"
19 CFLAGS="$CFLAGS $LIBUSB_CFLAGS"
20
21 AC_PATH_PROG(DOXYGEN,doxygen,false)
22 AM_CONDITIONAL(HAVE_DOXYGEN, test $DOXYGEN != false)
23
24 AC_CONFIG_MACRO_DIR([m4])
25
26 dnl checks for header files
27 AC_HEADER_STDC
28 AC_CHECK_HEADERS(sys/types.h)
29 AC_CHECK_HEADERS(pthread.h,, [AC_MSG_ERROR([pthread.h required])])
30
31 # pc variables
32 AC_SUBST(RTLSDR_PC_LIBS,["$LIBS"])
33 AC_SUBST(RTLSDR_PC_CFLAGS,["$CFLAGS"])
34
35 dnl checks for required libraries
36 dnl pthreads
37 AC_CHECK_LIB(pthread, pthread_create, [LIBS="$LIBS -lpthread"])
38
39 dnl libmath (for rtl_fm)
40 AC_CHECK_LIB(m, atan2, [LIBS="$LIBS -lm"])
41
42 dnl libmath (for rtl_adsb)
43 AC_CHECK_LIB(m, sqrt, [LIBS="$LIBS -lm"])
44
45 dnl librealtime (for rtl_test)
46 AC_CHECK_LIB(rt, clock_gettime, [LIBS="$LIBS -lrt"])
47
48 # The following test is taken from WebKit's webkit.m4
49 saved_CFLAGS="$CFLAGS"
50 CFLAGS="$CFLAGS -fvisibility=hidden "
51 AC_MSG_CHECKING([if ${CC} supports -fvisibility=hidden])
52 AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])],
53     [ AC_MSG_RESULT([yes])
54       SYMBOL_VISIBILITY="-fvisibility=hidden"],
55       AC_MSG_RESULT([no]))
56 CFLAGS="$saved_CFLAGS"
57 AC_SUBST(SYMBOL_VISIBILITY)
58
59 AC_MSG_CHECKING(whether compiler understands -Wall)
60 old_CFLAGS="$CFLAGS"
61 CFLAGS="$CFLAGS -Wall -Wextra -Wno-unused -Wsign-compare"
62 AC_TRY_COMPILE([],[],
63   AC_MSG_RESULT(yes),
64   AC_MSG_RESULT(no)
65   CFLAGS="$old_CFLAGS")
66
67 dnl Generate the output
68 AM_CONFIG_HEADER(config.h)
69
70 AC_OUTPUT(
71         librtlsdr.pc
72         include/Makefile
73         src/Makefile
74         Makefile
75         Doxyfile
76 )