340 lines
8.9 KiB
Bash
Executable file
340 lines
8.9 KiB
Bash
Executable file
#!/bin/sh
|
|
|
|
AC_INIT(Makefile)
|
|
AC_CONFIG_HEADER(sdccconf.h:sdccconf_in.h)
|
|
|
|
AC_PROG_AWK
|
|
|
|
AC_MSG_CHECKING(version of the package)
|
|
if test -f .version; then
|
|
VERSION=`cat .version`
|
|
elif test -f ../.version; then
|
|
VERSION=`cat ../.version`
|
|
else
|
|
VERSION="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(VERSION)
|
|
AC_SUBST(VERSIONHI)
|
|
AC_SUBST(VERSIONLO)
|
|
AC_SUBST(VERSIONP)
|
|
AC_DEFINE_UNQUOTED(SDCC_VERSION_LO, ${VERSIONLO})
|
|
AC_DEFINE_UNQUOTED(SDCC_VERSION_HI, ${VERSIONHI})
|
|
AC_DEFINE_UNQUOTED(SDCC_VERSION_P, ${VERSIONP})
|
|
AC_DEFINE_UNQUOTED(SDCC_VERSION_STR, "${VERSION}")
|
|
AC_ARG_PROGRAM
|
|
sdcc_cv_version=$VERSION
|
|
sdcc_cv_versionhi=$VERSIONHI
|
|
sdcc_cv_versionlo=$VERSIONLO
|
|
sdcc_cv_versionp=$VERSIONP
|
|
|
|
# Required programs
|
|
#-------------------
|
|
AC_PROG_CC
|
|
AC_PROG_CXX
|
|
AC_PROG_CPP
|
|
AC_PROG_INSTALL
|
|
AC_PROG_RANLIB
|
|
AC_PROG_LEX(flex, :)
|
|
AC_CHECK_PROG(YACC, bison, bison -y, :)
|
|
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_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
|
|
|
|
# Checking for header files.
|
|
# ===========================================================================
|
|
AC_HEADER_STDC
|
|
AC_CHECK_HEADERS(getopt.h)
|
|
AC_CHECK_HEADERS(unistd.h)
|
|
AC_CHECK_HEADERS(endian.h)
|
|
AC_CHECK_HEADERS(machine/endian.h)
|
|
AC_CHECK_HEADERS(malloc.h)
|
|
AC_CHECK_HEADERS(sys/isa_defs.h)
|
|
AC_CHECK_HEADERS(sys/socket.h)
|
|
AC_HEADER_DIRENT
|
|
|
|
# This must be after CPP
|
|
|
|
AC_CACHE_CHECK(which header file defines FD_ macros, s51_cv_fd,
|
|
[sdcc_cv_fd="unknown"
|
|
AC_EGREP_CPP(yes, [
|
|
#include <sys/time.h>
|
|
#ifdef FD_ZERO
|
|
yes
|
|
#endif], sdcc_cv_fd="<sys/time.h>")
|
|
AC_EGREP_CPP(yes, [
|
|
#include <sys/types.h>
|
|
#ifdef FD_ZERO
|
|
yes
|
|
#endif], sdcc_cv_fd="<sys/types.h>")
|
|
AC_EGREP_CPP(yes, [
|
|
#include <sys/select.h>
|
|
#ifdef FD_ZERO
|
|
yes
|
|
#endif], sdcc_cv_fd="<sys/types.h>")])
|
|
|
|
AC_DEFINE(FD_HEADER_OK, 0)
|
|
if echo $sdcc_cv_fd|grep time >/dev/null 2>&1; then
|
|
AC_DEFINE(FD_NEED_TIME_H, 1)
|
|
AC_DEFINE(FD_HEADER_OK, 1)
|
|
else
|
|
AC_DEFINE(FD_NEED_TIME_H, 0)
|
|
fi
|
|
if echo $sdcc_cv_fd|grep types >/dev/null 2>&1; then
|
|
AC_DEFINE(FD_NEED_TYPES_H, 1)
|
|
AC_DEFINE(FD_HEADER_OK, 1)
|
|
else
|
|
AC_DEFINE(FD_NEED_TYPES_H, 0)
|
|
fi
|
|
if echo $sdcc_cv_fd|grep select >/dev/null 2>&1; then
|
|
AC_DEFINE(FD_NEED_SELECT_H, 1)
|
|
AC_DEFINE(FD_HEADER_OK, 1)
|
|
else
|
|
AC_DEFINE(FD_NEED_SELECT_H, 0)
|
|
fi
|
|
|
|
AC_DEFINE_UNQUOTED(HEADER_FD, ${sdcc_cv_fd})
|
|
|
|
|
|
# Checking for functions
|
|
# ===========================================================================
|
|
AC_CHECK_FUNCS(strlen strcpy strcat strstr strcmp strerror strtok strdup)
|
|
AC_CHECK_FUNCS(strchr memcpy)
|
|
dnl AC_CHECK_FUNCS(getline)
|
|
dnl AC_CHECK_FUNCS(getdelim)
|
|
AC_CHECK_FUNCS(fgets)
|
|
AC_CHECK_FUNCS(yylex)
|
|
|
|
# check if -lsocket && -lxnet is required to compile socket stuff
|
|
AC_SEARCH_LIBS(socket,socket)
|
|
AC_SEARCH_LIBS(inet_addr,nsl xnet)
|
|
|
|
# Macro definitions
|
|
###################
|
|
|
|
# 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_CACHE_CHECK(whether $$1 accepts -$2,sdcc_cv_$1$2,
|
|
cat >_test_.c <<EOF
|
|
#include <stdio.h>
|
|
void main(void) {}
|
|
EOF
|
|
$$1 -v -$2 -c _test_.c 1>&5 2>&5
|
|
if test "$?" = "0"; then
|
|
sdcc_cv_$1$2="yes"
|
|
else
|
|
sdcc_cv_$1$2="no"
|
|
fi
|
|
rm -f _test_.* a.out)
|
|
])
|
|
|
|
|
|
# Checking characteristics of compilers and other programs
|
|
# --------------------------------------------------------
|
|
AC_CACHE_CHECK(whether preprocessor accepts -MM or -M,sdcc_cv_MM,
|
|
echo "#include <stdio.h>" >_test_.c
|
|
echo "" >>_test_.c
|
|
$CPP -v -MM _test_.c 1>&5 2>&5
|
|
if test "$?" = "0"; then
|
|
sdcc_cv_MM="-MM"
|
|
else
|
|
sdcc_cv_MM="-M"
|
|
fi
|
|
rm -f _test_.*)
|
|
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)
|
|
if test "$sdcc_cv_CCggdb" = "yes"; then
|
|
CFLAGS="-ggdb -O2"
|
|
fi
|
|
|
|
DD_COPT(CC, pipe)
|
|
if test "$sdcc_cv_CCpipe" = "yes"; then
|
|
CFLAGS="$CFLAGS -pipe"
|
|
fi
|
|
|
|
|
|
# Checks for typedefs, structures, and compiler characteristics.
|
|
# ===========================================================================
|
|
AC_TYPE_SIGNAL
|
|
|
|
#
|
|
#
|
|
if test "${prefix}" = "NONE"; then
|
|
prefix="/usr/local"
|
|
fi
|
|
|
|
config_in=`pwd`
|
|
sdcc_datadir=${datadir}/sdcc
|
|
AC_SUBST(sdcc_datadir)
|
|
|
|
# For some unknown reason, putting this assignment in a subshell
|
|
# like this causes the rvalue to be fully substituted. We need this
|
|
# for the defines below to generate the right thing. We keep this
|
|
# separate from the substituted sdcc_datadir because we want the
|
|
# latter for makefiles.
|
|
if test "${datadir}" = "\${prefix}/share"; then
|
|
sdcc_datadir_tmp=${prefix}/share/sdcc
|
|
else
|
|
sdcc_datadir_tmp=${datadir}/sdcc
|
|
fi
|
|
|
|
|
|
AC_DEFINE_UNQUOTED(STANDARD_INCLUDE_DIR, "${sdcc_datadir_tmp}/include")
|
|
AC_DEFINE_UNQUOTED(SDCC_INCLUDE_DIR, "${sdcc_datadir_tmp}/include")
|
|
AC_DEFINE_UNQUOTED(SDCC_LIB_DIR, "${sdcc_datadir_tmp}/lib")
|
|
AC_DEFINE_UNQUOTED(STD_LIB, "libsdcc")
|
|
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(PREFIX, "${prefix}")
|
|
AC_DEFINE_UNQUOTED(DATADIR, "${sdcc_datadir_tmp}")
|
|
AC_DEFINE_UNQUOTED(SRCDIR, "${config_in}")
|
|
|
|
|
|
|
|
# Now handle the port selection
|
|
rm -f ports.all ports.build
|
|
AC_ARG_ENABLE(mcs51-port,[ --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)
|
|
fi
|
|
|
|
AC_ARG_ENABLE(gbz80-port,[ --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)
|
|
fi
|
|
|
|
AC_ARG_ENABLE(z80-port,[ --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)
|
|
fi
|
|
|
|
AC_ARG_ENABLE(avr-port,[ --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)
|
|
fi
|
|
|
|
AC_ARG_ENABLE(ds390-port,[ --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)
|
|
else
|
|
echo ds390 >>ports.build
|
|
AC_DEFINE_UNQUOTED(OPT_DISABLE_DS390, 0)
|
|
fi
|
|
|
|
AC_ARG_ENABLE(pic-port,[ --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)
|
|
fi
|
|
|
|
AC_ARG_ENABLE(i186-port,[ --disable-i186-port Excludes the I186 port])
|
|
echo izt >>ports.all
|
|
if test "$enable_i186_port" = "no"; then
|
|
AC_DEFINE_UNQUOTED(OPT_DISABLE_I186, 1)
|
|
else
|
|
echo izt >>ports.build
|
|
AC_DEFINE_UNQUOTED(OPT_DISABLE_I186, 0)
|
|
fi
|
|
|
|
AC_ARG_ENABLE(tlcs900h-port,[ --disable-tlcs900h-port Excludes the TLCS900H port])
|
|
echo izt >>ports.all
|
|
if test "$enable_tlcs900h_port" = "no"; then
|
|
AC_DEFINE_UNQUOTED(OPT_DISABLE_TLCS900H, 1)
|
|
else
|
|
echo izt >>ports.build
|
|
AC_DEFINE_UNQUOTED(OPT_DISABLE_TLCS900H, 0)
|
|
fi
|
|
|
|
AC_ARG_ENABLE(ucsim,[ --disable-ucsim Disables configuring and building of ucsim])
|
|
OPT_ENABLE_UCSIM=$enable_ucsim
|
|
AC_SUBST(OPT_ENABLE_UCSIM)
|
|
|
|
AC_ARG_ENABLE(device-lib-build,[ --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,[ --disable-packihx Disables building packihx])
|
|
OPT_ENABLE_PACKIHX=$enable_packihx
|
|
AC_SUBST(OPT_ENABLE_PACKIHX)
|
|
|
|
AC_ARG_ENABLE(libgc,[ --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
|
|
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
|
|
|
|
# Generating output files
|
|
# ===========================================================================
|
|
AC_CONFIG_SUBDIRS(support/cpp2)
|
|
AC_CONFIG_SUBDIRS(packihx)
|
|
AC_CONFIG_SUBDIRS(sim/ucsim)
|
|
# MLH: removed as the rules are already in Makefile.common
|
|
#as/z80/Makefile
|
|
#link/z80/Makefile
|
|
AC_OUTPUT(main.mk:main_in.mk
|
|
src/Makefile
|
|
as/mcs51/Makefile
|
|
device/include/Makefile
|
|
device/lib/Makefile
|
|
debugger/mcs51/Makefile
|
|
Makefile.common:Makefile.common.in
|
|
)
|
|
|
|
# End of configure/configure.in
|