Skip to content

Commit

Permalink
build: configure check for crypto++
Browse files Browse the repository at this point in the history
  • Loading branch information
ygrek committed Aug 27, 2024
1 parent 05908f6 commit e23eec2
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 133 deletions.
1 change: 0 additions & 1 deletion config/Makefile.config.in
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ GNUTELLA2=@GNUTELLA2@
BITTORRENT=@BITTORRENT@
DONKEY=@DONKEY@
DONKEY_SUI=@DONKEY_SUI@
CRYPTOPPFLAGS=@CRYPTOPPFLAGS@
DONKEY_SERVER=@DONKEY_SERVER@
SOULSEEK=@SOULSEEK@
OPENFT=@OPENFT@
Expand Down
4 changes: 2 additions & 2 deletions config/Makefile.in
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ Makefile: config/Makefile.in
MAIN_SRCS=$(COMMON)/commonMain.ml

ifeq ("$(DONKEY_SUI)", "yes")
CRYPTOPP_LIBS_flags += -cc '$(CXX) $(CXXFLAGS)' -cclib '-lcryptopp' -ccopt '$(CRYPTOPPFLAGS)'
CRYPTOPP_LIBS_flags += -cc '$(CXX) $(CXXFLAGS)' -cclib '-lcryptopp'
DONKEY_SRCS += $(LIB)/CryptoPP.cc $(LIB)/CryptoPP_stubs.c $(SRC_DONKEY)/donkeySui1.ml $(SRC_DONKEY)/donkeySui.ml
else
DONKEY_SRCS += $(SRC_DONKEY)/donkeySui2.ml $(SRC_DONKEY)/donkeySui.ml
Expand Down Expand Up @@ -1874,7 +1874,7 @@ rpm: sourcedist
$(OCAMLC) -verbose -ccopt "-I $(OCAML_SRC)/byterun -o $*.o" -ccopt "$(CFLAGS)" $(LIBS_flags) -c $<

.cc.o :
$(CXX) $(CXXFLAGS) $(CRYPTOPPFLAGS) -o $*.o "-I$(OCAMLLIB)" -c $<
$(CXX) $(CXXFLAGS) -o $*.o "-I$(OCAMLLIB)" -c $<

.cmo.byte:
$(OCAMLC) -o $*.byte $(LIBS) $<
Expand Down
146 changes: 45 additions & 101 deletions config/configure
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,6 @@ REQUIRED_LABLGTK
GUI
DONKEY_SERVER
DONKEY_SUI_FILE
CRYPTOPPFLAGS
DONKEY_SUI
DONKEY
FASTTRACK
Expand Down Expand Up @@ -1961,6 +1960,39 @@ fi
as_fn_set_status $ac_retval

} # ac_fn_cxx_try_compile

# ac_fn_cxx_check_header_compile LINENO HEADER VAR INCLUDES
# ---------------------------------------------------------
# Tests whether HEADER exists and can be compiled using the include files in
# INCLUDES, setting the cache variable VAR accordingly.
ac_fn_cxx_check_header_compile ()
{
as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
printf %s "checking for $2... " >&6; }
if eval test \${$3+y}
then :
printf %s "(cached) " >&6
else $as_nop
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
$4
#include <$2>
_ACEOF
if ac_fn_cxx_try_compile "$LINENO"
then :
eval "$3=yes"
else $as_nop
eval "$3=no"
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
fi
eval ac_res=\$$3
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
printf "%s\n" "$ac_res" >&6; }
eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno

} # ac_fn_cxx_check_header_compile
ac_configure_args_raw=
for ac_arg
do
Expand Down Expand Up @@ -10543,7 +10575,6 @@ echo "---------------------------------------------"
echo ""

CXX_VERSION=
CRYPTOPPFLAGS=
echo "--------------------------------------"
echo " Checking activated networks."
echo "--------------------------------------"
Expand Down Expand Up @@ -10930,16 +10961,6 @@ ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu


