moar portability

This commit is contained in:
cathugger
2017-10-06 00:59:19 +00:00
parent 3bf616bee0
commit 0428ae301f
2 changed files with 47 additions and 3 deletions

View File

@@ -1,9 +1,9 @@
CC= @CC@ CC= @CC@
CSTD= -std=c99 -Wall -D_POSIX_C_SOURCE=200112L CSTD= @CSTD@ -Wall -D_POSIX_C_SOURCE=200112L
CFLAGS= $(CSTD) @CFLAGS@ -DED25519_@ED25519IMPL@ @MYDEFS@ CFLAGS= $(CSTD) @CFLAGS@ -DED25519_@ED25519IMPL@ @MYDEFS@
ASFLAGS= ASFLAGS=
LDFLAGS= -no-pie LDFLAGS= @NOPIE@
MV= mv MV= mv
ED25519_DEFS= -DED25519_ref10 -DED25519_amd64_51_30k -DED25519_amd64_64_24k -DED25519_donna ED25519_DEFS= -DED25519_ref10 -DED25519_amd64_51_30k -DED25519_amd64_64_24k -DED25519_donna

View File

@@ -2,9 +2,51 @@ AC_INIT(mkp224o)
# sanity check # sanity check
AC_CONFIG_SRCDIR([main.c]) AC_CONFIG_SRCDIR([main.c])
# C compiler # C compiler
: ${CFLAGS="-O3 -march=native -fomit-frame-pointer"} oldcflags="$CFLAGS"
AC_PROG_CC AC_PROG_CC
if test "x$oldcflags" != "x$CFLAGS"
then
oldcflags="-O3"
CFLAGS="-march=native"
AC_MSG_CHECKING([whether CC supports -march=native])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
[AC_MSG_RESULT([yes])]
[oldcflags="$oldcflags -march=native"],
[AC_MSG_RESULT([no])]
)
CFLAGS="-fomit-frame-pointer"
AC_MSG_CHECKING([whether CC supports -fomit-frame-pointer])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
[AC_MSG_RESULT([yes])]
[oldcflags="$oldcflags -fomit-frame-pointer"],
[AC_MSG_RESULT([no])]
)
CFLAGS="$oldcflags"
fi
cstd=""
oldcflags="$CFLAGS"
CFLAGS="-std=c99"
AC_MSG_CHECKING([whether CC supports -std=c99])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
[AC_MSG_RESULT([yes])]
[cstd="-std=c99"],
[AC_MSG_RESULT([no])]
)
CFLAGS="$oldcflags"
nopie=""
oldcflags="$CFLAGS"
CFLAGS="-no-pie"
AC_MSG_CHECKING([whether CC supports -no-pie])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([])],
[AC_MSG_RESULT([yes])]
[nopie="-no-pie"],
[AC_MSG_RESULT([no])]
)
CFLAGS="$oldcflags"
MYDEFS="" MYDEFS=""
ed25519impl="" ed25519impl=""
@@ -92,6 +134,8 @@ then
MYDEFS="$MYDEFS -DSTATISTICS" MYDEFS="$MYDEFS -DSTATISTICS"
fi fi
AC_SUBST(CSTD,["$cstd"])
AC_SUBST(ED25519IMPL,["$ed25519impl"]) AC_SUBST(ED25519IMPL,["$ed25519impl"])
AC_SUBST(MYDEFS,["$MYDEFS"]) AC_SUBST(MYDEFS,["$MYDEFS"])
AC_SUBST(NOPIE,["$nopie"])
AC_OUTPUT(Makefile) AC_OUTPUT(Makefile)