#!/bin/sh
AC_PREREQ(2.60)
-AC_INIT
+AC_INIT(.version)
AC_CONFIG_SRCDIR([Makefile.in])
-AC_CONFIG_HEADER(sdccconf.h:sdccconf_in.h)
+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 ${srcdir}/.version; then
- VERSION=`cat ${srcdir}/.version`
+ { 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}'`
-AC_MSG_RESULT(${VERSION})
+AC_SUBST(PACKAGE, [sdcc])
AC_SUBST(VERSION)
AC_SUBST(VERSIONHI)
AC_SUBST(VERSIONLO)
dnl Don't use AC_PROG_YACC
AC_CHECK_PROGS(YACC, 'bison -y' byacc yacc, :)
-AC_DEFUN(SDCC_REQUIRE_PROG,
+AC_DEFUN([SDCC_REQUIRE_PROG],
[if test "$1" = ":"; then
AC_MSG_ERROR([Cannot find required program $2.])
fi
AC_LANG_C
+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
# ===========================================================================
# supports option specified as the 2nd parameter
# For example: DD_CPORT(CXX, fPIC)
-AC_DEFUN(adl_DD_COPT, [
+AC_DEFUN([adl_DD_COPT], [
AC_CACHE_CHECK(whether $$1 accepts -$2,sdcc_cv_$1$2,
cat >_test_.c <<EOF
#include <stdio.h>
AC_DEFINE_UNQUOTED(TYPE_UWORD, unsigned $TYPE_WORD)
AC_DEFINE_UNQUOTED(TYPE_UDWORD, unsigned $TYPE_DWORD)
-AC_C_BIGENDIAN
+
+# 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 <sys/types.h>
+#include <sys/param.h>
+],
+[#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 <sys/types.h>
+#include <sys/param.h>
+], [#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
# ===========================================================================
# 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 "\\")
+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
###########
+# 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
+
# include_dir_suffix:
# *nix default: "sdcc/include"
-AC_ARG_VAR(include_dir_suffix, appended to datadir to define SDCC's include directory)
+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
-AC_SUBST(include_dir_suffix)
# lib_dir_suffix:
# *nix default: "sdcc/lib"
-AC_ARG_VAR(lib_dir_suffix, appended to datadir to define SDCC's library root directory)
+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
-AC_SUBST(lib_dir_suffix)
# docdir:
# *nix default: "${datadir}/sdcc/doc"
-AC_ARG_VAR(docdir, documentation installation directory)
+AC_ARG_VAR([docdir], [documentation installation directory])
if test "${docdir}" = ""; then
docdir="\${datadir}"/sdcc/doc
fi
-AC_SUBST(docdir)
AC_SUBST(EXEEXT)
############
AC_DEFINE_UNQUOTED(DIR_SEPARATOR_STRING, "${sdccconf_h_dir_separator}")
-AC_DEFINE_UNQUOTED(DIR_SEPARATOR_CHAR , '${sdccconf_h_dir_separator}')
+AC_DEFINE_UNQUOTED(DIR_SEPARATOR_CHAR, '${sdccconf_h_dir_separator}')
# prefix:
# default: "NONE", ${ac_default_prefix}: "/usr/local"
# Port selection helper
# ===========================================================================
# macro AC_DO_ENABLER()
-# $1 used to access enable_$1, e.g. enable-doc
+# $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_DO_DISABLER(sdcdb, SDCDB, [Disables building sdcdb])
AC_DO_ENABLER(doc, DOC, [Enables building the documentation])
-if test $OPT_ENABLE_DOC = 1; then
- 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, :)
+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)
# Generating output files
# ===========================================================================
-test $OPT_DISABLE_SDCPP = 0 && AC_CONFIG_SUBDIRS(support/cpp2)
+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([main.mk:main_in.mk
src/Makefile
device/include/Makefile
+as/asranlib/Makefile
support/librarian/Makefile
support/makebin/Makefile
support/regression/Makefile