# GCC miscompiles cryptopp.cc with -O2 on armhf
# http://mldonkey.sourceforge.net/phpBB2/viewtopic.php?p=32309#32309
# https://bugs.launchpad.net/ubuntu/+source/mldonkey/+bug/1060007
case "$host" in
armv7l-*-linux-gnueabihf)
CXXFLAGS="-g -Os"
;;
esac

if test -n "$ac_tool_prefix"; then
# Extract the first word of "${ac_tool_prefix}$CXX", so it can be a program name with args.
set dummy ${ac_tool_prefix}$CXX; ac_word=$2
Expand Down Expand Up @@ -11042,122 +11063,46 @@ else
NEWCXX="$ac_cv_prog_NEWCXX"
fi

{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking eMule SUI" >&5
printf %s "checking eMule SUI... " >&6; }
if test x"$NEWCXX" = x"no"
then
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
printf "%s\n" "no" >&6; }
CXX=
DONKEY_SUI=no
else
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
printf "%s\n" "yes" >&6; }
CXX=$NEWCXX
CXX_VERSION=`$CXX -dumpversion`
ac_ext=cpp
ac_cpp='$CXXCPP $CPPFLAGS'
ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_cxx_compiler_gnu


{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C++ compiler accepts -fno-omit-frame-pointer" >&5
printf %s "checking whether C++ compiler accepts -fno-omit-frame-pointer... " >&6; }
if test ${ax_cv_check_cxxflags___fno_omit_frame_pointer+y}
then :
printf %s "(cached) " >&6
else $as_nop

ax_check_save_flags=$CXXFLAGS
CXXFLAGS="$CXXFLAGS -fno-omit-frame-pointer"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main (void)
{
;
return 0;
}
_ACEOF
if ac_fn_cxx_try_compile "$LINENO"
then :
ax_cv_check_cxxflags___fno_omit_frame_pointer=yes
else $as_nop
ax_cv_check_cxxflags___fno_omit_frame_pointer=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
CXXFLAGS=$ax_check_save_flags
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cxxflags___fno_omit_frame_pointer" >&5
printf "%s\n" "$ax_cv_check_cxxflags___fno_omit_frame_pointer" >&6; }
if test "x$ax_cv_check_cxxflags___fno_omit_frame_pointer" = xyes
then :
CRYPTOPPFLAGS="-fno-omit-frame-pointer"
else $as_nop
:
fi

{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether C++ compiler accepts -mno-omit-leaf-frame-pointer" >&5
printf %s "checking whether C++ compiler accepts -mno-omit-leaf-frame-pointer... " >&6; }
if test ${ax_cv_check_cxxflags___mno_omit_leaf_frame_pointer+y}
for ac_header in cryptopp/rsa.h
do :
ac_fn_cxx_check_header_compile "$LINENO" "cryptopp/rsa.h" "ac_cv_header_cryptopp_rsa_h" "$ac_includes_default"
if test "x$ac_cv_header_cryptopp_rsa_h" = xyes
then :
printf %s "(cached) " >&6
else $as_nop

ax_check_save_flags=$CXXFLAGS
CXXFLAGS="$CXXFLAGS -mno-omit-leaf-frame-pointer"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
int
main (void)
{
printf "%s\n" "#define HAVE_CRYPTOPP_RSA_H 1" >>confdefs.h

;
return 0;
}
_ACEOF
if ac_fn_cxx_try_compile "$LINENO"
then :
ax_cv_check_cxxflags___mno_omit_leaf_frame_pointer=yes
else $as_nop
ax_cv_check_cxxflags___mno_omit_leaf_frame_pointer=no
fi
rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
CXXFLAGS=$ax_check_save_flags
fi
{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_check_cxxflags___mno_omit_leaf_frame_pointer" >&5
printf "%s\n" "$ax_cv_check_cxxflags___mno_omit_leaf_frame_pointer" >&6; }
if test "x$ax_cv_check_cxxflags___mno_omit_leaf_frame_pointer" = xyes
then :
CRYPTOPPFLAGS="$CRYPTOPPFLAGS -mno-omit-leaf-frame-pointer"
else $as_nop
:
DONKEY_SUI=no
fi

