Add support for specifying compiler options for mpers builds

Because some architectures are very, very special.

* configure.ac (cc_flags_m32, cc_flags_mx32): New variables. AC_SUBST
them.
* m4/mpers.m4 (MPERS_CFLAGS): Use instead of CFLAG, pushdef as
$cc_flags_$1.
Use mpers_name instead of CFLAG in AC_CACHE_CHECK messages.
Pass MPERS_CFLAGS as the second argument to mpers_test.sh
* mpers.sh: Add CC_ARCH_FLAGS as the second argument (PARSER_FILE
is moved to the third one). Do not expect leading dash in ARCH_FLAG
anymore.
* mpers_test.sh (mpers_cc_flags): New variable, initialise to the second
command line argument.
Pass $mpers_name without leading dash to mpers.sh.
Pass $mpers_cc_flags as the second argument to mpers.sh ($sample is
the third argument now).
* Makefile.am (mpers-m%.stamp:): Pass $(mpers_CC_FLAGS) as the second
argument to mpers.sh ($$f is now the third argument).
($(mpers_m32_targets)): Define target variable mpers_CC_FLAGS with the
value of @cc_flags_m32@
($(mpers_mx32_targets)): Define target variable mpers_CC_FLAGS with the
value of @cc_flags_mx32@
* tests/Makefile.am (MERS_CC_FLAGS): New variable.
* bootstrap: Append @cc_flags_$1@ to MPERS_CC_FLAGS. Append
$(MPERS_CC_FLAGS) to ARCH_MFLAGS.
This commit is contained in:
Eugene Syromyatnikov 2018-01-10 20:17:42 +00:00
parent 114c7d3e80
commit 558ece68c8
7 changed files with 27 additions and 15 deletions

View File

@ -1002,7 +1002,7 @@ mpers-m%.stamp: $(srcdir_mpers_source_files) | printers.h
CFLAGS="$(mpers_sh_opts) -DMPERS_IS_$(mpers_NAME)" \
CPP="$(CPP)" \
CPPFLAGS="$(mpers_sh_opts) -DIN_MPERS -DMPERS_IS_$(mpers_NAME)" \
$(srcdir)/mpers.sh -$(mpers_NAME) $$f || exit; \
$(srcdir)/mpers.sh $(mpers_NAME) $(mpers_CC_FLAGS) $$f || exit; \
done
> $@
@ -1073,6 +1073,7 @@ BUILT_SOURCES += $(mpers_m32_targets)
CLEANFILES += $(mpers_m32_targets)
$(mpers_m32_targets): mpers_NAME = m32
$(mpers_m32_targets): mpers_CC_FLAGS = @cc_flags_m32@
endif # HAVE_M32_MPERS
@ -1089,6 +1090,7 @@ BUILT_SOURCES += $(mpers_mx32_targets)
CLEANFILES += $(mpers_mx32_targets)
$(mpers_mx32_targets): mpers_NAME = mx32
$(mpers_mx32_targets): mpers_CC_FLAGS = @cc_flags_mx32@
endif # HAVE_MX32_MPERS

View File

@ -12,7 +12,8 @@ for m in m32 mx32; do
s='[[:space:]]*'
sed "s/@arch@/@arch_$m@/;
s/^MPERS_NAME$s=.*/& $m/;
s/^ARCH_MFLAGS$s=.*/& -DMPERS_IS_\$(MPERS_NAME) -$m/" \
s/^MPERS_CC_FLAGS$s=.*/& @cc_flags_$m@/;
s/^ARCH_MFLAGS$s=.*/& -DMPERS_IS_\$(MPERS_NAME) \$(MPERS_CC_FLAGS)/" \
tests/Makefile.am > $tests/Makefile.am
for f in tests/*; do
case "${f##*/}" in

View File

@ -71,6 +71,8 @@ AC_SUBST([MANPAGE_DATE], [manpage_date])
AC_MSG_CHECKING([for supported architecture])
arch_m32=
arch_mx32=
cc_flags_m32=-m32
cc_flags_mx32=-mx32
case "$host_cpu" in
bfin)
arch=bfin
@ -222,6 +224,8 @@ test -n "$arch_mx32" ||
AC_SUBST(arch)
AC_SUBST(arch_m32)
AC_SUBST(arch_mx32)
AC_SUBST(cc_flags_m32)
AC_SUBST(cc_flags_mx32)
AC_SUBST(arch_native)
MIPS_ABI=

View File

