From e686df81492aa7fbfb4ac5d556ac9255f36f1c74 Mon Sep 17 00:00:00 2001 From: Ulya Trofimovich Date: Sat, 19 Jan 2019 11:57:16 +0000 Subject: [PATCH] Use libtool to build libraries. --- .travis.yml | 3 +- re2c/Makefile.am | 14 ++++++--- re2c/Makefile.libre2c_posix.am | 50 +++++++++++++++---------------- re2c/__build.sh | 6 ++-- re2c/__build_asan.sh | 8 +++-- re2c/__build_clang.sh | 8 +++-- re2c/__build_clang_msan.sh | 11 +++++-- re2c/__build_lsan.sh | 8 +++-- re2c/__build_m32.sh | 8 +++-- re2c/__build_mingw.sh | 7 +++-- re2c/__build_redundant_exports.sh | 8 +++-- re2c/__build_ubsan.sh | 8 +++-- re2c/__distcheck.sh | 2 +- re2c/configure.ac | 10 ++++++- 14 files changed, 101 insertions(+), 50 deletions(-) diff --git a/.travis.yml b/.travis.yml index 43d486c6..f1a31e8d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -24,7 +24,8 @@ script: $CONFIG_DIR/configure \ --prefix="$(pwd)"/re2c-install \ --enable-docs \ - --enable-debug + --enable-debug \ + --enable-libs - make -j$(nproc) - make -j$(nproc) check VERBOSE=1 - make -j$(nproc) install diff --git a/re2c/Makefile.am b/re2c/Makefile.am index 092af731..7dfac23c 100644 --- a/re2c/Makefile.am +++ b/re2c/Makefile.am @@ -2,7 +2,7 @@ # do *not* add CXXFLAGS here, add them in configure.ac AM_CXXFLAGS = $(CXXFLAGSDEFAULT) if DEBUG - AM_CXXFLAGS += -DRE2C_DEBUG +AM_CXXFLAGS += -DRE2C_DEBUG endif RE2CFLAGS = -b -W @@ -176,6 +176,9 @@ re2c_GEN = \ $(re2c_GEN_HDR) nodist_re2c_SOURCES = $(re2c_GEN) +# custom rules create headers and must go before normal rules +BUILT_SOURCES = $(re2c_GEN_SRC) + # bootstrap sources re2c_BOOT_PARSER = bootstrap/src/parse/parser.cc re2c_BOOT_PARSER_HDR = bootstrap/src/parse/parser.h @@ -269,9 +272,6 @@ CLEANFILES = \ # lexer depends on bison-generated header $(re2c_GEN_LEX): $(re2c_GEN_PARSER) -# generate all sources before compiling -all: $(re2c_GEN_SRC) - # rebuild all re2c sources using newly built re2c .PHONY: bootstrap bootstrap: all @@ -340,4 +340,10 @@ TESTS = \ $(re2c_TESTSUITE) \ $(check_PROGRAMS) +# libraries go here (in included .am files) +if WITH_LIBS +ACLOCAL_AMFLAGS = -I m4 +lib_LTLIBRARIES = include $(top_srcdir)/Makefile.libre2c_posix.am +endif + diff --git a/re2c/Makefile.libre2c_posix.am b/re2c/Makefile.libre2c_posix.am index 435be8e8..b02ba351 100644 --- a/re2c/Makefile.libre2c_posix.am +++ b/re2c/Makefile.libre2c_posix.am @@ -1,10 +1,11 @@ # this file is incomplete and should be included from the main Makefile.am -noinst_LIBRARIES = libre2c_posix.a +lib_LTLIBRARIES += libre2c_posix.la -libre2c_posix_a_CXXFLAGS = $(AM_CXXFLAGS) -fPIC +libre2c_posix_la_CXXFLAGS = $(AM_CXXFLAGS) +libre2c_posix_la_LDFLAGS = -module -libre2c_posix_a_HDR = \ +libre2c_posix_la_HDR = \ libre2c_posix/lex.h \ libre2c_posix/regex.h \ libre2c_posix/regex-impl.h \ @@ -70,7 +71,7 @@ libre2c_posix_a_HDR = \ src/util/uniq_vector.h \ src/util/wrap_iter.h -libre2c_posix_a_SRC = \ +libre2c_posix_la_SRC = \ libre2c_posix/regcomp.cc \ libre2c_posix/regexec.cc \ libre2c_posix/regfree.cc \ @@ -129,46 +130,45 @@ libre2c_posix_a_SRC = \ src/util/range.cc \ src/util/s_to_n32_unsafe.cc -libre2c_posix_a_SOURCES = \ - $(libre2c_posix_a_HDR) \ - $(libre2c_posix_a_SRC) +libre2c_posix_la_SOURCES = \ + $(libre2c_posix_la_HDR) \ + $(libre2c_posix_la_SRC) -libre2c_posix_a_CUSTOM = \ +libre2c_posix_la_CUSTOM = \ libre2c_posix/lex.re \ libre2c_posix/parse.ypp \ src/options/ver_to_vernum.re -libre2c_posix_a_GEN_SRC = \ +libre2c_posix_la_GEN_SRC = \ libre2c_posix/lex.cc \ libre2c_posix/parse.cc \ src/options/ver_to_vernum.cc -libre2c_posix_a_GEN_HDR = \ +libre2c_posix_la_GEN_HDR = \ libre2c_posix/parse.h -libre2c_posix_a_GEN = \ - $(libre2c_posix_a_GEN_SRC) \ - $(libre2c_posix_a_GEN_HDR) +libre2c_posix_la_GEN = \ + $(libre2c_posix_la_GEN_SRC) \ + $(libre2c_posix_la_GEN_HDR) -libre2c_posix_a_BOOTSTRAP = \ +# custom rules create headers and must go before normal rules +BUILT_SOURCES += $(libre2c_posix_la_GEN_SRC) + +libre2c_posix_la_BOOTSTRAP = \ bootstrap/libre2c_posix/parse.cc \ bootstrap/libre2c_posix/parse.h \ bootstrap/libre2c_posix/lex.cc \ bootstrap/src/options/ver_to_vernum.cc -nodist_libre2c_posix_a_SOURCES = $(libre2c_posix_a_GEN) +nodist_libre2c_posix_la_SOURCES = $(libre2c_posix_la_GEN) EXTRA_DIST += \ - $(libre2c_posix_a_BOOTSTRAP) \ - $(libre2c_posix_a_CUSTOM) + $(libre2c_posix_la_BOOTSTRAP) \ + $(libre2c_posix_la_CUSTOM) -CLEANFILES += $(libre2c_posix_a_GEN) +CLEANFILES += $(libre2c_posix_la_GEN) # lexer depends on bison-generated header libre2c_posix/lex.cc: libre2c_posix/parse.cc -# generate all sources before compiling -all: $(libre2c_posix_a_GEN_SRC) - -libre2c_posix_a_test_SOURCES = libre2c_posix/test.cpp -libre2c_posix_a_test_LDADD = libre2c_posix.a -libre2c_posix_a_test_CXXFLAGS = $(libre2c_posix_a_CXXFLAGS) -check_PROGRAMS += libre2c_posix_a_test +libre2c_posix_la_test_SOURCES = libre2c_posix/test.cpp +libre2c_posix_la_test_LDADD = libre2c_posix.la +check_PROGRAMS += libre2c_posix_la_test diff --git a/re2c/__build.sh b/re2c/__build.sh index 1bc1018f..ae02cc05 100755 --- a/re2c/__build.sh +++ b/re2c/__build.sh @@ -5,6 +5,8 @@ rm -rf $builddir mkdir $builddir cd $builddir -../configure --enable-debug && \ -make -j5 +../configure \ + --enable-debug \ + --enable-libs \ + && make -j5 cd .. diff --git a/re2c/__build_asan.sh b/re2c/__build_asan.sh index dd3d1307..974c1cd2 100755 --- a/re2c/__build_asan.sh +++ b/re2c/__build_asan.sh @@ -5,6 +5,10 @@ rm -rf $builddir mkdir $builddir cd $builddir -../configure --enable-debug CXXFLAGS="-fsanitize=address" LDFLAGS="-fsanitize=address" && \ -make -j5 +../configure \ + --enable-debug \ + --enable-libs \ + CXXFLAGS="-fsanitize=address" \ + LDFLAGS="-fsanitize=address" \ + && make -j5 cd .. diff --git a/re2c/__build_clang.sh b/re2c/__build_clang.sh index 2f53ddba..56d2629e 100755 --- a/re2c/__build_clang.sh +++ b/re2c/__build_clang.sh @@ -5,6 +5,10 @@ rm -rf $builddir mkdir $builddir cd $builddir -../configure --enable-debug CC=clang CXX=clang++ && \ -make -j5 +../configure \ + --enable-debug \ + --enable-libs \ + CC=clang \ + CXX=clang++ \ + && make -j5 cd .. diff --git a/re2c/__build_clang_msan.sh b/re2c/__build_clang_msan.sh index 93633555..29c4af54 100755 --- a/re2c/__build_clang_msan.sh +++ b/re2c/__build_clang_msan.sh @@ -5,6 +5,13 @@ rm -rf $builddir mkdir $builddir cd $builddir -../configure --enable-debug CC=clang CXX=clang++ CFLAGS="-fsanitize=memory" CXXFLAGS="-fsanitize=memory" LDFLAGS="-fsanitize=memory" && \ -make -j5 +../configure \ + --enable-debug \ + --enable-libs \ + CC=clang \ + CXX=clang++ \ + CFLAGS="-fsanitize=memory" \ + CXXFLAGS="-fsanitize=memory" \ + LDFLAGS="-fsanitize=memory" \ + && make -j5 cd .. diff --git a/re2c/__build_lsan.sh b/re2c/__build_lsan.sh index 2fc0e990..7a55660d 100755 --- a/re2c/__build_lsan.sh +++ b/re2c/__build_lsan.sh @@ -5,6 +5,10 @@ rm -rf $builddir mkdir $builddir cd $builddir -../configure --enable-debug CXXFLAGS="-fsanitize=leak" LDFLAGS="-fsanitize=leak" && \ -make -j5 +../configure \ + --enable-debug \ + --enable-libs \ + CXXFLAGS="-fsanitize=leak" \ + LDFLAGS="-fsanitize=leak" \ + && make -j5 cd .. diff --git a/re2c/__build_m32.sh b/re2c/__build_m32.sh index dff24936..eeb47ed0 100755 --- a/re2c/__build_m32.sh +++ b/re2c/__build_m32.sh @@ -5,6 +5,10 @@ rm -rf $builddir mkdir $builddir cd $builddir -../configure --enable-debug CXXFLAGS="-m32" LDFLAGS="-m32" && \ -make -j5 +../configure \ + --enable-debug \ + --enable-libs \ + CXXFLAGS="-m32" \ + LDFLAGS="-m32" \ + && make -j5 cd .. diff --git a/re2c/__build_mingw.sh b/re2c/__build_mingw.sh index 417d0992..3fc951ba 100755 --- a/re2c/__build_mingw.sh +++ b/re2c/__build_mingw.sh @@ -5,6 +5,9 @@ rm -rf $builddir mkdir $builddir cd $builddir -../configure --enable-debug --host i686-w64-mingw32 && \ -make -j5 +../configure \ + --enable-debug \ + --enable-libs \ + --host i686-w64-mingw32 \ + && make -j5 cd .. diff --git a/re2c/__build_redundant_exports.sh b/re2c/__build_redundant_exports.sh index 9e094756..4f04c5a0 100755 --- a/re2c/__build_redundant_exports.sh +++ b/re2c/__build_redundant_exports.sh @@ -5,6 +5,10 @@ rm -rf $builddir mkdir $builddir cd $builddir -../configure --enable-debug CFLAGS="-ffunction-sections -fdata-sections" LDFLAGS="-Wl,--gc-sections -Wl,--print-gc-sections" && \ -make -j5 +../configure \ + --enable-debug \ + --enable-libs \ + CFLAGS="-ffunction-sections -fdata-sections" \ + LDFLAGS="-Wl,--gc-sections -Wl,--print-gc-sections" \ + && make -j5 cd .. diff --git a/re2c/__build_ubsan.sh b/re2c/__build_ubsan.sh index 20312205..543ba001 100755 --- a/re2c/__build_ubsan.sh +++ b/re2c/__build_ubsan.sh @@ -5,6 +5,10 @@ rm -rf $builddir mkdir $builddir cd $builddir -../configure --enable-debug CXXFLAGS="-fsanitize=undefined" LDFLAGS="-fsanitize=undefined" && \ -make -j5 +../configure \ + --enable-debug \ + --enable-libs \ + CXXFLAGS="-fsanitize=undefined" \ + LDFLAGS="-fsanitize=undefined" \ + && make -j5 cd .. diff --git a/re2c/__distcheck.sh b/re2c/__distcheck.sh index 0d4dd6d4..dd1e8529 100755 --- a/re2c/__distcheck.sh +++ b/re2c/__distcheck.sh @@ -19,7 +19,7 @@ do cd $builddir # 'make' implies 'make docs'; running both in parallel may cause data races # configure without --enable-debug, this is the release binary - ../configure --enable-docs \ + ../configure --enable-docs --enable-libs \ && $make_prog bootstrap -j5 \ && $make_prog distcheck -j5 cd .. diff --git a/re2c/configure.ac b/re2c/configure.ac index 3466e21a..582d952e 100644 --- a/re2c/configure.ac +++ b/re2c/configure.ac @@ -3,6 +3,10 @@ AM_INIT_AUTOMAKE([foreign subdir-objects dist-xz no-dist-gzip]) AM_SILENT_RULES([yes]) +LT_INIT([dlopen]) +AC_CONFIG_MACRO_DIRS([m4]) + + AC_CONFIG_SRCDIR([src/main.cc]) AC_CONFIG_HEADERS([config.h]) @@ -31,8 +35,12 @@ AM_COND_IF([REBUILD_DOCS], [ ]) +# --enable-libs +AC_ARG_ENABLE([libs], [AS_HELP_STRING([--enable-libs], [build libraries])]) +AM_CONDITIONAL([WITH_LIBS], [test "x$enable_libs" = "xyes"]) + + # checks for programs -AC_PROG_RANLIB AC_PATH_PROG(BISON, bison, no) AC_PROG_CC # used in skeleton tests AC_PROG_CXX -- 2.50.1