Skip to content

Commit 9f04648

Browse files
committed
sim: Move getopt checking inside SIM_AC_PLATFORM
This commit moves getopt declaration checker originally in sim/ configure.ac; added in commit 340aa4f ("sim: Check known getopt definition existence") to sim/m4/sim_ac_platform.m4 (inside the SIM_AC_PLATFORM macro). It also regenerates configuration files using the maintainer mode.
1 parent 7cbf359 commit 9f04648

File tree

3 files changed

+46
-42
lines changed

3 files changed

+46
-42
lines changed

sim/configure

Lines changed: 32 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -13517,6 +13517,38 @@ fi
1351713517

1351813518

1351913519

13520+
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a known getopt prototype in unistd.h" >&5
13521+
$as_echo_n "checking for a known getopt prototype in unistd.h... " >&6; }
13522+
if ${sim_cv_decl_getopt_unistd_h+:} false; then :
13523+
$as_echo_n "(cached) " >&6
13524+
else
13525+
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
13526+
/* end confdefs.h. */
13527+
#include <unistd.h>
13528+
int
13529+
main ()
13530+
{
13531+
extern int getopt (int, char *const*, const char *);
13532+
;
13533+
return 0;
13534+
}
13535+
_ACEOF
13536+
if ac_fn_c_try_compile "$LINENO"; then :
13537+
sim_cv_decl_getopt_unistd_h=yes
13538+
else
13539+
sim_cv_decl_getopt_unistd_h=no
13540+
fi
13541+
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
13542+
fi
13543+
13544+
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $sim_cv_decl_getopt_unistd_h" >&5
13545+
$as_echo "$sim_cv_decl_getopt_unistd_h" >&6; }
13546+
if test $sim_cv_decl_getopt_unistd_h = yes; then
13547+
13548+
$as_echo "#define HAVE_DECL_GETOPT 1" >>confdefs.h
13549+
13550+
fi
13551+
1352013552

1352113553

1352213554
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to enable maintainer-specific portions of Makefiles" >&5
@@ -16300,38 +16332,6 @@ $as_echo "${WARN_CFLAGS} ${WERROR_CFLAGS}" >&6; }
1630016332
fi
1630116333

1630216334

16303-
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a known getopt prototype in unistd.h" >&5
16304-
$as_echo_n "checking for a known getopt prototype in unistd.h... " >&6; }
16305-
if ${sim_cv_decl_getopt_unistd_h+:} false; then :
16306-
$as_echo_n "(cached) " >&6
16307-
else
16308-
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
16309-
/* end confdefs.h. */
16310-
#include <unistd.h>
16311-
int
16312-
main ()
16313-
{
16314-
extern int getopt (int, char *const*, const char *);
16315-
;
16316-
return 0;
16317-
}
16318-
_ACEOF
16319-
if ac_fn_c_try_compile "$LINENO"; then :
16320-
sim_cv_decl_getopt_unistd_h=yes
16321-
else
16322-
sim_cv_decl_getopt_unistd_h=no
16323-
fi
16324-
rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
16325-
fi
16326-
16327-
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $sim_cv_decl_getopt_unistd_h" >&5
16328-
$as_echo "$sim_cv_decl_getopt_unistd_h" >&6; }
16329-
if test $sim_cv_decl_getopt_unistd_h = yes; then
16330-
16331-
$as_echo "#define HAVE_DECL_GETOPT 1" >>confdefs.h
16332-
16333-
fi
16334-
1633516335

1633616336

1633716337

sim/configure.ac

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -187,16 +187,6 @@ SIM_AC_OPTION_STDIO
187187
SIM_AC_OPTION_TRACE
188188
SIM_AC_OPTION_WARNINGS
189189

190-
AC_MSG_CHECKING(for a known getopt prototype in unistd.h)
191-
AC_CACHE_VAL(sim_cv_decl_getopt_unistd_h,
192-
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <unistd.h>], [extern int getopt (int, char *const*, const char *);])],
193-
sim_cv_decl_getopt_unistd_h=yes, sim_cv_decl_getopt_unistd_h=no)])
194-
AC_MSG_RESULT($sim_cv_decl_getopt_unistd_h)
195-
if test $sim_cv_decl_getopt_unistd_h = yes; then
196-
AC_DEFINE([HAVE_DECL_GETOPT], 1,
197-
[Is the prototype for getopt in <unistd.h> in the expected format?])
198-
fi
199-
200190
dnl These are unfortunate. They are conditionally called by other sim macros
201191
dnl but always used by common/Make-common.in. So we have to subst here even
202192
dnl when the rest of the code is in the respective macros. Once we merge the

sim/m4/sim_ac_platform.m4

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,4 +201,18 @@ else
201201
fi
202202
AC_SUBST(READLINE_LIB)
203203
AC_SUBST(READLINE_CFLAGS)
204+
205+
dnl Determine whether we have a known getopt prototype in unistd.h
206+
dnl to make sure that we have correct getopt declaration on
207+
dnl include/getopt.h. The purpose of this is to sync with other Binutils
208+
dnl components and this logic is copied from ld/configure.ac.
209+
AC_MSG_CHECKING(for a known getopt prototype in unistd.h)
210+
AC_CACHE_VAL(sim_cv_decl_getopt_unistd_h,
211+
[AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include <unistd.h>], [extern int getopt (int, char *const*, const char *);])],
212+
sim_cv_decl_getopt_unistd_h=yes, sim_cv_decl_getopt_unistd_h=no)])
213+
AC_MSG_RESULT($sim_cv_decl_getopt_unistd_h)
214+
if test $sim_cv_decl_getopt_unistd_h = yes; then
215+
AC_DEFINE([HAVE_DECL_GETOPT], 1,
216+
[Is the prototype for getopt in <unistd.h> in the expected format?])
217+
fi
204218
])

0 commit comments

Comments
 (0)