Skip to content

Commit

Permalink
Adding C++ wrapper header and an empty library to test compiling with…
Browse files Browse the repository at this point in the history
… it. Library should be removed in favour of some kind of test.
  • Loading branch information
kshehata committed Apr 28, 2022
1 parent 9559757 commit dc911fc
Show file tree
Hide file tree
Showing 4 changed files with 502 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ maintainer-clean-local:
debian/libpbc0 debian/libpbc-dev/ debian/*debhelper.log debian/*debhelper debian/*substvars

lib_LTLIBRARIES = libpbc.la
if ENABLE_CXX
lib_LTLIBRARIES += libpbcxx.la
endif

# this should really be a versioned dir, i.e., $(includedir)/pbc-0.5.0
library_includedir = $(includedir)/pbc
Expand All @@ -32,6 +35,7 @@ include/pbc_i_param.h \
include/pbc_fp.h \
include/pbc_ternary_extension_field.h \
include/pbc.h \
include/pbcxx.h \
include/pbc_hilbert.h \
include/pbc_memory.h \
include/pbc_mnt.h \
Expand Down Expand Up @@ -61,6 +65,16 @@ libpbc_la_SOURCES = arith/field.c arith/z.c \
ecc/f_param.c ecc/g_param.c
libpbc_la_LDFLAGS = -lgmp -lm -version-info $(SO_VERSION) $(PBC_LDFLAGS) $(LIBPBC_LDFLAGS)

if ENABLE_CXX
PBCXX_LTLIBRARIES_OPTION = libpbcxx.la
endif
libpbcxx_la_CPPFLAGS = -Iinclude
libpbcxx_la_SOURCES = cxx/pbcxx.cc
libpbcxx_la_DEPENDENCIES = libpbc.la
libpbcxx_la_LIBADD = $(libpbcxx_la_DEPENDENCIES)
libpbcxx_la_LDFLAGS = $(PBC_LDFLAGS) $(LIBPBCXX_LDFLAGS) \
-version-info $(SO_VERSION)

# LDADD is fallback of program_LDADD
# explicit "-lgmp" fixes error of "undefined reference to GMP symbol"
# explicit "-lm" fixes error of "undefined reference to libm symbol"
Expand Down
23 changes: 23 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,14 @@ AC_ARG_ENABLE( debug,
[with_debug=y],
[with_debug=n])

AC_ARG_ENABLE(cxx,
AS_HELP_STRING([--enable-cxx],[enable C++ support [default=no]]),
[case $enableval in
yes|no|detect) ;;
*) AC_MSG_ERROR([bad value $enableval for --enable-cxx, need yes/no/detect]) ;;
esac],
[enable_cxx=no])

CFLAGS="$CFLAGS -Wall -W -Wfloat-equal -Wpointer-arith -Wcast-align -Wstrict-prototypes -Wredundant-decls \
-Wendif-labels -Wshadow -pipe -ffast-math -U__STRICT_ANSI__ -std=gnu99"
if test "$with_debug" == "y"; then
Expand All @@ -163,6 +171,17 @@ AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_CHECK_FUNCS([floor gettimeofday memmove memset pow sqrt strchr strdup])

# The C++ compiler, if desired.
if test $enable_cxx != no; then
AC_PROG_CXX
AC_PROG_CXXCPP
m4_ifndef([AX_CXX_COMPILE_STDCXX_11], [m4_fatal([Missing AX_CXX_COMPILE_STDCXX_11, install autoconf-archive])])
AX_CXX_COMPILE_STDCXX_11

fi

AM_CONDITIONAL(ENABLE_CXX, test $enable_cxx = yes)

AC_CONFIG_FILES([Makefile example/Makefile gen/Makefile])
AC_OUTPUT

Expand All @@ -182,6 +201,10 @@ echo "LFLAGS: $LFLAGS"
echo "YACC: $YACC"
echo "AM_YFLAGS: $AM_YFLAGS"
echo "YFLAGS: $YFLAGS"
if test $enable_cxx = yes; then
echo " CXX=\"$CXX\""
echo " CXXFLAGS=\"$CXXFLAGS\""
fi
echo "-----------------------------------------"
echo -ne "\n"

Expand Down
1 change: 1 addition & 0 deletions cxx/pbcxx.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
#include "pbcxx.h"
Loading

0 comments on commit dc911fc

Please sign in to comment.