Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remake configure options #86

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
116 changes: 56 additions & 60 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -192,71 +192,67 @@ AC_ARG_WITH([libcoap-dir],
SAFEC_STUB_DIR='$(abs_top_builddir)/safe_c_stub'
AC_SUBST(SAFEC_STUB_DIR)
# check for each of the possible safec options
AC_ARG_WITH(system-libsafec,
AS_HELP_STRING([--with-system-libsafec],
[select to use libsafec installed in the system]),
[with_system_libsafec="yes"],
[with_system_libsafec="no"])

AC_ARG_WITH([safec-dir],
[AS_HELP_STRING([--with-safec-dir=],
[AS_HELP_STRING([--with-safec-dir],
[location of SAFEC private installation])],
[safecdir="$withval"],
[safecdir="no"])

AC_ARG_ENABLE(safec,
[AS_HELP_STRING([--disable-safec],
[disable SAFEC use: **WARNING** this is not recommended])],
[disable_safec="yes"],
[disable_safec="no"])

AC_MSG_CHECKING(which libsafec to use)
if test "x$with_system_libsafec" = "xyes"; then

AC_MSG_RESULT(system installation);

PKG_CHECK_MODULES([libsafec], [libsafec])
LIBS="$LIBS $libsafec_LIBS"
CFLAGS="$CFLAGS $libsafec_CFLAGS"
CPPFLAGS="$CPPFLAGS $libsafec_CFLAGS"

AC_DEFINE([SYSTEM_LIBSAFEC],[1],[Define if using system installed SafeC])

else if test "x$safecdir" != "xno"; then

# a local installation of safec has been specified
AC_MSG_RESULT(private installation);

AC_SUBST([SAFEC_DIR], "$safecdir")
AC_SUBST([SAFEC_CFLAGS], "$safecdir/include")
AC_SUBST([SAFEC_LDFLAGS], "$safecdir/lib")
LDFLAGS="$LDFLAGS -L$safecdir/lib"
[],
[with_safec_dir="no"])
AC_ARG_WITH([libsafec],
[AS_HELP_STRING([--with-libsafec=system|builtin],
[choose libsafec installed in the system or builtin [default=builtin]])],
[],
[with_libsafec="builtin"])

# make sure it's there and linkable.
AC_CHECK_LIB([ciscosafec], [memset_s],
[], [AC_MSG_FAILURE([can't find CiscoSafeC lib])] [])
AS_IF([test "$with_libsafec" != "no" -a "$with_safec_dir" != "no"],
[AC_MSG_FAILURE([both --with-libsafec and --with-safec-dir options specified])])

AC_DEFINE([CISCO_LIBSAFEC],[1],[Define if using Cisco installed SafeC])
AS_IF([test "$with_libsafec" = "no" -a "$with_safec_dir" = "no"],
[AC_MSG_FAILURE([no libsafec option specified. Must be one of: --with-libsafec=system|builtin, --with-safec-dir])])

else if test "x$disable_safec" = "xyes"; then

AC_MSG_RESULT(builtin);

safecdir="$SAFEC_STUB_DIR"
AC_SUBST([SAFEC_DIR], "$safecdir")
AC_SUBST([SAFEC_CFLAGS], "$safecdir/include")
AC_SUBST([SAFEC_LDFLAGS], "$safecdir/lib")
LDFLAGS="$LDFLAGS -L$safecdir/lib"
LIBS="$LIBS -lsafe_lib"

else

AC_MSG_RESULT();
AC_MSG_FAILURE([No libsafec option specified. Must be one of: --with-system-libsafec, --with-safec-dir, --disable-safec])

fi
fi
fi
AC_MSG_CHECKING(which libsafec to use)
AS_CASE("$with_libsafec",
[system], [
AC_MSG_RESULT(system installation);

PKG_CHECK_MODULES([libsafec], [libsafec])
LIBS="$LIBS $libsafec_LIBS"
CFLAGS="$CFLAGS $libsafec_CFLAGS"
CPPFLAGS="$CPPFLAGS $libsafec_CFLAGS"

AC_DEFINE([SYSTEM_LIBSAFEC],[1],[Define if using system installed SafeC])
],
[builtin], [
AC_MSG_RESULT(builtin);

safecdir="$SAFEC_STUB_DIR"
AC_SUBST([SAFEC_DIR], "$safecdir")
AC_SUBST([SAFEC_CFLAGS], "$safecdir/include")
AC_SUBST([SAFEC_LDFLAGS], "$safecdir/lib")
LDFLAGS="$LDFLAGS -L$safecdir/lib"
LIBS="$LIBS -lsafe_lib"
],
[no], [],
[
AC_MSG_RESULT();
AC_MSG_FAILURE([invalid argument to --with-libsafec: must be "system" or "builtin"]);
])

AS_IF([test "$with_safec_dir" != "no"],
[
# a local installation of safec has been specified
AC_MSG_RESULT(private installation);
safecdir="$with_safec_dir"
AC_SUBST([SAFEC_DIR], "$safecdir")
AC_SUBST([SAFEC_CFLAGS], "$safecdir/include")
AC_SUBST([SAFEC_LDFLAGS], "$safecdir/lib")
LDFLAGS="$LDFLAGS -L$safecdir/lib"

# make sure it's there and linkable.
AC_CHECK_LIB([ciscosafec], [memset_s],
[], [AC_MSG_FAILURE([can't find CiscoSafeC lib])] [])

AC_DEFINE([CISCO_LIBSAFEC],[1],[Define if using Cisco installed SafeC])
])

AC_PREFIX_DEFAULT([/usr/local/est])

Expand Down