Skip to content

Commit

Permalink
build: use libtool for linking
Browse files Browse the repository at this point in the history
Signed-off-by: Fabio M. Di Nitto <fdinitto@redhat.com>
Reviewed-by: Jan Friesse <jfriesse@redhat.com>
  • Loading branch information
fabbione committed Aug 28, 2012
1 parent 02611b3 commit 76d18f9
Show file tree
Hide file tree
Showing 9 changed files with 161 additions and 293 deletions.
8 changes: 7 additions & 1 deletion Makefile.am
Expand Up @@ -42,9 +42,12 @@ EXTRA_DIST = autogen.sh $(SPEC).in \

AUTOMAKE_OPTIONS = foreign

ACLOCAL_AMFLAGS = -I m4

MAINTAINERCLEANFILES = Makefile.in aclocal.m4 configure depcomp \
config.guess config.sub missing install-sh \
autoheader automake autoconf test_lense.sh
autoheader automake autoconf test_lense.sh \
autoscan.log configure.scan ltmain.sh

dist_doc_DATA = LICENSE INSTALL README.recovery SECURITY TODO AUTHORS

Expand Down Expand Up @@ -188,3 +191,6 @@ gen-ChangeLog:
_version:
cd $(srcdir) && rm -rf autom4te.cache .version && autoreconf -i
$(MAKE) $(AM_MAKEFLAGS) Makefile

maintainer-clean-local:
rm -rf m4
2 changes: 1 addition & 1 deletion autogen.sh
@@ -1,5 +1,5 @@
#!/bin/sh
# Run this to generate all the initial makefiles, etc.

mkdir -p m4
echo Building configuration system...
autoreconf -i && echo Now run ./configure and make
70 changes: 7 additions & 63 deletions common_lib/Makefile.am
Expand Up @@ -29,70 +29,14 @@
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
# THE POSSIBILITY OF SUCH DAMAGE.

# Functions
uc=$(shell echo $1 | tr a-z A-Z)
get_soname=$(if $($(call uc,$1)_SONAME),$($(call uc,$1)_SONAME),$(SONAME))
get_major=$(firstword $(subst ., ,$(call get_soname,$1)))
get_sharedlibs=$(foreach lib,$(SHARED_LIBS_SO:lib%.so=%),lib$(lib).so.$(call get_soname,$(lib)))
get_sharedlibs_two=$(foreach lib,$(SHARED_LIBS_SO:lib%.so=%),lib$(lib).so.$(call get_major,$(lib)))
get_linker_add=$(if $($(call uc,$1)_LINKER_ADD),$($(call uc,$1)_LINKER_ADD))
MAINTAINERCLEANFILES = Makefile.in

MAINTAINERCLEANFILES = Makefile.in
AM_CFLAGS = -fPIC \
-I$(top_builddir)/include \
-I$(top_srcdir)/include

AM_CFLAGS = -fPIC
lib_LTLIBRARIES = libcorosync_common.la

INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include
libcorosync_common_la_SOURCES = error_conversion.c

lib_LIBRARIES = libcorosync_common.a
SHARED_LIBS_SO = $(lib_LIBRARIES:%.a=%.so)

libcorosync_common_a_SOURCES = error_conversion.c

SOMAJOR=4
SOMINOR=0
SOMICRO=0
SONAME=${SOMAJOR}.${SOMINOR}.${SOMICRO}

if BUILD_DARWIN

lib%.so: lib%.a $(LIBQB_LIBS)
$(CC) $(DARWIN_OPTS) $(call get_linker_add,$*) -Wl,-whole-archive $^ -Wl,-no-whole-archive -o $@
ln -sf lib$*.so.$(call get_soname,$*) lib$*.so
ln -sf lib$*.so.$(call get_soname,$*) lib$*.so.$(call get_major,$*)

else

if BUILD_SOLARIS

lib%.so.$(SONAME): lib%.a
$(LD) $(SOLARIS_OPTS) $(call get_linker_add,$*) -G -whole-archive $^ -no-whole-archive -o $@
ln -sf lib$*.so.$(call get_soname,$*) lib$*.so
ln -sf lib$*.so.$(call get_soname,$*) lib$*.so.$(call get_major,$*)

