File lrs-am.diff of Package lrslib
From: Jan Engelhardt <jengelh@inai.de>
Date: 2016-03-31 10:44:51.450482420 +0200
Fix the "typical problems seen in plain Makefiles":
* /lib is hardcoded
* shared library only a secondary citizen and not used for linking
programs even though there is good opportunity to do so.
* lack of proper shared library versioning
* upstream changed the ABI before without updating SONAME, address
with -release
Fix awkwardness:
* original Makefile builds plrs by way of `g++ -o plrs plrs.cpp
lrslib.c lrsgmp.c`; the mode of compilation is C, but the include
search path is CXX's... which is unsupported in managed build
systems because .c files are always built with CC.
(error: "#include <sstream>" - file not found)
To address that, lrslib.cpp is synthesized with BUILT_SOURCES,
and some extern "C" blocks are warranted.
---
Makefile.am | 47 +++++++++++++++++++++++++++++++++++++++++++++++
configure.ac | 10 ++++++++++
lrsgmp.h | 6 ++++++
lrslib.c | 12 ++++++------
lrslib.h | 7 ++++++-
lrsnashlib.c | 8 ++++----
6 files changed, 79 insertions(+), 11 deletions(-)
Index: lrslib-061/Makefile.am
===================================================================
--- /dev/null
+++ lrslib-061/Makefile.am
@@ -0,0 +1,47 @@
+ACLOCAL_AMFLAGS = -I m4
+AM_CPPFLAGS = -DTIMES -DSIGNALS
+lib_LTLIBRARIES = liblrsgmp.la
+liblrsgmp_la_SOURCES = lrslib.c lrsgmp.c
+liblrsgmp_la_CPPFLAGS = ${AM_CPPFLAGS} -DGMP
+liblrsgmp_la_LDFLAGS = -release ${PACKAGE_VERSION}
+liblrsgmp_la_LIBADD = -lgmp
+include_HEADERS = lrslib.h lrsgmp.h
+bin_PROGRAMS = 2nash lrs lrs1 lrsnash redund redund1 setnash setnash2
+bin_PROGRAMS += plrs plrs1 plrsmp
+EXTRA_PROGRAMS = fourier
+fourier_SOURCES = fourier.c
+fourier_CPPFLAGS = ${AM_CPPFLAGS} -DGMP
+fourier_LDADD = liblrsgmp.la
+lrs_SOURCES = lrs.c
+lrs_LDADD = liblrsgmp.la
+lrs1_SOURCES = lrs.c lrslib.c lrslong.c
+lrs1_CPPFLAGS = ${AM_CPPFLAGS} -DLRSLONG
+lrsnash_SOURCES = lrsnash.c lrsnashlib.c
+lrsnash_CPPFLAGS = ${AM_CPPFLAGS} -DGMP -DLRS_QUIET
+lrsnash_LDADD = liblrsgmp.la
+redund_SOURCES = redund.c
+redund_CPPFLAGS = ${AM_CPPFLAGS} -DGMP
+redund_LDADD = liblrsgmp.la
+redund1_SOURCES = redund.c lrslib.c lrslong.c
+redund1_CPPFLAGS = ${AM_CPPFLAGS} -DLRSLONG
+setnash_SOURCES = setupnash.c lrslib.c lrsmp.c
+setnash2_SOURCES = setupnash2.c lrslib.c lrsmp.c
+plrs_SOURCES = plrs.cpp lrslib.cpp lrsgmp.cpp
+plrs_CPPFLAGS = ${AM_CPPFLAGS} -DGMP -DPLRS
+plrs_LDADD = -lgmp -lboost_system -lboost_thread
+plrs1_SOURCES = plrs.cpp lrslib.cpp lrslong.cpp
+plrs1_CPPFLAGS = ${AM_CPPFLAGS} -DPLRS -DLRSLONG
+plrs1_LDADD = -lgmp -lboost_system -lboost_thread
+plrsmp_SOURCES = plrs.cpp lrslib.cpp lrsmp.cpp
+plrsmp_CPPFLAGS = ${AM_CPPFLAGS} -DPLRS
+plrsmp_LDADD = -lgmp -lboost_system -lboost_thread
+BUILT_SOURCES = lrslib.cpp lrsgmp.cpp lrslong.cpp
+# !@#$% for throwing .c files at g++ (original makefile)
+lrsgmp.cpp: lrsgmp.c
+ cp $< $@
+lrslib.cpp: lrslib.c
+ cp $< $@
+lrslong.cpp: lrslong.c
+ cp $< $@
+lrsmp.cpp: lrsmp.c
+ cp $< $@
Index: lrslib-061/configure.ac
===================================================================
--- /dev/null
+++ lrslib-061/configure.ac
@@ -0,0 +1,10 @@
+AC_INIT([lrslib], [062])
+AC_CONFIG_MACRO_DIR([m4])
+AM_INIT_AUTOMAKE([foreign subdir-objects tar-pax])
+AC_PROG_CC
+AC_PROG_CXX
+AC_PROG_INSTALL
+AC_DISABLE_STATIC
+LT_INIT
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
Index: lrslib-061/lrsgmp.h
===================================================================
--- lrslib-061.orig/lrsgmp.h
+++ lrslib-061/lrsgmp.h
@@ -151,6 +151,9 @@ extern FILE *lrs_ofp; /* output file p
/*********************************************************/
/* Initialization and allocation procedures - must use! */
/******************************************************* */
+#ifdef __cplusplus
+extern "C" {
+#endif
long lrs_mp_init (long dec_digits, FILE * lrs_ifp, FILE * lrs_ofp); /* max number of decimal digits, fps */
@@ -219,3 +222,6 @@ void lrs_default_digits_overflow ();
/* end of lrs_mp.h (vertex enumeration using lexicographic reverse search) */
+#ifdef __cplusplus
+}
+#endif
Index: lrslib-061/lrslib.h
===================================================================
--- lrslib-061.orig/lrslib.h
+++ lrslib-061/lrslib.h
@@ -206,7 +206,9 @@ typedef struct lrs_dat /* global probl
lrs_dic *Qhead, *Qtail;
}lrs_dat, lrs_dat_p;
-
+#ifdef __cplusplus
+extern "C" {
+#endif
#ifdef PLRS
/****************/
@@ -329,3 +331,6 @@ void lrs_set_obj_mp(lrs_dic *P, lrs_dat
+#ifdef __cplusplus
+}
+#endif