1
#  Copyright (c) 2009 Nokia Corporation
2
#  All rights reserved.
3
# 
4
#  Redistribution and use in source and binary forms, with or without
5
#  modification, are permitted provided that the following conditions are
6
#  met:
7
# 
8
#  * Redistributions of source code must retain the above copyright
9
#    notice, this list of conditions and the following disclaimer.
10
#  * Redistributions in binary form must reproduce the above copyright
11
#    notice, this list of conditions and the following disclaimer in the
12
#    documentation and/or other materials provided with the distribution.
13
#  * Neither the name of the Nokia Corporation nor the names of its
14
#    contributors may be used to endorse or promote products derived from
15
#    this software without specific prior written permission.
16
# 
17
#  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
18
#  IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
19
#  TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
20
#  PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
21
#  OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
22
#  EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
23
#  PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
24
#  PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
25
#  LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
26
#  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
27
#  SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28
#
29
# Author(s): 
30
31
AC_INIT([libnota-l-in],[3.0-2009.51],[http://notaworld.org])
32
AC_CONFIG_HEADERS([config.h])
33
34
AC_CONFIG_SRCDIR(l_in_up/l_if.c)
35
AC_CONFIG_MACRO_DIR([platform/m4])
36
37
AM_INIT_AUTOMAKE([dist-bzip2])
38
39
if test x$prefix = xNONE; then
40
   prefix=/usr/local
41
fi
42
AC_SUBST(prefix)
43
44
# libtool versioning
45
# REVISION gets incremented for non-ABI/API-break changes
46
# CURRENT/AGE get incremented for API/ABI-breaks; REVISION goes back to 0 
47
LTVERSION_REVISION=0
48
LTVERSION_CURRENT=3
49
LTVERSION_AGE=3
50
LIBL_IN_LTVERSION=${LTVERSION_CURRENT}:${LTVERSION_REVISION}:${LTVERSION_AGE}
51
AC_SUBST([LIBL_IN_LTVERSION])
52
53
# libtool release, some number we can decide
54
LIBL_IN_RELEASE=3:0:0
55
AC_SUBST([LIBL_IN_RELEASE])
56
57
AC_PROG_CC
58
AM_PROG_CC_STDC
59
AM_PROG_CC_C_O
60
AC_HEADER_STDC
61
AC_PROG_LIBTOOL
62
63
# require pkg-config
64
AC_PATH_PROG([PKG_CONFIG], [pkg-config], [no]) 
65
if test "x$PKG_CONFIG" = "xno"; then
66
   AC_MSG_ERROR([
67
   *** The pkg-config script could not be found. Make sure it is
68
   *** in your path, or set the PKG_CONFIG environment variable
69
   *** to the full path to pkg-config.]) 
70
fi
71
72
73
74
# Option to enable plugin support
75
AC_ARG_ENABLE(plugins,
76
              [AC_HELP_STRING([--enable-plugins],[Plugin support (default=no)])],
77
              [with_plugins=yes], [with_plugins=no])
78
if test "x$with_plugins" == "xyes" ; then
79
   AC_CHECK_HEADERS([dlfcn.h],,[AC_MSG_ERROR([--enable plugins requires dlfcn.h])])
80
   AC_DEFINE(NOTA_ENABLE_L_IN_PLUGINS,[1],[whether we allow l_in plugins])	
81
fi
82
83
AC_ARG_ENABLE(multi-reference-l_in_up,
84
              [AC_HELP_STRING([--enable-multi-reference-l_in_up],[Multiple l_inup (default=no)])],
85
              [with_multireflup=yes], [with_multireflup=no])
86
if test "x$with_multireflup" == "xyes" ; then
87
  L_MULTI_L_UP="-DNOTA_MULTIPLE_L_IN_UP"
88
  AC_SUBST(L_MULTI_L_UP)
89
else
90
  L_MULTI_L_UP=""
91
fi
92
93
94
AC_CHECK_HEADERS(assert.h)
95
96
dnl determine the transport; tcp is the default
97
dnl TODO: make 'dummy' the default for Cygwin?
98
dnl modules bt,usb are currently not working.
99
AC_MSG_CHECKING([what transports to build])
100
echo ""
101
AC_ARG_WITH(transports,AC_HELP_STRING(
102
  [--with-transports=<list>  compile tranport modules in <list>; 
103
                            modules must be comma-separated; 'all' will      
104
                            compile all modules; 'none' will compile 
105
                            none. Available working transport modules are: 
106
                            tcp|tcp_ip|fifo|usb|bt|bt_rfcomm|test|simple|dummy. Default is 'tcp']),
107
  transports="$withval",transports="tcp")
108
109
dnl when we selected 'all'...
110
dnl FIXME: for now, tcp/fifo will work together, but adding
111
dnl test fails. thus, 'all' mean tcp,fifo now
112
if test "x$transports" = "xall"; then
113
   transports="tcp,fifo,usb,bt,simple,dummy,single,example,tcp_ip,bt_rfcomm"
114
fi 
115
116
dnl or 'none'
117
if test "x$transports" = "xnone"; then
118
   transports=
119
fi
120
121
static_ip="none"
122
123
NOTA_TRANSPORT_MODULE_PREFIX="ld_"
124
SELECTED_TRANSPORTS=`echo $transports | sed 's/,/ /g'`
125
for transport in ${SELECTED_TRANSPORTS}; do
126
127
    NOTA_TRANSPORTS="${transport} ${NOTA_TRANSPORTS}"
128
129
    # magic
130
    module="${NOTA_TRANSPORT_MODULE_PREFIX}${transport}"
131
    NOTA_TRANSPORT_MODULES="${NOTA_TRANSPORT_MODULES} ${module}"
132
133
    # more magic    
134
    module_lib="../${module}/lib${module}.la"
135
    NOTA_TRANSPORT_LIBS="${NOTA_TRANSPORT_LIBS} $module_lib"    
136
137
    # is this transport even supported?
138
    if test ! -e ${module}/Makefile.am ; then 
139
       AC_MSG_ERROR(transport ${transport} is not supported)  
140
    fi
141
142
    if test "x$transport" == "xtest"; then
143
	AC_MSG_ERROR([transport $transport is not supported])
144
    fi 
145
  
146
    if test "x$transport" == "xtcp"; then
147
       have_tcp="yes"
148
149
       AC_MSG_CHECKING([if using static ip for tcp])
150
       echo ""
151
       AC_ARG_WITH(static_ip,AC_HELP_STRING(
152
       [--with-static_ip=ipaddress  ip where lmanager is found;]),
153
       static_ip="$withval",static_ip="none")
154
155
       if test "x$static_ip" == "xnone"; then
156
       	  LD_TCP_STATIC_IP=""
157
       else
158
          LD_TCP_STATIC_IP="-DLD_TCP_STATIC_IP -DLMANAGER_STATIC_IP=\\\"$static_ip\\\""
159
          AC_SUBST(LD_TCP_STATIC_IP)
160
       fi
161
    fi
162
    
163
    dnl building new TCP_IP transport
164
    if test "x$transport" == "xtcp_ip"; then
165
    	LD_TCP_IP_NO_UDP="-DLD_TCP_IP_NO_UDP"
166
    	AC_SUBST(LD_TCP_IP_NO_UDP)
167
    	
168
    	AC_MSG_CHECKING([if using static ip for tcp])
169
        echo ""
170
        AC_ARG_WITH(static_ip,AC_HELP_STRING(
171
        [--with-static_ip=ipaddress  ip where lmanager is found;]),
172
        static_ip="$withval",static_ip="none")
173
		
174
		if test "x$static_ip" == "xnone"; then
175
       	  LD_TCP_STATIC_IP=""
176
        else
177
          LD_TCP_STATIC_IP="-DLD_TCP_STATIC_IP -DLMANAGER_STATIC_IP=\\\"$static_ip\\\""
178
          AC_SUBST(LD_TCP_STATIC_IP)
179
        fi
180
	else
181
		LD_TCP_IP_NO_UDP=""		    	
182
    fi
183
   
184
    if test "x$transport" == "xbt"; then
185
       have_bt="yes"
186
    elif test "x$transport" == "xbt_rfcomm"; then
187
       have_bt="yes"
188
    else
189
       have_bt="no"
190
    fi
191
 
192
    dnl check for bluetooth; in debian/ubuntu, package is 'libbluetooth-dev'
193
    if test "x$have_bt" == "xyes"; then
194
       PKG_CHECK_MODULES(NOTA_BLUEZ,bluez,,
195
	AC_MSG_ERROR([Bluez not found; 
196
	please install libbluetooth-dev (Ubuntu/Debian)]))
197
       AC_SUBST(NOTA_BLUEZ_LIBS)
198
       AC_SUBST(NOTA_BLUEZ_CFLAGS)
199
    fi
200
201
202
    dnl check for usb; in debian/ubuntu, package is 'libusb-dev'
203
    if test "x$transport" == "xusb"; then
204
205
      #
206
	  # Enable branch coverage
207
	AC_ARG_ENABLE(gadget_fs,
208
		              [AC_HELP_STRING([--enable-gadget_fs],[enable gadget_fs support for usb clients)])],
209
		              [with_gadget_fs=yes], [with_gadget_fs=no])
210
	if test "x$with_gadget_fs" == "xyes" ; then
211
		NOTA_USB_DEVICE_GADGET_FS="-DUSB_DEVICE_GADGET_FS"
212
		AC_SUBST(NOTA_USB_DEVICE_GADGET_FS)
213
	else
214
215
		# we need a linux kernel header; it's name has changed 
216
		# with newer kernels (since 2.6.21)
217
		AC_MSG_CHECKING([USB kernel headers])
218
		if test -e "/usr/include/linux/usb_ch9.h"; then
219
			AC_DEFINE_UNQUOTED(NOTA_LINUX_KERNEL_BEFORE_2_6_21,1,
220
				["Whether we a linux kernel older than 2.6.21"])
221
			echo "found (old kernel)"
222
		elif test -e /usr/include/linux/usb/ch9.h; then
223
			echo "found"         	           		   	   
224
		else    
225
			AC_MSG_ERROR([usb linux kernel header not found;
226
			please install linux-headers (Ubuntu/Debian)])
227
		fi	
228
		         
229
		PKG_CHECK_MODULES(NOTA_LIBUSB,libusb,,
230
		AC_MSG_ERROR([libusb not found; 
231
		please install libusb-dev (Ubuntu/Debian)]))
232
		AC_SUBST(NOTA_LIBUSB_LIBS)
233
		AC_SUBST(NOTA_LIBUSB_CFLAGS)
234
	fi
235
    fi 
236
done
237
238
AM_CONDITIONAL(NOTA_HAVE_TCP,test "x$have_tcp" == "xyes")
239
			
240
AC_SUBST(NOTA_TRANSPORTS)
241
AC_SUBST(NOTA_TRANSPORT_MODULES)
242
AC_SUBST(NOTA_TRANSPORT_LIBS)
243
244
245
dnl what kind of threadlib to use?
246
ACX_PTHREAD
247
LIBS="$PTHREAD_LIBS $LIBS"
248
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
249
CC="$PTHREAD_CC"
250
251
dnl do we need -lrt?
252
AC_CHECK_LIB(rt,clock_gettime,[have_rtclock=yes],[have_rtclock=no])
253
AS_IF([test "x$have_rtclock" = "xyes"],[
254
	    LIBS="$LIBS -lrt"
255
	    ],[
256
dnl presumably, *BSD don't need (or have) -lr for get_clocktime; FIXME: verify this
257
       AC_CHECK_FUNC(clock_gettime)])
258
259
dnl do we need -ldl?
260
AC_CHECK_LIB(dl,dlopen,[have_dl=yes],[have_dl=no])
261
AS_IF([test "x$have_dl" = "xyes"],[
262
	    LIBS="$LIBS -ldl"
263
	    ],[
264
dnl presumably, *BSD don't need (or have) -ldl; FIXME: verify this
265
       AC_CHECK_FUNC(dlopen)])
266
267
       
268
AC_ARG_WITH(platform, [AC_HELP_STRING([--with-platform],
269
	[platform to build for: posix, symbian32, t-kernel])],
270
[case "${with_platform}" in
271
      posix)      NOTA_PLATFORM=${with_platform};;
272
      symbian32)  NOTA_PLATFORM=${with_platform};;
273
      t-kernel)   NOTA_PLATFORM=${with_platform};;