else

lib%.so: lib%.a
$(CC) -shared -o $@.$(call get_soname,$*) \
-Wl,-soname=lib$*.so.$(call get_major,$*) \
-Wl,-whole-archive $^ -Wl,-no-whole-archive $(LDFLAGS) $(LIBQB_LIBS) $(AM_LDFLAGS) $(call get_linker_add,$*)
ln -sf lib$*.so.$(call get_soname,$*) lib$*.so
ln -sf lib$*.so.$(call get_soname,$*) lib$*.so.$(call get_major,$*)

endif

endif

all-local: $(get_explicit_sharedlibs) $(SHARED_LIBS_SO)
@echo Built shared libs

install-exec-local:
$(INSTALL) -d $(DESTDIR)/$(libdir)
$(INSTALL) -m 755 $(get_sharedlibs) $(DESTDIR)/$(libdir)
$(CP) -a $(SHARED_LIBS_SO) $(get_sharedlibs_two) $(DESTDIR)/$(libdir)

uninstall-local:
cd $(DESTDIR)/$(libdir)/ && \
rm -f $(get_sharedlibs) $(SHARED_LIBS_SO) $(get_sharedlibs_two)

clean-local:
rm -f *.o *.a *.so* *.da *.bb *.bbg
libcorosync_common_la_LDFLAGS = -version-number 4:0:0
18 changes: 8 additions & 10 deletions configure.ac
Expand Up @@ -9,10 +9,15 @@ AC_INIT([corosync],
[discuss@lists.corosync.org])

AM_INIT_AUTOMAKE([-Wno-portability])

LT_PREREQ([2.2.6])
LT_INIT

AM_SILENT_RULES([yes])

AC_CONFIG_SRCDIR([lib/cpg.c])
AC_CONFIG_HEADER([include/corosync/config.h])
AC_CONFIG_MACRO_DIR([m4])

AC_CANONICAL_HOST

Expand Down Expand Up @@ -57,11 +62,13 @@ fi
sinclude(coroysync-default.m4)

AC_PROG_CC
AC_PROG_CXX
AC_PROG_INSTALL
AC_PROG_LN_S
AC_PROG_MAKE_SET
AC_PROG_RANLIB
AC_PROG_SED
AC_PROG_LIBTOOL

AC_CHECK_PROGS([GROFF], [groff])
AC_CHECK_PROGS([PKGCONFIG], [pkg-config])
Expand Down Expand Up @@ -318,14 +325,12 @@ AM_CONDITIONAL(BUILD_QDEVICES, test x$enable_qdevices = xyes)

# OS detection
# THIS SECTION MUST DIE!
CP=cp
OS_LDL="-ldl"
have_linux="no"
case "$host_os" in
*linux*)
AC_DEFINE_UNQUOTED([COROSYNC_LINUX], [1],
[Compiling for Linux platform])
OS_CFLAGS=""
OS_CPPFLAGS="-D_GNU_SOURCE"
OS_LDFLAGS=""
OS_DYFLAGS="-rdynamic"
Expand All @@ -335,8 +340,6 @@ case "$host_os" in
darwin*)
AC_DEFINE_UNQUOTED([COROSYNC_DARWIN], [1],
[Compiling for Darwin platform])
CP=rsync
OS_CFLAGS=""
OS_CPPFLAGS=""
OS_LDFLAGS=""
OS_DYFLAGS=""
Expand All @@ -355,7 +358,6 @@ case "$host_os" in
[Compiling for BSD platform])
AC_DEFINE_UNQUOTED([MAP_ANONYMOUS], [MAP_ANON],
[Shared memory define for Darwin platform])
OS_CFLAGS=""
OS_CPPFLAGS="-I/usr/local/include"
OS_LDFLAGS="-L/usr/local/lib"
OS_DYFLAGS="-export-dynamic"
Expand All @@ -377,8 +379,6 @@ case "$host_os" in
[Prevent being scheduled RR])
AC_DEFINE_UNQUOTED([_SEM_SEMUN_UNDEFINED], [1],
[The semun structure is undefined])
CP=rsync
OS_CFLAGS=""
OS_CPPFLAGS="-D_REENTRANT"
OS_LDFLAGS=""
OS_DYFLAGS="-Wl,-z,lazyload"
Expand All @@ -390,7 +390,6 @@ case "$host_os" in
;;
esac

