xref: /btstack/port/daemon/configure.ac (revision 4fd8b166ac64edfb0a9e51d94b4dfe091a84946b)
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(powermanagement, [AS_HELP_STRING([--disable-powermanagement],[Disable powermanagement])], USE_POWERMANAGEMENT=$enableval, USE_POWERMANAGEMENT="yes")
133edc84c5SMatthias RingwaldAC_ARG_ENABLE(launchd, [AS_HELP_STRING([--enable-launchd],[Compiles BTdaemon for use by launchd])], USE_LAUNCHD=$enableval, USE_LAUNCHD="no")
143edc84c5SMatthias 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")
153edc84c5SMatthias 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")
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
313edc84c5SMatthias Ringwald    echo "Cross-compiling for iPhone/iPod touch uses theos"
323edc84c5SMatthias Ringwald    ./config-iphone.sh
333edc84c5SMatthias Ringwald    exit 0
343edc84c5SMatthias Ringwaldfi
353edc84c5SMatthias Ringwald
363edc84c5SMatthias Ringwald# use capitals for transport type
373edc84c5SMatthias Ringwaldif test "x$HCI_TRANSPORT" = xusb; then
383edc84c5SMatthias Ringwald    HCI_TRANSPORT="USB"
393edc84c5SMatthias Ringwaldfi
403edc84c5SMatthias Ringwaldif test "x$HCI_TRANSPORT" = xh4; then
413edc84c5SMatthias Ringwald    HCI_TRANSPORT="H4"
423edc84c5SMatthias Ringwaldfi
433edc84c5SMatthias Ringwald
443edc84c5SMatthias Ringwald# validate USB support
453edc84c5SMatthias Ringwaldif test "x$HCI_TRANSPORT" = xUSB; then
463edc84c5SMatthias Ringwald    # pkg-config needed
473edc84c5SMatthias Ringwald    PKG_PROG_PKG_CONFIG
483edc84c5SMatthias Ringwald    # libusb installed?
493edc84c5SMatthias Ringwald    PKG_CHECK_MODULES([LIBUSB], [libusb-1.0], HAVE_LIBUSB="yes", HAVE_LIBUSB="no")
503edc84c5SMatthias Ringwald    if test "$HAVE_LIBUSB" == "no" ; then
513edc84c5SMatthias 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/)
523edc84c5SMatthias Ringwald    fi
533edc84c5SMatthias Ringwald    LIBUSB_LDFLAGS=$LIBUSB_LIBS
543edc84c5SMatthias Ringwaldfi
553edc84c5SMatthias RingwaldAM_CONDITIONAL(HAVE_LIBUSB, [test "x$HAVE_LIBUSB" == "xyes"])
563edc84c5SMatthias Ringwald
573edc84c5SMatthias Ringwaldecho
583edc84c5SMatthias Ringwaldecho "BTstack configured for HCI $HCI_TRANSPORT Transport"
593edc84c5SMatthias Ringwald
603edc84c5SMatthias RingwaldHAVE_SO_NOSIGPIPE="no"
613edc84c5SMatthias Ringwald
62528a4a3bSMatthias Ringwaldbtstack_run_loop_SOURCES="btstack_run_loop_posix.c"
633edc84c5SMatthias Ringwaldcase "$host_os" in
643edc84c5SMatthias Ringwald    darwin*)
65528a4a3bSMatthias Ringwald        btstack_run_loop_SOURCES="$btstack_run_loop_SOURCES btstack_run_loop_cocoa.m"
663edc84c5SMatthias Ringwald        LDFLAGS="$LDFLAGS -framework CoreFoundation -framework Foundation"
673edc84c5SMatthias Ringwald        BTSTACK_LIB_LDFLAGS="-dynamiclib -install_name \$(prefix)/lib/libBTstack.dylib"
683edc84c5SMatthias Ringwald        BTSTACK_LIB_EXTENSION="dylib"
697e300a85SMatthias Ringwald        REMOTE_DEVICE_DB_SOURCES="remote_device_db_cocoa.m rfcomm_service_db_cocoa.m"
703edc84c5SMatthias Ringwald        REMOTE_DEVICE_DB="remote_device_db_iphone"
713edc84c5SMatthias Ringwald        HAVE_SO_NOSIGPIPE="yes";
723edc84c5SMatthias Ringwald        ;;
733edc84c5SMatthias Ringwald    mingw*)
743edc84c5SMatthias Ringwald        echo "Building on mingw32"
753edc84c5SMatthias Ringwald        LDFLAGS="$LDFLAGS -lws2_32"
763edc84c5SMatthias Ringwald        BTSTACK_LIB_LDFLAGS="-shared"
773edc84c5SMatthias Ringwald        BTSTACK_LIB_EXTENSION="dll"
787e300a85SMatthias Ringwald        REMOTE_DEVICE_DB_SOURCES="remote_device_db_memory.c rfcomm_service_db_memory.c"
793edc84c5SMatthias Ringwald        REMOTE_DEVICE_DB="remote_device_db_memory"
803edc84c5SMatthias Ringwald        ;;
813edc84c5SMatthias Ringwald    *)
823edc84c5SMatthias Ringwald        BTSTACK_LIB_LDFLAGS="-shared -Wl,-rpath,\$(prefix)/lib"
833edc84c5SMatthias Ringwald        BTSTACK_LIB_EXTENSION="so"
847e300a85SMatthias Ringwald        REMOTE_DEVICE_DB_SOURCES="remote_device_db_memory.c rfcomm_service_db_memory.c"
853edc84c5SMatthias Ringwald        REMOTE_DEVICE_DB="remote_device_db_memory"
863edc84c5SMatthias Ringwald    ;;
873edc84c5SMatthias Ringwaldesac
883edc84c5SMatthias Ringwald
893edc84c5SMatthias Ringwald# treat warnings seriously
903edc84c5SMatthias RingwaldCFLAGS="$CFLAGS -Werror -Wall -Wpointer-arith"
913edc84c5SMatthias Ringwald
923edc84c5SMatthias Ringwald# 64-bit compilation requires position independent code (PIC) for libraries
933edc84c5SMatthias RingwaldBTSTACK_LIB_LDFLAGS+=" -fpic"
943edc84c5SMatthias Ringwald
953edc84c5SMatthias RingwaldAM_CONDITIONAL(USE_POWERMANAGEMENT, [test "x$USE_POWERMANAGEMENT" == "xyes"])
963edc84c5SMatthias Ringwald
973edc84c5SMatthias Ringwald# summary
983edc84c5SMatthias Ringwald
993edc84c5SMatthias Ringwaldecho "CC:                  $CC"
1003edc84c5SMatthias Ringwaldecho "CFLAGS:              $CFLAGS"
1013edc84c5SMatthias Ringwaldecho "LDFLAGS:             $LDFLAGS"
1023edc84c5SMatthias Ringwaldecho "BTSTACK_LIB_LDFLAGS: $BTSTACK_LIB_LDFLAGS"
1033edc84c5SMatthias Ringwald
1043edc84c5SMatthias Ringwaldif test "x$HCI_TRANSPORT" = xUSB; then
1053edc84c5SMatthias Ringwald    echo "USB_PRODUCT_ID:      $USB_PRODUCT_ID"
1063edc84c5SMatthias Ringwald    echo "USB_VENDOR_ID:       $USB_VENDOR_ID"
1073edc84c5SMatthias Ringwald    echo "LIBUSB_CFLAGS:       $LIBUSB_CFLAGS"
1083edc84c5SMatthias Ringwald    echo "LIBUSB_LDFLAGS:      $LIBUSB_LDFLAGS"
1093edc84c5SMatthias Ringwaldelse
1103edc84c5SMatthias Ringwald    echo "UART_DEVICE:         $UART_DEVICE"
1113edc84c5SMatthias Ringwald    echo "UART_SPEED:          $UART_SPEED"
1123edc84c5SMatthias Ringwaldfi
1133edc84c5SMatthias Ringwald
1143edc84c5SMatthias Ringwaldecho "USE_POWERMANAGEMENT: $USE_POWERMANAGEMENT"
1153edc84c5SMatthias Ringwaldecho "REMOTE_DEVICE_DB:    $REMOTE_DEVICE_DB"
1163edc84c5SMatthias Ringwaldecho "HAVE_SO_NOSIGPIPE:   $HAVE_SO_NOSIGPIPE"
1173edc84c5SMatthias Ringwaldecho
1183edc84c5SMatthias Ringwaldecho
1193edc84c5SMatthias Ringwald
1203edc84c5SMatthias Ringwald# create btstack-config.h
1213edc84c5SMatthias Ringwaldrm -f btstack-config.h
1223edc84c5SMatthias Ringwaldecho "//"                                       >> btstack-config.h
1233edc84c5SMatthias Ringwaldecho "// btstack-config.h"                      >> btstack-config.h
1243edc84c5SMatthias Ringwaldecho "// created by configure for BTstack "     >> btstack-config.h
1253edc84c5SMatthias Ringwaldecho "//" `date`                                >> btstack-config.h
1263edc84c5SMatthias Ringwaldecho "//"                                       >> btstack-config.h
1273edc84c5SMatthias Ringwaldecho                                            >> btstack-config.h
1283edc84c5SMatthias Ringwaldecho "#ifndef __BTSTACK_CONFIG"                 >> btstack-config.h
1293edc84c5SMatthias Ringwaldecho "#define __BTSTACK_CONFIG"                 >> btstack-config.h
1303edc84c5SMatthias Ringwaldecho                                            >> btstack-config.h
131*4fd8b166SMatthias Ringwald
132*4fd8b166SMatthias Ringwaldecho "// Port related features"                 >> btstack-config.h
133*4fd8b166SMatthias Ringwaldecho "#define HAVE_TIME"                        >> btstack-config.h
134*4fd8b166SMatthias Ringwaldecho "#define HAVE_MALLOC"                      >> btstack-config.h
135*4fd8b166SMatthias Ringwaldecho "#define HAVE_BZERO"                       >> btstack-config.h
136*4fd8b166SMatthias Ringwaldif test "x$HAVE_SO_NOSIGPIPE" == xyes ; then
137*4fd8b166SMatthias Ringwald    echo "#define HAVE_SO_NOSIGPIPE"            >> btstack-config.h
138*4fd8b166SMatthias Ringwaldfi
139*4fd8b166SMatthias Ringwald
140*4fd8b166SMatthias Ringwald# todo: HAVE -> ENABLE in features below
141*4fd8b166SMatthias Ringwald
142*4fd8b166SMatthias Ringwaldecho "// BTstack features that can be enabled"  >> btstack-config.h
143*4fd8b166SMatthias Ringwaldecho "#define HAVE_BLE"                         >> btstack-config.h
144*4fd8b166SMatthias Ringwaldecho "#define ENABLE_LOG_INFO "                 >> btstack-config.h
145*4fd8b166SMatthias Ringwaldecho "#define ENABLE_LOG_ERROR"                 >> btstack-config.h
146*4fd8b166SMatthias Ringwaldecho "#define HAVE_SDP"                         >> btstack-config.h
147*4fd8b166SMatthias Ringwaldecho "#define HAVE_RFCOMM"                      >> btstack-config.h
148*4fd8b166SMatthias Ringwald
149*4fd8b166SMatthias Ringwaldecho "// BTstack configuration. buffers, sizes, .." >> btstack-config.h
150*4fd8b166SMatthias Ringwaldecho "#define HCI_ACL_PAYLOAD_SIZE 1021" >> btstack-config.h
151*4fd8b166SMatthias Ringwaldecho "#define SDP_DES_DUMP" >> btstack-config.h
152*4fd8b166SMatthias Ringwald
153*4fd8b166SMatthias Ringwald# unsorted yet
154*4fd8b166SMatthias Ringwald# todo: USE_BLUETOOL -> HAVE_BLUETOOL
155*4fd8b166SMatthias Ringwald# todo: USE_POWERMANAGEMENT -> HAVE_POWERMANAGMENT / ENABLE_POWERMANAGEMENT
156*4fd8b166SMatthias Ringwald
1573edc84c5SMatthias Ringwaldif test "x$HCI_TRANSPORT" = xUSB; then
1583edc84c5SMatthias Ringwald    USB_SOURCES=hci_transport_h2_libusb.c
1593edc84c5SMatthias Ringwald    echo "#define HAVE_TRANSPORT_USB" >> btstack-config.h
1603edc84c5SMatthias Ringwald    echo "#define USB_PRODUCT_ID $USB_PRODUCT_ID" >> btstack-config.h
1613edc84c5SMatthias Ringwald    echo "#define USB_VENDOR_ID $USB_VENDOR_ID" >> btstack-config.h
1623edc84c5SMatthias Ringwaldelse
1633edc84c5SMatthias Ringwald    echo "#define HAVE_TRANSPORT_H4" >> btstack-config.h
1643edc84c5SMatthias Ringwald    echo "#define UART_DEVICE \"$UART_DEVICE\"" >> btstack-config.h
1653edc84c5SMatthias Ringwald    echo "#define UART_SPEED $UART_SPEED" >> btstack-config.h
1663edc84c5SMatthias Ringwald    if test "x$USE_BLUETOOL" = xyes; then
1673edc84c5SMatthias Ringwald        echo "#define USE_BLUETOOL" >> btstack-config.h
1683edc84c5SMatthias Ringwald    fi
1693edc84c5SMatthias Ringwald    if test "x$USE_POWERMANAGEMENT" = xyes; then
1703edc84c5SMatthias Ringwald        echo "#define USE_POWERMANAGEMENT" >> btstack-config.h
1713edc84c5SMatthias Ringwald    fi
1723edc84c5SMatthias Ringwaldfi
173*4fd8b166SMatthias Ringwald# are those still needed?
1743edc84c5SMatthias Ringwaldif test ! -z "$REMOTE_DEVICE_DB" ; then
1753edc84c5SMatthias Ringwald    echo "#define REMOTE_DEVICE_DB $REMOTE_DEVICE_DB" >> btstack-config.h
1763edc84c5SMatthias Ringwaldfi
1773edc84c5SMatthias Ringwald
178*4fd8b166SMatthias Ringwaldecho ""                     >> btstack-config.h
1793edc84c5SMatthias Ringwaldecho "#endif"               >> btstack-config.h
1803edc84c5SMatthias Ringwald
1813edc84c5SMatthias RingwaldAC_SUBST(HAVE_LIBUSB)
1823edc84c5SMatthias RingwaldAC_SUBST(REMOTE_DEVICE_DB_SOURCES)
1833edc84c5SMatthias RingwaldAC_SUBST(USB_SOURCES)
184528a4a3bSMatthias RingwaldAC_SUBST(btstack_run_loop_SOURCES)
1853edc84c5SMatthias RingwaldAC_SUBST(CFLAGS)
1863edc84c5SMatthias RingwaldAC_SUBST(CPPFLAGS)
1873edc84c5SMatthias RingwaldAC_SUBST(BTSTACK_LIB_LDFLAGS)
1883edc84c5SMatthias RingwaldAC_SUBST(BTSTACK_LIB_EXTENSION)
1893edc84c5SMatthias RingwaldAC_SUBST(LIBUSB_CFLAGS)
1903edc84c5SMatthias RingwaldAC_SUBST(LIBUSB_LDFLAGS)
1913edc84c5SMatthias RingwaldAC_OUTPUT(Makefile src/Makefile example/Makefile)
192