done
ac_ext=c
ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
ac_compiler_gnu=$ac_cv_c_compiler_gnu

CXX=$NEWCXX
CXX_VERSION=`$CXX -dumpversion`
DONKEY_SUI_FILE=DonkeySui1
if test "$DONKEY_SUI" = "yes"; then
DONKEY_SUI_FILE=DonkeySui1

printf "%s\n" "#define HAVE_CRYPTOPP 1" >>confdefs.h

fi
fi
fi
# AC_MSG_CHECKING(eDonkey server)
# if test -d ../src/networks/server; then
# AC_MSG_RESULT(no)
# DONKEY_SERVER=no
# else
# AC_MSG_RESULT(no)
# DONKEY_SERVER=no
# fi
else
DONKEY=no
DONKEY_SUI=no
Expand Down Expand Up @@ -11625,7 +11570,6 @@ fi






BUILD_SYSTEM="`uname -s` `uname -m` `uname -r`"
Expand Down
36 changes: 7 additions & 29 deletions config/configure.in
Original file line number Diff line number Diff line change
Expand Up @@ -987,7 +987,6 @@ echo "---------------------------------------------"
echo ""

CXX_VERSION=
CRYPTOPPFLAGS=
echo "--------------------------------------"
echo " Checking activated networks."
echo "--------------------------------------"
Expand All @@ -998,43 +997,23 @@ echo "--------------------------------------"
AC_MSG_RESULT(yes)
if test "$DONKEY_SUI" = "yes"; then
AC_PROG_CXX

# GCC miscompiles cryptopp.cc with -O2 on armhf
# http://mldonkey.sourceforge.net/phpBB2/viewtopic.php?p=32309#32309
# https://bugs.launchpad.net/ubuntu/+source/mldonkey/+bug/1060007
case "$host" in
armv7l-*-linux-gnueabihf)
CXXFLAGS="-g -Os"
;;
esac

AC_CHECK_TOOL(NEWCXX, [$CXX], [no])
AC_MSG_CHECKING(eMule SUI)
if test x"$NEWCXX" = x"no"
then
AC_MSG_RESULT(no)
CXX=
DONKEY_SUI=no
else
AC_MSG_RESULT(yes)
AC_LANG_PUSH([C++])
AX_CHECK_COMPILE_FLAG(-fno-omit-frame-pointer,CRYPTOPPFLAGS="-fno-omit-frame-pointer",,,)
AX_CHECK_COMPILE_FLAG(-mno-omit-leaf-frame-pointer,CRYPTOPPFLAGS="$CRYPTOPPFLAGS -mno-omit-leaf-frame-pointer",,,)
AC_LANG_POP([C++])
CXX=$NEWCXX
CXX_VERSION=`$CXX -dumpversion`
DONKEY_SUI_FILE=DonkeySui1
AC_DEFINE(HAVE_CRYPTOPP, 1, cryptopp)
AC_LANG_PUSH([C++])
AC_CHECK_HEADERS([cryptopp/rsa.h],,[DONKEY_SUI=no])
AC_LANG_POP([C++])
if test "$DONKEY_SUI" = "yes"; then
DONKEY_SUI_FILE=DonkeySui1
AC_DEFINE(HAVE_CRYPTOPP, 1, cryptopp)
fi
fi
fi
# AC_MSG_CHECKING(eDonkey server)
# if test -d ../src/networks/server; then
# AC_MSG_RESULT(no)
# DONKEY_SERVER=no
# else
# AC_MSG_RESULT(no)
# DONKEY_SERVER=no
# fi
else
DONKEY=no
DONKEY_SUI=no
Expand Down Expand Up @@ -1378,7 +1357,6 @@ AC_SUBST(OPENFT)
AC_SUBST(FASTTRACK)
AC_SUBST(DONKEY)
AC_SUBST(DONKEY_SUI)
AC_SUBST(CRYPTOPPFLAGS)
AC_SUBST(DONKEY_SUI_FILE)
AC_SUBST(DONKEY_SERVER)
AC_SUBST(GUI)
Expand Down

0 comments on commit e23eec2

Please sign in to comment.