xref: /btstack/port/daemon/configure.ac (revision 3edc84c5b6b1e23a3d103fe8ce1f6b5ad1df3498)
1*3edc84c5SMatthias Ringwald#                                               -*- Autoconf -*-
2*3edc84c5SMatthias Ringwald# Process this file with autoconf to produce a configure script.
3*3edc84c5SMatthias Ringwald
4*3edc84c5SMatthias RingwaldAC_PREREQ(2.60)
5*3edc84c5SMatthias RingwaldAC_INIT([BTstack], 0.1)
6*3edc84c5SMatthias RingwaldAC_CONFIG_AUX_DIR(config)
7*3edc84c5SMatthias RingwaldAM_INIT_AUTOMAKE
8*3edc84c5SMatthias Ringwald
9*3edc84c5SMatthias RingwaldAC_ARG_WITH(hci-transport, [AS_HELP_STRING([--with-hci-transport=transportType], [Specify BT type to use: h4, usb])], HCI_TRANSPORT=$withval, HCI_TRANSPORT="h4")
10*3edc84c5SMatthias RingwaldAC_ARG_WITH(uart-device, [AS_HELP_STRING([--with-uart-device=uartDevice], [Specify BT UART device to use])], UART_DEVICE=$withval, UART_DEVICE="DEFAULT")
11*3edc84c5SMatthias RingwaldAC_ARG_WITH(uart-speed, [AS_HELP_STRING([--with-uart-speed=uartSpeed], [Specify BT UART speed to use])], UART_SPEED=$withval, UART_SPEED="115200")
12*3edc84c5SMatthias RingwaldAC_ARG_ENABLE(powermanagement, [AS_HELP_STRING([--disable-powermanagement],[Disable powermanagement])], USE_POWERMANAGEMENT=$enableval, USE_POWERMANAGEMENT="yes")
13*3edc84c5SMatthias RingwaldAC_ARG_ENABLE(launchd, [AS_HELP_STRING([--enable-launchd],[Compiles BTdaemon for use by launchd])], USE_LAUNCHD=$enableval, USE_LAUNCHD="no")
14*3edc84c5SMatthias RingwaldAC_ARG_WITH(vendor-id, [AS_HELP_STRING([--with-vendor-id=vendorID], [Specify USB BT Dongle vendorID])], USB_VENDOR_ID=$withval, USB_VENDOR_ID="0")
15*3edc84c5SMatthias RingwaldAC_ARG_WITH(product-id, [AS_HELP_STRING([--with-product-id=productID], [Specify USB BT Dongle productID])], USB_PRODUCT_ID=$withval, USB_PRODUCT_ID="0")
16*3edc84c5SMatthias Ringwald
17*3edc84c5SMatthias Ringwald# BUILD/HOST/TARGET
18*3edc84c5SMatthias RingwaldAC_CANONICAL_HOST
19*3edc84c5SMatthias Ringwald
20*3edc84c5SMatthias Ringwald# Checks for programs.
21*3edc84c5SMatthias RingwaldAC_PROG_CC
22*3edc84c5SMatthias RingwaldAC_PROG_CPP
23*3edc84c5SMatthias RingwaldAC_PROG_OBJC
24*3edc84c5SMatthias RingwaldAC_PROG_INSTALL
25*3edc84c5SMatthias RingwaldAC_PROG_LN_S
26*3edc84c5SMatthias RingwaldAC_PROG_MAKE_SET
27*3edc84c5SMatthias Ringwald
28*3edc84c5SMatthias Ringwald# iPhone/iPod touch cross-compilation uses theos
29*3edc84c5SMatthias RingwaldSDK_PATH="$DEVELOPER_PATH/SDKs/iPhoneOS$SDK_VERSION.sdk"
30*3edc84c5SMatthias Ringwaldif test "x$target" = xiphone; then
31*3edc84c5SMatthias Ringwald    echo "Cross-compiling for iPhone/iPod touch uses theos"
32*3edc84c5SMatthias Ringwald    ./config-iphone.sh
33*3edc84c5SMatthias Ringwald    exit 0
34*3edc84c5SMatthias Ringwaldfi
35*3edc84c5SMatthias Ringwald
36*3edc84c5SMatthias Ringwald# use capitals for transport type
37*3edc84c5SMatthias Ringwaldif test "x$HCI_TRANSPORT" = xusb; then
38*3edc84c5SMatthias Ringwald    HCI_TRANSPORT="USB"
39*3edc84c5SMatthias Ringwaldfi
40*3edc84c5SMatthias Ringwaldif test "x$HCI_TRANSPORT" = xh4; then
41*3edc84c5SMatthias Ringwald    HCI_TRANSPORT="H4"
42*3edc84c5SMatthias Ringwaldfi
43*3edc84c5SMatthias Ringwald
44*3edc84c5SMatthias Ringwald# validate USB support
45*3edc84c5SMatthias Ringwaldif test "x$HCI_TRANSPORT" = xUSB; then
46*3edc84c5SMatthias Ringwald    # pkg-config needed
47*3edc84c5SMatthias Ringwald    PKG_PROG_PKG_CONFIG
48*3edc84c5SMatthias Ringwald    # libusb installed?
49*3edc84c5SMatthias Ringwald    PKG_CHECK_MODULES([LIBUSB], [libusb-1.0], HAVE_LIBUSB="yes", HAVE_LIBUSB="no")
50*3edc84c5SMatthias Ringwald    if test "$HAVE_LIBUSB" == "no" ; then
51*3edc84c5SMatthias Ringwald        AC_MSG_ERROR(USB Transport requested but libusb-1.0 not found using pkg-config. Please set PKG_CONFIG_PATH correctly and/or install libusb-1.0 from your distribution or from http://libusb.sourceforge.net/api-1.0/)
52*3edc84c5SMatthias Ringwald    fi
53*3edc84c5SMatthias Ringwald    LIBUSB_LDFLAGS=$LIBUSB_LIBS
54*3edc84c5SMatthias Ringwaldfi
55*3edc84c5SMatthias RingwaldAM_CONDITIONAL(HAVE_LIBUSB, [test "x$HAVE_LIBUSB" == "xyes"])
56*3edc84c5SMatthias Ringwald
57*3edc84c5SMatthias Ringwaldecho
58*3edc84c5SMatthias Ringwaldecho "BTstack configured for HCI $HCI_TRANSPORT Transport"
59*3edc84c5SMatthias Ringwald
60*3edc84c5SMatthias RingwaldHAVE_SO_NOSIGPIPE="no"
61*3edc84c5SMatthias Ringwald
62*3edc84c5SMatthias RingwaldRUN_LOOP_SOURCES="run_loop_posix.c"
63*3edc84c5SMatthias Ringwaldcase "$host_os" in
64*3edc84c5SMatthias Ringwald    darwin*)
65*3edc84c5SMatthias Ringwald        RUN_LOOP_SOURCES="$RUN_LOOP_SOURCES run_loop_cocoa.m"
66*3edc84c5SMatthias Ringwald        LDFLAGS="$LDFLAGS -framework CoreFoundation -framework Foundation"
67*3edc84c5SMatthias Ringwald        USE_COCOA_RUN_LOOP="yes"
68*3edc84c5SMatthias Ringwald        BTSTACK_LIB_LDFLAGS="-dynamiclib -install_name \$(prefix)/lib/libBTstack.dylib"
69*3edc84c5SMatthias Ringwald        BTSTACK_LIB_EXTENSION="dylib"
70*3edc84c5SMatthias Ringwald        REMOTE_DEVICE_DB_SOURCES="remote_device_db_cocoa.m"
71*3edc84c5SMatthias Ringwald        REMOTE_DEVICE_DB="remote_device_db_iphone"
72*3edc84c5SMatthias Ringwald        HAVE_SO_NOSIGPIPE="yes";
73*3edc84c5SMatthias Ringwald        ;;
74*3edc84c5SMatthias Ringwald    mingw*)
75*3edc84c5SMatthias Ringwald        echo "Building on mingw32"
76*3edc84c5SMatthias Ringwald        USE_COCOA_RUN_LOOP="no"
77*3edc84c5SMatthias Ringwald        LDFLAGS="$LDFLAGS -lws2_32"
78*3edc84c5SMatthias Ringwald        BTSTACK_LIB_LDFLAGS="-shared"
79*3edc84c5SMatthias Ringwald        BTSTACK_LIB_EXTENSION="dll"
80*3edc84c5SMatthias Ringwald        REMOTE_DEVICE_DB_SOURCES="remote_device_db_memory.c"
81*3edc84c5SMatthias Ringwald        REMOTE_DEVICE_DB="remote_device_db_memory"
82*3edc84c5SMatthias Ringwald        ;;
83*3edc84c5SMatthias Ringwald    *)
84*3edc84c5SMatthias Ringwald        USE_COCOA_RUN_LOOP="no"
85*3edc84c5SMatthias Ringwald        BTSTACK_LIB_LDFLAGS="-shared -Wl,-rpath,\$(prefix)/lib"
86*3edc84c5SMatthias Ringwald        BTSTACK_LIB_EXTENSION="so"
87*3edc84c5SMatthias Ringwald        REMOTE_DEVICE_DB_SOURCES="remote_device_db_memory.c"
88*3edc84c5SMatthias Ringwald        REMOTE_DEVICE_DB="remote_device_db_memory"
89*3edc84c5SMatthias Ringwald    ;;
90*3edc84c5SMatthias Ringwaldesac
91*3edc84c5SMatthias Ringwald
92*3edc84c5SMatthias Ringwald# treat warnings seriously
93*3edc84c5SMatthias RingwaldCFLAGS="$CFLAGS -Werror -Wall -Wpointer-arith"
94*3edc84c5SMatthias Ringwald
95*3edc84c5SMatthias Ringwald# 64-bit compilation requires position independent code (PIC) for libraries
96*3edc84c5SMatthias RingwaldBTSTACK_LIB_LDFLAGS+=" -fpic"
97*3edc84c5SMatthias Ringwald
98*3edc84c5SMatthias RingwaldAM_CONDITIONAL(USE_POWERMANAGEMENT, [test "x$USE_POWERMANAGEMENT" == "xyes"])
99*3edc84c5SMatthias Ringwald
100*3edc84c5SMatthias Ringwald# summary
101*3edc84c5SMatthias Ringwald
102*3edc84c5SMatthias Ringwaldecho "CC:                  $CC"
103*3edc84c5SMatthias Ringwaldecho "CFLAGS:              $CFLAGS"
104*3edc84c5SMatthias Ringwaldecho "LDFLAGS:             $LDFLAGS"
105*3edc84c5SMatthias Ringwaldecho "BTSTACK_LIB_LDFLAGS: $BTSTACK_LIB_LDFLAGS"
106*3edc84c5SMatthias Ringwald
107*3edc84c5SMatthias Ringwaldif test "x$HCI_TRANSPORT" = xUSB; then
108*3edc84c5SMatthias Ringwald    echo "USB_PRODUCT_ID:      $USB_PRODUCT_ID"
109*3edc84c5SMatthias Ringwald    echo "USB_VENDOR_ID:       $USB_VENDOR_ID"
110*3edc84c5SMatthias Ringwald    echo "LIBUSB_CFLAGS:       $LIBUSB_CFLAGS"
111*3edc84c5SMatthias Ringwald    echo "LIBUSB_LDFLAGS:      $LIBUSB_LDFLAGS"
112*3edc84c5SMatthias Ringwaldelse
113*3edc84c5SMatthias Ringwald    echo "UART_DEVICE:         $UART_DEVICE"
114*3edc84c5SMatthias Ringwald    echo "UART_SPEED:          $UART_SPEED"
115*3edc84c5SMatthias Ringwaldfi
116*3edc84c5SMatthias Ringwald
117*3edc84c5SMatthias Ringwaldecho "USE_POWERMANAGEMENT: $USE_POWERMANAGEMENT"
118*3edc84c5SMatthias Ringwaldecho "USE_COCOA_RUN_LOOP:  $USE_COCOA_RUN_LOOP"
119*3edc84c5SMatthias Ringwaldecho "REMOTE_DEVICE_DB:    $REMOTE_DEVICE_DB"
120*3edc84c5SMatthias Ringwaldecho "HAVE_SO_NOSIGPIPE:   $HAVE_SO_NOSIGPIPE"
121*3edc84c5SMatthias Ringwaldecho
122*3edc84c5SMatthias Ringwaldecho
123*3edc84c5SMatthias Ringwald
124*3edc84c5SMatthias Ringwald# create btstack-config.h
125*3edc84c5SMatthias Ringwaldrm -f btstack-config.h
126*3edc84c5SMatthias Ringwaldecho "//"                                       >> btstack-config.h
127*3edc84c5SMatthias Ringwaldecho "// btstack-config.h"                      >> btstack-config.h
128*3edc84c5SMatthias Ringwaldecho "// created by configure for BTstack "     >> btstack-config.h
129*3edc84c5SMatthias Ringwaldecho "//" `date`                                >> btstack-config.h
130*3edc84c5SMatthias Ringwaldecho "//"                                       >> btstack-config.h
131*3edc84c5SMatthias Ringwaldecho                                            >> btstack-config.h
132*3edc84c5SMatthias Ringwaldecho "#ifndef __BTSTACK_CONFIG"                 >> btstack-config.h
133*3edc84c5SMatthias Ringwaldecho "#define __BTSTACK_CONFIG"                 >> btstack-config.h
134*3edc84c5SMatthias Ringwaldecho                                            >> btstack-config.h
135*3edc84c5SMatthias Ringwaldif test "x$HCI_TRANSPORT" = xUSB; then
136*3edc84c5SMatthias Ringwald    USB_SOURCES=hci_transport_h2_libusb.c
137*3edc84c5SMatthias Ringwald    echo "#define HAVE_TRANSPORT_USB" >> btstack-config.h
138*3edc84c5SMatthias Ringwald    echo "#define USB_PRODUCT_ID $USB_PRODUCT_ID" >> btstack-config.h
139*3edc84c5SMatthias Ringwald    echo "#define USB_VENDOR_ID $USB_VENDOR_ID" >> btstack-config.h
140*3edc84c5SMatthias Ringwaldelse
141*3edc84c5SMatthias Ringwald    echo "#define HAVE_TRANSPORT_H4" >> btstack-config.h
142*3edc84c5SMatthias Ringwald    echo "#define UART_DEVICE \"$UART_DEVICE\"" >> btstack-config.h
143*3edc84c5SMatthias Ringwald    echo "#define UART_SPEED $UART_SPEED" >> btstack-config.h
144*3edc84c5SMatthias Ringwald    if test "x$USE_BLUETOOL" = xyes; then
145*3edc84c5SMatthias Ringwald        echo "#define USE_BLUETOOL" >> btstack-config.h
146*3edc84c5SMatthias Ringwald    fi
147*3edc84c5SMatthias Ringwald    if test "x$USE_POWERMANAGEMENT" = xyes; then
148*3edc84c5SMatthias Ringwald        echo "#define USE_POWERMANAGEMENT" >> btstack-config.h
149*3edc84c5SMatthias Ringwald    fi
150*3edc84c5SMatthias Ringwaldfi
151*3edc84c5SMatthias Ringwaldif test "x$USE_COCOA_RUN_LOOP" = xyes; then
152*3edc84c5SMatthias Ringwald    echo "#define USE_COCOA_RUN_LOOP" >> btstack-config.h
153*3edc84c5SMatthias Ringwaldfi
154*3edc84c5SMatthias Ringwaldecho "#define USE_POSIX_RUN_LOOP" >> btstack-config.h
155*3edc84c5SMatthias Ringwaldecho "#define HAVE_SDP" >> btstack-config.h
156*3edc84c5SMatthias Ringwaldecho "#define HAVE_RFCOMM" >> btstack-config.h
157*3edc84c5SMatthias Ringwaldif test ! -z "$REMOTE_DEVICE_DB" ; then
158*3edc84c5SMatthias Ringwald    echo "#define REMOTE_DEVICE_DB $REMOTE_DEVICE_DB" >> btstack-config.h
159*3edc84c5SMatthias Ringwaldfi
160*3edc84c5SMatthias Ringwaldif test "x$HAVE_SO_NOSIGPIPE" == xyes ; then
161*3edc84c5SMatthias Ringwald    echo "#define HAVE_SO_NOSIGPIPE" >> btstack-config.h
162*3edc84c5SMatthias Ringwaldfi
163*3edc84c5SMatthias Ringwald
164*3edc84c5SMatthias Ringwald# often not present for embedded
165*3edc84c5SMatthias Ringwaldecho "#define HAVE_TIME" >> btstack-config.h
166*3edc84c5SMatthias Ringwaldecho "#define HAVE_MALLOC" >> btstack-config.h
167*3edc84c5SMatthias Ringwaldecho "#define HAVE_BZERO" >> btstack-config.h
168*3edc84c5SMatthias Ringwaldecho "#define HAVE_BLE" >> btstack-config.h
169*3edc84c5SMatthias Ringwaldecho "#define ENABLE_LOG_INFO " >> btstack-config.h
170*3edc84c5SMatthias Ringwaldecho "#define ENABLE_LOG_ERROR" >> btstack-config.h
171*3edc84c5SMatthias Ringwaldecho "#define HCI_ACL_PAYLOAD_SIZE 1021" >> btstack-config.h
172*3edc84c5SMatthias Ringwaldecho "#define SDP_DES_DUMP" >> btstack-config.h
173*3edc84c5SMatthias Ringwaldecho >> btstack-config.h
174*3edc84c5SMatthias Ringwaldecho "#endif" >> btstack-config.h
175*3edc84c5SMatthias Ringwald
176*3edc84c5SMatthias RingwaldAC_SUBST(HAVE_LIBUSB)
177*3edc84c5SMatthias RingwaldAC_SUBST(REMOTE_DEVICE_DB_SOURCES)
178*3edc84c5SMatthias RingwaldAC_SUBST(USB_SOURCES)
179*3edc84c5SMatthias RingwaldAC_SUBST(RUN_LOOP_SOURCES)
180*3edc84c5SMatthias RingwaldAC_SUBST(CFLAGS)
181*3edc84c5SMatthias RingwaldAC_SUBST(CPPFLAGS)
182*3edc84c5SMatthias RingwaldAC_SUBST(BTSTACK_LIB_LDFLAGS)
183*3edc84c5SMatthias RingwaldAC_SUBST(BTSTACK_LIB_EXTENSION)
184*3edc84c5SMatthias RingwaldAC_SUBST(LIBUSB_CFLAGS)
185*3edc84c5SMatthias RingwaldAC_SUBST(LIBUSB_LDFLAGS)
186*3edc84c5SMatthias RingwaldAC_OUTPUT(Makefile src/Makefile example/Makefile)
187