X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=configure.in;h=dc4bab5b88fd57579cba9c02aba3656fa34a5bd5;hb=d08e6df2202ed3f19b681221b502dedb3c6c8a28;hp=5396bad2af0335ca0b1f1af58dc187e7cfe98fb1;hpb=358bb36a50196d00ce93614ea02553cd1743e5e4;p=fw%2Fsdcc diff --git a/configure.in b/configure.in old mode 100755 new mode 100644 index 5396bad2..dc4bab5b --- a/configure.in +++ b/configure.in @@ -1,27 +1,28 @@ #!/bin/sh -AC_PREREQ(2.54) -AC_INIT -AC_CONFIG_SRCDIR([Makefile]) -AC_CONFIG_HEADER(sdccconf.h:sdccconf_in.h) +AC_PREREQ(2.60) +AC_INIT(.version) +AC_CONFIG_SRCDIR([Makefile.in]) +AC_CONFIG_HEADER([sdccconf.h:sdccconf_in.h as/link/asxxxx_config.h]) AC_PROG_AWK AC_MSG_CHECKING(version of the package) -if test -f .version; then - VERSION=`cat .version` +if test -f ${srcdir}/.version; then + { read VERSION; } < ${srcdir}/.version + AC_MSG_RESULT($VERSION) elif test -f ../.version; then - VERSION=`cat ../.version` + { read VERSION; } < ../.version + AC_MSG_RESULT($VERSION) else VERSION="0.0.0" + AC_MSG_RESULT(unknown using 0.0.0) fi VERSIONHI=`echo $VERSION|$AWK 'BEGIN {FS="."} {print $1}'` VERSIONLO=`echo $VERSION|$AWK 'BEGIN {FS="."} {print $2}'` VERSIONP=`echo $VERSION|$AWK 'BEGIN {FS="."} {print $3}'` -# Assume no special extension -EXEEXT=`echo $EXEEXT` -AC_MSG_RESULT(${VERSION}) +AC_SUBST(PACKAGE, [sdcc]) AC_SUBST(VERSION) AC_SUBST(VERSIONHI) AC_SUBST(VERSIONLO) @@ -40,38 +41,40 @@ sdcc_cv_versionp=$VERSIONP # Required programs # =========================================================================== AC_PROG_CC -AC_PROG_CXX AC_PROG_CPP AC_PROG_INSTALL AC_PROG_RANLIB -AC_PROG_LEX -AC_PROG_YACC AC_CHECK_PROG(AUTOCONF, autoconf, autoconf, :) AC_CHECK_PROG(STRIP, strip, strip, :) AC_CHECK_PROG(AS, as, as, :) AC_CHECK_PROG(CP, cp, cp, :) -AC_CHECK_PROG(LYX, lyx, lyx, :) -AC_CHECK_PROG(LATEX, latex, latex, :) -AC_CHECK_PROG(LATEX2HTML, latex2html, latex2html, :) -AC_CHECK_PROG(PDFLATEX, pdflatex, pdflatex, :) -AC_CHECK_PROG(DVIPDF, dvipdf, dvipdf, :) +dnl Don't use AC_PROG_LEX +dnl LEXLIB is not useful in gcc. +AC_CHECK_PROGS(LEX, flex lex, :) -AC_DEFUN(SDCC_REQUIRE_PROG, +dnl Don't use AC_PROG_YACC +AC_CHECK_PROGS(YACC, 'bison -y' byacc yacc, :) + +AC_DEFUN([SDCC_REQUIRE_PROG], [if test "$1" = ":"; then AC_MSG_ERROR([Cannot find required program $2.]) fi ]) SDCC_REQUIRE_PROG($YACC, bison) -SDCC_REQUIRE_PROG($LEX, lex) - -AC_LANG([C]) +SDCC_REQUIRE_PROG($LEX, flex) +AC_LANG_C -# Checking for header files. -# =========================================================================== -AC_CHECK_HEADERS(sys/socket.h) +AC_ARG_WITH([ccache], + AC_HELP_STRING([--without-ccache], [do not use ccache even if available]), + [], []) +case x${with_ccache-yes} in + xyes) AC_CHECK_PROG([CCACHE], [ccache], [ccache], []) ;; + xno) AC_SUBST([CCACHE], []) ;; + *) AC_SUBST([CCACHE], [$with_ccache]) ;; +esac # Checking for functions @@ -83,11 +86,11 @@ AC_CHECK_FUNCS(vsnprintf snprintf vsprintf mkstemp) # Macro definitions # =========================================================================== -# DD_COPT macro checks if the compiler specified as the 1st parameter +# adl_DD_COPT macro checks if the compiler specified as the 1st parameter # supports option specified as the 2nd parameter # For example: DD_CPORT(CXX, fPIC) -AC_DEFUN(DD_COPT, [ +AC_DEFUN([adl_DD_COPT], [ AC_CACHE_CHECK(whether $$1 accepts -$2,sdcc_cv_$1$2, cat >_test_.c < @@ -102,25 +105,212 @@ fi rm -f _test_.* a.out) ]) -# This macro _AC_DEFINEs VARNAME to the expansion of the DIR variable, -# taking care of fixing up ${prefix} and such. +# This macro expands DIR and assigns it to RET. +# If DIR is NONE, then it's replaced by DEFAULT. # -# Note that the 3 argument form is only supported with autoconf 2.13 -# and later (i.e. only where _AC_DEFINE supports 3 arguments). +# Based on AC_DEFINE_DIR # # Examples: # -# AC_DEFINE_DIR(DATADIR, datadir) -# AC_DEFINE_DIR(PROG_PATH, bindir, [Location of installed binaries]) +# adl_EXPAND(prefix, "/usr/local", expanded_prefix) -AC_DEFUN([AC_DEFINE_DIR], [ +AC_DEFUN([adl_EXPAND], [ test "x$prefix" = xNONE && prefix="$ac_default_prefix" test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' - ac_define_dir=`eval echo [$]$2` - ac_define_dir=`eval echo [$]ac_define_dir` - ifelse($3, , - AC_DEFINE_UNQUOTED($1, "$ac_define_dir"), - AC_DEFINE_UNQUOTED($1, "$ac_define_dir", $3)) + ac_expand=[$]$1 + test "x$ac_expand" = xNONE && ac_expand="[$]$2" + ac_expand=`eval echo [$]ac_expand` + $3=`eval echo [$]ac_expand` +]) + +# adl_NORMALIZE_PATH +# +# - empty paths are changed to '.' +# - trailing slashes are removed +# - repeated slashes are squeezed except a leading doubled slash '//' +# (which might indicate a networked disk on some OS). +# +# +# REFERENCE_STRING is used to turn '/' into '\' and vice-versa: if +# REFERENCE_STRING contains some backslashes, all slashes and backslashes +# are turned into backslashes, otherwise they are all turned into slashes. +# +# This makes processing of DOS filenames quite easier, because you can turn a +# filename to the Unix notation, make your processing, and turn it back to +# original notation. + +dnl Available from the GNU Autoconf Macro Archive at: +dnl http://www.gnu.org/software/ac-archive/htmldoc/normpath.html +dnl +AC_DEFUN([adl_NORMALIZE_PATH], +[case ":[$]$1:" in +dnl change empty paths to '.' + ::) $1='.' ;; +dnl strip trailing slashes + :*[[\\/]]:) $1=`echo "[$]$1" | sed 's,[[\\/]]*[$],,'` ;; + :*:) ;; +esac +dnl squeze repeated slashes +case ifelse($2,,"[$]$1",$2) in +dnl if the path contains any backslashes, turn slashes into backslashes + +dnl Bernhard Held 2003-04-06 +dnl This was the original line. It does not: +dnl - convert the first slash +dnl - replace a slash with a double-backslash +dnl *\\*) $1=`echo "[$]$1" | sed 's,\(.\)[[\\/]][[\\/]]*,\1\\\\,g'` ;; + *\\*) $1=`echo "[$]$1" | sed 's,\(.\)[[\\/]][[\\/]]*,\1\\\\\\\\,g + s,^[[\\/]],\\\\\\\\,'` ;; + +dnl if the path contains slashes, also turn backslashes into slashes + *) $1=`echo "[$]$1" | sed 's,\(.\)[[\\/]][[\\/]]*,\1/,g'` ;; +esac]) + + +# adl_COMPUTE_RELATIVE_PATH +# +# PATH_LIST is a space-separated list of colon-separated triplets of the form +# 'FROM:TO:RESULT'. This function iterates over these triplets and set $RESULT +# to the relative path from $FROM to $TO. Note that $FROM and $TO needs to be +# absolute filenames for this macro to success. + +AC_DEFUN([adl_COMPUTE_RELATIVE_PATHS], +[for _lcl_i in $1; do + _lcl_from=\[$]`echo "[$]_lcl_i" | sed 's,:.*$,,'` + _lcl_to=\[$]`echo "[$]_lcl_i" | sed 's,^[[^:]]*:,,' | sed 's,:[[^:]]*$,,'` + _lcl_result_var=`echo "[$]_lcl_i" | sed 's,^.*:,,'` + adl_RECURSIVE_EVAL([[$]_lcl_from], [_lcl_from]) + adl_RECURSIVE_EVAL([[$]_lcl_to], [_lcl_to]) + _lcl_notation="$_lcl_from$_lcl_to" + adl_NORMALIZE_PATH([_lcl_from],['/']) + adl_NORMALIZE_PATH([_lcl_to],['/']) + adl_COMPUTE_RELATIVE_PATH([_lcl_from], [_lcl_to], [_lcl_result_tmp]) + adl_NORMALIZE_PATH([_lcl_result_tmp],["[$]_lcl_notation"]) + eval $_lcl_result_var='[$]_lcl_result_tmp' +done]) + +## Note: +## ***** +## The following helper macros are too fragile to be used out +## of adl_COMPUTE_RELATIVE_PATHS (mainly because they assume that +## paths are normalized), that's why I'm keeping them in the same file. +## Still, some of them maybe worth to reuse. + +dnl adl_COMPUTE_RELATIVE_PATH(FROM, TO, RESULT) +dnl =========================================== +dnl Compute the relative path to go from $FROM to $TO and set the value +dnl of $RESULT to that value. This function work on raw filenames +dnl (for instead it will considerate /usr//local and /usr/local as +dnl two distinct paths), you should really use adl_COMPUTE_REALTIVE_PATHS +dnl instead to have the paths sanitized automatically. +dnl +dnl For instance: +dnl first_dir=/somewhere/on/my/disk/bin +dnl second_dir=/somewhere/on/another/disk/share +dnl adl_COMPUTE_RELATIVE_PATH(first_dir, second_dir, first_to_second) +dnl will set $first_to_second to '../../../another/disk/share'. +AC_DEFUN([adl_COMPUTE_RELATIVE_PATH], +[adl_COMPUTE_COMMON_PATH([$1], [$2], [_lcl_common_prefix]) +adl_COMPUTE_BACK_PATH([$1], [_lcl_common_prefix], [_lcl_first_rel]) +adl_COMPUTE_SUFFIX_PATH([$2], [_lcl_common_prefix], [_lcl_second_suffix]) +$3="[$]_lcl_first_rel[$]_lcl_second_suffix"]) + +dnl adl_COMPUTE_COMMON_PATH(LEFT, RIGHT, RESULT) +dnl ============================================ +dnl Compute the common path to $LEFT and $RIGHT and set the result to $RESULT. +dnl +dnl For instance: +dnl first_path=/somewhere/on/my/disk/bin +dnl second_path=/somewhere/on/another/disk/share +dnl adl_COMPUTE_COMMON_PATH(first_path, second_path, common_path) +dnl will set $common_path to '/somewhere/on'. +AC_DEFUN([adl_COMPUTE_COMMON_PATH], +[$3='' +_lcl_second_prefix_match='' +while test "[$]_lcl_second_prefix_match" != 0; do + _lcl_first_prefix=`expr "x[$]$1" : "x\([$]$3/*[[^/]]*\)"` + _lcl_second_prefix_match=`expr "x[$]$2" : "x[$]_lcl_first_prefix"` + if test "[$]_lcl_second_prefix_match" != 0; then + if test "[$]_lcl_first_prefix" != "[$]$3"; then + $3="[$]_lcl_first_prefix" + else + _lcl_second_prefix_match=0 + fi + fi +done]) + +dnl adl_COMPUTE_SUFFIX_PATH(PATH, SUBPATH, RESULT) +dnl ============================================== +dnl Substrack $SUBPATH from $PATH, and set the resulting suffix +dnl (or the empty string if $SUBPATH is not a subpath of $PATH) +dnl to $RESULT. +dnl +dnl For instace: +dnl first_path=/somewhere/on/my/disk/bin +dnl second_path=/somewhere/on +dnl adl_COMPUTE_SUFFIX_PATH(first_path, second_path, common_path) +dnl will set $common_path to '/my/disk/bin'. +AC_DEFUN([adl_COMPUTE_SUFFIX_PATH], +[$3=`expr "x[$]$1" : "x[$]$2/*\(.*\)"`]) + +dnl adl_COMPUTE_BACK_PATH(PATH, SUBPATH, RESULT) +dnl ============================================ +dnl Compute the relative path to go from $PATH to $SUBPATH, knowing that +dnl $SUBPATH is a subpath of $PATH (any other words, only repeated '../' +dnl should be needed to move from $PATH to $SUBPATH) and set the value +dnl of $RESULT to that value. If $SUBPATH is not a subpath of PATH, +dnl set $RESULT to the empty string. +dnl +dnl For instance: +dnl first_path=/somewhere/on/my/disk/bin +dnl second_path=/somewhere/on +dnl adl_COMPUTE_BACK_PATH(first_path, second_path, back_path) +dnl will set $back_path to '../../../'. +AC_DEFUN([adl_COMPUTE_BACK_PATH], +[adl_COMPUTE_SUFFIX_PATH([$1], [$2], [_lcl_first_suffix]) +$3='' +_lcl_tmp='xxx' +while test "[$]_lcl_tmp" != ''; do + _lcl_tmp=`expr "x[$]_lcl_first_suffix" : "x[[^/]]*/*\(.*\)"` + if test "[$]_lcl_first_suffix" != ''; then + _lcl_first_suffix="[$]_lcl_tmp" + $3="../[$]$3" + fi +done]) + + +dnl adl_RECURSIVE_EVAL(VALUE, RESULT) +dnl ================================= +dnl Interpolate the VALUE in loop until it does not change, +dnl and set the result to $RESULT. +dnl WARNING: It is easy to get an infinite loop with some unsane input. +AC_DEFUN([adl_RECURSIVE_EVAL], +[_lcl_receval="$1" +$2=`(test "x$prefix" = xNONE && prefix="$ac_default_prefix" + test "x$exec_prefix" = xNONE && exec_prefix="${prefix}" + _lcl_receval_old='' + while test "[$]_lcl_receval_old" != "[$]_lcl_receval"; do + _lcl_receval_old="[$]_lcl_receval" + eval _lcl_receval="\"[$]_lcl_receval\"" + done + echo "[$]_lcl_receval")`]) + +dnl adl_NORMALIZE_DEFINE_UNQUOTED(var, DEFINE, REFERENCE_STRING) +AC_DEFUN([adl_NORMALIZE_DEFINE_UNQUOTED], [ + ac_ndu=[$]$1 + adl_NORMALIZE_PATH([ac_ndu], [$]$3) + AC_DEFINE_UNQUOTED($2, "${ac_ndu}") +]) + +dnl adl_NORMALIZE_PATH_MSG(input_string, var, dir_separator) +dnl ======================================================== +dnl call adl_NORMALIZE_PATH and format it for the result message +AC_DEFUN([adl_NORMALIZE_PATH_MSG], [ +dnl replace /./ by / +$2=`echo "$1" | sed 's,/\./,/,g'` +adl_NORMALIZE_PATH([$2], [$3]) +dnl replace \\ by \ +$2=`echo "[$]$2" | sed 's,\\\\\\\\,\\\\,g'` ]) @@ -140,16 +330,17 @@ M_OR_MM=$sdcc_cv_MM AC_SUBST(M_OR_MM) # This is the first time when CFLAGS are set/modified!! -DD_COPT(CC, ggdb) +adl_DD_COPT(CC, ggdb) if test "$sdcc_cv_CCggdb" = "yes"; then - CFLAGS="-ggdb -O2" + CFLAGS="-ggdb ${CFLAGS}" fi -DD_COPT(CC, pipe) +adl_DD_COPT(CC, pipe) if test "$sdcc_cv_CCpipe" = "yes"; then - CFLAGS="$CFLAGS -pipe" + CFLAGS="-pipe $CFLAGS" fi + # Checks for typedefs, structures, and compiler characteristics. # =========================================================================== AC_TYPE_SIGNAL @@ -158,30 +349,36 @@ AC_CHECK_SIZEOF(char) AC_CHECK_SIZEOF(short) AC_CHECK_SIZEOF(int) AC_CHECK_SIZEOF(long) +AC_C_CHAR_UNSIGNED type_name() { - if expr "$ac_cv_sizeof_char" '>=' "$1" >/dev/null; then - echo "char" - exit - fi - if expr "$ac_cv_sizeof_short" '>=' "$1" >/dev/null; then - echo "short" - exit - fi - if expr "$ac_cv_sizeof_int" '>=' "$1" >/dev/null; then - echo "int" - exit - fi - if expr "$ac_cv_sizeof_long" '>=' "$1" >/dev/null; then - echo "long" - exit - fi + if expr "$ac_cv_sizeof_char" '>=' "$1" >/dev/null; then + echo "char" + exit + fi + if expr "$ac_cv_sizeof_short" '>=' "$1" >/dev/null; then + echo "short" + exit + fi + if expr "$ac_cv_sizeof_int" '>=' "$1" >/dev/null; then + echo "int" + exit + fi + if expr "$ac_cv_sizeof_long" '>=' "$1" >/dev/null; then echo "long" + exit + fi + echo "long" } AC_MSG_CHECKING(type name for byte) -TYPE_BYTE=`type_name 1` +TYPE_CHAR=`type_name 1` +if test "$ac_cv_c_char_unsigned" = "yes"; then + TYPE_BYTE="signed $TYPE_CHAR" +else + TYPE_BYTE=$TYPE_CHAR +fi AC_MSG_RESULT($TYPE_BYTE) AC_MSG_CHECKING(type name for word) TYPE_WORD=`type_name 2` @@ -189,46 +386,196 @@ AC_MSG_RESULT($TYPE_WORD) AC_MSG_CHECKING(type name for dword) TYPE_DWORD=`type_name 4` AC_MSG_RESULT($TYPE_DWORD) + AC_DEFINE_UNQUOTED(TYPE_BYTE, $TYPE_BYTE) AC_DEFINE_UNQUOTED(TYPE_WORD, $TYPE_WORD) AC_DEFINE_UNQUOTED(TYPE_DWORD, $TYPE_DWORD) -AC_C_BIGENDIAN +AC_DEFINE_UNQUOTED(TYPE_UBYTE, unsigned $TYPE_CHAR) +AC_DEFINE_UNQUOTED(TYPE_UWORD, unsigned $TYPE_WORD) +AC_DEFINE_UNQUOTED(TYPE_UDWORD, unsigned $TYPE_DWORD) + + +# SDCC_BUILD_BIGENDIAN ([ACTION-IF-TRUE], [ACTION-IF-FALSE], [ACTION-IF-UNKNOWN]) +# ------------------------------------------------------------------------- +AC_DEFUN([SDCC_BUILD_BIGENDIAN], +[AC_CACHE_CHECK(whether host machine byte ordering is bigendian, sdcc_cv_build_bigendian, +[# See if sys/param.h defines the BYTE_ORDER macro. +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include +#include +], +[#if ! (defined BYTE_ORDER && defined BIG_ENDIAN && defined LITTLE_ENDIAN \ + && BYTE_ORDER && BIG_ENDIAN && LITTLE_ENDIAN) + bogus endian macros +#endif +])], +[# It does; now see whether it defined to BIG_ENDIAN or not. +AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include +#include +], [#if BYTE_ORDER != BIG_ENDIAN + not big endian +#endif +])], [sdcc_cv_build_bigendian=yes], [sdcc_cv_build_bigendian=no])], +[# It does not; compile a test program. +AC_RUN_IFELSE( +[AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT], [[ + /* Are we little or big endian? From Harbison&Steele. */ + union + { + long int l; + char c[sizeof (long int)]; + } u; + u.l = 1; + return u.c[sizeof (long int) - 1] == 1; +]])], + [sdcc_cv_build_bigendian=no], + [sdcc_cv_build_bigendian=yes], +[# try to guess the endianness by grepping values into an object file + sdcc_cv_build_bigendian=unknown + AC_COMPILE_IFELSE([AC_LANG_PROGRAM( +[[short int ascii_mm[] = { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 }; +short int ascii_ii[] = { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 }; +void _ascii () { char *s = (char *) ascii_mm; s = (char *) ascii_ii; } +short int ebcdic_ii[] = { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 }; +short int ebcdic_mm[] = { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 }; +void _ebcdic () { char *s = (char *) ebcdic_mm; s = (char *) ebcdic_ii; }]], +[[ _ascii (); _ebcdic (); ]])], +[if grep BIGenDianSyS conftest.$ac_objext >/dev/null ; then + sdcc_cv_build_bigendian=yes +fi +if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then + if test "$sdcc_cv_build_bigendian" = unknown; then + sdcc_cv_build_bigendian=no + else + # finding both strings is unlikely to happen, but who knows? + sdcc_cv_build_bigendian=unknown + fi +fi])])])]) +case $sdcc_cv_build_bigendian in + yes) + m4_default([$1], + [AC_DEFINE([BUILD_WORDS_BIGENDIAN], 1, + [Define to 1 if your processor stores words with the most significant + byte first (like Motorola and SPARC, unlike Intel and VAX).])]) ;; + no) + $2 ;; + *) + m4_default([$3], + [AC_MSG_ERROR([unknown endianness +presetting sdcc_cv_build_bigendian=no (or yes) will help])]) ;; +esac +])# SDCC_BUILD_BIGENDIAN + +SDCC_BUILD_BIGENDIAN # Set standard installation paths # =========================================================================== -case $host in - *mingw32*) - MINGW32_HOST="yes" - ;; - *) - MINGW32_HOST="no" - ;; -esac -AC_MSG_CHECKING(host mingw32) -AC_MSG_RESULT($MINGW32_HOST) +# In the Makefiles we need paths with '/' as directory separator, even if +# crosscompiling for Win32. +# And we want to preserve the macros (e.g. ${prefix}) in the Makefiles. +# The variables in the Makefiles are replaced by AC_SUBST() +# +# In sdccconf.h the '/' in paths can be replaced by "\\" (normalized), if +# +# The macros are expanded for the header. +# The variables in the header are replaced by AC_*DEFINE*() +# sdccconf_h_dir_separator contains a backslash. +AC_ARG_VAR([sdccconf_h_dir_separator], [needed in sdccconf.h: either "/" (default) or "\\"]) +if test "x${sdccconf_h_dir_separator}" = "x"; then + sdccconf_h_dir_separator="/" +fi + +# Makefiles +########### -# prefix: *nix default is "NONE" -# prefix: mingw32 default is "/sdcc" -if test "$prefix" = NONE; then - if test "$MINGW32_HOST" = "no"; then - prefix="/usr/local" - else - prefix="/sdcc" - fi +# LIB_TYPE: +# *nix default: "RANLIB" + +AC_ARG_VAR([LIB_TYPE], [library type: LIB, SDCCLIB, AR or RANLIB (default)]) +if test "${LIB_TYPE}" = ""; then + LIB_TYPE="RANLIB" fi -# datadir: *nix default is "${prefix}/share" -if test "$datadir" = "\${prefix}/share"; then - if test "$MINGW32_HOST" = "no"; then - datadir="\${prefix}/share/sdcc" - fi -# mingw32 default is "/sdcc" -elif test "$datadir" = "/sdcc"; then - if test "$MINGW32_HOST" = "yes"; then - datadir="\${prefix}" - fi +# include_dir_suffix: +# *nix default: "sdcc/include" + +AC_ARG_VAR([include_dir_suffix], [appended to datadir to define SDCC's include directory]) +if test "${include_dir_suffix}" = ""; then + include_dir_suffix="sdcc/include" +fi + +# lib_dir_suffix: +# *nix default: "sdcc/lib" +AC_ARG_VAR([lib_dir_suffix], [appended to datadir to define SDCC's library root directory]) +if test "${lib_dir_suffix}" = ""; then + lib_dir_suffix="sdcc/lib" +fi + +# docdir: +# *nix default: "${datadir}/sdcc/doc" +AC_ARG_VAR([docdir], [documentation installation directory]) +if test "${docdir}" = ""; then + docdir="\${datadir}"/sdcc/doc +fi + +AC_SUBST(EXEEXT) + +# sdccconf.h +############ + +AC_DEFINE_UNQUOTED(DIR_SEPARATOR_STRING, "${sdccconf_h_dir_separator}") +AC_DEFINE_UNQUOTED(DIR_SEPARATOR_CHAR, '${sdccconf_h_dir_separator}') + +# prefix: +# default: "NONE", ${ac_default_prefix}: "/usr/local" +adl_EXPAND(prefix, ac_default_prefix, expanded_prefix) +adl_NORMALIZE_DEFINE_UNQUOTED(expanded_prefix, PREFIX, sdccconf_h_dir_separator) + +# exec_prefix: +# default: "${prefix}" +adl_EXPAND(exec_prefix, expanded_prefix, expanded_exec_prefix) +adl_NORMALIZE_DEFINE_UNQUOTED(expanded_exec_prefix, EXEC_PREFIX, sdccconf_h_dir_separator) + +# bindir: +# default: "${exec_prefix}/bin" +adl_EXPAND(bindir, "NONE", expanded_bindir) +adl_NORMALIZE_DEFINE_UNQUOTED(expanded_bindir, BINDIR, sdccconf_h_dir_separator) + +# datadir: +# default: "${prefix}/share" +adl_EXPAND(datadir, "NONE", expanded_datadir) +adl_NORMALIZE_DEFINE_UNQUOTED(expanded_datadir, DATADIR, sdccconf_h_dir_separator) + +# include/lib suffix +norm_inc_dir_suffix=${include_dir_suffix} +adl_NORMALIZE_PATH([norm_inc_dir_suffix], [$sdccconf_h_dir_separator]) +AC_DEFINE_UNQUOTED(INCLUDE_DIR_SUFFIX, + DIR_SEPARATOR_STRING "${norm_inc_dir_suffix}") +norm_lib_dir_suffix=${lib_dir_suffix} +adl_NORMALIZE_PATH([norm_lib_dir_suffix], [$sdccconf_h_dir_separator]) +AC_DEFINE_UNQUOTED(LIB_DIR_SUFFIX, + DIR_SEPARATOR_STRING "${norm_lib_dir_suffix}") + +# relative paths +adl_COMPUTE_RELATIVE_PATHS([expanded_bindir:expanded_datadir:bin2data_dir]) +adl_NORMALIZE_PATH(bin2data_dir, [$sdccconf_h_dir_separator]) +AC_DEFINE_UNQUOTED(BIN2DATA_DIR, + DIR_SEPARATOR_STRING "${bin2data_dir}") + +adl_COMPUTE_RELATIVE_PATHS([expanded_prefix:expanded_bindir:prefix2bin_dir]) +adl_NORMALIZE_PATH(prefix2bin_dir, [$sdccconf_h_dir_separator]) +AC_DEFINE_UNQUOTED(PREFIX2BIN_DIR, + DIR_SEPARATOR_STRING "${prefix2bin_dir}") + +adl_COMPUTE_RELATIVE_PATHS([expanded_prefix:expanded_datadir:prefix2data_dir]) +adl_NORMALIZE_PATH(prefix2data_dir, [$sdccconf_h_dir_separator]) +if test "${prefix2data_dir}" = "."; then + # small optimization for Mingw32; otherwise Borut will complain ;-) + AC_DEFINE_UNQUOTED(PREFIX2DATA_DIR, "") +else + AC_DEFINE_UNQUOTED(PREFIX2DATA_DIR, + DIR_SEPARATOR_STRING "${prefix2data_dir}") fi # standard libs @@ -237,180 +584,272 @@ AC_DEFINE_UNQUOTED(STD_INT_LIB, "libint") AC_DEFINE_UNQUOTED(STD_LONG_LIB, "liblong") AC_DEFINE_UNQUOTED(STD_FP_LIB, "libfloat") AC_DEFINE_UNQUOTED(STD_DS390_LIB, "libds390") -AC_DEFINE_UNQUOTED(STD_xa51_LIB, "xa51") - -AC_DEFINE_DIR(PREFIX, "${prefix}") -AC_DEFINE_DIR(DATADIR, "$datadir") -AC_SUBST(datadir) +AC_DEFINE_UNQUOTED(STD_DS400_LIB, "libds400") +AC_DEFINE_UNQUOTED(STD_XA51_LIB, "libxa51") -# search paths -bin_dir_suffix="bin" -AC_DEFINE_DIR(BIN_DIR_SUFFIX, "${bin_dir_suffix}") - - if test "$MINGW32_HOST" = "no"; then - search_suffix="share/sdcc" - else - search_suffix="" - fi -AC_DEFINE_DIR(SEARCH_SUFFIX, "${search_suffix}") +# SDCC runtime environment variables +sdcc_dir_name="SDCC_HOME" +AC_DEFINE_UNQUOTED(SDCC_DIR_NAME, "${sdcc_dir_name}") -include_dir_suffix="include" -AC_DEFINE_DIR(INCLUDE_DIR_SUFFIX, "${include_dir_suffix}") +sdcc_include_name="SDCC_INCLUDE" +AC_DEFINE_UNQUOTED(SDCC_INCLUDE_NAME, "${sdcc_include_name}") -lib_dir_suffix="lib" -AC_DEFINE_UNQUOTED(LIB_DIR_SUFFIX, "${lib_dir_suffix}") +sdcc_lib_name="SDCC_LIB" +AC_DEFINE_UNQUOTED(SDCC_LIB_NAME, "${sdcc_lib_name}") -### -# sdcc_datadir is still used in [device,lib]/Makefile -sdcc_datadir=${datadir} -AC_SUBST(sdcc_datadir) +# Port selection helper +# =========================================================================== +# macro AC_DO_ENABLER() +# $1 used to access enable_$1, e.g. enable_doc +# $2 OPT_DISABLE_$2, normally uppercase of $1, e.g. DOC +# $3 help string +AC_DEFUN([AC_DO_ENABLER], [ + AC_ARG_ENABLE($1, AC_HELP_STRING([--enable-$1], $3)) + + if test "[$]enable_$1" = "yes"; then + OPT_ENABLE_$2=1 + else + OPT_ENABLE_$2=0 + fi + + AC_DEFINE_UNQUOTED(OPT_ENABLE_$2, [$]OPT_ENABLE_$2) + AC_SUBST(OPT_ENABLE_$2) +]) -# SDCC_[INCLUDE,LIB]_DIR is still used in SDCCmain.c -if test "${includedir}" = "\${prefix}/include"; then - includedir="${datadir}/include" -fi -AC_DEFINE_DIR(SDCC_INCLUDE_DIR, "${includedir}") -AC_DEFINE_DIR(SDCC_LIB_DIR, "${datadir}/lib") -### +# macro AC_DO_DISABLER() +# $1 used to access disable_$1, e.g. ucsim +# $2 OPT_DISABLE_$2, normally uppercase of $1, e.g. UCSIM +# $3 help string +AC_DEFUN([AC_DO_DISABLER], [ + AC_ARG_ENABLE($1, AC_HELP_STRING([--disable-$1], $3)) + + dnl the '-' in 'device-lib' needs special handling, + dnl because the variable is 'enable_device_lib' + arg1=`echo $1 | sed s/-/_/` + + if test "`eval echo \\$enable_$arg1`" = "no"; then + OPT_DISABLE_$2=1 + else + OPT_DISABLE_$2=0 + fi + + AC_DEFINE_UNQUOTED(OPT_DISABLE_$2, [$]OPT_DISABLE_$2) + AC_SUBST(OPT_DISABLE_$2) +]) -# environment variables -sdcc_dir_name="SDCC_HOME" -AC_DEFINE_DIR(SDCC_DIR_NAME, "${sdcc_dir_name}") -sdcc_include_name="SDCC_INCLUDE" -AC_DEFINE_DIR(SDCC_INCLUDE_NAME, "${sdcc_include_name}") -sdcc_lib_name="SDCC_LIB" -AC_DEFINE_DIR(SDCC_LIB_NAME, "${sdcc_lib_name}") +# macro AC_DO_PORT($1, $2, $3, $4) +# $1 used to access enable_$2_port, e.g. gbz80 +# $2 port name in ports.all and ports.build, e.g. z80 +# $3 OPT_DISABLE_$3, normally uppercase of $2, e.g. GBZ80 +# $4 help string +AC_DEFUN([AC_DO_PORT], [ + AC_ARG_ENABLE($1-port, + AC_HELP_STRING([--disable-$1-port], $4)) + + if test "[$]enable_$1_port" = "no"; then + OPT_DISABLE_$3=1 + else + enable_$1_port="yes" + OPT_DISABLE_$3=0 + fi + + AC_DEFINE_UNQUOTED(OPT_DISABLE_$3, [$]OPT_DISABLE_$3) + AC_SUBST(OPT_DISABLE_$3) + + echo $2 >>ports.all + if test [$]OPT_DISABLE_$3 = 0; then + echo $2 >>ports.build + fi +]) # Now handle the port selection # =========================================================================== rm -f ports.all ports.build -AC_ARG_ENABLE(mcs51-port, - AC_HELP_STRING([--disable-mcs51-port], - [Excludes the Intel mcs51 port])) -echo mcs51 >>ports.all -if test "$enable_mcs51_port" = "no"; then - AC_DEFINE_UNQUOTED(OPT_DISABLE_MCS51, 1) -else - echo mcs51 >>ports.build - AC_DEFINE_UNQUOTED(OPT_DISABLE_MCS51, 0) +AC_DO_PORT(mcs51, mcs51, MCS51, [Excludes the Intel mcs51 port]) +AC_DO_PORT(gbz80, z80, GBZ80, [Excludes the Gameboy gbz80 port]) +AC_DO_PORT(z80, z80, Z80, [Excludes the z80 port]) +AC_DO_PORT(avr, avr, AVR, [Excludes the AVR port]) +AC_DO_PORT(ds390, ds390, DS390, [Excludes the DS390 port]) +AC_DEFINE_UNQUOTED(OPT_DISABLE_TININative, $OPT_DISABLE_DS390) +AC_DO_PORT(ds400, ds400, DS400, [Excludes the DS400 port]) +AC_DO_PORT(pic, pic, PIC, [Excludes the PIC port]) +AC_DO_PORT(pic16, pic16, PIC16, [Excludes the PIC16 port]) +AC_DO_PORT(xa51, xa51, XA51, [Excludes the XA51 port]) +AC_DO_PORT(hc08, hc08, HC08, [Excludes the HC08 port]) + +AC_DO_DISABLER(ucsim, UCSIM, [Disables configuring and building of ucsim]) +AC_DO_DISABLER(device-lib, DEVICE_LIB, [Disables building device libraries]) +AC_DO_DISABLER(packihx, PACKIHX, [Disables building packihx]) +AC_DO_DISABLER(sdcpp, SDCPP, [Disables building sdcpp]) +AC_DO_DISABLER(sdcdb, SDCDB, [Disables building sdcdb]) + +AC_DO_ENABLER(doc, DOC, [Enables building the documentation]) +AC_CHECK_PROG([LYX], [lyx], [lyx], [:]) +AC_CHECK_PROG([LATEX2HTML], [latex2html], [latex2html], [:]) +AC_CHECK_PROG([PDFLATEX], [pdflatex], [pdflatex], [:]) +AC_CHECK_PROG([PDFOPT], [pdfopt], [pdfopt], [:]) +AC_CHECK_PROG([MAKEINDEX], [makeindex], [makeindex], [:]) + +if test $OPT_ENABLE_DOC = 1; then + SDCC_REQUIRE_PROG($LYX, lyx) + SDCC_REQUIRE_PROG($LATEX2HTML, latex2html) + SDCC_REQUIRE_PROG($PDFLATEX, pdflatex) + SDCC_REQUIRE_PROG($PDFOPT, pdfopt) + SDCC_REQUIRE_PROG($MAKEINDEX, makeindex) fi -AC_ARG_ENABLE(gbz80-port, - AC_HELP_STRING([--disable-gbz80-port], - [Excludes the Gameboy gbz80 port])) -echo z80 >>ports.all -if test "$enable_gbz80_port" = "no"; then - AC_DEFINE_UNQUOTED(OPT_DISABLE_GBZ80, 1) -else - echo z80 >>ports.build - AC_DEFINE_UNQUOTED(OPT_DISABLE_GBZ80, 0) +AC_DO_ENABLER(libgc, LIBGC, [Use the Bohem memory allocator. Lower runtime footprint.]) +if test $OPT_ENABLE_LIBGC = 1; then + AC_CHECK_LIB(gc, GC_malloc) + if test $ac_cv_lib_gc_GC_malloc = no; then + AC_MSG_ERROR([Cannot find library libgc with Bohem memory allocator.]) + fi fi -AC_ARG_ENABLE(z80-port, - AC_HELP_STRING([--disable-z80-port], - [Excludes the z80 port])) -echo z80 >>ports.all -if test "$enable_z80_port" = "no"; then - AC_DEFINE_UNQUOTED(OPT_DISABLE_Z80, 1) -else - echo z80 >>ports.build - AC_DEFINE_UNQUOTED(OPT_DISABLE_Z80, 0) +#remove duplicates +uniq ports.all ports +mv ports ports.all +uniq ports.build ports +mv ports ports.build + +# Generating output files +# =========================================================================== +test $OPT_DISABLE_SDCPP = 0 && AC_CONFIG_SUBDIRS(support/cpp) +test $OPT_DISABLE_PACKIHX = 0 && AC_CONFIG_SUBDIRS(support/packihx) +test $OPT_DISABLE_UCSIM = 0 && AC_CONFIG_SUBDIRS(sim/ucsim) +test $OPT_DISABLE_SDCDB = 0 && AC_CONFIG_SUBDIRS(debugger/mcs51) +AC_CONFIG_FILES([doc/Makefile]) + +test $OPT_DISABLE_AVR = 0 && AC_CONFIG_FILES([src/avr/Makefile]) + +if test $OPT_DISABLE_DS390 = 0; then + AC_CONFIG_FILES([src/ds390/Makefile]) + test $OPT_DISABLE_DEVICE_LIB = 0 && AC_CONFIG_FILES([device/lib/ds390/Makefile]) fi -AC_ARG_ENABLE(avr-port, - AC_HELP_STRING([--disable-avr-port], - [Excludes the AVR port])) -echo avr >>ports.all -if test "$enable_avr_port" = "no"; then - AC_DEFINE_UNQUOTED(OPT_DISABLE_AVR, 1) -else - echo avr >>ports.build - AC_DEFINE_UNQUOTED(OPT_DISABLE_AVR, 0) +if test $OPT_DISABLE_DS400 = 0; then + AC_CONFIG_FILES([src/ds400/Makefile]) + test $OPT_DISABLE_DEVICE_LIB = 0 && AC_CONFIG_FILES([device/lib/ds400/Makefile]) fi -AC_ARG_ENABLE(ds390-port, - AC_HELP_STRING([--disable-ds390-port], - [Excludes the DS390 port])) -echo ds390 >>ports.all -if test "$enable_ds390_port" = "no"; then - AC_DEFINE_UNQUOTED(OPT_DISABLE_DS390, 1) - AC_DEFINE_UNQUOTED(OPT_DISABLE_TININative, 1) -else - echo ds390 >>ports.build - AC_DEFINE_UNQUOTED(OPT_DISABLE_DS390, 0) - AC_DEFINE_UNQUOTED(OPT_DISABLE_TININative, 0) +if test $OPT_DISABLE_HC08 = 0; then + AC_CONFIG_FILES([src/hc08/Makefile + as/hc08/Makefile + as/link/hc08/Makefile]) + test $OPT_DISABLE_DEVICE_LIB = 0 && AC_CONFIG_FILES([device/lib/hc08/Makefile]) fi -AC_ARG_ENABLE(pic-port, - AC_HELP_STRING([--disable-pic-port], - [Excludes the PIC port])) -echo pic >>ports.all -if test "$enable_pic_port" = "no"; then - AC_DEFINE_UNQUOTED(OPT_DISABLE_PIC, 1) -else - echo pic >>ports.build - AC_DEFINE_UNQUOTED(OPT_DISABLE_PIC, 0) +if test $OPT_DISABLE_MCS51 = 0; then + AC_CONFIG_FILES([src/mcs51/Makefile + as/mcs51/Makefile + as/link/mcs51/Makefile]) + test $OPT_DISABLE_DEVICE_LIB = 0 && AC_CONFIG_FILES([device/lib/mcs51/Makefile + device/lib/small/Makefile + device/lib/medium/Makefile + device/lib/large/Makefile]) fi -AC_ARG_ENABLE(xa51-port, - AC_HELP_STRING([--disable-xa51-port], - [Excludes the XA51 port])) -echo xa51 >>ports.all -if test "$enable_xa51_port" = "no"; then - AC_DEFINE_UNQUOTED(OPT_DISABLE_XA51, 1) -else - echo xa51 >>ports.build - AC_DEFINE_UNQUOTED(OPT_DISABLE_XA51, 0) +if test $OPT_DISABLE_PIC = 0; then + AC_CONFIG_FILES(src/pic/Makefile) + test $OPT_DISABLE_DEVICE_LIB = 0 && AC_CONFIG_SUBDIRS(device/lib/pic) +fi +if test $OPT_DISABLE_PIC16 = 0; then + AC_CONFIG_FILES(src/pic16/Makefile) + test $OPT_DISABLE_DEVICE_LIB = 0 && AC_CONFIG_SUBDIRS(device/lib/pic16) fi -AC_ARG_ENABLE(ucsim, - AC_HELP_STRING([--disable-ucsim], - [Disables configuring and building of ucsim])) -OPT_ENABLE_UCSIM=$enable_ucsim -AC_SUBST(OPT_ENABLE_UCSIM) - -AC_ARG_ENABLE(device-lib-build, - AC_HELP_STRING([--disable-device-lib-build], - [Disables automatically building device libraries])) -OPT_ENABLE_DEVICE_LIB_BUILD=$enable_device_lib_build -AC_SUBST(OPT_ENABLE_DEVICE_LIB_BUILD) - -AC_ARG_ENABLE(packihx, - AC_HELP_STRING([--disable-packihx], - [Disables building packihx])) -OPT_ENABLE_PACKIHX=$enable_packihx -AC_SUBST(OPT_ENABLE_PACKIHX) - -AC_ARG_ENABLE(libgc, - AC_HELP_STRING([--enable-libgc], - [Use the Bohem memory allocator. Lower runtime footprint.])) -if test "$enable_libgc" = "yes"; then - AC_CHECK_LIB(gc, GC_malloc) - OPT_ENABLE_LIBGC=1 -else - OPT_ENABLE_LIBGC=0 +test $OPT_DISABLE_XA51 = 0 && AC_CONFIG_FILES([src/xa51/Makefile]) + +if test $OPT_DISABLE_Z80 = 0; then + AC_CONFIG_FILES([src/z80/Makefile + as/Makefile + as/z80/Makefile + as/link/Makefile + as/link/z80/Makefile]) + test $OPT_DISABLE_DEVICE_LIB = 0 && AC_CONFIG_FILES([device/lib/z80/Makefile + device/lib/gbz80/Makefile]) fi -AC_DEFINE_UNQUOTED(OPT_ENABLE_LIBGC, $OPT_ENABLE_LIBGC) -#remove duplicates -cat ports.all | uniq >ports -mv ports ports.all -cat ports.build | uniq >ports -mv ports ports.build +test $OPT_DISABLE_DEVICE_LIB = 0 && AC_CONFIG_FILES([device/lib/Makefile]) -# Generating output files -# =========================================================================== -AC_CONFIG_SUBDIRS(support/cpp2) -AC_CONFIG_SUBDIRS(packihx) -AC_CONFIG_SUBDIRS(sim/ucsim) AC_CONFIG_FILES([main.mk:main_in.mk src/Makefile -as/mcs51/Makefile device/include/Makefile -device/lib/Makefile -debugger/mcs51/Makefile +as/asranlib/Makefile +support/librarian/Makefile +support/makebin/Makefile +support/regression/Makefile +support/valdiag/Makefile +Makefile Makefile.common:Makefile.common.in ]) AC_OUTPUT +# I found no better place +mkdir -p bin + +# Prepare result message +# ====================== + +# In the C-header we need \\ as dir-separator, but in the message only \ +dirch=${sdccconf_h_dir_separator} +test ${dirch} = '\\' && dirch='\' + +# calc friendly strings +adl_NORMALIZE_PATH_MSG(/${prefix2bin_dir}, [binPath], [$dirch]) +adl_NORMALIZE_PATH_MSG(/${prefix2data_dir}/${norm_inc_dir_suffix}, [incPath1], [$dirch]) +adl_NORMALIZE_PATH_MSG(/${bin2data_dir}/${norm_inc_dir_suffix}, [incPath2], [$dirch]) +adl_NORMALIZE_PATH_MSG(${expanded_datadir}/${norm_inc_dir_suffix}, [incPath3], [$dirch]) +adl_NORMALIZE_PATH_MSG(/${prefix2data_dir}/${norm_lib_dir_suffix}, [libPath1], [$dirch]) +adl_NORMALIZE_PATH_MSG(/${bin2data_dir}/${norm_lib_dir_suffix}, [libPath2], [$dirch]) +adl_NORMALIZE_PATH_MSG(${expanded_datadir}/${norm_lib_dir_suffix}, [libPath3], [$dirch]) + +AC_MSG_RESULT([ +sdcc ${VERSION} is now configured for + + Build: ${build_alias} + Host: ${host_alias} + Source directory: ${srcdir} + C compiler: ${CC} + CFLAGS: ${CFLAGS} + + ENABLED Ports: + avr ${enable_avr_port} + ds390 ${enable_ds390_port} + ds400 ${enable_ds400_port} + gbz80 ${enable_gbz80_port} + hc08 ${enable_hc08_port} + mcs51 ${enable_mcs51_port} + pic ${enable_pic_port} + pic16 ${enable_pic16_port} + xa51 ${enable_xa51_port} + z80 ${enable_z80_port} + + Disable packihx: ${OPT_DISABLE_PACKIHX} + Disable ucsim: ${OPT_DISABLE_UCSIM} + Disable device lib: ${OPT_DISABLE_DEVICE_LIB} + Disable sdcpp: ${OPT_DISABLE_SDCPP} + Disable sdcdb: ${OPT_DISABLE_SDCDB} + Enable documentation: ${OPT_ENABLE_DOC} + Enable libgc: ${OPT_ENABLE_LIBGC} + + Install paths: + binary files: ${exec_prefix} + include files: ${datadir}/${include_dir_suffix} + library files: ${datadir}/${lib_dir_suffix} + documentation: ${docdir} + + prefix: ${prefix} + datadir: ${datadir} + datarootdir: ${datarootdir} + + Search paths (incomplete, see manual for all search paths): + binary files: \$SDCC_HOME${binPath} + include files: ${incPath1} + path(argv[[0]])${incPath2} + ${incPath3} + library files: \$SDCC_HOME${libPath1}${dirch} + path(argv[[0]])${libPath2}${dirch} + ${libPath3}${dirch} +]) # End of configure/configure.in