4 AC_CONFIG_HEADER(sdccconf.h:sdccconf_in.h)
8 AC_MSG_CHECKING(version of the package)
9 if test -f .version; then
10 VERSION=`cat .version`
11 elif test -f ../.version; then
12 VERSION=`cat ../.version`
16 VERSIONHI=`echo $VERSION|$AWK 'BEGIN {FS="."} {print $1}'`
17 VERSIONLO=`echo $VERSION|$AWK 'BEGIN {FS="."} {print $2}'`
18 VERSIONP=`echo $VERSION|$AWK 'BEGIN {FS="."} {print $3}'`
19 # Assume no special extension
22 AC_MSG_RESULT(${VERSION})
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}")
32 sdcc_cv_version=$VERSION
33 sdcc_cv_versionhi=$VERSIONHI
34 sdcc_cv_versionlo=$VERSIONLO
35 sdcc_cv_versionp=$VERSIONP
45 AC_CHECK_PROG(YACC, bison, bison -y, :)
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, :)
51 AC_DEFUN(SDCC_REQUIRE_PROG,
52 [if test "$1" = ":"; then
53 AC_MSG_ERROR([Cannot find required program $2.])
57 SDCC_REQUIRE_PROG($YACC, bison)
58 SDCC_REQUIRE_PROG($LEX, lex)
62 # Checking for header files.
63 # ===========================================================================
65 AC_CHECK_HEADERS(getopt.h)
66 AC_CHECK_HEADERS(unistd.h)
67 AC_CHECK_HEADERS(endian.h)
68 AC_CHECK_HEADERS(machine/endian.h)
69 AC_CHECK_HEADERS(malloc.h)
70 AC_CHECK_HEADERS(sys/isa_defs.h)
71 AC_CHECK_HEADERS(sys/socket.h)
74 # This must be after CPP
76 AC_CACHE_CHECK(which header file defines FD_ macros, s51_cv_fd,
82 #endif], sdcc_cv_fd="<sys/time.h>")
84 #include <sys/types.h>
87 #endif], sdcc_cv_fd="<sys/types.h>")
89 #include <sys/select.h>
92 #endif], sdcc_cv_fd="<sys/types.h>")])
94 AC_DEFINE(FD_HEADER_OK, 0)
95 if echo $sdcc_cv_fd|grep time >/dev/null 2>&1; then
96 AC_DEFINE(FD_NEED_TIME_H, 1)
97 AC_DEFINE(FD_HEADER_OK, 1)
99 AC_DEFINE(FD_NEED_TIME_H, 0)
101 if echo $sdcc_cv_fd|grep types >/dev/null 2>&1; then
102 AC_DEFINE(FD_NEED_TYPES_H, 1)
103 AC_DEFINE(FD_HEADER_OK, 1)
105 AC_DEFINE(FD_NEED_TYPES_H, 0)
107 if echo $sdcc_cv_fd|grep select >/dev/null 2>&1; then
108 AC_DEFINE(FD_NEED_SELECT_H, 1)
109 AC_DEFINE(FD_HEADER_OK, 1)
111 AC_DEFINE(FD_NEED_SELECT_H, 0)
114 AC_DEFINE_UNQUOTED(HEADER_FD, ${sdcc_cv_fd})
117 # Checking for functions
118 # ===========================================================================
119 AC_CHECK_FUNCS(strlen strcpy strcat strstr strcmp strerror strtok strdup)
120 AC_CHECK_FUNCS(strchr memcpy vsnprintf snprintf vsprintf)
121 AC_CHECK_FUNCS(mkstemp)
122 dnl AC_CHECK_FUNCS(getline)
123 dnl AC_CHECK_FUNCS(getdelim)
124 AC_CHECK_FUNCS(fgets)
125 AC_CHECK_FUNCS(yylex)
127 # check if -lsocket && -lxnet is required to compile socket stuff
128 AC_SEARCH_LIBS(socket,socket)
129 AC_SEARCH_LIBS(inet_addr,nsl xnet)
134 # DD_COPT macro checks if the compiler specified as the 1st parameter
135 # supports option specified as the 2nd parameter
136 # For example: DD_CPORT(CXX, fPIC)
139 AC_CACHE_CHECK(whether $$1 accepts -$2,sdcc_cv_$1$2,
144 $$1 -v -$2 -c _test_.c 1>&5 2>&5
145 if test "$?" = "0"; then
150 rm -f _test_.* a.out)
154 # Checking characteristics of compilers and other programs
155 # --------------------------------------------------------
156 AC_CACHE_CHECK(whether preprocessor accepts -MM or -M,sdcc_cv_MM,
157 echo "#include <stdio.h>" >_test_.c
159 $CPP -v -MM _test_.c 1>&5 2>&5
160 if test "$?" = "0"; then
169 # This is the first time when CFLAGS are set/modified!!
171 if test "$sdcc_cv_CCggdb" = "yes"; then
176 if test "$sdcc_cv_CCpipe" = "yes"; then
177 CFLAGS="$CFLAGS -pipe"
181 # Checks for typedefs, structures, and compiler characteristics.
182 # ===========================================================================
185 if test "$cross_compiling" = "no"; then
186 AC_CHECK_SIZEOF(char)
187 AC_CHECK_SIZEOF(short)
189 AC_CHECK_SIZEOF(long)
191 if $CXX -v 2>&1|grep "mingw" >/dev/null 2>&1; then
204 if expr "$ac_cv_sizeof_char" '>=' "$1" >/dev/null; then
208 if expr "$ac_cv_sizeof_short" '>=' "$1" >/dev/null; then
212 if expr "$ac_cv_sizeof_int" '>=' "$1" >/dev/null; then
216 if expr "$ac_cv_sizeof_long" '>=' "$1" >/dev/null; then
223 AC_MSG_CHECKING(type name for byte)
224 TYPE_BYTE=`type_name 1`
225 AC_MSG_RESULT($TYPE_BYTE)
226 AC_MSG_CHECKING(type name for word)
227 TYPE_WORD=`type_name 2`
228 AC_MSG_RESULT($TYPE_WORD)
229 AC_MSG_CHECKING(type name for dword)
230 TYPE_DWORD=`type_name 4`
231 AC_MSG_RESULT($TYPE_DWORD)
232 AC_DEFINE_UNQUOTED(TYPE_BYTE, $TYPE_BYTE)
233 AC_DEFINE_UNQUOTED(TYPE_WORD, $TYPE_WORD)
234 AC_DEFINE_UNQUOTED(TYPE_DWORD, $TYPE_DWORD)
239 if test "${prefix}" = "NONE"; then
244 sdcc_datadir=${datadir}/sdcc
245 AC_SUBST(sdcc_datadir)
247 # For some unknown reason, putting this assignment in a subshell
248 # like this causes the rvalue to be fully substituted. We need this
249 # for the defines below to generate the right thing. We keep this
250 # separate from the substituted sdcc_datadir because we want the
251 # latter for makefiles.
252 if test "${datadir}" = "\${prefix}/share"; then
253 sdcc_datadir_tmp=${prefix}/share/sdcc
255 sdcc_datadir_tmp=${datadir}/sdcc
258 if test "${includedir}" = "\${prefix}/include"; then
259 AC_DEFINE_UNQUOTED(STANDARD_INCLUDE_DIR, "${sdcc_datadir_tmp}/include")
260 AC_DEFINE_UNQUOTED(SDCC_INCLUDE_DIR, "${sdcc_datadir_tmp}/include")
262 AC_DEFINE_UNQUOTED(STANDARD_INCLUDE_DIR, "${includedir}")
263 AC_DEFINE_UNQUOTED(SDCC_INCLUDE_DIR, "${includedir}")
266 AC_DEFINE_UNQUOTED(SDCC_LIB_DIR, "${sdcc_datadir_tmp}/lib")
267 AC_DEFINE_UNQUOTED(STD_LIB, "libsdcc")
268 AC_DEFINE_UNQUOTED(STD_INT_LIB, "libint")
269 AC_DEFINE_UNQUOTED(STD_LONG_LIB, "liblong")
270 AC_DEFINE_UNQUOTED(STD_FP_LIB, "libfloat")
271 AC_DEFINE_UNQUOTED(STD_DS390_LIB, "libds390")
272 AC_DEFINE_UNQUOTED(STD_xa51_LIB, "xa51")
274 AC_DEFINE_UNQUOTED(PREFIX, "${prefix}")
275 AC_DEFINE_UNQUOTED(DATADIR, "${sdcc_datadir_tmp}")
276 AC_DEFINE_UNQUOTED(SRCDIR, "${config_in}")
280 # Now handle the port selection
281 rm -f ports.all ports.build
282 AC_ARG_ENABLE(mcs51-port,[ --disable-mcs51-port Excludes the Intel mcs51 port])
283 echo mcs51 >>ports.all
284 if test "$enable_mcs51_port" = "no"; then
285 AC_DEFINE_UNQUOTED(OPT_DISABLE_MCS51, 1)
287 echo mcs51 >>ports.build
288 AC_DEFINE_UNQUOTED(OPT_DISABLE_MCS51, 0)
291 AC_ARG_ENABLE(gbz80-port,[ --disable-gbz80-port Excludes the Gameboy gbz80 port])
293 if test "$enable_gbz80_port" = "no"; then
294 AC_DEFINE_UNQUOTED(OPT_DISABLE_GBZ80, 1)
296 echo z80 >>ports.build
297 AC_DEFINE_UNQUOTED(OPT_DISABLE_GBZ80, 0)
300 AC_ARG_ENABLE(z80-port,[ --disable-z80-port Excludes the z80 port])
302 if test "$enable_z80_port" = "no"; then
303 AC_DEFINE_UNQUOTED(OPT_DISABLE_Z80, 1)
305 echo z80 >>ports.build
306 AC_DEFINE_UNQUOTED(OPT_DISABLE_Z80, 0)
309 AC_ARG_ENABLE(avr-port,[ --disable-avr-port Excludes the AVR port])
311 if test "$enable_avr_port" = "no"; then
312 AC_DEFINE_UNQUOTED(OPT_DISABLE_AVR, 1)
314 echo avr >>ports.build
315 AC_DEFINE_UNQUOTED(OPT_DISABLE_AVR, 0)
318 AC_ARG_ENABLE(ds390-port,[ --disable-ds390-port Excludes the DS390 port])
319 echo ds390 >>ports.all
320 if test "$enable_ds390_port" = "no"; then
321 AC_DEFINE_UNQUOTED(OPT_DISABLE_DS390, 1)
322 AC_DEFINE_UNQUOTED(OPT_DISABLE_TININative, 1)
324 echo ds390 >>ports.build
325 AC_DEFINE_UNQUOTED(OPT_DISABLE_DS390, 0)
326 AC_DEFINE_UNQUOTED(OPT_DISABLE_TININative, 0)
329 AC_ARG_ENABLE(pic-port,[ --disable-pic-port Excludes the PIC port])
331 if test "$enable_pic_port" = "no"; then
332 AC_DEFINE_UNQUOTED(OPT_DISABLE_PIC, 1)
334 echo pic >>ports.build
335 AC_DEFINE_UNQUOTED(OPT_DISABLE_PIC, 0)
338 AC_ARG_ENABLE(xa51-port,[ --disable-xa51-port Excludes the XA51 port])
339 echo xa51 >>ports.all
340 if test "$enable_xa51_port" = "no"; then
341 AC_DEFINE_UNQUOTED(OPT_DISABLE_XA51, 1)
343 echo xa51 >>ports.build
344 AC_DEFINE_UNQUOTED(OPT_DISABLE_XA51, 0)
347 AC_ARG_ENABLE(ucsim,[ --disable-ucsim Disables configuring and building of ucsim])
348 OPT_ENABLE_UCSIM=$enable_ucsim
349 AC_SUBST(OPT_ENABLE_UCSIM)
351 AC_ARG_ENABLE(device-lib-build,[ --disable-device-lib-build Disables automatically building device libraries])
352 OPT_ENABLE_DEVICE_LIB_BUILD=$enable_device_lib_build
353 AC_SUBST(OPT_ENABLE_DEVICE_LIB_BUILD)
355 AC_ARG_ENABLE(packihx,[ --disable-packihx Disables building packihx])
356 OPT_ENABLE_PACKIHX=$enable_packihx
357 AC_SUBST(OPT_ENABLE_PACKIHX)
359 AC_ARG_ENABLE(libgc,[ --enable-libgc Use the Bohem memory allocator. Lower runtime footprint.])
360 if test "$enable_libgc" = "yes"; then
361 AC_CHECK_LIB(gc, GC_malloc)
366 AC_DEFINE_UNQUOTED(OPT_ENABLE_LIBGC, $OPT_ENABLE_LIBGC)
369 cat ports.all | uniq >ports
371 cat ports.build | uniq >ports
374 # Generating output files
375 # ===========================================================================
376 AC_CONFIG_SUBDIRS(support/cpp2)
377 AC_CONFIG_SUBDIRS(packihx)
378 AC_CONFIG_SUBDIRS(sim/ucsim)
379 # MLH: removed as the rules are already in Makefile.common
382 AC_OUTPUT(main.mk:main_in.mk
385 device/include/Makefile
387 debugger/mcs51/Makefile
388 Makefile.common:Makefile.common.in
391 # End of configure/configure.in