274
      *)          AC_MSG_ERROR([unsupported platform]);;
275
 esac], [NOTA_PLATFORM=posix])
276
NOTA_PLATFORM_DIR=${top_srcdir}/platform/${NOTA_PLATFORM}
277
AC_SUBST(NOTA_PLATFORM_DIR)
278
AC_SUBST(NOTA_PLATFORM)
279
280
# endianness -- 
281
# note, we can use AC_C_BIGENDIAN, but we also allow overriding it,
282
# as it won't work when cross-compiling.
283
AC_ARG_WITH(endianness,	[AC_HELP_STRING([--with-endianness],
284
	[endianness to use: big or little])],
285
[case "${with_endianness}" in
286
      big|small)  NOTA_ENDIANNESS=${with_endianness};;
287
      *)              AC_MSG_ERROR([unsupported endianness]);;
288
 esac], [AC_C_BIGENDIAN([NOTA_ENDIANNESS=big],[NOTA_ENDIANNESS=little])])
289
	
290
AC_SUBST(NOTA_ENDIANNESS)
291
292
# define some stuff, easier in Makefile.am...
293
AM_CONDITIONAL(NOTA_BIG_ENDIAN,[test "x$NOTA_ENDIANNESS" == "xbig"])
294
AM_CONDITIONAL(NOTA_LITTLE_ENDIAN,[test "x$NOTA_ENDIANNESS" == "xlittle"])
295
296
# FIXME: make an easy -D for posix.c, so we don't need source changes
297
# yet; this should be handled with config.h instead
298
if test "x$NOTA_ENDIANNESS" == "xbig"; then
299
   ENDIAN_FLAGS="-DBIG_ENDIAN_MACHINE"
