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