altos: Update quaternion tests to check vectors_to_rotation
[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 AC_INIT([altos], 1.2.9.3)
22 AC_CONFIG_SRCDIR([src/core/ao.h])
23 AM_INIT_AUTOMAKE([foreign dist-bzip2])
24 AM_MAINTAINER_MODE
25
26 VERSION_DASH=`echo $VERSION | sed 's/\./-/g'`
27 AC_SUBST(VERSION_DASH)
28
29
30 dnl ==========================================================================
31 dnl Java library versions
32
33 ALTOSUILIB_VERSION=1
34 ALTOSLIB_VERSION=2
35
36 AC_SUBST(ALTOSLIB_VERSION)
37 AC_DEFINE(ALTOSLIB_VERSION,$ALTOSLIB_VERSION,[Version of the AltosLib package])
38 AC_SUBST(ALTOSUILIB_VERSION)
39 AC_DEFINE(ALTOSUILIB_VERSION,$ALTOSUILIB_VERSION,[Version of the AltosUILib package])
40
41 dnl ==========================================================================
42
43 AM_CONFIG_HEADER(config.h)
44
45 AC_ARG_WITH(freetts, AS_HELP_STRING([--with-freetts=PATH],
46         [Set freetts class path (default /usr/share/java)]),
47         [FREETTS=$withval], [FREETTS=/usr/share/java])
48
49 AC_SUBST(FREETTS)
50
51 AC_ARG_WITH(jfreechart, AS_HELP_STRING([--with-jfreechart=PATH],
52         [Set jfreechart class path (default /usr/share/java)]),
53         [JFREECHART=$withval], [JFREECHART=/usr/share/java])
54
55 AC_SUBST(JFREECHART)
56
57 AC_ARG_WITH(jcommon, AS_HELP_STRING([--with-jcommon=PATH],
58         [Set jcommon class path (default /usr/share/java)]),
59         [JCOMMON=$withval], [JCOMMON=/usr/share/java])
60
61 AC_SUBST(JCOMMON)
62
63 AC_ARG_WITH(jvm, AS_HELP_STRING([--with-jvm-include=PATH],
64         [Set jvm include path for jni builds (default searches in /usr/lib/jvm)]),
65         [JVM_INCLUDE=$withval], [JVM_INCLUDE=auto])
66
67 if test "x$JVM_INCLUDE" = "xauto"; then
68         AC_MSG_CHECKING([JVM include files])
69         for jvm in default-java java-6-openjdk java-6-sun; do
70                 if test "x$JVM_INCLUDE" = "xauto"; then
71                         INCLUDE="/usr/lib/jvm/$jvm/include"
72                         if test -f "$INCLUDE"/jni.h; then
73                                 JVM_INCLUDE="$INCLUDE"
74                         fi
75                 fi
76         done
77         if test "x$JVM_INCLUDE" = "xauto"; then
78                 AC_MSG_ERROR([no JVM include files found])
79         fi
80         AC_MSG_RESULT([$JVM_INCLUDE])
81 fi
82
83 AC_SUBST(JVM_INCLUDE)
84
85 AC_ARG_WITH(android, AS_HELP_STRING([--with-android=PATH],
86         [Set android SDK path (default searches in a variety of places)]),
87         [ANDROID_SDK=$withval], [ANDROID_SDK=${ANDROID_SDK:-auto}])
88
89 if test "x$ANDROID_SDK" = "xauto"; then
90         AC_MSG_CHECKING([Android SDK])
91         for sdk in ../android/android-sdk-linux ../android/android-sdk ../android-sdk ../android-sdk-linux $HOME/android; do
92                 if test "x$ANDROID_SDK" = "xauto"; then
93                         SDK="$sdk"
94                         if test -f "$SDK/SDK Readme.txt"; then
95                                 ANDROID_SDK=`readlink -m "$SDK"`
96                         fi
97                 fi
98         done
99         if test "x$ANDROID_SDK" = "xauto"; then
100                 AC_MSG_NOTICE([no Android SDK found])
101                 ANDROID_SDK=no
102         fi
103         AC_MSG_RESULT([$ANDROID_SDK])
104 fi
105 if test "x$ANDROID_SDK" != "xno"; then
106         AC_MSG_CHECKING([Android SDK version])
107         SDK_VERSION=`grep -i '^Pkg.Revision=' $ANDROID_SDK/tools/source.properties | cut -f2- -d= | sed s/^r//`
108         SDK_MAJOR_VERSION="`echo $SDK_VERSION | sed 's/[[^0-9]].*//'`"
109         if test "$SDK_MAJOR_VERSION" -lt 17 ; then
110                 AC_MSG_NOTICE([SDK version $SDK_VERSION is too old. Need >= r17])
111                 ANDROID_SDK=no
112         else
113                 AC_MSG_RESULT([$SDK_VERSION])
114         fi
115 fi
116 if test "x$ANDROID_SDK" != "xno"; then
117         AC_MSG_CHECKING([Android SDK API Level])
118         if test -f "$ANDROID_SDK/platforms/android-10/source.properties"; then
119                 API_LEVEL=`sed -ne 's/^AndroidVersion.ApiLevel=//p' $ANDROID_SDK/platforms/android-10/source.properties`
120                 if test "$API_LEVEL" = "10"; then
121                         AC_MSG_RESULT([$API_LEVEL])
122                 else
123                         AC_MSG_NOTICE([API Level 10 not installed correctly.])
124                         ANDROID_SDK=no
125                 fi
126         else
127                 AC_MSG_NOTICE([API Level 10 not installed, but is required.])
128                 ANDROID_SDK=no
129         fi
130 fi
131 if test "x$ANDROID_SDK" != "xno"; then
132         AC_MSG_CHECKING([Android SDK required extras])
133         if test -f "$ANDROID_SDK/extras/android/support/source.properties"; then
134                 ANDROID_SUPPORT_LIB_NAME=`sed -ne 's/^Extra.NameDisplay=//p' $ANDROID_SDK/extras/android/support/source.properties`
135                 if test -f "$ANDROID_SDK/extras/google/google_play_services/source.properties"; then
136                         GOOGLE_PLAY_SERVICES_NAME=`sed -ne 's/^Extra.NameDisplay=//p' $ANDROID_SDK/extras/google/google_play_services/source.properties`
137                         AC_MSG_RESULT([$ANDROID_SUPPORT_LIB_NAME, $GOOGLE_PLAY_SERVICES_NAME])
138                 else
139                         AC_MSG_NOTICE([Google Play Services library not installed.])
140                         ANDROID_SDK=no
141                 fi
142         else
143                 AC_MSG_NOTICE([Android Support Library not installed.])
144                 ANDROID_SDK=no
145         fi
146 fi
147
148 if test "x$ANDROID_SDK" != "xno"; then
149         HAVE_ANDROID_SDK="yes"
150 else
151         HAVE_ANDROID_SDK="no"
152 fi
153
154 AM_CONDITIONAL([ANDROID], [test x$ANDROID_SDK != xno])
155
156 AC_SUBST(ANDROID_SDK)
157
158 AC_ARG_WITH(fat-dir, AS_HELP_STRING([--with-fat-dir=PATH],
159             [Set the directory to install the 'fat' distribution files to (defaults to not installing)]),
160             [FATDIR=$withval], [FATDIR=none])
161
162 AM_CONDITIONAL(FATINSTALL, [test "x$FATDIR" != "xnone"])
163
164 AC_SUBST(FATDIR)
165
166 AC_PROG_CC
167 AC_PROG_INSTALL
168 AC_PROG_LN_S
169 AC_PROG_LIBTOOL
170 PKG_PROG_PKG_CONFIG
171
172 CFLAGS="-g"
173 WARN_CFLAGS=""
174 if test "x$GCC" = "xyes"; then
175         WARN_CFLAGS="-Wall -Wpointer-arith -Wstrict-prototypes \
176         -Wmissing-prototypes -Wmissing-declarations \
177         -Wnested-externs -fno-strict-aliasing"
178         AC_DEFINE_UNQUOTED(HAVE_WARNING_CPP_DIRECTIVE,1,
179         [Can use #warning in C files])
180 fi
181 AC_SUBST(WARN_CFLAGS)
182
183 #
184 # Configure SDCC
185 #
186
187 AC_ARG_WITH([sdcc],
188             [AS_HELP_STRING([--with-sdcc],
189                             [Name of SDCC])],
190             [],
191             [with_sdcc=auto])
192
193 if test "x$with_sdcc" != "xno"; then        
194         if test "x$with_sdcc" = "xauto"; then
195                 with_sdcc="sdcc"
196                 AC_CHECK_PROG([HAVE_SDCC],[$with_sdcc], yes, no)
197         else
198                 HAVE_SDCC=yes
199         fi
200 else
201         HAVE_SDCC=no
202 fi
203
204 if test "x$HAVE_SDCC" = "xno"; then
205         AC_MSG_WARN([SDCC not found, cc1111 binaries will not be built])
206 else
207         SDCC=$with_sdcc
208 fi
209
210 AC_SUBST(SDCC)
211 AC_SUBST(HAVE_SDCC)
212
213 #
214 # Configure ARM compiler for STM32L and LPC11U14
215 #
216
217 AC_ARG_WITH([arm-cc],
218             [AS_HELP_STRING([--with-arm-cc],
219                             [Name of ARM C compiler])],
220             [],
221             [with_arm_cc=auto])
222
223 if test "x$with_arm_cc" != "xno"; then      
224         if test "x$with_arm_cc" = "xauto"; then
225                 with_arm_cc="arm-none-eabi-gcc"
226                 AC_CHECK_PROG([HAVE_ARM_CC],[$with_arm_cc], yes, no)
227         else
228                 HAVE_ARM_CC=yes
229         fi
230 else
231         HAVE_ARM_CC=no
232 fi
233
234 if test "x$HAVE_ARM_CC" = "xno"; then
235         AC_MSG_WARN([Arm compiler not found, ARM binaries will not be built])
236 else
237         ARM_CC=$with_arm_cc
238 fi
239 AC_SUBST(HAVE_ARM_CC)
240 AC_SUBST(ARM_CC)
241
242 if test "x$HAVE_ARM_CC" = "xyes"; then
243         save_CC="$CC"
244         save_CFLAGS="$CFLAGS"
245         save_LIBS="$LIBS"
246         CC="$ARM_CC"
247         CFLAGS="-mthumb -mcpu=cortex-m0"
248         LIBS="-ffreestanding -nostdlib"
249         AC_LANG_PUSH([C])
250
251         AC_MSG_CHECKING([if ]$ARM_CC[ supports cortex-m0])
252         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([int i;])],
253                           [HAVE_ARM_M0_CC=yes],
254                           [HAVE_ARM_M0_CC=no])
255         AC_MSG_RESULT([$HAVE_ARM_M0_CC])
256
257         AC_CHECK_LIB(pdclib-cortex-m0,memcpy,
258                      [],
259                      [HAVE_ARM_M0_CC=no])
260
261         CFLAGS="-mthumb -mcpu=cortex-m3"
262         AC_MSG_CHECKING([if ]$ARM_CC[ supports cortex-m3])
263         AC_COMPILE_IFELSE([AC_LANG_PROGRAM([int i;])],
264                           [HAVE_ARM_M3_CC=yes],
265                           [HAVE_ARM_M3_CC=no])
266         AC_MSG_RESULT([$HAVE_ARM_M3_CC])
267
268         AC_CHECK_LIB(pdclib-cortex-m3,memcpy,
269                      [],
270                      [HAVE_ARM_M3_CC=no])
271
272         AC_LANG_POP([C])
273         LIBS="$save_LIBS"
274         CFLAGS="$save_CFLAGS"
275         CC="$save_CC"
276 else
277         HAVE_ARM_M3_CC=no
278         HAVE_ARM_M0_CC=no
279 fi
280 AC_SUBST(HAVE_ARM_M3_CC)
281 AC_SUBST(HAVE_ARM_M0_CC)
282         
283 if test "x$HAVE_ARM_M3_CC" = "xno"; then
284         AC_MSG_WARN([No cortex-m3 arm compiler found, STM32L binaries will not be built])
285 fi
286
287 if test "x$HAVE_ARM_M0_CC" = "xno"; then
288         AC_MSG_WARN([No cortex-m0 arm compiler found, LPC11U14 binaries will not be built])
289 fi
290
291 #
292 # Configure AVR compiler
293 #
294
295 AC_ARG_WITH([avr-cc],
296             [AS_HELP_STRING([--with-avr-cc],
297                             [Name of AVR C compiler])],
298             [],
299             [with_avr_cc=auto])
300
301 if test "x$with_avr_cc" != "xno"; then      
302         if test "x$with_avr_cc" = "xauto"; then
303                 with_avr_cc="avr-gcc"
304                 AC_CHECK_PROG([HAVE_AVR_CC],[$with_avr_cc], yes, no)
305         else
306                 HAVE_AVR_CC=yes
307         fi
308 else
309         HAVE_AVR_CC=no
310 fi
311
312 AC_ARG_WITH([avr-objcopy],
313             [AS_HELP_STRING([--with-avr-objcopy],
314                             [Name of AVR objcopy])],
315             [],
316             [with_avr_objcopy=auto])
317
318 if test "x$with_avr_objcopy" != "xno"; then         
319         if test "x$with_avr_objcopy" = "xauto"; then
320                 with_avr_objcopy="avr-objcopy"
321                 AC_CHECK_PROG([HAVE_AVR_OBJCOPY],[$with_avr_objcopy], yes, no)
322         else
323                 HAVE_AVR_OBJCOPY=yes
324         fi
325 else
326         HAVE_AVR_OBJCOPY=no
327 fi
328
329 if test "x$HAVE_AVR_CC" = "xno" -o "x$HAVE_AVR_OBJCOPY" = "xno"; then
330         AC_MSG_WARN([AVR compiler and objcopy not found, atmel binaries will not be built])
331         HAVE_AVR_CC=no
332 else
333         save_CC="$CC"
334         save_CFLAGS="$CFLAGS"
335         save_LIBS="$LIBS"
336
337         CC="$with_avr_cc"
338         CFLAGS="-mmcu=attiny85"
339         AC_LANG_PUSH([C])
340         AC_MSG_CHECKING([if ]$with_avr_cc[ can link programs])
341         AC_LINK_IFELSE([AC_LANG_PROGRAM([])],
342                           [AVR_LINK=yes],
343                           [AVR_LINK=no])
344         AC_MSG_RESULT([$AVR_LINK])
345         AC_LANG_POP([C])
346
347         LIBS="$save_LIBS"
348         CFLAGS="$save_CFLAGS"
349         CC="$save_CC"
350
351         if test "x$AVR_LINK" = xyes; then
352                 AVR_CC=$with_avr_cc
353                 AVR_OBJCOPY=$with_avr_objcopy
354         else
355                 HAVE_AVR_CC=no;
356         fi
357 fi
358
359 AC_SUBST(AVR_CC)
360 AC_SUBST(AVR_OBJCOPY)
361 AC_SUBST(HAVE_AVR_CC)
362
363 AC_CHECK_PROG([HAVE_NICKLE], [nickle], yes, no)
364 if test "x$HAVE_NICKLE" = "xno"; then
365         AC_MSG_ERROR([Please install nickle to build AltOs])
366 fi
367
368 AC_CHECK_LIB(readline, readline)
369
370 PKG_CHECK_MODULES([LIBUSB], [libusb-1.0])
371
372 AC_CHECK_HEADERS(libelf.h libelf/libelf.h, [break])
373 AC_CHECK_HEADERS(gelf.h libelf/gelf.h, [break])
374
375 PKG_CHECK_MODULES([LIBSTLINK], [stlink], [HAVE_STLINK=yes], [HAVE_STLINK=no])
376
377 AM_CONDITIONAL([LIBSTLINK], [test x$HAVE_STLINK != xno])
378
379 AC_OUTPUT([
380 Makefile
381 src/Makedefs
382 altoslib/Makefile
383 altosuilib/Makefile
384 altosuilib/AltosUIVersion.java
385 altosui/Makefile
386 altosui/Info.plist
387 altosui/altos-windows.nsi
388 libaltos/Makefile
389 micropeak/Makefile
390 micropeak/Info.plist
391 micropeak/micropeak-windows.nsi
392 altosdroid/Makefile
393 altosdroid/local.properties
394 ao-tools/Makefile
395 ao-tools/lib/Makefile
396 ao-tools/ao-rawload/Makefile
397 ao-tools/ao-dbg/Makefile
398 ao-tools/ao-bitbang/Makefile
399 ao-tools/ao-eeprom/Makefile
400 ao-tools/ao-list/Makefile
401 ao-tools/ao-load/Makefile
402 ao-tools/ao-telem/Makefile
403 ao-tools/ao-stmload/Makefile
404 ao-tools/ao-send-telem/Makefile
405 ao-tools/ao-sky-flash/Makefile
406 ao-tools/ao-dumpflash/Makefile
407 ao-tools/ao-edit-telem/Makefile
408 ao-tools/ao-dump-up/Makefile
409 ao-utils/Makefile
410 src/Version
411 ])
412
413 echo ""
414 echo "  Package: ${PACKAGE_NAME} ${PACKAGE_VERSION}"
415 echo ""
416 echo "  Configuration"
417 echo "    Arm compiler................: ${ARM_CC}"
418 echo "    STM32L support..............: ${HAVE_ARM_M3_CC}"
419 echo "    LPC11U14 support............: ${HAVE_ARM_M0_CC}"
420 echo "    SDCC........................: ${SDCC}"
421 echo "    CC1111 support..............: ${HAVE_SDCC}"
422 echo "    AVR compiler................: ${AVR_CC} ${AVR_OBJCOPY}"
423 echo "    AVR support.................: ${HAVE_AVR_CC}"
424 echo "    Android support.............: ${HAVE_ANDROID_SDK}"
425 echo "    STlink support..............: ${HAVE_STLINK}"
426 echo ""
427 echo "  Java paths"
428 echo "    freetts.....................: ${FREETTS}"
429 echo "    jfreechart..................: ${JFREECHART}"
430 echo "    jcommon.....................: ${JCOMMON}"
431 echo "    JVM include.................: ${JVM_INCLUDE}"
432 if test x${ANDROID_SDK} != "xno"; then
433 echo ""
434 echo "  Android path"
435 echo "    Android SDK.................: ${ANDROID_SDK}"
436 fi
437 echo ""