Imported Upstream version 2.9.0
[debian/cc1111] / debugger / mcs51 / configure.in
1 #!/bin/sh
2
3 AC_PREREQ(2.60)
4 AC_INIT
5 AC_CONFIG_SRCDIR([Makefile.in])
6 AC_CONFIG_HEADER(config.h)
7
8
9 wi_LIB_READLINE
10
11 # Required programs
12 # ===========================================================================
13 AC_PROG_CC
14 AC_PROG_CPP
15 AC_PROG_INSTALL
16 AC_PROG_RANLIB
17 AC_CHECK_PROG(AUTOCONF, autoconf, autoconf, :)
18 AC_CHECK_PROG(STRIP, strip, strip, :)
19 AC_CHECK_PROG(AS, as, as, :)
20 AC_CHECK_PROG(CP, cp, cp, :)
21
22 AC_LANG_C
23
24
25 # Checking for header files.
26 # ===========================================================================
27 socket_type=unknown
28 AC_CHECK_HEADERS(sys/socket.h, socket_type=sys_socket_h)
29 if test $socket_type = unknown; then
30   AC_CHECK_HEADERS(winsock2.h, socket_type=winsock2_h)
31 fi
32
33
34 # Checking for functions/libs
35 # ===========================================================================
36 if test $socket_type = winsock2_h; then
37   LIBS="-lws2_32 $LIBS"
38 else
39   AC_CHECK_LIB(socket,socket)
40   AC_CHECK_LIB(nsl,xdr_short)
41 fi
42
43
44 # Macro definitions
45 # ===========================================================================
46
47 # adl_DD_COPT macro checks if the compiler specified as the 1st parameter
48 # supports option specified as the 2nd parameter
49 # For example: DD_CPORT(CXX, fPIC)
50
51 AC_DEFUN(adl_DD_COPT, [
52 AC_CACHE_CHECK(whether $$1 accepts -$2,sdcc_cv_$1$2,
53 cat >_test_.c <<EOF
54 #include <stdio.h>
55 void main(void) {}
56 EOF
57 $$1 -v -$2 -c _test_.c 1>&5 2>&5
58 if test "$?" = "0"; then
59   sdcc_cv_$1$2="yes"
60 else
61   sdcc_cv_$1$2="no"
62 fi
63 rm -f _test_.* a.out)
64 ])
65
66 # This macro expands DIR and assigns it to RET.
67 # If DIR is NONE, then it's replaced by DEFAULT.
68 #
69 # Based on AC_DEFINE_DIR
70 #
71 # Examples:
72 #
73 #  adl_EXPAND(prefix, "/usr/local", expanded_prefix)
74
75 AC_DEFUN([adl_EXPAND], [
76   test "x$prefix" = xNONE && prefix="$ac_default_prefix"
77   test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
78   ac_expand=[$]$1
79   test "x$ac_expand" = xNONE && ac_expand="[$]$2"
80   ac_expand=`eval echo [$]ac_expand`
81   $3=`eval echo [$]ac_expand`
82 ])
83
84 # adl_NORMALIZE_PATH
85 #
86 #  - empty paths are changed to '.'
87 #  - trailing slashes are removed
88 #  - repeated slashes are squeezed except a leading doubled slash '//'
89 #    (which might indicate a networked disk on some OS).
90 #
91 #
92 # REFERENCE_STRING is used to turn '/' into '\' and vice-versa: if
93 # REFERENCE_STRING contains some backslashes, all slashes and backslashes
94 # are turned into backslashes, otherwise they are all turned into slashes.
95 #
96 # This makes processing of DOS filenames quite easier, because you can turn a
97 # filename to the Unix notation, make your processing, and turn it back to
98 # original notation.
99
100 dnl Available from the GNU Autoconf Macro Archive at:
101 dnl http://www.gnu.org/software/ac-archive/htmldoc/normpath.html
102 dnl
103 AC_DEFUN([adl_NORMALIZE_PATH],
104 [case ":[$]$1:" in
105 dnl change empty paths to '.'
106   ::) $1='.' ;;
107 dnl strip trailing slashes
108   :*[[\\/]]:) $1=`echo "[$]$1" | sed 's,[[\\/]]*[$],,'` ;;
109   :*:) ;;
110 esac
111 dnl squeze repeated slashes
112 case ifelse($2,,"[$]$1",$2) in
113 dnl if the path contains any backslashes, turn slashes into backslashes
114
115 dnl Bernhard Held 2003-04-06
116 dnl This was the original line. It does not:
117 dnl - convert the first slash
118 dnl - replace a slash with a double-backslash
119 dnl *\\*) $1=`echo "[$]$1" | sed 's,\(.\)[[\\/]][[\\/]]*,\1\\\\,g'` ;;
120     *\\*) $1=`echo "[$]$1" | sed 's,\(.\)[[\\/]][[\\/]]*,\1\\\\\\\\,g
121                                   s,^[[\\/]],\\\\\\\\,'` ;;
122
123 dnl if the path contains slashes, also turn backslashes into slashes
124  *) $1=`echo "[$]$1" | sed 's,\(.\)[[\\/]][[\\/]]*,\1/,g'` ;;
125 esac])
126
127
128 dnl adl_NORMALIZE_DEFINE_UNQUOTED(var, DEFINE, REFERENCE_STRING)
129 AC_DEFUN([adl_NORMALIZE_DEFINE_UNQUOTED], [
130   ac_ndu=[$]$1
131   adl_NORMALIZE_PATH([ac_ndu], [$]$3)
132   AC_DEFINE_UNQUOTED($2, "${ac_ndu}")
133 ])
134
135
136 # Checking characteristics of compilers and other programs
137 # ===========================================================================
138 AC_CACHE_CHECK(whether preprocessor accepts -MM or -M,sdcc_cv_MM,
139 echo "#include <stdio.h>" >_test_.c
140 echo "" >>_test_.c
141 $CPP -v -MM _test_.c 1>&5 2>&5
142 if test "$?" = "0"; then
143   sdcc_cv_MM="-MM"
144 else
145   sdcc_cv_MM="-M"
146 fi
147 rm -f _test_.*)
148 M_OR_MM=$sdcc_cv_MM
149 AC_SUBST(M_OR_MM)
150
151 # This is the first time when CFLAGS are set/modified!!
152 adl_DD_COPT(CC, ggdb)
153 if test "$sdcc_cv_CCggdb" = "yes"; then
154   CFLAGS="-ggdb ${CFLAGS}"
155 fi
156
157 adl_DD_COPT(CC, pipe)
158 if test "$sdcc_cv_CCpipe" = "yes"; then
159   CFLAGS="-pipe $CFLAGS"
160 fi
161
162
163 # Set standard installation paths
164 # ===========================================================================
165
166 # In the Makefiles we need paths with '/' as directory separator, even if
167 # crosscompiling for Win32.
168 # And we want to preserve the macros (e.g. ${prefix}) in the Makefiles.
169 # The variables in the Makefiles are replaced by AC_SUBST()
170 #
171 # In sdccconf.h the '/' in paths can be replaced by "\\" (normalized), if
172 #
173 # The macros are expanded for the header.
174 # The variables in the header are replaced by AC_*DEFINE*()
175 # sdccconf_h_dir_separator contains a backslash.
176 AC_ARG_VAR(sdccconf_h_dir_separator, needed in sdccconf.h: either "/" (default) or "\\")
177 if test "x${sdccconf_h_dir_separator}" = "x"; then
178     sdccconf_h_dir_separator="/"
179 fi
180
181 # Makefiles
182 ###########
183
184 # lib_dir_suffix:
185 # *nix default: "sdcc/lib"
186 AC_ARG_VAR(lib_dir_suffix, appended to datadir to define SDCC's library root directory)
187 if test "${lib_dir_suffix}" = ""; then
188     lib_dir_suffix="sdcc/lib"
189 fi
190 AC_SUBST(lib_dir_suffix)
191
192 AC_SUBST(EXEEXT)
193
194 # sdccconf.h
195 ############
196
197 AC_DEFINE_UNQUOTED(DIR_SEPARATOR_STRING, "${sdccconf_h_dir_separator}")
198
199 # datadir:
200 # default: "${prefix}/share"
201 adl_EXPAND(datadir, "NONE", expanded_datadir)
202 adl_NORMALIZE_DEFINE_UNQUOTED(expanded_datadir, DATADIR, sdccconf_h_dir_separator)
203
204 # lib suffix
205 norm_lib_dir_suffix=${lib_dir_suffix}
206 adl_NORMALIZE_PATH([norm_lib_dir_suffix], [$sdccconf_h_dir_separator])
207 AC_DEFINE_UNQUOTED(LIB_DIR_SUFFIX,
208                    DIR_SEPARATOR_STRING "${norm_lib_dir_suffix}")
209
210
211 # Generating output files
212 # ===========================================================================
213 AC_CONFIG_FILES([Makefile])
214 AC_OUTPUT
215
216 # End of configure/configure.in