Merge branch 'branch-1.3' into debian
[fw/altos] / configure.ac
1 dnl
2 dnl  Copyright © 2008,2009 Keith Packard <keithp@keithp.com>
3 dnl
4 dnl  This program is free software; you can redistribute it and/or modify
5 dnl  it under the terms of the GNU General Public License as published by
6 dnl  the Free Software Foundation; either version 2 of the License, or
7 dnl  (at your option) any later version.
8 dnl
9 dnl  This program is distributed in the hope that it will be useful, but
10 dnl  WITHOUT ANY WARRANTY; without even the implied warranty of
11 dnl  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 dnl  General Public License for more details.
13 dnl
14 dnl  You should have received a copy of the GNU General Public License along
15 dnl  with this program; if not, write to the Free Software Foundation, Inc.,
16 dnl  59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
17 dnl
18 dnl Process this file with autoconf to create configure.
19
20 AC_PREREQ(2.57)
21 <<<<<<< HEAD
22 AC_INIT([altos], 1.2.1)
23 =======
24 AC_INIT([altos], 1.3)
25 >>>>>>> branch-1.3
26 AC_CONFIG_SRCDIR([src/core/ao.h])
27 AM_INIT_AUTOMAKE([foreign dist-bzip2])
28 AM_MAINTAINER_MODE
29
30 VERSION_DASH=`echo $VERSION | sed 's/\./-/g'`
31 AC_SUBST(VERSION_DASH)
32
33 dnl ==========================================================================
34 dnl Java library versions
35
36 ALTOSUILIB_VERSION=1
37 ALTOSLIB_VERSION=2
38
39 AC_SUBST(ALTOSLIB_VERSION)
40 AC_DEFINE(ALTOSLIB_VERSION,$ALTOSLIB_VERSION,[Version of the AltosLib package])
41 AC_SUBST(ALTOSUILIB_VERSION)
42 AC_DEFINE(ALTOSUILIB_VERSION,$ALTOSUILIB_VERSION,[Version of the AltosUILib package])
43
44 dnl ==========================================================================
45
46 AM_CONFIG_HEADER(config.h)
47
48 AC_ARG_WITH(freetts, AS_HELP_STRING([--with-freetts=PATH],
49         [Set freetts class path (default /usr/share/java)]),
50         [FREETTS=$withval], [FREETTS=/usr/share/java])
51
52 AC_SUBST(FREETTS)
53
54 AC_ARG_WITH(jfreechart, AS_HELP_STRING([--with-jfreechart=PATH],
55         [Set jfreechart class path (default /usr/share/java)]),
56         [JFREECHART=$withval], [JFREECHART=/usr/share/java])
57
58 AC_SUBST(JFREECHART)
59
60 AC_ARG_WITH(jcommon, AS_HELP_STRING([--with-jcommon=PATH],
61         [Set jcommon class path (default /usr/share/java)]),
62         [JCOMMON=$withval], [JCOMMON=/usr/share/java])
63
64 AC_SUBST(JCOMMON)
65
66 AC_ARG_WITH(jvm, AS_HELP_STRING([--with-jvm-include=PATH],
67         [Set jvm include path for jni builds (default searches in /usr/lib/jvm)]),
68         [JVM_INCLUDE=$withval], [JVM_INCLUDE=auto])
69
70 if test "x$JVM_INCLUDE" = "xauto"; then
71         AC_MSG_CHECKING([JVM include files])
72         for jvm in default-java java-6-openjdk java-6-sun; do
73                 if test "x$JVM_INCLUDE" = "xauto"; then
74                         INCLUDE="/usr/lib/jvm/$jvm/include"
75                         if test -f "$INCLUDE"/jni.h; then
76                                 JVM_INCLUDE="$INCLUDE"
77                         fi
78                 fi
79         done
80         if test "x$JVM_INCLUDE" = "xauto"; then
81                 AC_MSG_ERROR([no JVM include files found])
82         fi
83         AC_MSG_RESULT([$JVM_INCLUDE])
84 fi
85
86 AC_SUBST(JVM_INCLUDE)
87
88 AC_ARG_WITH(android, AS_HELP_STRING([--with-android=PATH],
89         [Set android SDK path (default searches in a variety of places)]),
90         [ANDROID_SDK=$withval], [ANDROID_SDK=${ANDROID_SDK:-auto}])
91
92 if test "x$ANDROID_SDK" = "xauto"; then
93         AC_MSG_CHECKING([Android SDK])
94         for sdk in ../android/android-sdk-linux ../android/android-sdk ../android-sdk ../android-sdk-linux $HOME/android; do
95                 if test "x$ANDROID_SDK" = "xauto"; then
96                         SDK="$sdk"
97                         if test -f "$SDK/SDK Readme.txt"; then
98                                 ANDROID_SDK=`readlink -m "$SDK"`
99                         fi
100                 fi
101         done
102         if test "x$ANDROID_SDK" = "xauto"; then
103                 AC_MSG_NOTICE([no Android SDK found])
104                 ANDROID_SDK=no
105         fi
106         AC_MSG_RESULT([$ANDROID_SDK])
107 fi
108 if test "x$ANDROID_SDK" != "xno"; then
109         AC_MSG_CHECKING([Android SDK version])
110         SDK_VERSION=`grep -i '^Pkg.Revision=' $ANDROID_SDK/tools/source.properties | cut -f2- -d= | sed s/^r//`
111         SDK_MAJOR_VERSION="`echo $SDK_VERSION | sed 's/[[^0-9]].*//'`"
112         if test "$SDK_MAJOR_VERSION" -lt 17 ; then
113                 AC_MSG_NOTICE([SDK version $SDK_VERSION is too old. Need >= r17])
114                 ANDROID_SDK=no
115         else
116                 AC_MSG_RESULT([$SDK_VERSION])
117         fi
118 fi
119 if test "x$ANDROID_SDK" != "xno"; then
120         AC_MSG_CHECKING([Android SDK API Level])
121         if test -f "$ANDROID_SDK/platforms/android-10/source.properties"; then
122                 API_LEVEL=`sed -ne 's/^AndroidVersion.ApiLevel=//p' $ANDROID_SDK/platforms/android-10/source.properties`
123                 if test "$API_LEVEL" = "10"; then
124                         AC_MSG_RESULT([$API_LEVEL])
125                 else
126                         AC_MSG_NOTICE([API Level 10 not installed correctly.])
127                         ANDROID_SDK=no
128                 fi
129         else
130                 AC_MSG_NOTICE([API Level 10 not installed, but is required.])
131                 ANDROID_SDK=no
132         fi
133 fi
134 if test "x$ANDROID_SDK" != "xno"; then
135         AC_MSG_CHECKING([Android SDK required extras])
136         if test -f "$ANDROID_SDK/extras/android/support/source.properties"; then
137                 ANDROID_SUPPORT_LIB_NAME=`sed -ne 's/^Extra.NameDisplay=//p' $ANDROID_SDK/extras/android/support/source.properties`
138                 if test -f "$ANDROID_SDK/extras/google/google_play_services/source.properties"; then
139                         GOOGLE_PLAY_SERVICES_NAME=`sed -ne 's/^Extra.NameDisplay=//p' $ANDROID_SDK/extras/google/google_play_services/source.properties`
140                         AC_MSG_RESULT([$ANDROID_SUPPORT_LIB_NAME, $GOOGLE_PLAY_SERVICES_NAME])
141                 else
142                         AC_MSG_NOTICE([Google Play Services library not installed.])
143                         ANDROID_SDK=no
144                 fi
145         else
146                 AC_MSG_NOTICE([Android Support Library not installed.])
147                 ANDROID_SDK=no
148         fi
149 fi
150
151 if test "x$ANDROID_SDK" != "xno"; then
152         HAVE_ANDROID_SDK="yes"
153 else
154         HAVE_ANDROID_SDK="no"
155 fi
156
157 AM_CONDITIONAL([ANDROID], [test x$ANDROID_SDK != xno])
158
159 AC_SUBST(ANDROID_SDK)
160
161 AC_ARG_WITH(fat-dir, AS_HELP_STRING([--with-fat-dir=PATH],
162             [Set the directory to install the 'fat' distribution files to (defaults to not installing)]),
163             [FATDIR=$withval], [FATDIR=none])
164
165 AM_CONDITIONAL(FATINSTALL, [test "x$FATDIR" != "xnone"])
166
167 AC_SUBST(FATDIR)
168
169 AC_PROG_CC
170 AC_PROG_INSTALL
171 AC_PROG_LN_S
172 AC_PROG_LIBTOOL
173 PKG_PROG_PKG_CONFIG
174
175 CFLAGS="-g"
176 WARN_CFLAGS=""
177 if test "x$GCC" = "xyes"; then
178         WARN_CFLAGS="-Wall -Wpointer-arith -Wstrict-prototypes \
179         -Wmissing-prototypes -Wmissing-declarations \
180         -Wnested-externs -fno-strict-aliasing"
181         AC_DEFINE_UNQUOTED(HAVE_WARNING_CPP_DIRECTIVE,1,
182         [Can use #warning in C files])
183 fi
184 AC_SUBST(WARN_CFLAGS)
185
186 #
187 # Configure SDCC
188 #
189
190 AC_ARG_WITH([sdcc],
191             [AS_HELP_STRING([--with-sdcc],
192                             [Name of SDCC])],
193             [],
194             [with_sdcc=auto])
195
196 if test "x$with_sdcc" != "xno"; then        
197         if test "x$with_sdcc" = "xauto"; then
198                 with_sdcc="sdcc"
199                 AC_CHECK_PROG([HAVE_SDCC],[$with_sdcc], yes, no)
200         else
201                 HAVE_SDCC=yes
202         fi
203 else
204         HAVE_SDCC=no
205 fi
206
207 if test "x$HAVE_SDCC" = "xno"; then
208         AC_MSG_WARN([SDCC not found, cc1111 binaries will not be built])
209 else
210         SDCC=$with_sdcc
211 fi
212
213 AC_SUBST(SDCC)
214 AC_SUBST(HAVE_SDCC)
215
216 #
217 # Configure ARM compiler for STM32L and LPC11U14
218 #
219
220 AC_ARG_WITH([arm-cc],
221             [AS_HELP_STRING([--with-arm-cc],
222                             [Name of ARM C compiler])],
223             [],
224             [with_arm_cc=auto])
225
226 if test "x$with_arm_cc" != "xno"; then      
227         if test "x$with_arm_cc" = "xauto"; then
228                 with_arm_cc="arm-none-eabi-gcc"
229                 AC_CHECK_PROG([HAVE_ARM_CC],[$with_arm_cc], yes, no)
230         else
231                 HAVE_ARM_CC=yes
232         fi
233 else
234         HAVE_ARM_CC=no
235 fi
236
237 if test "x$HAVE_ARM_CC" = "xno"; then
238         AC_MSG_WARN([Arm compiler not found, ARM binaries will not be built])
239 else
240         ARM_CC=$with_arm_cc
241 fi
242 AC_SUBST(HAVE_ARM_CC)
243 AC_SUBST(ARM_CC)
244
245 if test -d pdclib -a x"$HAVE_ARM_CC" = xyes; then
246         PDCLIB_ROOT='$(TOPDIR)/../pdclib-root'
247         PDCLIB_INCLUDES='-I$(TOPDIR)/../pdclib-root/include'
248         PDCLIB_LIBS_M0='-L$(TOPDIR)/../pdclib-root/lib -lpdclib-cortex-m0'
249         PDCLIB_LIBS_M3='-L$(TOPDIR)/../pdclib-root/lib -lpdclib-cortex-m3'
250         HAVE_PDCLIB=yes
251 else
252         PDCLIB_INCLUDES=''
253         PDCLIB_LIBS_M0='-lpdclib-cortex-m0'
254         PDCLIB_LIBS_M3='-lpdclib-cortex-m3'
255         HAVE_PDCLIB=no
256 fi
257
258 AM_CONDITIONAL(PDCLIB, [test x$HAVE_PDCLIB = xyes])
259
260 AC_SUBST(PDCLIB_INCLUDES)
261 AC_SUBST(PDCLIB_LIBS_M0)
262 AC_SUBST(PDCLIB_LIBS_M3)
263 AC_SUBST(PDCLIB_ROOT)
264 AC_SUBST(HAVE_PDCLIB)
265
266 if test "x$HAVE_ARM_CC" = "xyes"; then
267         save_CC="$CC"
268         save_CFLAGS="$CFLAGS"
269         save_LIBS="$LIBS"
270         CC="$ARM_CC"
271         CFLAGS="-mthumb -mcpu=cortex-m0"
272         LIBS="-ffreestanding -nostdlib"
273         AC_LANG_PUSH([C])
274
275         AC_MSG_CHECKING([if ]$ARM_CC[ supports cortex-m0])
276         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([int i;])],
277                           [HAVE_ARM_M0_CC=yes],
278                           [HAVE_ARM_M0_CC=no])
279         AC_MSG_RESULT([$HAVE_ARM_M0_CC])
280
281         CFLAGS="-mthumb -mcpu=cortex-m3"
282         AC_MSG_CHECKING([if ]$ARM_CC[ supports cortex-m3])
283         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([int i;])],
284                           [HAVE_ARM_M3_CC=yes],
285                           [HAVE_ARM_M3_CC=no])
286         AC_MSG_RESULT([$HAVE_ARM_M3_CC])
287
288         if test x$HAVE_PDCLIB != xyes; then
289                 AC_CHECK_LIB(pdclib-cortex-m0,memcpy,
290                              [],
291                              [HAVE_ARM_M0_CC=no])
292
293                 AC_CHECK_LIB(pdclib-cortex-m3,memcpy,
294                              [],
295                              [HAVE_ARM_M3_CC=no])
296         fi
297
298         AC_LANG_POP([C])
299         LIBS="$save_LIBS"
300         CFLAGS="$save_CFLAGS"
301         CC="$save_CC"
302 else
303         HAVE_ARM_M3_CC=no
304         HAVE_ARM_M0_CC=no
305 fi
306 AC_SUBST(HAVE_ARM_M3_CC)
307 AC_SUBST(HAVE_ARM_M0_CC)
308         
309 if test "x$HAVE_ARM_M3_CC" = "xno"; then
310         AC_MSG_WARN([No cortex-m3 arm compiler found, STM32L binaries will not be built])
311 fi
312
313 if test "x$HAVE_ARM_M0_CC" = "xno"; then
314         AC_MSG_WARN([No cortex-m0 arm compiler found, LPC11U14 binaries will not be built])
315 fi
316
317 #
318 # Configure AVR compiler
319 #
320
321 AC_ARG_WITH([avr-cc],
322             [AS_HELP_STRING([--with-avr-cc],
323                             [Name of AVR C compiler])],
324             [],
325             [with_avr_cc=auto])
326
327 if test "x$with_avr_cc" != "xno"; then      
328         if test "x$with_avr_cc" = "xauto"; then
329                 with_avr_cc="avr-gcc"
330                 AC_CHECK_PROG([HAVE_AVR_CC],[$with_avr_cc], yes, no)
331         else
332                 HAVE_AVR_CC=yes
333         fi
334 else
335         HAVE_AVR_CC=no
336 fi
337
338 AC_ARG_WITH([avr-objcopy],
339             [AS_HELP_STRING([--with-avr-objcopy],
340                             [Name of AVR objcopy])],
341             [],
342             [with_avr_objcopy=auto])
343
344 if test "x$with_avr_objcopy" != "xno"; then         
345         if test "x$with_avr_objcopy" = "xauto"; then
346                 with_avr_objcopy="avr-objcopy"
347                 AC_CHECK_PROG([HAVE_AVR_OBJCOPY],[$with_avr_objcopy], yes, no)
348         else
349                 HAVE_AVR_OBJCOPY=yes
350         fi
351 else
352         HAVE_AVR_OBJCOPY=no
353 fi
354
355 if test "x$HAVE_AVR_CC" = "xno" -o "x$HAVE_AVR_OBJCOPY" = "xno"; then
356         AC_MSG_WARN([AVR compiler and objcopy not found, atmel binaries will not be built])
357         HAVE_AVR_CC=no
358 else
359         save_CC="$CC"
360         save_CFLAGS="$CFLAGS"
361         save_LIBS="$LIBS"
362
363         CC="$with_avr_cc"
364         CFLAGS="-mmcu=attiny85"
365         AC_LANG_PUSH([C])
366         AC_MSG_CHECKING([if ]$with_avr_cc[ can link programs])
367         AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
368                           [AVR_LINK=yes],
369                           [AVR_LINK=no])
370         AC_MSG_RESULT([$AVR_LINK])
371         AC_LANG_POP([C])
372
373         LIBS="$save_LIBS"
374         CFLAGS="$save_CFLAGS"
375         CC="$save_CC"
376
377         if test "x$AVR_LINK" = xyes; then
378                 AVR_CC=$with_avr_cc
379                 AVR_OBJCOPY=$with_avr_objcopy
380         else
381                 HAVE_AVR_CC=no;
382         fi
383 fi
384
385 AC_SUBST(AVR_CC)
386 AC_SUBST(AVR_OBJCOPY)
387 AC_SUBST(HAVE_AVR_CC)
388
389 AC_CHECK_PROG([HAVE_NICKLE], [nickle], yes, no)
390 if test "x$HAVE_NICKLE" = "xno"; then
391         AC_MSG_ERROR([Please install nickle to build AltOs])
392 fi
393
394 AC_ARG_WITH([readline],
395             [AS_HELP_STRING([--with-readline],
396                               [enable readline functionality in ao-dbg @<:@default=auto@:>@])],
397               [],
398               [with_readline=auto])
399                               
400 LIBREADLINE_LIBS=
401
402 if test x"$with_readline" != "xno"; then
403         AC_CHECK_LIB([readline], [main],
404                       [AC_SUBST([LIBREADLINE], ["-lreadline -lncurses"])
405                        AC_DEFINE([HAVE_LIBREADLINE], [1],
406                          [Define if you have libreadline])],
407                       [if test "x$with_readline" != xauto; then
408                          AC_MSG_ERROR([--with-readline was given, but test for readline failed])
409                        fi],
410                        -lncurses)
411 fi
412
413 PKG_CHECK_MODULES([LIBUSB], [libusb-1.0])
414
415 AC_CHECK_HEADERS(libelf.h libelf/libelf.h, [break])
416 AC_CHECK_HEADERS(gelf.h libelf/gelf.h, [break])
417
418 AC_ARG_WITH([stlink],
419             [AS_HELP_STRING([--with-stlink],
420                             [Build tools that use the stlink library (default: auto)])],
421             [],
422             [with_stlink=auto])
423
424 if test x"$with_stlink" != "xno"; then
425         PKG_CHECK_MODULES([STLINK], [stlink], [HAVE_STLINK=yes], [HAVE_STLINK=no])
426         if test x"$HAVE_STLINK" = "xno" -a x"$with_stlink" != "xauto"; then
427                 AC_MSG_ERROR([--with-stlink was given, but stlink was not found])
428         fi
429 else
430         HAVE_STLINK=no
431 fi
432
433 if test x"$HAVE_STLINK" = "xyes"; then
434         AC_DEFINE(HAVE_STLINK,1,[Using STlink library])
435 fi
436
437 AM_CONDITIONAL([LIBSTLINK], [test x$HAVE_STLINK == xyes])
438
439 AC_OUTPUT([
440 Makefile
441 src/Makedefs
442 altoslib/Makefile
443 altosuilib/Makefile
444 altosuilib/AltosUIVersion.java
445 altosui/Makefile
446 altosui/Info.plist
447 altosui/altos-windows.nsi
448 libaltos/Makefile
449 micropeak/Makefile
450 micropeak/Info.plist
451 micropeak/micropeak-windows.nsi
452 altosdroid/Makefile
453 altosdroid/local.properties
454 ao-tools/Makefile
455 ao-tools/lib/Makefile
456 ao-tools/ao-rawload/Makefile
457 ao-tools/ao-dbg/Makefile
458 ao-tools/ao-bitbang/Makefile
459 ao-tools/ao-eeprom/Makefile
460 ao-tools/ao-list/Makefile
461 ao-tools/ao-load/Makefile
462 ao-tools/ao-telem/Makefile
463 ao-tools/ao-stmload/Makefile
464 ao-tools/ao-send-telem/Makefile
465 ao-tools/ao-sky-flash/Makefile
466 ao-tools/ao-dumpflash/Makefile
467 ao-tools/ao-edit-telem/Makefile
468 ao-tools/ao-dump-up/Makefile
469 ao-tools/ao-elftohex/Makefile
470 ao-tools/ao-usbload/Makefile
471 ao-tools/ao-flash/Makefile
472 ao-utils/Makefile
473 src/Version
474 ])
475
476 echo ""
477 echo "  Package: ${PACKAGE_NAME} ${PACKAGE_VERSION}"
478 echo ""
479 echo "  Configuration"
480 echo "    Arm compiler................: ${ARM_CC}"
481 echo "    STM32L support..............: ${HAVE_ARM_M3_CC}"
482 echo "    LPC11U14 support............: ${HAVE_ARM_M0_CC}"
483 echo "    SDCC........................: ${SDCC}"
484 echo "    CC1111 support..............: ${HAVE_SDCC}"
485 echo "    AVR compiler................: ${AVR_CC} ${AVR_OBJCOPY}"
486 echo "    AVR support.................: ${HAVE_AVR_CC}"
487 echo "    Android support.............: ${HAVE_ANDROID_SDK}"
488 echo "    STlink support..............: ${HAVE_STLINK}"
489 echo "    Local pdclib................: ${HAVE_PDCLIB}"
490 echo ""
491 echo "  Java paths"
492 echo "    freetts.....................: ${FREETTS}"
493 echo "    jfreechart..................: ${JFREECHART}"
494 echo "    jcommon.....................: ${JCOMMON}"
495 echo "    JVM include.................: ${JVM_INCLUDE}"
496 if test x${ANDROID_SDK} != "xno"; then
497 echo ""
498 echo "  Android path"
499 echo "    Android SDK.................: ${ANDROID_SDK}"
500 fi
501 echo ""