* as/asx8051.dsp: corrected output directories
[fw/sdcc] / configure.in
1 #!/bin/sh
2
3 AC_PREREQ(2.54)
4 AC_INIT
5 AC_CONFIG_SRCDIR([Makefile.in])
6 AC_CONFIG_HEADER(sdccconf.h:sdccconf_in.h)
7
8 AC_PROG_AWK
9
10 AC_MSG_CHECKING(version of the package)
11 if test -f ${srcdir}/.version; then
12   VERSION=`cat ${srcdir}/.version`
13 elif test -f ../.version; then
14   VERSION=`cat ../.version`
15 else
16   VERSION="0.0.0"
17 fi
18 VERSIONHI=`echo $VERSION|$AWK 'BEGIN {FS="."} {print $1}'`
19 VERSIONLO=`echo $VERSION|$AWK 'BEGIN {FS="."} {print $2}'`
20 VERSIONP=`echo $VERSION|$AWK 'BEGIN {FS="."} {print $3}'`
21
22 AC_MSG_RESULT(${VERSION})
23 AC_SUBST(VERSION)
24 AC_SUBST(VERSIONHI)
25 AC_SUBST(VERSIONLO)
26 AC_SUBST(VERSIONP)
27 AC_DEFINE_UNQUOTED(SDCC_VERSION_LO, ${VERSIONLO})
28 AC_DEFINE_UNQUOTED(SDCC_VERSION_HI, ${VERSIONHI})
29 AC_DEFINE_UNQUOTED(SDCC_VERSION_P, ${VERSIONP})
30 AC_DEFINE_UNQUOTED(SDCC_VERSION_STR, "${VERSION}")
31 AC_ARG_PROGRAM
32 sdcc_cv_version=$VERSION
33 sdcc_cv_versionhi=$VERSIONHI
34 sdcc_cv_versionlo=$VERSIONLO
35 sdcc_cv_versionp=$VERSIONP
36
37
38 # Required programs
39 # ===========================================================================
40 AC_PROG_CC
41 AC_PROG_CPP
42 AC_PROG_INSTALL
43 AC_PROG_RANLIB
44 AC_PROG_LEX
45 AC_PROG_YACC
46 AC_CHECK_PROG(AUTOCONF, autoconf, autoconf, :)
47 AC_CHECK_PROG(STRIP, strip, strip, :)
48 AC_CHECK_PROG(AS, as, as, :)
49 AC_CHECK_PROG(CP, cp, cp, :)
50
51 AC_DEFUN(SDCC_REQUIRE_PROG,
52 [if test "$1" = ":"; then
53   AC_MSG_ERROR([Cannot find required program $2.])
54  fi
55 ])
56
57 SDCC_REQUIRE_PROG($YACC, bison)
58 SDCC_REQUIRE_PROG($LEX, lex)
59
60 AC_LANG_C
61
62
63 # Checking for functions
64 # ===========================================================================
65 AC_CHECK_FUNCS(strerror)
66 AC_CHECK_FUNCS(vsnprintf snprintf vsprintf mkstemp)
67
68
69 # Macro definitions
70 # ===========================================================================
71
72 # adl_DD_COPT macro checks if the compiler specified as the 1st parameter
73 # supports option specified as the 2nd parameter
74 # For example: DD_CPORT(CXX, fPIC)
75
76 AC_DEFUN(adl_DD_COPT, [
77 AC_CACHE_CHECK(whether $$1 accepts -$2,sdcc_cv_$1$2,
78 cat >_test_.c <<EOF
79 #include <stdio.h>
80 void main(void) {}
81 EOF
82 $$1 -v -$2 -c _test_.c 1>&5 2>&5
83 if test "$?" = "0"; then
84   sdcc_cv_$1$2="yes"
85 else
86   sdcc_cv_$1$2="no"
87 fi
88 rm -f _test_.* a.out)
89 ])
90
91 # This macro expands DIR and assigns it to RET.
92 # If DIR is NONE, then it's replaced by DEFAULT.
93 #
94 # Based on AC_DEFINE_DIR
95 #
96 # Examples:
97 #
98 #  adl_EXPAND(prefix, "/usr/local", expanded_prefix)
99
100 AC_DEFUN([adl_EXPAND], [
101   test "x$prefix" = xNONE && prefix="$ac_default_prefix"
102   test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
103   ac_expand=[$]$1
104   test "x$ac_expand" = xNONE && ac_expand="[$]$2"
105   ac_expand=`eval echo [$]ac_expand`
106   $3=`eval echo [$]ac_expand`
107 ])
108
109 # adl_NORMALIZE_PATH
110 #
111 #  - empty paths are changed to '.'
112 #  - trailing slashes are removed
113 #  - repeated slashes are squeezed except a leading doubled slash '//'
114 #    (which might indicate a networked disk on some OS).
115 #
116 #
117 # REFERENCE_STRING is used to turn '/' into '\' and vice-versa: if
118 # REFERENCE_STRING contains some backslashes, all slashes and backslashes
119 # are turned into backslashes, otherwise they are all turned into slashes.
120 #
121 # This makes processing of DOS filenames quite easier, because you can turn a
122 # filename to the Unix notation, make your processing, and turn it back to
123 # original notation.
124
125 dnl Available from the GNU Autoconf Macro Archive at:
126 dnl http://www.gnu.org/software/ac-archive/htmldoc/normpath.html
127 dnl
128 AC_DEFUN([adl_NORMALIZE_PATH],
129 [case ":[$]$1:" in
130 dnl change empty paths to '.'
131   ::) $1='.' ;;
132 dnl strip trailing slashes
133   :*[[\\/]]:) $1=`echo "[$]$1" | sed 's,[[\\/]]*[$],,'` ;;
134   :*:) ;;
135 esac
136 dnl squeze repeated slashes
137 case ifelse($2,,"[$]$1",$2) in
138 dnl if the path contains any backslashes, turn slashes into backslashes
139
140 dnl Bernhard Held 2003-04-06
141 dnl This was the original line. It does not:
142 dnl - convert the first slash
143 dnl - replace a slash with a double-backslash
144 dnl *\\*) $1=`echo "[$]$1" | sed 's,\(.\)[[\\/]][[\\/]]*,\1\\\\,g'` ;;
145     *\\*) $1=`echo "[$]$1" | sed 's,\(.\)[[\\/]][[\\/]]*,\1\\\\\\\\,g
146                                   s,^[[\\/]],\\\\\\\\,'` ;;
147
148 dnl if the path contains slashes, also turn backslashes into slashes
149  *) $1=`echo "[$]$1" | sed 's,\(.\)[[\\/]][[\\/]]*,\1/,g'` ;;
150 esac])
151
152
153 # adl_COMPUTE_RELATIVE_PATH
154 #
155 # PATH_LIST is a space-separated list of colon-separated triplets of the form
156 # 'FROM:TO:RESULT'. This function iterates over these triplets and set $RESULT
157 # to the relative path from $FROM to $TO. Note that $FROM and $TO needs to be
158 # absolute filenames for this macro to success.
159
160 AC_DEFUN([adl_COMPUTE_RELATIVE_PATHS],
161 [for _lcl_i in $1; do
162   _lcl_from=\[$]`echo "[$]_lcl_i" | sed 's,:.*$,,'`
163   _lcl_to=\[$]`echo "[$]_lcl_i" | sed 's,^[[^:]]*:,,' | sed 's,:[[^:]]*$,,'`
164   _lcl_result_var=`echo "[$]_lcl_i" | sed 's,^.*:,,'`
165   adl_RECURSIVE_EVAL([[$]_lcl_from], [_lcl_from])
166   adl_RECURSIVE_EVAL([[$]_lcl_to], [_lcl_to])
167   _lcl_notation="$_lcl_from$_lcl_to"
168   adl_NORMALIZE_PATH([_lcl_from],['/'])
169   adl_NORMALIZE_PATH([_lcl_to],['/'])
170   adl_COMPUTE_RELATIVE_PATH([_lcl_from], [_lcl_to], [_lcl_result_tmp])
171   adl_NORMALIZE_PATH([_lcl_result_tmp],["[$]_lcl_notation"])
172   eval $_lcl_result_var='[$]_lcl_result_tmp'
173 done])
174
175 ## Note:
176 ## *****
177 ## The following helper macros are too fragile to be used out
178 ## of adl_COMPUTE_RELATIVE_PATHS (mainly because they assume that
179 ## paths are normalized), that's why I'm keeping them in the same file.
180 ## Still, some of them maybe worth to reuse.
181
182 dnl adl_COMPUTE_RELATIVE_PATH(FROM, TO, RESULT)
183 dnl ===========================================
184 dnl Compute the relative path to go from $FROM to $TO and set the value
185 dnl of $RESULT to that value.  This function work on raw filenames
186 dnl (for instead it will considerate /usr//local and /usr/local as
187 dnl two distinct paths), you should really use adl_COMPUTE_REALTIVE_PATHS
188 dnl instead to have the paths sanitized automatically.
189 dnl
190 dnl For instance:
191 dnl    first_dir=/somewhere/on/my/disk/bin
192 dnl    second_dir=/somewhere/on/another/disk/share
193 dnl    adl_COMPUTE_RELATIVE_PATH(first_dir, second_dir, first_to_second)
194 dnl will set $first_to_second to '../../../another/disk/share'.
195 AC_DEFUN([adl_COMPUTE_RELATIVE_PATH],
196 [adl_COMPUTE_COMMON_PATH([$1], [$2], [_lcl_common_prefix])
197 adl_COMPUTE_BACK_PATH([$1], [_lcl_common_prefix], [_lcl_first_rel])
198 adl_COMPUTE_SUFFIX_PATH([$2], [_lcl_common_prefix], [_lcl_second_suffix])
199 $3="[$]_lcl_first_rel[$]_lcl_second_suffix"])
200
201 dnl adl_COMPUTE_COMMON_PATH(LEFT, RIGHT, RESULT)
202 dnl ============================================
203 dnl Compute the common path to $LEFT and $RIGHT and set the result to $RESULT.
204 dnl
205 dnl For instance:
206 dnl    first_path=/somewhere/on/my/disk/bin
207 dnl    second_path=/somewhere/on/another/disk/share
208 dnl    adl_COMPUTE_COMMON_PATH(first_path, second_path, common_path)
209 dnl will set $common_path to '/somewhere/on'.
210 AC_DEFUN([adl_COMPUTE_COMMON_PATH],
211 [$3=''
212 _lcl_second_prefix_match=''
213 while test "[$]_lcl_second_prefix_match" != 0; do
214   _lcl_first_prefix=`expr "x[$]$1" : "x\([$]$3/*[[^/]]*\)"`
215   _lcl_second_prefix_match=`expr "x[$]$2" : "x[$]_lcl_first_prefix"`
216   if test "[$]_lcl_second_prefix_match" != 0; then
217     if test "[$]_lcl_first_prefix" != "[$]$3"; then
218       $3="[$]_lcl_first_prefix"
219     else
220       _lcl_second_prefix_match=0
221     fi
222   fi
223 done])
224
225 dnl adl_COMPUTE_SUFFIX_PATH(PATH, SUBPATH, RESULT)
226 dnl ==============================================
227 dnl Substrack $SUBPATH from $PATH, and set the resulting suffix
228 dnl (or the empty string if $SUBPATH is not a subpath of $PATH)
229 dnl to $RESULT.
230 dnl
231 dnl For instace:
232 dnl    first_path=/somewhere/on/my/disk/bin
233 dnl    second_path=/somewhere/on
234 dnl    adl_COMPUTE_SUFFIX_PATH(first_path, second_path, common_path)
235 dnl will set $common_path to '/my/disk/bin'.
236 AC_DEFUN([adl_COMPUTE_SUFFIX_PATH],
237 [$3=`expr "x[$]$1" : "x[$]$2/*\(.*\)"`])
238
239 dnl adl_COMPUTE_BACK_PATH(PATH, SUBPATH, RESULT)
240 dnl ============================================
241 dnl Compute the relative path to go from $PATH to $SUBPATH, knowing that
242 dnl $SUBPATH is a subpath of $PATH (any other words, only repeated '../'
243 dnl should be needed to move from $PATH to $SUBPATH) and set the value
244 dnl of $RESULT to that value.  If $SUBPATH is not a subpath of PATH,
245 dnl set $RESULT to the empty string.
246 dnl
247 dnl For instance:
248 dnl    first_path=/somewhere/on/my/disk/bin
249 dnl    second_path=/somewhere/on
250 dnl    adl_COMPUTE_BACK_PATH(first_path, second_path, back_path)
251 dnl will set $back_path to '../../../'.
252 AC_DEFUN([adl_COMPUTE_BACK_PATH],
253 [adl_COMPUTE_SUFFIX_PATH([$1], [$2], [_lcl_first_suffix])
254 $3=''
255 _lcl_tmp='xxx'
256 while test "[$]_lcl_tmp" != ''; do
257   _lcl_tmp=`expr "x[$]_lcl_first_suffix" : "x[[^/]]*/*\(.*\)"`
258   if test "[$]_lcl_first_suffix" != ''; then
259      _lcl_first_suffix="[$]_lcl_tmp"
260      $3="../[$]$3"
261   fi
262 done])
263
264
265 dnl adl_RECURSIVE_EVAL(VALUE, RESULT)
266 dnl =================================
267 dnl Interpolate the VALUE in loop until it does not change,
268 dnl and set the result to $RESULT.
269 dnl WARNING: It is easy to get an infinite loop with some unsane input.
270 AC_DEFUN([adl_RECURSIVE_EVAL],
271 [_lcl_receval="$1"
272 $2=`(test "x$prefix" = xNONE && prefix="$ac_default_prefix"
273      test "x$exec_prefix" = xNONE && exec_prefix="${prefix}"
274      _lcl_receval_old=''
275      while test "[$]_lcl_receval_old" != "[$]_lcl_receval"; do
276        _lcl_receval_old="[$]_lcl_receval"
277        eval _lcl_receval="\"[$]_lcl_receval\""
278      done
279      echo "[$]_lcl_receval")`])
280
281 dnl adl_NORMALIZE_DEFINE_UNQUOTED(var, DEFINE, REFERENCE_STRING)
282 AC_DEFUN([adl_NORMALIZE_DEFINE_UNQUOTED], [
283   ac_ndu=[$]$1
284   adl_NORMALIZE_PATH([ac_ndu], [$]$3)
285   AC_DEFINE_UNQUOTED($2, "${ac_ndu}")
286 ])
287
288 dnl adl_NORMALIZE_PATH_MSG(input_string, var, dir_separator)
289 dnl ========================================================
290 dnl call adl_NORMALIZE_PATH and format it for the result message
291 AC_DEFUN([adl_NORMALIZE_PATH_MSG], [
292 dnl replace /./ by /
293 $2=`echo "$1" | sed 's,/\./,/,g'`
294 adl_NORMALIZE_PATH([$2], [$3])
295 dnl replace \\ by \
296 $2=`echo "[$]$2" | sed 's,\\\\\\\\,\\\\,g'`
297 ])
298
299
300 # Checking characteristics of compilers and other programs
301 # ===========================================================================
302 AC_CACHE_CHECK(whether preprocessor accepts -MM or -M,sdcc_cv_MM,
303 echo "#include <stdio.h>" >_test_.c
304 echo "" >>_test_.c
305 $CPP -v -MM _test_.c 1>&5 2>&5
306 if test "$?" = "0"; then
307   sdcc_cv_MM="-MM"
308 else
309   sdcc_cv_MM="-M"
310 fi
311 rm -f _test_.*)
312 M_OR_MM=$sdcc_cv_MM
313 AC_SUBST(M_OR_MM)
314
315 # This is the first time when CFLAGS are set/modified!!
316 adl_DD_COPT(CC, ggdb)
317 if test "$sdcc_cv_CCggdb" = "yes"; then
318   CFLAGS="-ggdb ${CFLAGS}"
319 fi
320
321 adl_DD_COPT(CC, pipe)
322 if test "$sdcc_cv_CCpipe" = "yes"; then
323   CFLAGS="-pipe $CFLAGS"
324 fi
325
326
327 # Checks for typedefs, structures, and compiler characteristics.
328 # ===========================================================================
329 AC_TYPE_SIGNAL
330
331 AC_CHECK_SIZEOF(char)
332 AC_CHECK_SIZEOF(short)
333 AC_CHECK_SIZEOF(int)
334 AC_CHECK_SIZEOF(long)
335 AC_C_CHAR_UNSIGNED
336
337 type_name()
338 {
339   if expr "$ac_cv_sizeof_char" '>=' "$1" >/dev/null; then
340       echo "char"
341     exit
342   fi
343   if expr "$ac_cv_sizeof_short" '>=' "$1" >/dev/null; then
344     echo "short"
345     exit
346   fi
347   if expr "$ac_cv_sizeof_int" '>=' "$1" >/dev/null; then
348     echo "int"
349     exit
350   fi
351   if expr "$ac_cv_sizeof_long" '>=' "$1" >/dev/null; then
352     echo "long"
353     exit
354   fi
355   echo "long"
356 }
357
358 AC_MSG_CHECKING(type name for byte)
359 TYPE_CHAR=`type_name 1`
360 if test "$ac_cv_c_char_unsigned" = "yes"; then
361   TYPE_BYTE="signed $TYPE_CHAR"
362 else
363   TYPE_BYTE=$TYPE_CHAR
364 fi
365 AC_MSG_RESULT($TYPE_BYTE)
366 AC_MSG_CHECKING(type name for word)
367 TYPE_WORD=`type_name 2`
368 AC_MSG_RESULT($TYPE_WORD)
369 AC_MSG_CHECKING(type name for dword)
370 TYPE_DWORD=`type_name 4`
371 AC_MSG_RESULT($TYPE_DWORD)
372
373 AC_DEFINE_UNQUOTED(TYPE_BYTE,  $TYPE_BYTE)
374 AC_DEFINE_UNQUOTED(TYPE_WORD,  $TYPE_WORD)
375 AC_DEFINE_UNQUOTED(TYPE_DWORD, $TYPE_DWORD)
376
377 AC_DEFINE_UNQUOTED(TYPE_UBYTE,  unsigned $TYPE_CHAR)
378 AC_DEFINE_UNQUOTED(TYPE_UWORD,  unsigned $TYPE_WORD)
379 AC_DEFINE_UNQUOTED(TYPE_UDWORD, unsigned $TYPE_DWORD)
380
381 AC_C_BIGENDIAN
382
383 # Set standard installation paths
384 # ===========================================================================
385
386 # In the Makefiles we need paths with '/' as directory separator, even if
387 # crosscompiling for Win32.
388 # And we want to preserve the macros (e.g. ${prefix}) in the Makefiles.
389 # The variables in the Makefiles are replaced by AC_SUBST()
390 #
391 # In sdccconf.h the '/' in paths can be replaced by "\\" (normalized), if
392 #
393 # The macros are expanded for the header.
394 # The variables in the header are replaced by AC_*DEFINE*()
395 # sdccconf_h_dir_separator contains a backslash.
396 AC_ARG_VAR(sdccconf_h_dir_separator, needed in sdccconf.h: either "/" (default) or "\\")
397 if test "x${sdccconf_h_dir_separator}" = "x"; then
398     sdccconf_h_dir_separator="/"
399 fi
400
401 # Makefiles
402 ###########
403
404 # include_dir_suffix:
405 # *nix default: "sdcc/include"
406
407 AC_ARG_VAR(include_dir_suffix, appended to datadir to define SDCC's include directory)
408 if test "${include_dir_suffix}" = ""; then
409     include_dir_suffix="sdcc/include"
410 fi
411 AC_SUBST(include_dir_suffix)
412
413 # lib_dir_suffix:
414 # *nix default: "sdcc/lib"
415 AC_ARG_VAR(lib_dir_suffix, appended to datadir to define SDCC's library root directory)
416 if test "${lib_dir_suffix}" = ""; then
417     lib_dir_suffix="sdcc/lib"
418 fi
419 AC_SUBST(lib_dir_suffix)
420
421 # docdir:
422 # *nix default: "${datadir}/sdcc/doc"
423 AC_ARG_VAR(docdir, documentation installation directory)
424 if test "${docdir}" = ""; then
425     docdir="\${datadir}"/sdcc/doc
426 fi
427 AC_SUBST(docdir)
428
429 AC_SUBST(EXEEXT)
430
431 # sdccconf.h
432 ############
433
434 AC_DEFINE_UNQUOTED(DIR_SEPARATOR_STRING, "${sdccconf_h_dir_separator}")
435 AC_DEFINE_UNQUOTED(DIR_SEPARATOR_CHAR  , '${sdccconf_h_dir_separator}')
436
437 # prefix:
438 # default: "NONE", ${ac_default_prefix}: "/usr/local"
439 adl_EXPAND(prefix, ac_default_prefix, expanded_prefix)
440 adl_NORMALIZE_DEFINE_UNQUOTED(expanded_prefix, PREFIX, sdccconf_h_dir_separator)
441
442 # exec_prefix:
443 # default: "${prefix}"
444 adl_EXPAND(exec_prefix, expanded_prefix, expanded_exec_prefix)
445 adl_NORMALIZE_DEFINE_UNQUOTED(expanded_exec_prefix, EXEC_PREFIX, sdccconf_h_dir_separator)
446
447 # bindir:
448 # default: "${exec_prefix}/bin"
449 adl_EXPAND(bindir, "NONE", expanded_bindir)
450 adl_NORMALIZE_DEFINE_UNQUOTED(expanded_bindir, BINDIR, sdccconf_h_dir_separator)
451
452 # datadir:
453 # default: "${prefix}/share"
454 adl_EXPAND(datadir, "NONE", expanded_datadir)
455 adl_NORMALIZE_DEFINE_UNQUOTED(expanded_datadir, DATADIR, sdccconf_h_dir_separator)
456
457 # include/lib suffix
458 norm_inc_dir_suffix=${include_dir_suffix}
459 adl_NORMALIZE_PATH([norm_inc_dir_suffix], [$sdccconf_h_dir_separator])
460 AC_DEFINE_UNQUOTED(INCLUDE_DIR_SUFFIX,
461                    DIR_SEPARATOR_STRING "${norm_inc_dir_suffix}")
462 norm_lib_dir_suffix=${lib_dir_suffix}
463 adl_NORMALIZE_PATH([norm_lib_dir_suffix], [$sdccconf_h_dir_separator])
464 AC_DEFINE_UNQUOTED(LIB_DIR_SUFFIX,
465                    DIR_SEPARATOR_STRING "${norm_lib_dir_suffix}")
466
467 # relative paths
468 adl_COMPUTE_RELATIVE_PATHS([expanded_bindir:expanded_datadir:bin2data_dir])
469 adl_NORMALIZE_PATH(bin2data_dir, [$sdccconf_h_dir_separator])
470 AC_DEFINE_UNQUOTED(BIN2DATA_DIR,
471                    DIR_SEPARATOR_STRING "${bin2data_dir}")
472
473 adl_COMPUTE_RELATIVE_PATHS([expanded_prefix:expanded_bindir:prefix2bin_dir])
474 adl_NORMALIZE_PATH(prefix2bin_dir, [$sdccconf_h_dir_separator])
475 AC_DEFINE_UNQUOTED(PREFIX2BIN_DIR,
476                    DIR_SEPARATOR_STRING "${prefix2bin_dir}")
477
478 adl_COMPUTE_RELATIVE_PATHS([expanded_prefix:expanded_datadir:prefix2data_dir])
479 adl_NORMALIZE_PATH(prefix2data_dir, [$sdccconf_h_dir_separator])
480 if test "${prefix2data_dir}" = "."; then
481     # small optimization for Mingw32; otherwise Borut will complain ;-)
482     AC_DEFINE_UNQUOTED(PREFIX2DATA_DIR, "")
483 else
484     AC_DEFINE_UNQUOTED(PREFIX2DATA_DIR,
485                        DIR_SEPARATOR_STRING "${prefix2data_dir}")
486 fi
487
488 # standard libs
489 AC_DEFINE_UNQUOTED(STD_LIB,       "libsdcc")
490 AC_DEFINE_UNQUOTED(STD_INT_LIB,   "libint")
491 AC_DEFINE_UNQUOTED(STD_LONG_LIB,  "liblong")
492 AC_DEFINE_UNQUOTED(STD_FP_LIB,    "libfloat")
493 AC_DEFINE_UNQUOTED(STD_DS390_LIB, "libds390")
494 AC_DEFINE_UNQUOTED(STD_DS400_LIB, "libds400")
495 AC_DEFINE_UNQUOTED(STD_XA51_LIB,  "libxa51")
496
497 # SDCC runtime environment variables
498 sdcc_dir_name="SDCC_HOME"
499 AC_DEFINE_UNQUOTED(SDCC_DIR_NAME, "${sdcc_dir_name}")
500
501 sdcc_include_name="SDCC_INCLUDE"
502 AC_DEFINE_UNQUOTED(SDCC_INCLUDE_NAME, "${sdcc_include_name}")
503
504 sdcc_lib_name="SDCC_LIB"
505 AC_DEFINE_UNQUOTED(SDCC_LIB_NAME, "${sdcc_lib_name}")
506
507 # Port selection helper
508 # ===========================================================================
509 # macro AC_DO_ENABLER()
510 #   $1 used to access enable_$1, e.g. enable-doc
511 #   $2 OPT_DISABLE_$2, normally uppercase of $1, e.g. DOC
512 #   $3 help string
513 AC_DEFUN([AC_DO_ENABLER], [
514   AC_ARG_ENABLE($1, AC_HELP_STRING([--enable-$1], $3))
515
516   if test "[$]enable_$1" = "yes"; then
517     OPT_ENABLE_$2=1
518   else
519     OPT_ENABLE_$2=0
520   fi
521
522   AC_DEFINE_UNQUOTED(OPT_ENABLE_$2, [$]OPT_ENABLE_$2)
523   AC_SUBST(OPT_ENABLE_$2)
524 ])
525
526 # macro AC_DO_DISABLER()
527 #   $1 used to access disable_$1, e.g. ucsim
528 #   $2 OPT_DISABLE_$2, normally uppercase of $1, e.g. UCSIM
529 #   $3 help string
530 AC_DEFUN([AC_DO_DISABLER], [
531   AC_ARG_ENABLE($1, AC_HELP_STRING([--disable-$1], $3))
532
533   dnl the '-' in 'device-lib' needs special handling,
534   dnl because the variable is 'enable_device_lib'
535   arg1=`echo $1 | sed s/-/_/`
536
537   if test "`eval echo \\$enable_$arg1`" = "no"; then
538     OPT_DISABLE_$2=1
539   else
540     OPT_DISABLE_$2=0
541   fi
542
543   AC_DEFINE_UNQUOTED(OPT_DISABLE_$2, [$]OPT_DISABLE_$2)
544   AC_SUBST(OPT_DISABLE_$2)
545 ])
546
547 # macro AC_DO_PORT($1, $2, $3, $4)
548 #   $1 used to access enable_$2_port, e.g. gbz80
549 #   $2 port name in ports.all and ports.build, e.g. z80
550 #   $3 OPT_DISABLE_$3, normally uppercase of $2, e.g. GBZ80
551 #   $4 help string
552 AC_DEFUN([AC_DO_PORT], [
553   AC_ARG_ENABLE($1-port,
554                 AC_HELP_STRING([--disable-$1-port], $4))
555
556   if test "[$]enable_$1_port" = "no"; then
557     OPT_DISABLE_$3=1
558   else
559     enable_$1_port="yes"
560     OPT_DISABLE_$3=0
561   fi
562
563   AC_DEFINE_UNQUOTED(OPT_DISABLE_$3, [$]OPT_DISABLE_$3)
564   AC_SUBST(OPT_DISABLE_$3)
565
566   echo $2 >>ports.all
567   if test [$]OPT_DISABLE_$3 = 0; then
568     echo $2 >>ports.build
569   fi
570 ])
571
572 # Now handle the port selection
573 # ===========================================================================
574 rm -f ports.all ports.build
575 AC_DO_PORT(mcs51, mcs51, MCS51, [Excludes the Intel mcs51 port])
576 AC_DO_PORT(gbz80, z80,   GBZ80, [Excludes the Gameboy gbz80 port])
577 AC_DO_PORT(z80,   z80,   Z80,   [Excludes the z80 port])
578 AC_DO_PORT(avr,   avr,   AVR,   [Excludes the AVR port])
579 AC_DO_PORT(ds390, ds390, DS390, [Excludes the DS390 port])
580 AC_DEFINE_UNQUOTED(OPT_DISABLE_TININative, $OPT_DISABLE_DS390)
581 AC_DO_PORT(ds400, ds400, DS400, [Excludes the DS400 port])
582 AC_DO_PORT(pic,   pic,   PIC,   [Excludes the PIC port])
583 AC_DO_PORT(pic16, pic16, PIC16, [Excludes the PIC16 port])
584 AC_DO_PORT(xa51,  xa51,  XA51,  [Excludes the XA51 port])
585 AC_DO_PORT(hc08,  hc08,  HC08,  [Excludes the HC08 port])
586
587 AC_DO_DISABLER(ucsim,      UCSIM,      [Disables configuring and building of ucsim])
588 AC_DO_DISABLER(device-lib, DEVICE_LIB, [Disables building device libraries])
589 AC_DO_DISABLER(packihx,    PACKIHX,    [Disables building packihx])
590 AC_DO_DISABLER(sdcpp,      SDCPP,      [Disables building sdcpp])
591 AC_DO_DISABLER(sdcdb,      SDCDB,      [Disables building sdcdb])
592
593 AC_DO_ENABLER(doc,   DOC,   [Enables building the documentation])
594 if test $OPT_ENABLE_DOC = 1; then
595   AC_CHECK_PROG(LYX,        lyx,        lyx, :)
596   AC_CHECK_PROG(LATEX2HTML, latex2html, latex2html, :)
597   AC_CHECK_PROG(PDFLATEX,   pdflatex,   pdflatex, :)
598   AC_CHECK_PROG(PDFOPT,     pdfopt,     pdfopt, :)
599   AC_CHECK_PROG(MAKEINDEX,  makeindex,  makeindex, :)
600
601   SDCC_REQUIRE_PROG($LYX,        lyx)
602   SDCC_REQUIRE_PROG($LATEX2HTML, latex2html)
603   SDCC_REQUIRE_PROG($PDFLATEX,   pdflatex)
604   SDCC_REQUIRE_PROG($PDFOPT,     pdfopt)
605   SDCC_REQUIRE_PROG($MAKEINDEX,  makeindex)
606 fi
607
608 AC_DO_ENABLER(libgc, LIBGC, [Use the Bohem memory allocator. Lower runtime footprint.])
609 if test $OPT_ENABLE_LIBGC = 1; then
610   AC_CHECK_LIB(gc, GC_malloc)
611   if test $ac_cv_lib_gc_GC_malloc = no; then
612     AC_MSG_ERROR([Cannot find library libgc with Bohem memory allocator.])
613   fi
614 fi
615
616 #remove duplicates
617 uniq ports.all ports
618 mv ports ports.all
619 uniq ports.build ports
620 mv ports ports.build
621
622 # Generating output files
623 # ===========================================================================
624 test $OPT_DISABLE_SDCPP   = 0 && AC_CONFIG_SUBDIRS(support/cpp2)
625 test $OPT_DISABLE_PACKIHX = 0 && AC_CONFIG_SUBDIRS(support/packihx)
626 test $OPT_DISABLE_UCSIM   = 0 && AC_CONFIG_SUBDIRS(sim/ucsim)
627 test $OPT_DISABLE_SDCDB   = 0 && AC_CONFIG_SUBDIRS(debugger/mcs51)
628 AC_CONFIG_FILES([doc/Makefile])
629
630 test $OPT_DISABLE_AVR = 0 && AC_CONFIG_FILES([src/avr/Makefile])
631
632 if test $OPT_DISABLE_DS390 = 0; then
633   AC_CONFIG_FILES([src/ds390/Makefile])
634   test $OPT_DISABLE_DEVICE_LIB = 0 && AC_CONFIG_FILES([device/lib/ds390/Makefile])
635 fi
636
637 if test $OPT_DISABLE_DS400 = 0; then
638   AC_CONFIG_FILES([src/ds400/Makefile])
639   test $OPT_DISABLE_DEVICE_LIB = 0 && AC_CONFIG_FILES([device/lib/ds400/Makefile])
640 fi
641
642 if test $OPT_DISABLE_HC08 = 0; then
643   AC_CONFIG_FILES([src/hc08/Makefile
644                    as/hc08/Makefile]
645                    as/link/hc08/Makefile])
646   test $OPT_DISABLE_DEVICE_LIB = 0 && AC_CONFIG_FILES([device/lib/hc08/Makefile])
647 fi
648
649 if test $OPT_DISABLE_MCS51 = 0; then
650   AC_CONFIG_FILES([src/mcs51/Makefile
651                    as/mcs51/Makefile
652                    as/link/mcs51/Makefile])
653   test $OPT_DISABLE_DEVICE_LIB = 0 && AC_CONFIG_FILES([device/lib/mcs51/Makefile
654                                                        device/lib/small/Makefile
655                                                        device/lib/medium/Makefile
656                                                        device/lib/large/Makefile])
657 fi
658
659 if test $OPT_DISABLE_PIC = 0; then
660   AC_CONFIG_FILES(src/pic/Makefile)
661   test $OPT_DISABLE_DEVICE_LIB = 0 && AC_CONFIG_SUBDIRS(device/lib/pic)
662 fi
663 if test $OPT_DISABLE_PIC16 = 0; then
664   AC_CONFIG_FILES(src/pic16/Makefile)
665   test $OPT_DISABLE_DEVICE_LIB = 0 && AC_CONFIG_SUBDIRS(device/lib/pic16)
666 fi
667
668 test $OPT_DISABLE_XA51 = 0 && AC_CONFIG_FILES([src/xa51/Makefile])
669
670 if test $OPT_DISABLE_Z80 = 0; then
671   AC_CONFIG_FILES([src/z80/Makefile
672                    as/Makefile
673                    as/z80/Makefile
674                    as/link/Makefile
675                    as/link/z80/Makefile])
676   test $OPT_DISABLE_DEVICE_LIB = 0 && AC_CONFIG_FILES([device/lib/z80/Makefile
677                                                        device/lib/gbz80/Makefile])
678 fi
679
680 test $OPT_DISABLE_DEVICE_LIB = 0 && AC_CONFIG_FILES([device/lib/Makefile])
681
682 AC_CONFIG_FILES([main.mk:main_in.mk
683 src/Makefile
684 device/include/Makefile
685 support/librarian/Makefile
686 support/makebin/Makefile
687 support/regression/Makefile
688 support/valdiag/Makefile
689 Makefile
690 Makefile.common:Makefile.common.in
691 ])
692 AC_OUTPUT
693
694 # I found no better place
695 mkdir -p bin
696
697 # Prepare result message
698 # ======================
699
700 # In the C-header we need \\ as dir-separator, but in the message only \
701 dirch=${sdccconf_h_dir_separator}
702 test ${dirch} = '\\' && dirch='\'
703
704 # calc friendly strings
705 adl_NORMALIZE_PATH_MSG(/${prefix2bin_dir},                         [binPath],  [$dirch])
706 adl_NORMALIZE_PATH_MSG(/${prefix2data_dir}/${norm_inc_dir_suffix}, [incPath1], [$dirch])
707 adl_NORMALIZE_PATH_MSG(/${bin2data_dir}/${norm_inc_dir_suffix},    [incPath2], [$dirch])
708 adl_NORMALIZE_PATH_MSG(${expanded_datadir}/${norm_inc_dir_suffix}, [incPath3], [$dirch])
709 adl_NORMALIZE_PATH_MSG(/${prefix2data_dir}/${norm_lib_dir_suffix}, [libPath1], [$dirch])
710 adl_NORMALIZE_PATH_MSG(/${bin2data_dir}/${norm_lib_dir_suffix},    [libPath2], [$dirch])
711 adl_NORMALIZE_PATH_MSG(${expanded_datadir}/${norm_lib_dir_suffix}, [libPath3], [$dirch])
712
713 AC_MSG_RESULT([
714 sdcc ${VERSION} is now configured for
715
716   Build:                ${build_alias}
717   Host:                 ${host_alias}
718   Source directory:     ${srcdir}
719   C compiler:           ${CC}
720   CFLAGS:               ${CFLAGS}
721
722   ENABLED Ports:
723     avr                 ${enable_avr_port}
724     ds390               ${enable_ds390_port}
725     ds400               ${enable_ds400_port}
726     gbz80               ${enable_gbz80_port}
727     hc08                ${enable_hc08_port}
728     pic                 ${enable_pic_port}
729     pic16               ${enable_pic16_port}
730     xa51                ${enable_xa51_port}
731     z80                 ${enable_z80_port}
732
733   Disable packihx:      ${OPT_DISABLE_PACKIHX}
734   Disable ucsim:        ${OPT_DISABLE_UCSIM}
735   Disable device lib:   ${OPT_DISABLE_DEVICE_LIB}
736   Disable sdcpp:        ${OPT_DISABLE_SDCPP}
737   Disable sdcdb:        ${OPT_DISABLE_SDCDB}
738   Enable documentation: ${OPT_ENABLE_DOC}
739   Enable libgc:         ${OPT_ENABLE_LIBGC}
740
741   Install paths:
742     binary files:       ${exec_prefix}
743     include files:      ${datadir}/${include_dir_suffix}
744     library files:      ${datadir}/${lib_dir_suffix}
745     documentation:      ${docdir}
746
747     prefix:             ${prefix}
748     datadir:            ${datadir}
749
750   Search paths (incomplete, see manual for all search paths):
751     binary files:       \$SDCC_HOME${binPath}
752     include files:      ${incPath1}
753                         path(argv[[0]])${incPath2}
754                         ${incPath3}
755     library files:      \$SDCC_HOME${libPath1}${dirch}<model>
756                         path(argv[[0]])${libPath2}${dirch}<model>
757                         ${libPath3}${dirch}<model>
758 ])
759 # End of configure/configure.in