AC_SUBST(CP)
# *FLAGS handling goes here

ENV_CFLAGS="$CFLAGS"
Expand Down Expand Up @@ -596,7 +595,7 @@ if test "x${enable_user_flags}" = xyes; then
fi

# final build of *FLAGS
CFLAGS="$ENV_CFLAGS $OPT_CFLAGS $GDB_FLAGS $OS_CFLAGS \
CFLAGS="$ENV_CFLAGS $OPT_CFLAGS $GDB_FLAGS \
$COVERAGE_CFLAGS $EXTRA_WARNINGS $WERROR_CFLAGS $NSS_CFLAGS"
CPPFLAGS="$ENV_CPPFLAGS $ANSI_CPPFLAGS $OS_CPPFLAGS"
LDFLAGS="$ENV_LDFLAGS $COVERAGE_LDFLAGS $OS_LDFLAGS"
Expand Down Expand Up @@ -666,7 +665,6 @@ AC_MSG_RESULT([ Extra compiler warnings = ${EXTRA_WARNING}])
AC_MSG_RESULT([ Env. defined CFLAG = ${ENV_CFLAGS}])
AC_MSG_RESULT([ Env. defined CPPFLAGS = ${ENV_CPPFLAGS}])
AC_MSG_RESULT([ Env. defined LDFLAGS = ${ENV_LDFLAGS}])
AC_MSG_RESULT([ OS defined CFLAGS = ${OS_CFLAGS}])
AC_MSG_RESULT([ OS defined CPPFLAGS = ${OS_CPPFLAGS}])
AC_MSG_RESULT([ OS defined LDFLAGS = ${OS_LDFLAGS}])
AC_MSG_RESULT([ OS defined LDL = ${OS_LDL}])
Expand Down
61 changes: 37 additions & 24 deletions cts/agents/Makefile.am
Expand Up @@ -29,40 +29,53 @@
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
# THE POSSIBILITY OF SUCH DAMAGE.

MAINTAINERCLEANFILES = Makefile.in
INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include \
-I$(top_builddir)/include/corosync
MAINTAINERCLEANFILES = Makefile.in

SOURCES =
TEST_AGENTS = cpg_test_agent sam_test_agent votequorum_test_agent
TEST_AGENTS = cpg_test_agent \
sam_test_agent \
votequorum_test_agent

SHELL_TESTS = mem_leak_test.sh \
net_breaker.sh \
cmap-dispatch-deadlock.sh \
shm_leak_audit.sh

noinst_HEADERS = common_test_agent.h

if INSTALL_TESTAGENTS
agentdir = $(datadir)/$(PACKAGE)/tests
bin_PROGRAMS = $(TEST_AGENTS)
dist_agent_SCRIPTS = mem_leak_test.sh net_breaker.sh cmap-dispatch-deadlock.sh shm_leak_audit.sh
AM_CFLAGS = -fPIC
agentdir = $(datadir)/$(PACKAGE)/tests
bin_PROGRAMS = $(TEST_AGENTS)
dist_agent_SCRIPTS = $(SHELL_TESTS)
else
noinst_PROGRAMS = $(TEST_AGENTS)
noinst_SCRIPTS = mem_leak_test.sh net_breaker.sh cmap-dispatch-deadlock.sh shm_leak_audit.sh
noinst_PROGRAMS = $(TEST_AGENTS)
noinst_SCRIPTS = $(SHELL_TESTS)
endif

noinst_HEADERS = common_test_agent.h
AM_CPPFLAGS = -I$(top_builddir)/include \
-I$(top_srcdir)/include \
-I$(top_builddir)/include/corosync

