Last-Update: 2014-12-10
Forwarded: https://code.google.com/p/crcutil/issues/detail?id=4
Author: Dmitry Smirnov <onlyjob@member.fsf.org>
Description: build proper library

--- a/Makefile.am
+++ b/Makefile.am
@@ -1,9 +1,47 @@
-AM_CXXFLAGS=-DCRCUTIL_USE_MM_CRC32=1 -Wall -msse2 -Icode
+AM_CXXFLAGS=-DCRCUTIL_USE_MM_CRC32=1 -Wall -mcrc32 -Icode
 AM_CFLAGS=$(AM_CXXFLAGS)
+
+lib_LTLIBRARIES = libcrcutil.la
+libcrcutil_la_SOURCES = \
+    code/crc32c_sse4.cc \
+    code/multiword_128_64_gcc_amd64_sse2.cc \
+    code/multiword_64_64_cl_i386_mmx.cc \
+    code/multiword_64_64_gcc_amd64_asm.cc \
+    code/multiword_64_64_gcc_i386_mmx.cc
+
+libcrcutil_la_LDFLAGS = -version-info $(LIBCRCUTIL_SO_VERSION) -no-undefined
+libcrcutil_includedir = $(includedir)/crcutil
+libcrcutil_include_HEADERS = \
+    code/base_types.h \
+    code/crc32c_sse4.h \
+    code/crc32c_sse4_intrin.h \
+    code/crc_casts.h \
+    code/generic_crc.h \
+    code/gf_util.h \
+    code/platform.h \
+    code/protected_crc.h \
+    code/rolling_crc.h \
+    code/std_headers.h \
+    code/uint128_sse2.h
+
+pkgconfigdir = $(libdir)/pkgconfig
+pkgconfig_DATA = libcrcutil.pc
+
 check_PROGRAMS=crcutil_ut
 TESTS=crcutil_ut
-crcutil_ut_SOURCES=code/base_types.h code/crc32c_sse4.cc code/crc32c_sse4.h code/crc32c_sse4_intrin.h code/crc_casts.h code/generic_crc.h code/gf_util.h code/multiword_128_64_gcc_amd64_sse2.cc code/multiword_64_64_cl_i386_mmx.cc code/multiword_64_64_gcc_amd64_asm.cc code/multiword_64_64_gcc_i386_mmx.cc code/platform.h code/protected_crc.h code/rolling_crc.h code/std_headers.h code/uint128_sse2.h tests/aligned_alloc.h tests/bob_jenkins_rng.h tests/rdtsc.h tests/set_hi_pri.c tests/unittest.cc tests/unittest.h tests/unittest_helper.h 
+crcutil_ut_SOURCES = \
+    tests/aligned_alloc.h \
+    tests/bob_jenkins_rng.h \
+    tests/rdtsc.h \
+    tests/set_hi_pri.c \
+    tests/unittest.cc \
+    tests/unittest.h \
+    tests/unittest_helper.h
+
+crcutil_ut_LDADD = libcrcutil.la
+
 tmpdir=/tmp
 tmp_PROGRAMS=usage
+usage_LDADD=libcrcutil.la
 usage_CXXFLAGS=$(AM_CXXFLAGS) -Itests
-usage_SOURCES=code/base_types.h code/crc32c_sse4.cc code/crc32c_sse4.h code/crc32c_sse4_intrin.h code/crc_casts.h code/generic_crc.h code/gf_util.h code/multiword_128_64_gcc_amd64_sse2.cc code/multiword_64_64_cl_i386_mmx.cc code/multiword_64_64_gcc_amd64_asm.cc code/multiword_64_64_gcc_i386_mmx.cc code/platform.h code/protected_crc.h code/rolling_crc.h code/std_headers.h code/uint128_sse2.h examples/interface.cc examples/interface.h examples/usage.cc tests/aligned_alloc.h 
+usage_SOURCES = examples/interface.cc examples/interface.h examples/usage.cc
--- a/configure.ac
+++ b/configure.ac
@@ -3,13 +3,19 @@
 
 AC_PREREQ([2.65])
 AC_INIT([crcutil], [1.0], [crcutil@googlegroups.com], [crcutil])
 AM_INIT_AUTOMAKE([subdir-objects serial-tests])
-AC_CONFIG_FILES([Makefile]) 
+AC_CONFIG_FILES([Makefile
+    libcrcutil.pc:libcrcutil.pc.in
+])
 AC_OUTPUT()
 AC_CONFIG_SRCDIR([tests/aligned_alloc.h])
 AC_CONFIG_HEADERS([config.h])
 
+# http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
+AC_SUBST([LIBCRCUTIL_SO_VERSION], [0:1:0])
+LT_INIT([])
+
 # Checks for programs.
 AC_PROG_CXX
 AC_PROG_CC
 AC_PROG_INSTALL
--- /dev/null
+++ b/libcrcutil.pc.in
@@ -0,0 +1,10 @@
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+libdir=@libdir@
+includedir=@includedir@/crcutil
+
+Name: @PACKAGE_NAME@
+Description: library for cyclic redundancy check (CRC) computation.
+Version: @PACKAGE_VERSION@
+Libs: -L${libdir} -lcrcutil
+Cflags: -I${includedir}