@ -82,7 +82,7 @@ pushdef([mpers_name], [$1])
pushdef([MPERS_NAME], translit([$1], [a-z], [A-Z]))
pushdef([HAVE_MPERS], [HAVE_]MPERS_NAME[_MPERS])
pushdef([HAVE_RUNTIME], [HAVE_]MPERS_NAME[_RUNTIME])
pushdef([CFLAG], [-$1])
pushdef([MPERS_CFLAGS], [$cc_flags_$1])
pushdef([st_cv_cc], [st_cv_$1_cc])
pushdef([st_cv_runtime], [st_cv_$1_runtime])
pushdef([st_cv_mpers], [st_cv_$1_mpers])
@ -106,30 +106,32 @@ case "$arch" in
IFLAG=-I.])
popdef([gnu_stubs])
saved_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS CFLAG $IFLAG"
AC_CACHE_CHECK([for CFLAG compile support], [st_cv_cc],
CFLAGS="$CFLAGS MPERS_CFLAGS $IFLAG"
AC_CACHE_CHECK([for mpers_name personality compile support], [st_cv_cc],
[AC_COMPILE_IFELSE([AC_LANG_SOURCE([[#include <stdint.h>
int main(){return 0;}]])],
[st_cv_cc=yes],
[st_cv_cc=no])])
if test $st_cv_cc = yes; then
AC_CACHE_CHECK([for CFLAG runtime support], [st_cv_runtime],
AC_CACHE_CHECK([for mpers_name personality runtime support],
[st_cv_runtime],
[AC_RUN_IFELSE([AC_LANG_SOURCE([[#include <stdint.h>
int main(){return 0;}]])],
[st_cv_runtime=yes],
[st_cv_runtime=no],
[st_cv_runtime=no])])
AC_CACHE_CHECK([whether mpers.sh CFLAG works], [st_cv_mpers],
AC_CACHE_CHECK([whether mpers.sh mpers_name MPERS_CFLAGS works],
[st_cv_mpers],
[if READELF="$READELF" \
CC="$CC" CPP="$CPP" CPPFLAGS="$CPPFLAGS" \
$srcdir/mpers_test.sh [$1]; then
$srcdir/mpers_test.sh [$1] MPERS_CFLAGS; then
st_cv_mpers=yes
else
st_cv_mpers=no
fi])
if test $st_cv_mpers = yes; then
AC_DEFINE(HAVE_MPERS, [1],
[Define to 1 if you have CFLAG mpers support])
[Define to 1 if you have mpers_name mpers support])
st_MPERS_STRUCT_STAT([])
st_MPERS_STRUCT_STAT([64])
@ -176,7 +178,7 @@ AM_CONDITIONAL(HAVE_MPERS, [test "$st_cv_mpers" = yes])
popdef([st_cv_mpers])
popdef([st_cv_runtime])
popdef([st_cv_cc])
popdef([CFLAG])
popdef([MPERS_CFLAGS])
popdef([HAVE_RUNTIME])
popdef([HAVE_MPERS])
popdef([MPERS_NAME])

View File

@ -30,7 +30,8 @@ export LC_ALL=C
MPERS_AWK="${0%/*}/mpers.awk"
ARCH_FLAG=$1
PARSER_FILE=$2
CC_ARCH_FLAG=$2
PARSER_FILE=$3
READELF="${READELF:-readelf}"
CC="${CC-gcc}"
@ -39,7 +40,7 @@ CPP="${CPP-$CC -E}"
CPPFLAGS="$CPPFLAGS -MM -MG"
VAR_NAME='mpers_target_var'
BITS_DIR="mpers${ARCH_FLAG}"
BITS_DIR="mpers-${ARCH_FLAG}"
mkdir -p ${BITS_DIR}
set -- $(sed -r -n \
@ -62,7 +63,7 @@ for m_type; do
grep -F -q "${m_type}.h" "${f_i}" ||
continue
sed -i -e '/DEF_MPERS_TYPE/d' "${f_c}"
$CC $CFLAGS $ARCH_FLAG "${f_c}" -o "${f_o}"
$CC $CFLAGS $CC_ARCH_FLAG "${f_c}" -o "${f_o}"
$READELF --debug-dump=info "${f_o}" > "${f_d1}"
sed -r -n '
/^[[:space:]]*<1>/,/^[[:space:]]*<1><[^>]+>: Abbrev Number: 0/!d
@ -71,6 +72,6 @@ for m_type; do
s/^[[:space:]]*((<[[:xdigit:]]+>){2}):[[:space:]]+/\1\n/
s/[[:space:]]+$//
p' "${f_d1}" > "${f_d2}"
gawk -v VAR_NAME="$VAR_NAME" -v ARCH_FLAG="${ARCH_FLAG#-}" \
gawk -v VAR_NAME="$VAR_NAME" -v ARCH_FLAG="${ARCH_FLAG}" \
-f "$MPERS_AWK" "${f_d2}" > "${f_h}"
done

View File

@ -28,6 +28,7 @@
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
mpers_name="$1"; shift
mpers_cc_flags="$1"; shift
size="$(printf %s "$mpers_name" |tr -cd '[0-9]')"
[ "$size" -gt 0 ]
@ -124,5 +125,5 @@ EOF
CFLAGS="$CPPFLAGS -I${srcdir} -DMPERS_IS_${mpers_name}" \
CPPFLAGS="$CPPFLAGS -I${srcdir} -DIN_MPERS -DMPERS_IS_${mpers_name}" \
"$mpers_sh" "-$mpers_name" "$sample"
"$mpers_sh" "$mpers_name" "$mpers_cc_flags" "$sample"
cmp "$expected" "$mpers_dir"/sample_struct.h > /dev/null

View File

@ -30,6 +30,7 @@ OS = linux
ARCH = @arch@
NATIVE_ARCH = @arch_native@
MPERS_NAME =
MPERS_CC_FLAGS =
ARCH_MFLAGS =
AM_CFLAGS = $(WARN_CFLAGS)
AM_CPPFLAGS = $(ARCH_MFLAGS) \