cpg_test_agent_SOURCES = cpg_test_agent.c common_test_agent.c
cpg_test_agent_CFLAGS = $(nss_CFLAGS)
cpg_test_agent_LDADD = -lcpg -lcfg -lcorosync_common $(LIBQB_LIBS) $(nss_LIBS)
cpg_test_agent_LDFLAGS = -L../../lib -L. -L../../common_lib
AM_CFLAGS = -fPIC

sam_test_agent_SOURCES = sam_test_agent.c common_test_agent.c
sam_test_agent_LDADD = -lsam -lquorum -lcmap -lcorosync_common $(LIBQB_LIBS)
sam_test_agent_LDFLAGS = -L../../lib -L../../common_lib
cpg_test_agent_SOURCES = cpg_test_agent.c common_test_agent.c
cpg_test_agent_CFLAGS = $(nss_CFLAGS)
cpg_test_agent_LDADD = $(LIBQB_LIBS) $(nss_LIBS) \
$(top_builddir)/lib/libcfg.la \
$(top_builddir)/lib/libcpg.la \
$(top_builddir)/common_lib/libcorosync_common.la

votequorum_test_agent_SOURCES = votequorum_test_agent.c common_test_agent.c
votequorum_test_agent_LDADD = -lvotequorum -lquorum -lcorosync_common $(LIBQB_LIBS)
votequorum_test_agent_LDFLAGS = -L../../lib -L../../common_lib
sam_test_agent_SOURCES = sam_test_agent.c common_test_agent.c
sam_test_agent_LDADD = $(LIBQB_LIBS) \
$(top_builddir)/lib/libsam.la \
$(top_builddir)/lib/libcmap.la \
$(top_builddir)/lib/libquorum.la \
$(top_builddir)/common_lib/libcorosync_common.la

clean-local:
rm -f *.o *.a *.so* *.da *.bb *.bbg
votequorum_test_agent_SOURCES = votequorum_test_agent.c common_test_agent.c
votequorum_test_agent_LDADD = $(LIBQB_LIBS) \
$(top_builddir)/lib/libquorum.la \
$(top_builddir)/lib/libvotequorum.la \
$(top_builddir)/common_lib/libcorosync_common.la

lint:
-splint $(LINT_FLAGS) $(CFLAGS) *.c
Expand Down
84 changes: 23 additions & 61 deletions exec/Makefile.am
Expand Up @@ -31,83 +31,45 @@

MAINTAINERCLEANFILES = Makefile.in

AM_CFLAGS = -fPIC -DLOGCONFIG_USE_ICMAP=1
AM_CFLAGS = -fPIC

INCLUDES = -I$(top_builddir)/include -I$(top_srcdir)/include $(nss_CFLAGS) $(rdmacm_CFLAGS) $(ibverbs_CFLAGS)
AM_CPPFLAGS = -DLOGCONFIG_USE_ICMAP=1 \
-I$(top_builddir)/include \
-I$(top_srcdir)/include \
$(nss_CFLAGS) $(rdmacm_CFLAGS) $(ibverbs_CFLAGS)

noinst_HEADERS = apidef.h cs_queue.h logconfig.h main.h \
quorum.h service.h timer.h totemconfig.h \
totemmrp.h totemnet.h totemudp.h totemiba.h \
totemrrp.h totemudpu.h totemsrp.h util.h vsf.h \
schedwrk.h sync.h fsm.h votequorum.h vsf_ykd.h \
totemcrypto.h

TOTEM_SRC = totemip.c totemnet.c totemudp.c \
totemudpu.c totemrrp.c totemsrp.c totemmrp.c \
totempg.c cs_queue.h totemcrypto.c
totempg.c totemcrypto.c

if BUILD_RDMA
TOTEM_SRC += totemiba.c
endif

lib_LIBRARIES = libtotem_pg.a
sbin_PROGRAMS = corosync
lib_LTLIBRARIES = libtotem_pg.la
libtotem_pg_la_SOURCES = $(TOTEM_SRC)
libtotem_pg_la_LDFLAGS = -version-number $(subst .,:,$(SONAME))
libtotem_pg_la_LIBADD = -lpthread $(nss_LIBS) $(rdmacm_LIBS) $(ibverbs_LIBS)

libtotem_pg_a_SOURCES = $(TOTEM_SRC)
sbin_PROGRAMS = corosync

