adjust for mach os-x support
[fw/sdcc] / configure.in
1 #!/bin/sh
2
3 AC_INIT(Makefile)
4 AC_CONFIG_HEADER(sdccconf.h:sdccconf_in.h)
5
6 AC_PROG_AWK
7
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`
13 else
14   VERSION="0.0.0"
15 fi
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
20 EXEEXT=`echo $EXEEXT`
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 # Required programs
38 #-------------------
39 AC_PROG_CC
40 AC_PROG_CXX
41 AC_PROG_CPP
42 AC_PROG_INSTALL
43 AC_PROG_RANLIB
44 AC_PROG_LEX(flex, :)
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, :)
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 # Checking for header files.
63 # ===========================================================================
64 AC_HEADER_STDC
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)
72 AC_HEADER_DIRENT
73
74 # This must be after CPP
75
76 AC_CACHE_CHECK(which header file defines FD_ macros, s51_cv_fd,
77 [sdcc_cv_fd="unknown"
78 AC_EGREP_CPP(yes, [
79 #include <sys/time.h>
80 #ifdef FD_ZERO
81 yes
82 #endif], sdcc_cv_fd="<sys/time.h>")
83 AC_EGREP_CPP(yes, [
84 #include <sys/types.h>
85 #ifdef FD_ZERO
86 yes
87 #endif], sdcc_cv_fd="<sys/types.h>")
88 AC_EGREP_CPP(yes, [
89 #include <sys/select.h>
90 #ifdef FD_ZERO
91 yes
92 #endif], sdcc_cv_fd="<sys/types.h>")])
93
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)
98 else
99 AC_DEFINE(FD_NEED_TIME_H, 0)
100 fi
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)
104 else
105 AC_DEFINE(FD_NEED_TYPES_H, 0)
106 fi
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)
110 else
111 AC_DEFINE(FD_NEED_SELECT_H, 0)
112 fi
113
114 AC_DEFINE_UNQUOTED(HEADER_FD, ${sdcc_cv_fd})
115
116
117 # Checking for functions
118 # ===========================================================================
119 AC_CHECK_FUNCS(strlen strcpy strcat strstr strcmp strerror strtok strdup)
120 AC_CHECK_FUNCS(strchr memcpy)
121 dnl AC_CHECK_FUNCS(getline)
122 dnl AC_CHECK_FUNCS(getdelim)
123 AC_CHECK_FUNCS(fgets)
124 AC_CHECK_FUNCS(yylex)
125
126 # check if -lsocket && -lxnet is required to compile socket stuff
127 AC_SEARCH_LIBS(socket,socket)
128 AC_SEARCH_LIBS(inet_addr,nsl xnet)
129
130 # Macro definitions
131 ###################
132
133 # DD_COPT macro checks if the compiler specified as the 1st parameter
134 # supports option specified as the 2nd parameter
135 # For example: DD_CPORT(CXX, fPIC)
136
137 AC_DEFUN(DD_COPT, [
138 AC_CACHE_CHECK(whether $$1 accepts -$2,sdcc_cv_$1$2,
139 cat >_test_.c <<EOF
140 #include <stdio.h>
141 void main(void) {}
142 EOF
143 $$1 -v -$2 -c _test_.c 1>&5 2>&5
144 if test "$?" = "0"; then
145   sdcc_cv_$1$2="yes"
146 else
147   sdcc_cv_$1$2="no"
148 fi
149 rm -f _test_.* a.out)
150 ])
151
152
153 # Checking characteristics of compilers and other programs
154 # --------------------------------------------------------
155 AC_CACHE_CHECK(whether preprocessor accepts -MM or -M,sdcc_cv_MM,
156 echo "#include <stdio.h>" >_test_.c
157 echo "" >>_test_.c
158 $CPP -v -MM _test_.c 1>&5 2>&5
159 if test "$?" = "0"; then
160   sdcc_cv_MM="-MM"
161 else
162   sdcc_cv_MM="-M"
163 fi
164 rm -f _test_.*)
165 M_OR_MM=$sdcc_cv_MM
166 AC_SUBST(M_OR_MM)
167
168 # This is the first time when CFLAGS are set/modified!!
169 DD_COPT(CC, ggdb)
170 if test "$sdcc_cv_CCggdb" = "yes"; then
171   CFLAGS="-ggdb -O2"
172 fi
173
174 DD_COPT(CC, pipe)
175 if test "$sdcc_cv_CCpipe" = "yes"; then
176   CFLAGS="$CFLAGS -pipe"
177 fi
178
179
180 # Checks for typedefs, structures, and compiler characteristics.
181 # ===========================================================================
182 AC_TYPE_SIGNAL
183
184 #
185 #
186 if test "${prefix}" = "NONE"; then
187     prefix="/usr/local"
188 fi
189
190 config_in=`pwd`
191 sdcc_datadir=${datadir}/sdcc
192 AC_SUBST(sdcc_datadir)
193
194 # For some unknown reason, putting this assignment in a subshell
195 # like this causes the rvalue to be fully substituted. We need this
196 # for the defines below to generate the right thing. We keep this
197 # separate from the substituted sdcc_datadir because we want the
198 # latter for makefiles.
199 if test "${datadir}" = "\${prefix}/share"; then
200     sdcc_datadir_tmp=${prefix}/share/sdcc
201 else
202     sdcc_datadir_tmp=${datadir}/sdcc
203 fi
204
205
206 AC_DEFINE_UNQUOTED(STANDARD_INCLUDE_DIR, "${sdcc_datadir_tmp}/include")
207 AC_DEFINE_UNQUOTED(SDCC_INCLUDE_DIR, "${sdcc_datadir_tmp}/include")
208 AC_DEFINE_UNQUOTED(SDCC_LIB_DIR, "${sdcc_datadir_tmp}/lib")
209 AC_DEFINE_UNQUOTED(STD_LIB, "libsdcc")
210 AC_DEFINE_UNQUOTED(STD_INT_LIB, "libint")
211 AC_DEFINE_UNQUOTED(STD_LONG_LIB, "liblong")
212 AC_DEFINE_UNQUOTED(STD_FP_LIB, "libfloat")
213 AC_DEFINE_UNQUOTED(STD_DS390_LIB, "libds390")
214
215 AC_DEFINE_UNQUOTED(PREFIX, "${prefix}")
216 AC_DEFINE_UNQUOTED(DATADIR, "${sdcc_datadir_tmp}")
217 AC_DEFINE_UNQUOTED(SRCDIR, "${config_in}")
218
219
220
221 # Now handle the port selection
222 rm -f ports.all ports.build
223 AC_ARG_ENABLE(mcs51-port,[  --disable-mcs51-port    Excludes the Intel mcs51 port])
224 echo mcs51 >>ports.all
225 if test "$enable_mcs51_port" = "no"; then
226     AC_DEFINE_UNQUOTED(OPT_DISABLE_MCS51, 1)
227 else
228     echo mcs51 >>ports.build
229     AC_DEFINE_UNQUOTED(OPT_DISABLE_MCS51, 0)
230 fi
231
232 AC_ARG_ENABLE(gbz80-port,[  --disable-gbz80-port    Excludes the Gameboy gbz80 port])
233 echo z80 >>ports.all
234 if test "$enable_gbz80_port" = "no"; then
235     AC_DEFINE_UNQUOTED(OPT_DISABLE_GBZ80, 1)
236 else
237     echo z80 >>ports.build
238     AC_DEFINE_UNQUOTED(OPT_DISABLE_GBZ80, 0)
239 fi
240
241 AC_ARG_ENABLE(z80-port,[  --disable-z80-port      Excludes the z80 port])
242 echo z80 >>ports.all
243 if test "$enable_z80_port" = "no"; then
244     AC_DEFINE_UNQUOTED(OPT_DISABLE_Z80, 1)
245 else
246     echo z80 >>ports.build
247     AC_DEFINE_UNQUOTED(OPT_DISABLE_Z80, 0)
248 fi
249
250 AC_ARG_ENABLE(avr-port,[  --disable-avr-port      Excludes the AVR port])
251 echo avr >>ports.all
252 if test "$enable_avr_port" = "no"; then
253     AC_DEFINE_UNQUOTED(OPT_DISABLE_AVR, 1)
254 else
255     echo avr >>ports.build
256     AC_DEFINE_UNQUOTED(OPT_DISABLE_AVR, 0)
257 fi
258
259 AC_ARG_ENABLE(ds390-port,[  --disable-ds390-port    Excludes the DS390 port])
260 echo ds390 >>ports.all
261 if test "$enable_ds390_port" = "no"; then
262     AC_DEFINE_UNQUOTED(OPT_DISABLE_DS390, 1)
263 else
264     echo ds390 >>ports.build
265     AC_DEFINE_UNQUOTED(OPT_DISABLE_DS390, 0)
266 fi
267
268 AC_ARG_ENABLE(pic-port,[  --disable-pic-port      Excludes the PIC port])
269 echo pic >>ports.all
270 if test "$enable_pic_port" = "no"; then
271     AC_DEFINE_UNQUOTED(OPT_DISABLE_PIC, 1)
272 else
273     echo pic >>ports.build
274     AC_DEFINE_UNQUOTED(OPT_DISABLE_PIC, 0)
275 fi
276
277 AC_ARG_ENABLE(i186-port,[  --disable-i186-port     Excludes the I186 port])
278 echo izt >>ports.all
279 if test "$enable_i186_port" = "no"; then
280     AC_DEFINE_UNQUOTED(OPT_DISABLE_I186, 1)
281 else
282     echo izt >>ports.build
283     AC_DEFINE_UNQUOTED(OPT_DISABLE_I186, 0)
284 fi
285
286 AC_ARG_ENABLE(tlcs900h-port,[  --disable-tlcs900h-port Excludes the TLCS900H port])
287 echo izt >>ports.all
288 if test "$enable_tlcs900h_port" = "no"; then
289     AC_DEFINE_UNQUOTED(OPT_DISABLE_TLCS900H, 1)
290 else
291     echo izt >>ports.build
292     AC_DEFINE_UNQUOTED(OPT_DISABLE_TLCS900H, 0)
293 fi
294
295 AC_ARG_ENABLE(ucsim,[  --disable-ucsim         Disables configuring and building of ucsim])
296 OPT_ENABLE_UCSIM=$enable_ucsim
297 AC_SUBST(OPT_ENABLE_UCSIM)
298
299 AC_ARG_ENABLE(device-lib-build,[  --disable-device-lib-build Disables automatically building device libraries])
300 OPT_ENABLE_DEVICE_LIB_BUILD=$enable_device_lib_build
301 AC_SUBST(OPT_ENABLE_DEVICE_LIB_BUILD)
302
303 AC_ARG_ENABLE(packihx,[  -disable-packihx     Disables building packihx])
304 OPT_ENABLE_PACKIHX=$enable_packihx
305 AC_SUBST(OPT_ENABLE_PACKIHX)
306
307 #remove duplicates
308 cat ports.all | uniq >ports
309 mv ports ports.all
310 cat ports.build | uniq >ports
311 mv ports ports.build
312
313 # Generating output files
314 # ===========================================================================
315 AC_CONFIG_SUBDIRS(support/cpp2)
316 AC_CONFIG_SUBDIRS(packihx)
317 AC_CONFIG_SUBDIRS(sim/ucsim)
318 # MLH: removed as the rules are already in Makefile.common
319 #as/z80/Makefile
320 #link/z80/Makefile
321 AC_OUTPUT(main.mk:main_in.mk
322 src/Makefile
323 as/mcs51/Makefile
324 support/cpp/Makefile
325 device/include/Makefile
326 device/lib/Makefile
327 debugger/mcs51/Makefile
328 Makefile.common:Makefile.common.in
329 )
330
331 # End of configure/configure.in