From 4e0185faf3f97f0d027cf74df54d4b08adf1d355 Mon Sep 17 00:00:00 2001 From: Michael Orlitzky Date: Wed, 15 May 2024 09:51:06 -0400 Subject: [PATCH 1/1] */*: patch build system for Gentoo - No "external" anything - Use libtool for libraries - Unbundle gmp and cddlib - Use modern cddlib include path - Detect deps with pkg-config - Build lib-reg after lib - Don't hide all symbols with -fvisibility=hidden??? --- Makefile.am | 8 +--- configure.ac | 92 +++++++------------------------------- lib-src-reg/LPinterface.hh | 4 +- lib-src-reg/Makefile.am | 7 +-- lib-src/Makefile.am | 5 +-- src-reg/Makefile.am | 19 +------- src/Makefile.am | 19 +------- wrap-gmp-gmpxx/Makefile.am | 1 - 8 files changed, 29 insertions(+), 126 deletions(-) diff --git a/Makefile.am b/Makefile.am index 17f6960..02f80f3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,7 +1 @@ -SUBDIRS = wrap-gmp-gmpxx lib-src-reg lib-src src-reg src examples share -EXTRA_DIST = external/Makefile -EXTRA_DIST += external/gmp-6.2.1.tar.bz2 -EXTRA_DIST += external/cddlib-0.94j-TOPCOMb.tar.gz -EXTRA_DIST += external/qsopt_ex-2.5.10.3.tar.gz -EXTRA_DIST += external/gmpxx-patch - +SUBDIRS = wrap-gmp-gmpxx lib-src lib-src-reg src src-reg examples share diff --git a/configure.ac b/configure.ac index 2372711..0e6efd7 100644 --- a/configure.ac +++ b/configure.ac @@ -10,96 +10,36 @@ AC_SUBST([TOPCOMROOT], [`pwd`]) dnl set some compilation switches consistently: AC_SUBST([AM_CPPFLAGS], ["-DSTL_SYMMETRIES -DSTL_CONTAINERS -DSTL_FLIPS -DSTL_CHIROTOPE -DGMPRATIONAL -DPERMLIB_DOMAIN_INT -DUSE_LEXORDER]") -AC_SUBST([AM_CXXFLAGS], [" -fvisibility=hidden -fvisibility-inlines-hidden -pthread -std=c++17"]) -AC_SUBST([AM_LDFLAGS], ["-L../external/lib]") - -dnl backup the user variable LDFLAGS: -dnl AC_SUBST([LDFLAGS_backup], [${LDFLAGS}]) - -dnl add local libraries to LDFLAGS so that AC_CHECK_LIB will find them: -dnl AC_SUBST([LDFLAGS], ["-L${TOPCOMROOT}/external/lib"]) +AC_SUBST([AM_CXXFLAGS], ["-std=c++17"]) dnl Checks for programs. AC_PROG_CC AC_PROG_INSTALL AC_PROG_CXX -AC_PROG_RANLIB +LT_INIT dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST dnl Check for libraries: -dnl Make libgmp if requested: -AC_LANG_PUSH(C++) -AC_CHECK_HEADERS([gmpxx.h]) -AC_LANG_POP -AM_CONDITIONAL(USE_LOCAL_GMP, [test "x$ac_cv_header_gmpxx_h" = "xno"]) -if test "x$ac_cv_header_gmpxx_h" = "xyes"; then - AC_MSG_NOTICE([system libgmp is used]) -else - AC_MSG_NOTICE([gmpxx.h not found on system - building gmp locally ...]) - make -C external gmp - AC_MSG_NOTICE([... done]) -fi - -dnl Make libcddgmp: -make -C external cdd - -dnl Check for requests for third-party packages: -dnl Check for qsopt_ex: -AC_MSG_CHECKING(whether QSOpt_ex support was enabled) -AC_ARG_ENABLE([qsoptex], - AS_HELP_STRING([--enable-qsoptex], - [use QSOpt_ex as an LP solver for regularity checks (requires QSOpt_ex includes in ${TOPCOM}/external/include and libqsopt_ex.a in ${TOPCOM}/external/lib (built automatically during configure)]) +PKG_CHECK_MODULES( + [GMPXX], + [gmpxx],[ + LIBS="${LIBS} ${GMPXX_LIBS}" + CPPFLAGS="${CPPFLAGS} ${GMPXX_CFLAGS}" + ], + [AC_MSG_ERROR([gmpxx not found])] ) -AM_CONDITIONAL(USE_QSOPTEX, [test "x$enable_qsoptex" = "xyes"]) -if test "x$enable_qsoptex" = "xyes"; then - AC_MSG_RESULT(yes) - AC_DEFINE(HAVE_LIBQSOPTEX) - - dnl Check for compression libraries (qsopt_ex uses them if they are present): - AC_CHECK_LIB([z], [gzopen], [], AC_MSG_NOTICE([compiling without libz])) - AC_CHECK_LIB([bz2], [BZ2_bzopen], [], AC_MSG_NOTICE([compiling without libbz2])) - - dnl Make libqsopt_ex: - make -C external qso -else - AC_MSG_RESULT(no) -fi - -dnl Check for soplex: -AC_MSG_CHECKING(whether soplex support was enabled) -AC_ARG_ENABLE([soplex], - AS_HELP_STRING([--enable-soplex], - [use soplex as an LP solver for regularity checks (requires soplex includes and boost in ${TOPCOM}/external/include and libsoplex.a in ${TOPCOM}/external/lib)]) +PKG_CHECK_MODULES( + [CDDLIB], + [cddlib],[ + LIBS="${LIBS} ${CDDLIB_LIBS}" + CPPFLAGS="${CPPFLAGS} ${CDDLIB_CFLAGS}" + ], + [AC_MSG_ERROR([cddlib not found])] ) -if test "x$enable_soplex" = "xyes"; then - AC_MSG_RESULT(yes) - - dnl Check for compression library (soplex needs it): - AC_CHECK_LIB([z], [gzopen], [LIBS="-lsoplex $LIBS"; AC_DEFINE(HAVE_LIBSOPLEX)], AC_MSG_NOTICE([libz missing => soplex not enabled])) -else - AC_MSG_RESULT(no) -fi -AM_CONDITIONAL(USE_SOPLEX, [test "x$ac_cv_lib_z_gzopen" = "xyes" -a "x$enable_soplex" = "xyes"]) - -dnl Check for Permlib: -dnl AC_MSG_CHECKING(whether permlib support was enabled) -dnl AC_ARG_ENABLE([permlib], -dnl AS_HELP_STRING([--enable-permlib], -dnl [support permlib for symmetry checks (requires permlib-includes and boost in ${TOPCOM}/external/include)]) -dnl ) -dnl AM_CONDITIONAL(USE_PERMLIB, [test "x$enable_permlib" = "xyes"]) -dnl if test "x$enable_permlib" = "xyes"; then -dnl AC_DEFINE(HAVE_LIBPERMLIB) -dnl AC_MSG_RESULT(yes) -dnl else -dnl AC_MSG_RESULT(no) -dnl fi -dnl restore the user variable LDLFAGS: -dnl AC_SUBST([LDFLAGS], [${LDFLAGS_backup}]) AC_CONFIG_FILES([wrap-gmp-gmpxx/Makefile lib-src/Makefile lib-src-reg/Makefile src/Makefile src-reg/Makefile examples/Makefile share/Makefile Makefile]) AC_OUTPUT diff --git a/lib-src-reg/LPinterface.hh b/lib-src-reg/LPinterface.hh index 6522dbe..c376887 100644 --- a/lib-src-reg/LPinterface.hh +++ b/lib-src-reg/LPinterface.hh @@ -21,8 +21,8 @@ #include "LabelSet.hh" #include "Rational.h" -#include "setoper.h" -#include "cdd.h" +#include "cddlib/setoper.h" +#include "cddlib/cdd.h" namespace topcom { diff --git a/lib-src-reg/Makefile.am b/lib-src-reg/Makefile.am index fa8de11..13a0c87 100644 --- a/lib-src-reg/Makefile.am +++ b/lib-src-reg/Makefile.am @@ -1,6 +1,6 @@ -lib_LIBRARIES = libCHECKREG.a +lib_LTLIBRARIES = libCHECKREG.la -libCHECKREG_a_SOURCES = \ +libCHECKREG_la_SOURCES = \ QSOinterface.cc \ SPXinterface.cc \ LPinterface.cc \ @@ -12,9 +12,10 @@ SPXinterface.hh \ RegularityCheck.hh \ LPinterface.hh +libCHECKREG_la_LIBADD = ../lib-src/libTOPCOM.la + AM_CPPFLAGS += -I../lib-src AM_CPPFLAGS += -I../wrap-gmp-gmpxx -AM_CPPFLAGS += -I../external/include AM_CPPFLAGS += -I$(includedir) AM_CPPFLAGS += -ftemplate-depth=100 diff --git a/lib-src/Makefile.am b/lib-src/Makefile.am index c048061..dbaa888 100644 --- a/lib-src/Makefile.am +++ b/lib-src/Makefile.am @@ -1,6 +1,6 @@ -lib_LIBRARIES = libTOPCOM.a +lib_LTLIBRARIES = libTOPCOM.la -libTOPCOM_a_SOURCES = \ +libTOPCOM_la_SOURCES = \ Admissibles.cc \ CheckTriang.cc \ Circuits.cc \ @@ -134,7 +134,6 @@ Volumes.hh AM_CPPFLAGS += -I../lib-src-reg AM_CPPFLAGS += -I../wrap-gmp-gmpxx -AM_CPPFLAGS += -I../external/include AM_CPPFLAGS += -I$(includedir) AM_CPPFLAGS += -ftemplate-depth=100 diff --git a/src-reg/Makefile.am b/src-reg/Makefile.am index ed4a016..78e9c44 100644 --- a/src-reg/Makefile.am +++ b/src-reg/Makefile.am @@ -2,27 +2,12 @@ bin_PROGRAMS = checkregularity checkregularity_SOURCES = checkregularity.cc -LDADD = ../lib-src/libTOPCOM.a \ - ../lib-src-reg/libCHECKREG.a \ - ../external/lib/libcddgmp.a -if USE_QSOPTEX -LDADD += ../external/lib/libqsopt_ex.a -endif - -if USE_SOPLEX -LDADD += ../external/lib/libsoplex.a -endif -if USE_LOCAL_GMP -LDADD += ../external/lib/libgmpxx.a \ - ../external/lib/libgmp.a -else -LIBS += -lgmpxx -lgmp -endif +checkregularity_LDADD = ../lib-src/libTOPCOM.la \ + ../lib-src-reg/libCHECKREG.la AM_CPPFLAGS += -I../lib-src AM_CPPFLAGS += -I../lib-src-reg AM_CPPFLAGS += -I../wrap-gmp-gmpxx -AM_CPPFLAGS += -I../external/include AM_CPPFLAGS += -I$(includedir) AM_CPPFLAGS += -ftemplate-depth=100 diff --git a/src/Makefile.am b/src/Makefile.am index c97ecc5..ce723fb 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -121,27 +121,12 @@ santos_triang_SOURCES = santos_triang.cc santos_dim4_triang_SOURCES = santos_dim4_triang.cc santos_22_triang_SOURCES = santos_22_triang.cc -LDADD = ../lib-src/libTOPCOM.a \ - ../lib-src-reg/libCHECKREG.a \ - ../external/lib/libcddgmp.a -if USE_QSOPTEX -LDADD += ../external/lib/libqsopt_ex.a -endif -if USE_SOPLEX -LDADD += ../external/lib/libsoplex.a -endif -if USE_LOCAL_GMP -LDADD += ../external/lib/libgmpxx.a \ - ../external/lib/libgmp.a -else -LIBS += -lgmpxx -lgmp -endif - +LDADD = ../lib-src/libTOPCOM.la \ + ../lib-src-reg/libCHECKREG.la AM_CPPFLAGS += -I../lib-src AM_CPPFLAGS += -I../lib-src-reg AM_CPPFLAGS += -I../wrap-gmp-gmpxx -AM_CPPFLAGS += -I../external/include AM_CPPFLAGS += -I$(includedir) AM_CPPFLAGS += -ftemplate-depth=100 diff --git a/wrap-gmp-gmpxx/Makefile.am b/wrap-gmp-gmpxx/Makefile.am index f85cfc5..41ad248 100644 --- a/wrap-gmp-gmpxx/Makefile.am +++ b/wrap-gmp-gmpxx/Makefile.am @@ -2,5 +2,4 @@ include_HEADERS = \ Integer.h \ Rational.h -AM_CPPFLAGS += -I../external/include AM_CPPFLAGS += -I$(includedir) -- 2.43.2