corosync_SOURCES = vsf_ykd.c coroparse.c vsf_quorum.c sync.c \
logsys.c cfg.c cmap.c cpg.c mon.c pload.c \
votequorum.c wd.c util.c schedwrk.c main.c \
apidef.c quorum.c icmap.c timer.c \
ipc_glue.c service.c logconfig.c totemconfig.c
corosync_LDADD = -ltotem_pg -lcorosync_common $(LIBQB_LIBS) $(statgrab_LIBS)
corosync_DEPENDENCIES = libtotem_pg.so.$(SONAME) ../common_lib/libcorosync_common.so
corosync_LDFLAGS = $(OS_DYFLAGS) -L./ -L../common_lib

TOTEM_OBJS = $(TOTEM_SRC:%.c=%.o)

SHARED_LIBS = $(lib_LIBRARIES:%.a=%.so.$(SONAME))
SHARED_LIBS_SO = $(SHARED_LIBS:%.so.$(SONAME)=%.so)
SHARED_LIBS_SO_TWO = $(SHARED_LIBS:%.so.$(SONAME)=%.so.$(SOMAJOR))

noinst_HEADERS = apidef.h logconfig.h main.h \
quorum.h service.h timer.h totemconfig.h \
totemmrp.h totemnet.h totemudp.h totemiba.h totemrrp.h \
totemudpu.h totemsrp.h util.h vsf.h schedwrk.h \
sync.h fsm.h votequorum.h vsf_ykd.h totemcrypto.h

if BUILD_DARWIN
libtotem_pg.so.$(SONAME): $(TOTEM_OBJS)
$(CC) $(LDFLAGS) $(DARWIN_OPTS) $(TOTEM_OBJS) -o $@ -lpthread
ln -sf libtotem_pg.so.$(SONAME) libtotem_pg.so
ln -sf libtotem_pg.so.$(SONAME) libtotem_pg.so.$(SOMAJOR)

else

if BUILD_SOLARIS
libtotem_pg.so.$(SONAME): $(TOTEM_OBJS)
$(LD) $(LDFLAGS) -G $(TOTEM_OBJS) -o $@ -lpthread
ln -sf libtotem_pg.so.$(SONAME) libtotem_pg.so
ln -sf libtotem_pg.so.$(SONAME) libtotem_pg.so.$(SOMAJOR)

else
libtotem_pg.so.$(SONAME): $(TOTEM_OBJS)
$(CC) -shared -o $@ \
-Wl,-soname=libtotem_pg.so.$(SOMAJOR) \
$(LDFLAGS) $^ $(nss_LIBS) $(rdmacm_LIBS) $(ibverbs_LIBS) -lpthread
ln -sf libtotem_pg.so.$(SONAME) libtotem_pg.so
ln -sf libtotem_pg.so.$(SONAME) libtotem_pg.so.$(SOMAJOR)

endif

endif
corosync_LDADD = libtotem_pg.la ../common_lib/libcorosync_common.la \
$(LIBQB_LIBS) $(statgrab_LIBS)
corosync_DEPENDENCIES = libtotem_pg.la ../common_lib/libcorosync_common.la

lint:
-splint $(INCLUDES) $(LINT_FLAGS) $(CFLAGS) *.c

all-local: $(SHARED_LIBS)
@echo Built corosync Executive

install-exec-local:
$(INSTALL) -d $(DESTDIR)/$(libdir)
$(INSTALL) -m 755 $(SHARED_LIBS) $(DESTDIR)/$(libdir)
$(CP) -a $(SHARED_LIBS_SO) $(SHARED_LIBS_SO_TWO) $(DESTDIR)/$(libdir)

uninstall-local:
cd $(DESTDIR)/$(libdir) && \
rm -f $(SHARED_LIBS) $(SHARED_LIBS_SO) $(SHARED_LIBS_SO_TWO)

clean-local:
rm -f corosync *.o gmon.out *.da *.bb *.bbg *.so*
-splint $(AM_CPPFLAGS) $(LINT_FLAGS) $(CFLAGS) *.c

0 comments on commit 76d18f9

Please sign in to comment.