5 AC_CONFIG_SRCDIR([Makefile.in])
6 AC_CONFIG_HEADER(config.h)
12 # ===========================================================================
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, :)
25 # Checking for header files.
26 # ===========================================================================
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)
34 # Checking for functions/libs
35 # ===========================================================================
36 if test $socket_type = winsock2_h; then
39 AC_CHECK_LIB(socket,socket)
40 AC_CHECK_LIB(nsl,xdr_short)
45 # ===========================================================================
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)
51 AC_DEFUN(adl_DD_COPT, [
52 AC_CACHE_CHECK(whether $$1 accepts -$2,sdcc_cv_$1$2,
57 $$1 -v -$2 -c _test_.c 1>&5 2>&5
58 if test "$?" = "0"; then
66 # This macro expands DIR and assigns it to RET.
67 # If DIR is NONE, then it's replaced by DEFAULT.
69 # Based on AC_DEFINE_DIR
73 # adl_EXPAND(prefix, "/usr/local", expanded_prefix)
75 AC_DEFUN([adl_EXPAND], [
76 test "x$prefix" = xNONE && prefix="$ac_default_prefix"
77 test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
79 test "x$ac_expand" = xNONE && ac_expand="[$]$2"
80 ac_expand=`eval echo [$]ac_expand`
81 $3=`eval echo [$]ac_expand`
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).
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.
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
100 dnl Available from the GNU Autoconf Macro Archive at:
101 dnl http://www.gnu.org/software/ac-archive/htmldoc/normpath.html
103 AC_DEFUN([adl_NORMALIZE_PATH],
105 dnl change empty paths to '.'
107 dnl strip trailing slashes
108 :*[[\\/]]:) $1=`echo "[$]$1" | sed 's,[[\\/]]*[$],,'` ;;
111 dnl squeze repeated slashes
112 case ifelse($2,,"[$]$1",$2) in
113 dnl if the path contains any backslashes, turn slashes into backslashes
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,^[[\\/]],\\\\\\\\,'` ;;
123 dnl if the path contains slashes, also turn backslashes into slashes
124 *) $1=`echo "[$]$1" | sed 's,\(.\)[[\\/]][[\\/]]*,\1/,g'` ;;
128 dnl adl_NORMALIZE_DEFINE_UNQUOTED(var, DEFINE, REFERENCE_STRING)
129 AC_DEFUN([adl_NORMALIZE_DEFINE_UNQUOTED], [
131 adl_NORMALIZE_PATH([ac_ndu], [$]$3)
132 AC_DEFINE_UNQUOTED($2, "${ac_ndu}")
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
141 $CPP -v -MM _test_.c 1>&5 2>&5
142 if test "$?" = "0"; then
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}"
157 adl_DD_COPT(CC, pipe)
158 if test "$sdcc_cv_CCpipe" = "yes"; then
159 CFLAGS="-pipe $CFLAGS"
163 # Set standard installation paths
164 # ===========================================================================
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()
171 # In sdccconf.h the '/' in paths can be replaced by "\\" (normalized), if
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="/"
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"
190 AC_SUBST(lib_dir_suffix)
197 AC_DEFINE_UNQUOTED(DIR_SEPARATOR_STRING, "${sdccconf_h_dir_separator}")
200 # default: "${prefix}/share"
201 adl_EXPAND(datadir, "NONE", expanded_datadir)
202 adl_NORMALIZE_DEFINE_UNQUOTED(expanded_datadir, DATADIR, sdccconf_h_dir_separator)
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}")
211 # Generating output files
212 # ===========================================================================
213 AC_CONFIG_FILES([Makefile])
216 # End of configure/configure.in