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_ENABLE(launchd, [AS_HELP_STRING([--enable-launchd],[Compiles BTdaemon for use by launchd])], USE_LAUNCHD=$enableval, USE_LAUNCHD="no") 133edc84c5SMatthias 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") 143edc84c5SMatthias 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") 153edc84c5SMatthias Ringwald 163edc84c5SMatthias Ringwald# BUILD/HOST/TARGET 173edc84c5SMatthias RingwaldAC_CANONICAL_HOST 183edc84c5SMatthias Ringwald 193edc84c5SMatthias Ringwald# Checks for programs. 203edc84c5SMatthias RingwaldAC_PROG_CC 213edc84c5SMatthias RingwaldAC_PROG_CPP 223edc84c5SMatthias RingwaldAC_PROG_OBJC 233edc84c5SMatthias RingwaldAC_PROG_INSTALL 243edc84c5SMatthias RingwaldAC_PROG_LN_S 253edc84c5SMatthias RingwaldAC_PROG_MAKE_SET 263edc84c5SMatthias Ringwald 273edc84c5SMatthias Ringwald# iPhone/iPod touch cross-compilation uses theos 283edc84c5SMatthias RingwaldSDK_PATH="$DEVELOPER_PATH/SDKs/iPhoneOS$SDK_VERSION.sdk" 293edc84c5SMatthias Ringwaldif test "x$target" = xiphone; then 30875088e2SMatthias Ringwald echo "Cross-compiling for iPhone/iPod touch uses theos, please checkout port/ios" 313edc84c5SMatthias Ringwald exit 0 323edc84c5SMatthias Ringwaldfi 333edc84c5SMatthias Ringwald 343edc84c5SMatthias Ringwaldcase "$host_os" in 353edc84c5SMatthias Ringwald darwin*) 361686c0edSMatthias Ringwald btstack_run_loop_SOURCES="btstack_run_loop_posix.c btstack_run_loop_corefoundation.m" 373edc84c5SMatthias Ringwald LDFLAGS="$LDFLAGS -framework CoreFoundation -framework Foundation" 383edc84c5SMatthias Ringwald BTSTACK_LIB_LDFLAGS="-dynamiclib -install_name \$(prefix)/lib/libBTstack.dylib" 393edc84c5SMatthias Ringwald BTSTACK_LIB_EXTENSION="dylib" 40f8d88472SMatthias Ringwald REMOTE_DEVICE_DB_SOURCES="btstack_link_key_db_corefoundation.m btstack_device_name_db_corefoundation.m rfcomm_service_db_corefoundation.m" 41f8d88472SMatthias Ringwald BTSTACK_LINK_KEY_DB_INSTANCE="btstack_link_key_db_corefoundation_instance" 42f8d88472SMatthias Ringwald BTSTACK_DEVICE_NAME_DB_INSTANCE="btstack_device_name_db_corefoundation_instance" 43bce95a16SMatthias Ringwald UNIX_SOCKETS=yes 441686c0edSMatthias Ringwald LIBUSB_REQUIRED_FOR_USB=yes 453edc84c5SMatthias Ringwald ;; 463edc84c5SMatthias Ringwald mingw*) 473edc84c5SMatthias Ringwald echo "Building on mingw32" 481686c0edSMatthias Ringwald btstack_run_loop_SOURCES="btstack_run_loop_windows.c" 493edc84c5SMatthias Ringwald LDFLAGS="$LDFLAGS -lws2_32" 503edc84c5SMatthias Ringwald BTSTACK_LIB_LDFLAGS="-shared" 513edc84c5SMatthias Ringwald BTSTACK_LIB_EXTENSION="dll" 52a98592bcSMatthias Ringwald REMOTE_DEVICE_DB_SOURCES="btstack_link_key_db_memory.c rfcomm_service_db_memory.c" 53af204097SMatthias Ringwald BTSTACK_LINK_KEY_DB_INSTANCE="btstack_link_key_db_memory_instance" 54af204097SMatthias Ringwald # BTSTACK_DEVICE_NAME_DB_INSTANCE="btstack_device_name_db_memory_instance" 551686c0edSMatthias Ringwald UNIX_SOCKETS=no 561686c0edSMatthias Ringwald LIBUSB_REQUIRED_FOR_USB=no 573edc84c5SMatthias Ringwald ;; 583edc84c5SMatthias Ringwald *) 591686c0edSMatthias Ringwald btstack_run_loop_SOURCES="btstack_run_loop_posix.c" 603edc84c5SMatthias Ringwald BTSTACK_LIB_LDFLAGS="-shared -Wl,-rpath,\$(prefix)/lib" 613edc84c5SMatthias Ringwald BTSTACK_LIB_EXTENSION="so" 628c274258SMatthias Ringwald REMOTE_DEVICE_DB_SOURCES="btstack_link_key_db_memory.c rfcomm_service_db_memory.c" 63af204097SMatthias Ringwald BTSTACK_LINK_KEY_DB_INSTANCE="btstack_link_key_db_memory_instance" 648c274258SMatthias Ringwald # BTSTACK_DEVICE_NAME_DB_INSTANCE="btstack_device_name_db_fs_instance" 65bce95a16SMatthias Ringwald UNIX_SOCKETS=yes 661686c0edSMatthias Ringwald LIBUSB_REQUIRED_FOR_USB=yes 673edc84c5SMatthias Ringwald ;; 683edc84c5SMatthias Ringwaldesac 693edc84c5SMatthias Ringwald 70*3d0114c2SMatthias Ringwald 71*3d0114c2SMatthias Ringwald# use capitals for transport type 72*3d0114c2SMatthias Ringwaldif test "x$HCI_TRANSPORT" = xusb; then 73*3d0114c2SMatthias Ringwald HCI_TRANSPORT="USB" 74*3d0114c2SMatthias Ringwaldfi 75*3d0114c2SMatthias Ringwaldif test "x$HCI_TRANSPORT" = xh4; then 76*3d0114c2SMatthias Ringwald HCI_TRANSPORT="H4" 77*3d0114c2SMatthias Ringwaldfi 78*3d0114c2SMatthias Ringwald 79*3d0114c2SMatthias Ringwald# validate USB support on non-windows 80*3d0114c2SMatthias Ringwaldif test "x$HCI_TRANSPORT" = xUSB && test "x$LIBUSB_REQUIRED_FOR_USB" == xyes; then 81*3d0114c2SMatthias Ringwald # pkg-config needed 82*3d0114c2SMatthias Ringwald PKG_PROG_PKG_CONFIG 83*3d0114c2SMatthias Ringwald # libusb installed? 84*3d0114c2SMatthias Ringwald PKG_CHECK_MODULES([LIBUSB], [libusb-1.0], HAVE_LIBUSB="yes", HAVE_LIBUSB="no") 85*3d0114c2SMatthias Ringwald if test "$HAVE_LIBUSB" == "no" ; then 86*3d0114c2SMatthias 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/) 87*3d0114c2SMatthias Ringwald fi 88*3d0114c2SMatthias Ringwald LIBUSB_LDFLAGS=$LIBUSB_LIBS 89*3d0114c2SMatthias Ringwaldfi 90*3d0114c2SMatthias RingwaldAM_CONDITIONAL(HAVE_LIBUSB, [test "x$HAVE_LIBUSB" == "xyes"]) 91*3d0114c2SMatthias Ringwald 92*3d0114c2SMatthias Ringwaldecho 93*3d0114c2SMatthias Ringwaldecho "BTstack configured for HCI $HCI_TRANSPORT Transport" 94*3d0114c2SMatthias Ringwald 95*3d0114c2SMatthias Ringwald 963edc84c5SMatthias Ringwald# treat warnings seriously 973edc84c5SMatthias RingwaldCFLAGS="$CFLAGS -Werror -Wall -Wpointer-arith" 983edc84c5SMatthias Ringwald 993edc84c5SMatthias Ringwald# 64-bit compilation requires position independent code (PIC) for libraries 1003edc84c5SMatthias RingwaldBTSTACK_LIB_LDFLAGS+=" -fpic" 1013edc84c5SMatthias Ringwald 1023edc84c5SMatthias Ringwald# summary 1033edc84c5SMatthias Ringwald 1043edc84c5SMatthias Ringwaldecho "CC: $CC" 1053edc84c5SMatthias Ringwaldecho "CFLAGS: $CFLAGS" 1063edc84c5SMatthias Ringwaldecho "LDFLAGS: $LDFLAGS" 1073edc84c5SMatthias Ringwaldecho "BTSTACK_LIB_LDFLAGS: $BTSTACK_LIB_LDFLAGS" 1083edc84c5SMatthias Ringwald 1093edc84c5SMatthias Ringwaldif test "x$HCI_TRANSPORT" = xUSB; then 1103edc84c5SMatthias Ringwald echo "USB_PRODUCT_ID: $USB_PRODUCT_ID" 1113edc84c5SMatthias Ringwald echo "USB_VENDOR_ID: $USB_VENDOR_ID" 1123edc84c5SMatthias Ringwald echo "LIBUSB_CFLAGS: $LIBUSB_CFLAGS" 1133edc84c5SMatthias Ringwald echo "LIBUSB_LDFLAGS: $LIBUSB_LDFLAGS" 1143edc84c5SMatthias Ringwaldelse 1153edc84c5SMatthias Ringwald echo "UART_DEVICE: $UART_DEVICE" 1163edc84c5SMatthias Ringwald echo "UART_SPEED: $UART_SPEED" 1173edc84c5SMatthias Ringwaldfi 1183edc84c5SMatthias Ringwald 119af204097SMatthias Ringwaldecho "BTSTACK_LINK_KEY_DB: $BTSTACK_LINK_KEY_DB_INSTANCE" 120af204097SMatthias Ringwaldecho "BTSTACK_DEVICE_NAME_DB: $BTSTACK_DEVICE_NAME_DB_INSTANCE" 121bce95a16SMatthias Ringwaldecho "UNIX_SOCKETS: $UNIX_SOCKETS" 1223edc84c5SMatthias Ringwaldecho 1233edc84c5SMatthias Ringwald 1247907f069SMatthias Ringwald# create btstack_config.h 1257907f069SMatthias Ringwaldrm -f btstack_config.h 1267907f069SMatthias Ringwaldecho "//" >> btstack_config.h 1277907f069SMatthias Ringwaldecho "// btstack_config.h" >> btstack_config.h 1287907f069SMatthias Ringwaldecho "// created by configure for BTstack " >> btstack_config.h 1297907f069SMatthias Ringwaldecho "//" `date` >> btstack_config.h 1307907f069SMatthias Ringwaldecho "//" >> btstack_config.h 1317907f069SMatthias Ringwaldecho >> btstack_config.h 1327907f069SMatthias Ringwaldecho "#ifndef __BTSTACK_CONFIG" >> btstack_config.h 1337907f069SMatthias Ringwaldecho "#define __BTSTACK_CONFIG" >> btstack_config.h 1347907f069SMatthias Ringwaldecho >> btstack_config.h 1354fd8b166SMatthias Ringwald 1367907f069SMatthias Ringwaldecho "// Port related features" >> btstack_config.h 1379277c443SMatthias Ringwaldecho "#define HAVE_POSIX_FILE_IO" >> btstack_config.h 138d0755cd6SMatthias Ringwaldecho "#define HAVE_POSIX_TIME" >> btstack_config.h 1397907f069SMatthias Ringwaldecho "#define HAVE_MALLOC" >> btstack_config.h 140bce95a16SMatthias Ringwaldif test "x$UNIX_SOCKETS" == xyes; then 141bce95a16SMatthias Ringwald echo "#define HAVE_UNIX_SOCKETS" >> btstack_config.h 142bce95a16SMatthias Ringwaldfi 1437907f069SMatthias Ringwaldecho >> btstack_config.h 1444fd8b166SMatthias Ringwald 1454fd8b166SMatthias Ringwald# todo: HAVE -> ENABLE in features below 1464fd8b166SMatthias Ringwald 1477907f069SMatthias Ringwaldecho "// BTstack features that can be enabled" >> btstack_config.h 1487907f069SMatthias Ringwaldecho "#define ENABLE_BLE" >> btstack_config.h 149e7f94a8eSMatthias Ringwald# echo "#define ENABLE_LE_PERIPHERAL" >> btstack_config.h 150e7f94a8eSMatthias Ringwaldecho "#define ENABLE_LE_CENTRAL" >> btstack_config.h 15180b9a8caSMatthias Ringwaldecho "#define ENABLE_CLASSIC" >> btstack_config.h 1527907f069SMatthias Ringwaldecho "#define ENABLE_LOG_ERROR" >> btstack_config.h 1537907f069SMatthias Ringwaldecho "#define ENABLE_LOG_INFO " >> btstack_config.h 1547907f069SMatthias Ringwaldecho "#define ENABLE_RFCOMM" >> btstack_config.h 1557907f069SMatthias Ringwaldecho "#define ENABLE_SDP" >> btstack_config.h 1567907f069SMatthias Ringwaldecho "#define ENABLE_SDP_DES_DUMP" >> btstack_config.h 1577907f069SMatthias Ringwaldecho >> btstack_config.h 1584fd8b166SMatthias Ringwald 1597907f069SMatthias Ringwaldecho "// BTstack configuration. buffers, sizes, .." >> btstack_config.h 1607907f069SMatthias Ringwaldecho "#define HCI_ACL_PAYLOAD_SIZE 1021" >> btstack_config.h 16122aa1512SMatthias Ringwaldecho "#define MAX_NR_LE_DEVICE_DB_ENTRIES 1" >> btstack_config.h 1627907f069SMatthias Ringwaldecho >> btstack_config.h 1634fd8b166SMatthias Ringwald 1647907f069SMatthias Ringwaldecho "// Daemon configuration" >> btstack_config.h 1653edc84c5SMatthias Ringwaldif test "x$HCI_TRANSPORT" = xUSB; then 1663edc84c5SMatthias Ringwald USB_SOURCES=hci_transport_h2_libusb.c 1677907f069SMatthias Ringwald echo "#define HAVE_TRANSPORT_USB" >> btstack_config.h 1687907f069SMatthias Ringwald echo "#define USB_PRODUCT_ID $USB_PRODUCT_ID" >> btstack_config.h 1697907f069SMatthias Ringwald echo "#define USB_VENDOR_ID $USB_VENDOR_ID" >> btstack_config.h 1703edc84c5SMatthias Ringwaldelse 1717907f069SMatthias Ringwald echo "#define HAVE_TRANSPORT_H4" >> btstack_config.h 1727907f069SMatthias Ringwald echo "#define UART_DEVICE \"$UART_DEVICE\"" >> btstack_config.h 1737907f069SMatthias Ringwald echo "#define UART_SPEED $UART_SPEED" >> btstack_config.h 1743edc84c5SMatthias Ringwaldfi 175af204097SMatthias Ringwaldif test ! -z "$BTSTACK_LINK_KEY_DB_INSTANCE" ; then 176af204097SMatthias Ringwald echo "#define BTSTACK_LINK_KEY_DB_INSTANCE $BTSTACK_LINK_KEY_DB_INSTANCE" >> btstack_config.h 177af204097SMatthias Ringwaldfi 178af204097SMatthias Ringwaldif test ! -z "$BTSTACK_DEVICE_NAME_DB_INSTANCE" ; then 179af204097SMatthias Ringwald echo "#define BTSTACK_DEVICE_NAME_DB_INSTANCE $BTSTACK_DEVICE_NAME_DB_INSTANCE" >> btstack_config.h 1803edc84c5SMatthias Ringwaldfi 1813edc84c5SMatthias Ringwald 1827907f069SMatthias Ringwaldecho >> btstack_config.h 1837907f069SMatthias Ringwaldecho "#endif" >> btstack_config.h 1843edc84c5SMatthias Ringwald 1853edc84c5SMatthias RingwaldAC_SUBST(HAVE_LIBUSB) 1863edc84c5SMatthias RingwaldAC_SUBST(REMOTE_DEVICE_DB_SOURCES) 1873edc84c5SMatthias RingwaldAC_SUBST(USB_SOURCES) 188528a4a3bSMatthias RingwaldAC_SUBST(btstack_run_loop_SOURCES) 1893edc84c5SMatthias RingwaldAC_SUBST(CFLAGS) 1903edc84c5SMatthias RingwaldAC_SUBST(CPPFLAGS) 1913edc84c5SMatthias RingwaldAC_SUBST(BTSTACK_LIB_LDFLAGS) 1923edc84c5SMatthias RingwaldAC_SUBST(BTSTACK_LIB_EXTENSION) 1933edc84c5SMatthias RingwaldAC_SUBST(LIBUSB_CFLAGS) 1943edc84c5SMatthias RingwaldAC_SUBST(LIBUSB_LDFLAGS) 1953edc84c5SMatthias RingwaldAC_OUTPUT(Makefile src/Makefile example/Makefile) 196