300
else
301
   ENDIAN_FLAGS="-DLITTLE_ENDIAN_MACHINE"
302
fi
303
AC_SUBST(ENDIAN_FLAGS)
304
305
306
307
308
# fatal warnings or not?
309
AC_ARG_ENABLE(fatal-warnings,
310
              [AC_HELP_STRING([--disable-fatal-warnings],[whether to abort when on error conditions])],
311
              [disable_fatal_warnings=yes], [disable_fatal_warnings=no])
312
AS_IF([test "x$disable_fatal_warnings" == "xyes"],[
313
  AC_DEFINE_UNQUOTED(NOTA_DISABLE_FATAL_WARNINGS,[1],[whether we abort on errors or not])])
314
315
  
316
#
317
# Enable branch coverage
318
AC_ARG_ENABLE(coverage,
319
              [AC_HELP_STRING([--enable-coverage],[enable measuring brachcoverage on H_IN core files using gcov, (requires static linking on singleprocess, with targets software linked with -fprofile-arcs to have gcov runtime support)])],
320
              [with_coverage=yes], [with_coverage=no])
321
if test "x$with_coverage" == "xyes" ; then
322
  CFLAGS="-g -O0 -ftest-coverage -fprofile-arcs -static"
323
  NOTA_COVERAGE_FLAGS="-DNOTA_H_IN_BRANCH_COVERAGE"
