xref: /btstack/port/daemon/configure.ac (revision 43b344c96e85792e565c06d279c8e8a1a7e3cfb5)
13edc84c5SMatthias Ringwald#                                               -*- Autoconf -*-
23edc84c5SMatthias Ringwald# Process this file with autoconf to produce a configure script.
33edc84c5SMatthias Ringwald
43edc84c5SMatthias RingwaldAC_PREREQ(2.60)
53edc84c5SMatthias RingwaldAC_INIT([BTstack], 0.1)
63edc84c5SMatthias RingwaldAC_CONFIG_AUX_DIR(config)
73edc84c5SMatthias RingwaldAM_INIT_AUTOMAKE
83edc84c5SMatthias Ringwald
93edc84c5SMatthias 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")
103edc84c5SMatthias RingwaldAC_ARG_WITH(uart-device,   [AS_HELP_STRING([--with-uart-device=uartDevice],      [Specify BT UART device to use])],        UART_DEVICE=$withval,        UART_DEVICE="DEFAULT")
113edc84c5SMatthias RingwaldAC_ARG_WITH(uart-speed,    [AS_HELP_STRING([--with-uart-speed=uartSpeed],        [Specify BT UART speed to use])],         UART_SPEED=$withval,         UART_SPEED="115200")
123edc84c5SMatthias 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")
133edc84c5SMatthias 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")
148129e542SMatthias RingwaldAC_ARG_ENABLE(launchd,     [AS_HELP_STRING([--enable-launchd],                   [Compiles BTdaemon for use by launchd])], USE_LAUNCHD=$enableval,      USE_LAUNCHD="no")
158129e542SMatthias RingwaldAC_ARG_ENABLE(intel-usb,   [AS_HELP_STRING([--enable-intel-usb],                 [Enable Intel firmware support ])],       ENABLE_INTEL_USB=$enableval, ENABLE_INTEL_USB="no")
163edc84c5SMatthias Ringwald
173edc84c5SMatthias Ringwald# BUILD/HOST/TARGET
183edc84c5SMatthias RingwaldAC_CANONICAL_HOST
193edc84c5SMatthias Ringwald
203edc84c5SMatthias Ringwald# Checks for programs.
213edc84c5SMatthias RingwaldAC_PROG_CC
223edc84c5SMatthias RingwaldAC_PROG_CPP
233edc84c5SMatthias RingwaldAC_PROG_OBJC
243edc84c5SMatthias RingwaldAC_PROG_INSTALL
253edc84c5SMatthias RingwaldAC_PROG_LN_S
263edc84c5SMatthias RingwaldAC_PROG_MAKE_SET
273edc84c5SMatthias Ringwald
283edc84c5SMatthias Ringwald# iPhone/iPod touch cross-compilation uses theos
293edc84c5SMatthias RingwaldSDK_PATH="$DEVELOPER_PATH/SDKs/iPhoneOS$SDK_VERSION.sdk"
303edc84c5SMatthias Ringwaldif test "x$target" = xiphone; then
31875088e2SMatthias Ringwald    echo "Cross-compiling for iPhone/iPod touch uses theos, please checkout port/ios"
323edc84c5SMatthias Ringwald    exit 0
333edc84c5SMatthias Ringwaldfi
343edc84c5SMatthias Ringwald
353edc84c5SMatthias Ringwaldcase "$host_os" in
363edc84c5SMatthias Ringwald    darwin*)
376f122aa3SMatthias Ringwald        btstack_run_loop_SOURCES="btstack_run_loop_posix.o btstack_run_loop_corefoundation.m"
38abb9d6cbSMatthias Ringwald        LDFLAGS+="-framework CoreFoundation -framework Foundation"
393edc84c5SMatthias Ringwald        BTSTACK_LIB_LDFLAGS="-dynamiclib -install_name \$(prefix)/lib/libBTstack.dylib"
403edc84c5SMatthias Ringwald        BTSTACK_LIB_EXTENSION="dylib"
41e9b53984SMatthias Ringwald        REMOTE_DEVICE_DB_SOURCES="btstack_device_name_db_corefoundation.m rfcomm_service_db_corefoundation.m"
42f8d88472SMatthias Ringwald        BTSTACK_DEVICE_NAME_DB_INSTANCE="btstack_device_name_db_corefoundation_instance"
43bce95a16SMatthias Ringwald        UNIX_SOCKETS=yes
445a351b20SMatthias Ringwald        HCI_USB_LIB=libusb
45793a0509SMatthias Ringwald        UART_DRIVER=posix
463edc84c5SMatthias Ringwald        ;;
473edc84c5SMatthias Ringwald    mingw*)
483edc84c5SMatthias Ringwald        echo "Building on mingw32"
49de9043e0SMatthias Ringwald        btstack_run_loop_SOURCES="btstack_run_loop_windows.o"
500a2968ebSMatthias Ringwald        LDFLAGS+="-lws2_32 -static-libgcc"
513edc84c5SMatthias Ringwald        BTSTACK_LIB_LDFLAGS="-shared"
523edc84c5SMatthias Ringwald        BTSTACK_LIB_EXTENSION="dll"
53de9043e0SMatthias Ringwald        REMOTE_DEVICE_DB_SOURCES="rfcomm_service_db_memory.o"
54af204097SMatthias Ringwald        # BTSTACK_DEVICE_NAME_DB_INSTANCE="btstack_device_name_db_memory_instance"
551686c0edSMatthias Ringwald        UNIX_SOCKETS=no
565a351b20SMatthias Ringwald        HCI_USB_LIB=winusb
57793a0509SMatthias Ringwald        UART_DRIVER=block_windows
583edc84c5SMatthias Ringwald        ;;
593edc84c5SMatthias Ringwald    *)
606f122aa3SMatthias Ringwald        btstack_run_loop_SOURCES="btstack_run_loop_posix.o"
613edc84c5SMatthias Ringwald        BTSTACK_LIB_LDFLAGS="-shared -Wl,-rpath,\$(prefix)/lib"
623edc84c5SMatthias Ringwald        BTSTACK_LIB_EXTENSION="so"
63de9043e0SMatthias Ringwald        REMOTE_DEVICE_DB_SOURCES="rfcomm_service_db_memory.o"
648c274258SMatthias Ringwald        # BTSTACK_DEVICE_NAME_DB_INSTANCE="btstack_device_name_db_fs_instance"
65bce95a16SMatthias Ringwald        UNIX_SOCKETS=yes
665a351b20SMatthias Ringwald        HCI_USB_LIB=libusb
67793a0509SMatthias Ringwald        UART_DRIVER=posix
683edc84c5SMatthias Ringwald    ;;
693edc84c5SMatthias Ringwaldesac
703edc84c5SMatthias Ringwald
713d0114c2SMatthias Ringwald
723d0114c2SMatthias Ringwald# use capitals for transport type
733d0114c2SMatthias Ringwaldif test "x$HCI_TRANSPORT" = xusb; then
743d0114c2SMatthias Ringwald    HCI_TRANSPORT="USB"
753d0114c2SMatthias Ringwaldfi
763d0114c2SMatthias Ringwaldif test "x$HCI_TRANSPORT" = xh4; then
773d0114c2SMatthias Ringwald    HCI_TRANSPORT="H4"
783d0114c2SMatthias Ringwaldfi
793d0114c2SMatthias Ringwald
8051102e18SMatthias Ringwald# set linker flags for winusb if selected
8151102e18SMatthias Ringwaldif test "x$HCI_TRANSPORT" = xUSB && test "x$HCI_USB_LIB" == xwinusb; then
8251102e18SMatthias Ringwald    USB_LDFLAGS="-lsetupapi -lwinusb"
8351102e18SMatthias Ringwaldfi
8451102e18SMatthias Ringwald
853d0114c2SMatthias Ringwald# validate USB support on non-windows
865a351b20SMatthias Ringwaldif test "x$HCI_TRANSPORT" = xUSB && test "x$HCI_USB_LIB" == xlibusb; then
873d0114c2SMatthias Ringwald    # pkg-config needed
883d0114c2SMatthias Ringwald    PKG_PROG_PKG_CONFIG
893d0114c2SMatthias Ringwald    # libusb installed?
903d0114c2SMatthias Ringwald    PKG_CHECK_MODULES([LIBUSB], [libusb-1.0], HAVE_LIBUSB="yes", HAVE_LIBUSB="no")
913d0114c2SMatthias Ringwald    if test "$HAVE_LIBUSB" == "no" ; then
923d0114c2SMatthias 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/)
933d0114c2SMatthias Ringwald    fi
94abb9d6cbSMatthias Ringwald    echo $LIBUSB_CFLAGS
95abb9d6cbSMatthias Ringwald    echo $LIBUSB_LIBS
9651102e18SMatthias Ringwald    USB_CFLAGS=$LIBUSB_CFLAGS
976358dec7SMatthias Ringwald    USB_LDFLAGS=$LIBUSB_LIBS
983d0114c2SMatthias Ringwaldfi
993d0114c2SMatthias Ringwald
1003d0114c2SMatthias Ringwaldecho
1013d0114c2SMatthias Ringwaldecho "BTstack configured for HCI $HCI_TRANSPORT Transport"
1023d0114c2SMatthias Ringwald
1033d0114c2SMatthias Ringwald
1043edc84c5SMatthias Ringwald# treat warnings seriously
1053edc84c5SMatthias RingwaldCFLAGS="$CFLAGS -Werror -Wall -Wpointer-arith"
1063edc84c5SMatthias Ringwald
1073edc84c5SMatthias Ringwald# 64-bit compilation requires position independent code (PIC) for libraries
10828eca24fSMatthias RingwaldCFLAGS+=" -fPIC"
1093edc84c5SMatthias Ringwald
1103edc84c5SMatthias Ringwald# summary
1113edc84c5SMatthias Ringwald
1123edc84c5SMatthias Ringwaldecho "CC:                      $CC"
1133edc84c5SMatthias Ringwaldecho "CFLAGS:                  $CFLAGS"
1143edc84c5SMatthias Ringwaldecho "LDFLAGS:                 $LDFLAGS"
1153edc84c5SMatthias Ringwaldecho "BTSTACK_LIB_LDFLAGS:     $BTSTACK_LIB_LDFLAGS"
1163edc84c5SMatthias Ringwald
1173edc84c5SMatthias Ringwaldif test "x$HCI_TRANSPORT" = xUSB; then
1183edc84c5SMatthias Ringwald    echo "USB_PRODUCT_ID:          $USB_PRODUCT_ID"
1193edc84c5SMatthias Ringwald    echo "USB_VENDOR_ID:           $USB_VENDOR_ID"
1206358dec7SMatthias Ringwald    echo "USB_CFLAGS:              $USB_CFLAGS"
1216358dec7SMatthias Ringwald    echo "USB_LDFLAGS:             $USB_LDFLAGS"
1223edc84c5SMatthias Ringwaldelse
1233edc84c5SMatthias Ringwald    echo "UART_DEVICE:             $UART_DEVICE"
1243edc84c5SMatthias Ringwald    echo "UART_SPEED:              $UART_SPEED"
1253edc84c5SMatthias Ringwaldfi
1263edc84c5SMatthias Ringwald
127a05b2457SMatthias Ringwaldecho "Persistent storage:      $REMOTE_DEVICE_DB_SOURCES"
128bce95a16SMatthias Ringwaldecho "UNIX_SOCKETS:            $UNIX_SOCKETS"
1293edc84c5SMatthias Ringwaldecho
1303edc84c5SMatthias Ringwald
1317907f069SMatthias Ringwald# create btstack_config.h
1327907f069SMatthias Ringwaldrm -f btstack_config.h
1337907f069SMatthias Ringwaldecho "//"                                                  >> btstack_config.h
1347907f069SMatthias Ringwaldecho "// btstack_config.h"                                 >> btstack_config.h
1357907f069SMatthias Ringwaldecho "// created by configure for BTstack"                 >> btstack_config.h
1367907f069SMatthias Ringwaldecho "//" `date`                                           >> btstack_config.h
1377907f069SMatthias Ringwaldecho "//"                                                  >> btstack_config.h
1387907f069SMatthias Ringwaldecho                                                       >> btstack_config.h
139be3a5e5fSMatthias Ringwaldecho "#ifndef BTSTACK_CONFIG_H"                            >> btstack_config.h
140be3a5e5fSMatthias Ringwaldecho "#define BTSTACK_CONFIG_H"                            >> btstack_config.h
1417907f069SMatthias Ringwaldecho                                                       >> btstack_config.h
1424fd8b166SMatthias Ringwald
1437907f069SMatthias Ringwaldecho "// Port related features"                            >> btstack_config.h
1449277c443SMatthias Ringwaldecho "#define HAVE_POSIX_FILE_IO"                          >> btstack_config.h
145d0755cd6SMatthias Ringwaldecho "#define HAVE_POSIX_TIME"                             >> btstack_config.h
1467907f069SMatthias Ringwaldecho "#define HAVE_MALLOC"                                 >> btstack_config.h
147bce95a16SMatthias Ringwaldif test "x$UNIX_SOCKETS" == xyes; then
148bce95a16SMatthias Ringwald    echo "#define HAVE_UNIX_SOCKETS"                       >> btstack_config.h
149bce95a16SMatthias Ringwaldfi
1507907f069SMatthias Ringwaldecho                                                       >> btstack_config.h
1514fd8b166SMatthias Ringwald
1527907f069SMatthias Ringwaldecho "// BTstack features that can be enabled"             >> btstack_config.h
1537907f069SMatthias Ringwaldecho "#define ENABLE_BLE"                                  >> btstack_config.h
15480b9a8caSMatthias Ringwaldecho "#define ENABLE_CLASSIC"                              >> btstack_config.h
1552c0de6c9SMatthias Ringwaldecho "#define ENABLE_GATT_CLIENT_PAIRING"                  >> btstack_config.h
1562c0de6c9SMatthias Ringwaldecho "#define ENABLE_LE_CENTRAL"                           >> btstack_config.h
1572c0de6c9SMatthias Ringwaldecho "#define ENABLE_LE_PERIPHERAL"                        >> btstack_config.h
1582c0de6c9SMatthias Ringwaldecho "#define ENABLE_LE_SECURE_CONNECTIONS"                >> btstack_config.h
1597907f069SMatthias Ringwaldecho "#define ENABLE_LOG_ERROR"                            >> btstack_config.h
1607907f069SMatthias Ringwaldecho "#define ENABLE_LOG_INFO "                            >> btstack_config.h
1612c0de6c9SMatthias Ringwaldecho "#define ENABLE_MICRO_ECC_FOR_LE_SECURE_CONNECTIONS"  >> btstack_config.h
162*43b344c9SMatthias Ringwaldecho "#define ENABLE_SOFTWARE_AES128"                      >> btstack_config.h
16395f861f5SMatthias Ringwaldecho "#define ENABLE_PRINTF_HEXDUMP"                       >> btstack_config.h
1647907f069SMatthias Ringwaldecho "#define ENABLE_RFCOMM"                               >> btstack_config.h
1657907f069SMatthias Ringwaldecho "#define ENABLE_SDP"                                  >> btstack_config.h
1667907f069SMatthias Ringwaldecho                                                       >> btstack_config.h
1674fd8b166SMatthias Ringwald
1687907f069SMatthias Ringwaldecho "// BTstack configuration. buffers, sizes, .."        >> btstack_config.h
1697907f069SMatthias Ringwaldecho "#define HCI_ACL_PAYLOAD_SIZE 1021"                   >> btstack_config.h
170be3a5e5fSMatthias Ringwaldecho "#define NVM_NUM_LINK_KEYS         20"                >> btstack_config.h
171be3a5e5fSMatthias Ringwaldecho "#define NVM_NUM_DEVICE_DB_ENTRIES 16"                >> btstack_config.h
1727907f069SMatthias Ringwaldecho                                                       >> btstack_config.h
1734fd8b166SMatthias Ringwald
1747907f069SMatthias Ringwaldecho "// Daemon configuration" >> btstack_config.h
1753edc84c5SMatthias Ringwaldif test "x$HCI_TRANSPORT" = xUSB; then
1765a351b20SMatthias Ringwald    USB_SOURCES=hci_transport_h2_$HCI_USB_LIB.c
1777907f069SMatthias Ringwald    echo "#define HAVE_TRANSPORT_USB" >> btstack_config.h
1787907f069SMatthias Ringwald    echo "#define USB_PRODUCT_ID $USB_PRODUCT_ID" >> btstack_config.h
1797907f069SMatthias Ringwald    echo "#define USB_VENDOR_ID $USB_VENDOR_ID" >> btstack_config.h
1808129e542SMatthias Ringwald
1818129e542SMatthias Ringwald    if test "x$ENABLE_INTEL_USB" = xyes; then
1828129e542SMatthias Ringwald        echo "#define HAVE_INTEL_USB" >> btstack_config.h
1838129e542SMatthias Ringwald        FIRMWARE_FILES="\${INTEL_FILES}"
1848129e542SMatthias Ringwald        USB_SOURCES+=" btstack_chipset_intel_firmware.c"
1858129e542SMatthias Ringwald    fi
1863edc84c5SMatthias Ringwaldelse
187793a0509SMatthias Ringwald    UART_SOURCES=btstack_uart_$UART_DRIVER.o
1887907f069SMatthias Ringwald    echo "#define HAVE_TRANSPORT_H4" >> btstack_config.h
1897907f069SMatthias Ringwald    echo "#define UART_DEVICE \"$UART_DEVICE\"" >> btstack_config.h
1907907f069SMatthias Ringwald    echo "#define UART_SPEED $UART_SPEED" >> btstack_config.h
1913edc84c5SMatthias Ringwaldfi
192af204097SMatthias Ringwaldif test ! -z "$BTSTACK_DEVICE_NAME_DB_INSTANCE" ; then
193af204097SMatthias Ringwald    echo "#define BTSTACK_DEVICE_NAME_DB_INSTANCE $BTSTACK_DEVICE_NAME_DB_INSTANCE" >> btstack_config.h
1943edc84c5SMatthias Ringwaldfi
1953edc84c5SMatthias Ringwald
1967907f069SMatthias Ringwaldecho                        >> btstack_config.h
1977907f069SMatthias Ringwaldecho "#endif"               >> btstack_config.h
1983edc84c5SMatthias Ringwald
1998129e542SMatthias RingwaldAC_SUBST(FIRMWARE_FILES)
2003edc84c5SMatthias RingwaldAC_SUBST(REMOTE_DEVICE_DB_SOURCES)
2013edc84c5SMatthias RingwaldAC_SUBST(USB_SOURCES)
2022ab22389SMatthias RingwaldAC_SUBST(UART_SOURCES)
203528a4a3bSMatthias RingwaldAC_SUBST(btstack_run_loop_SOURCES)
2043edc84c5SMatthias RingwaldAC_SUBST(CFLAGS)
2053edc84c5SMatthias RingwaldAC_SUBST(CPPFLAGS)
2063edc84c5SMatthias RingwaldAC_SUBST(BTSTACK_LIB_LDFLAGS)
2073edc84c5SMatthias RingwaldAC_SUBST(BTSTACK_LIB_EXTENSION)
2086358dec7SMatthias RingwaldAC_SUBST(USB_CFLAGS)
2096358dec7SMatthias RingwaldAC_SUBST(USB_LDFLAGS)
2103edc84c5SMatthias RingwaldAC_OUTPUT(Makefile src/Makefile example/Makefile)
211