324
  AC_SUBST(NOTA_COVERAGE_FLAGS)
325
fi
326
327
328
329
# 
330
# Disable NOTA_INLINE 
331
AC_ARG_ENABLE(l_in_inline,
332
              [AC_HELP_STRING([--disable-l_in_inline],[disable forced inline function usage in L_IN])],
333
              [disable_inline=yes])
334
if test "x$disable_inline" == "xyes" ; then
335
  L_IN_DISABLE_NOTA_INLINE="-DDISABLE_INLINE_OPTIMIZATION"
336
  AC_SUBST(L_IN_DISABLE_NOTA_INLINE)
337
else
338
  L_IN_DISABLE_NOTA_INLINE=""
339
  NOTA_FLAGS=`echo $CFLAGS | tr -d "-"` 
340
  for flag in ${NOTA_FLAGS}; do
341
     if test "x$flag" == "xO0"; then
342
        dnl disabling NOTA_INLINE as no optimizations are expected
343
        L_IN_DISABLE_NOTA_INLINE="-DDISABLE_INLINE_OPTIMIZATION"
344
        AC_SUBST(L_IN_DISABLE_NOTA_INLINE)
345
     fi
346
  done
347
fi
348
349
350
AC_OUTPUT([
351
Makefile
352
platform/Makefile
353
platform/posix/Makefile
354
platform/symbian32/Makefile
355
platform/t-kernel/Makefile
356
platform/m4/Makefile
357
ld_common/Makefile
358
ld_common/posix/Makefile
359
ld_common/symbian32/Makefile
360
ld_common/t-kernel/Makefile
361
l_in_up/Makefile
362
man/Makefile
363
inc/Makefile
364
inc/l_in/Makefile
365
ld_tcp/Makefile
366
ld_tcp_ip/Makefile
367
ld_fifo/Makefile
368
ld_dummy/Makefile
369
ld_simple/Makefile
370
ld_tester/Makefile
371
ld_perf/Makefile
372
ld_usb/Makefile
373
ld_bt/Makefile
374
ld_bt_rfcomm/Makefile
375
ld_single/Makefile
376
ld_example/Makefile
377
nota-l_in-3.0.pc])
378
379
380
echo
381
echo "L_IN configure results"
382
echo "---------------------------------------"
383
echo "Transport (Ldown)       : $NOTA_TRANSPORTS"
384
if test "x$static_ip" == "xnone"; then
385
echo -n ""
386
else
387
echo "TCP static ip           : $static_ip"
388
fi
389
echo "Transport libs          : $NOTA_TRANSPORT_LIBS"
390
echo "Platform                : $NOTA_PLATFORM"
391
echo "Build / Target          : ${build} / ${target}"
392
echo "Endianness              : $NOTA_ENDIANNESS"
393
echo "Disable fatal warnings  : ${disable_fatal_warnings}"
394
echo "Plugin support          : ${with_plugins}"
395
echo "Multiple ref l_up       : ${with_multireflup}"
396
echo "Branch coverage         : ${with_coverage}"
397
echo "NOTA_INLINE             : ${L_IN_DISABLE_NOTA_INLINE}"
398
echo ""
399
echo "Prefix                  : ${prefix}"
400
echo ""
401
echo "Now, run 'make' to compile l_in"