diff mbox

[1/7] Makefile: Enable building shared libraries

Message ID 20120104210620.8810.32134.stgit@degas.1015granger.net
State Accepted
Headers show

Commit Message

Chuck Lever Jan. 4, 2012, 9:06 p.m. UTC
The new junction plug-ins will be shared libraries.  You can't build
a shared library from static libraries, so all of the libraries we
have in fedfs-utils need to be converted to shared libraries.

The use of "-fPIC" as a flag on $(LD) is incorrect, so I moved it to
$(CFLAGS) where needed.  "-fPIE" is appropriate for finished
executables.

As a final touch I converted all of the existing commands to grab the
shared version instead of the static version of each library.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---

 .gitignore                       |    3 +++
 src/fedfsc/Makefile.am           |   15 +++++++--------
 src/fedfsd/Makefile.am           |   15 +++++++--------
 src/libadmin/Makefile.am         |    6 +++---
 src/libjunction/Makefile.am      |   10 +++++-----
 src/libnsdb/Makefile.am          |   11 ++++++-----
 src/libparser/Makefile.am        |   10 +++++-----
 src/libsi/Makefile.am            |   10 +++++-----
 src/libxlog/Makefile.am          |   10 +++++-----
 src/mount/Makefile.am            |   11 +++++------
 src/nsdbc/Makefile.am            |   13 ++++++-------
 src/nsdbparams/Makefile.am       |   13 ++++++-------
 src/resolve-junction/Makefile.am |   15 +++++++--------
 13 files changed, 70 insertions(+), 72 deletions(-)
diff mbox

Patch

diff --git a/.gitignore b/.gitignore
index e9ab4a6..468a533 100644
--- a/.gitignore
+++ b/.gitignore
@@ -6,6 +6,8 @@  ChangeLog
 Doxygen/
 .*.swp
 *.o
+*.lo
+*.la
 src/fedfsd/fedfsd
 src/resolve-junction/resolve-junction
 src/nsdbparams/nsdbparams
@@ -64,4 +66,5 @@  libtool
 stamp-h1
 depcomp
 .deps/
+.libs/
 .stgit*
diff --git a/src/fedfsc/Makefile.am b/src/fedfsc/Makefile.am
index 2fd4d4d..2659e35 100644
--- a/src/fedfsc/Makefile.am
+++ b/src/fedfsc/Makefile.am
@@ -32,16 +32,15 @@  sbin_PROGRAMS		= fedfs-null \
 			  fedfs-lookup-replication
 LDADD			= $(LIBTIRPC) $(LIBLDAP) $(LIBLBER) \
 			  $(LIBSQLITE3) $(LIBIDN) $(LIBUUID) \
-			  $(top_builddir)/src/libadmin/libadmin.a \
-			  $(top_builddir)/src/libjunction/libjunction.a \
-			  $(top_builddir)/src/libnsdb/libnsdb.a \
-			  $(top_builddir)/src/libxlog/libxlog.a
+			  $(top_builddir)/src/libadmin/libadmin.la \
+			  $(top_builddir)/src/libjunction/libjunction.la \
+			  $(top_builddir)/src/libnsdb/libnsdb.la \
+			  $(top_builddir)/src/libxlog/libxlog.la
 
 CLEANFILES		= cscope.in.out cscope.out cscope.po.out *~
 DISTCLEANFILES		= Makefile.in
 
-AM_CFLAGS		= -ggdb -fstrict-aliasing -fpie -Wall -Wextra \
-			  -pedantic -Wformat=2 -Wstrict-aliasing=2 \
-			  -Wp,-D_FORTIFY_SOURCE=2
+AM_CFLAGS		= -ggdb -fstrict-aliasing -fPIE \
+			  -Wall -Wextra -pedantic -Wformat=2 \
+			  -Wstrict-aliasing=2 -Wp,-D_FORTIFY_SOURCE=2
 AM_CPPFLAGS		= -I. -I$(top_srcdir)/src/include -I/usr/include/tirpc
-AM_LDFLAGS		= -fPIC
diff --git a/src/fedfsd/Makefile.am b/src/fedfsd/Makefile.am
index c8332dc..37fd42f 100644
--- a/src/fedfsd/Makefile.am
+++ b/src/fedfsd/Makefile.am
@@ -29,19 +29,18 @@  sbin_PROGRAMS		= fedfsd
 fedfsd_SOURCES		= listen.c main.c privilege.c svc.c
 fedfsd_LDADD		= $(LIBTIRPC) $(LIBLDAP) $(LIBLBER) \
 			  $(LIBSQLITE3) $(LIBIDN) $(LIBUUID) $(LIBCAP) \
-			  $(top_builddir)/src/libadmin/libadmin.a \
-			  $(top_builddir)/src/libnsdb/libnsdb.a \
-			  $(top_builddir)/src/libjunction/libjunction.a \
-			  $(top_builddir)/src/libxlog/libxlog.a
+			  $(top_builddir)/src/libadmin/libadmin.la \
+			  $(top_builddir)/src/libnsdb/libnsdb.la \
+			  $(top_builddir)/src/libjunction/libjunction.la \
+			  $(top_builddir)/src/libxlog/libxlog.la
 
 CLEANFILES		= cscope.in.out cscope.out cscope.po.out *~
 DISTCLEANFILES		= Makefile.in
 
-AM_CFLAGS		= -ggdb -fstrict-aliasing -fpie -Wall -Wextra \
-			  -pedantic -Wformat=2 -Wstrict-aliasing=2 \
-			  -Wp,-D_FORTIFY_SOURCE=2
+AM_CFLAGS		= -ggdb -fstrict-aliasing -fPIE \
+			  -Wall -Wextra -pedantic -Wformat=2 \
+			  -Wstrict-aliasing=2 -Wp,-D_FORTIFY_SOURCE=2
 AM_CPPFLAGS		= -I. -I$(top_srcdir)/src/include -I/usr/include/tirpc
-AM_LDFLAGS		= -fPIC
 
 #######################################################################
 # The following allows the current practice of having
diff --git a/src/libadmin/Makefile.am b/src/libadmin/Makefile.am
index ac0095b..d59bc57 100644
--- a/src/libadmin/Makefile.am
+++ b/src/libadmin/Makefile.am
@@ -23,12 +23,12 @@ 
 ##	http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
 ##
 
-noinst_LIBRARIES	= libadmin.a
-libadmin_a_SOURCES	= fedfs_admin_clnt.c fedfs_admin_svc.c fedfs_admin_xdr.c
+noinst_LTLIBRARIES	= libadmin.la
+libadmin_la_SOURCES	= fedfs_admin_clnt.c fedfs_admin_svc.c fedfs_admin_xdr.c
 
 CLEANFILES		= cscope.in.out cscope.out cscope.po.out *~
 DISTCLEANFILES		= Makefile.in
 
 # Squelch compiler warnings for rpcgen-produced source code
-AM_CFLAGS		= -ggdb -fstrict-aliasing -fpie
+AM_CFLAGS		= -ggdb -fstrict-aliasing -fPIC
 AM_CPPFLAGS		= -I. -I$(top_srcdir)/src/include -I/usr/include/tirpc
diff --git a/src/libjunction/Makefile.am b/src/libjunction/Makefile.am
index b9e7b1a..bc97bf3 100644
--- a/src/libjunction/Makefile.am
+++ b/src/libjunction/Makefile.am
@@ -23,13 +23,13 @@ 
 ##	http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
 ##
 
-noinst_LIBRARIES	= libjunction.a
-libjunction_a_SOURCES	= junction.c
+noinst_LTLIBRARIES	= libjunction.la
+libjunction_la_SOURCES	= junction.c
 
 CLEANFILES		= cscope.in.out cscope.out cscope.po.out *~
 DISTCLEANFILES		= Makefile.in
 
-AM_CFLAGS		= -ggdb -fstrict-aliasing -fpie -Wall -Wextra \
-			  -pedantic -Wformat=2 -Wstrict-aliasing=2 \
-			  -Wp,-D_FORTIFY_SOURCE=2
+AM_CFLAGS		= -ggdb -fstrict-aliasing -fPIC \
+			  -Wall -Wextra -pedantic -Wformat=2 \
+			  -Wstrict-aliasing=2 -Wp,-D_FORTIFY_SOURCE=2
 AM_CPPFLAGS		= -I. -I$(top_srcdir)/src/include
diff --git a/src/libnsdb/Makefile.am b/src/libnsdb/Makefile.am
index f0a4dd6..cd7805b 100644
--- a/src/libnsdb/Makefile.am
+++ b/src/libnsdb/Makefile.am
@@ -24,14 +24,15 @@ 
 ##
 
 noinst_HEADERS		= nsdb-internal.h
-noinst_LIBRARIES	= libnsdb.a
-libnsdb_a_SOURCES	= administrator.c annotation.c display.c fileserver.c \
+
+noinst_LTLIBRARIES	= libnsdb.la
+libnsdb_la_SOURCES	= administrator.c annotation.c display.c fileserver.c \
 			  ldap.c nsdb.c path.c sqlite.c
 
 CLEANFILES		= cscope.in.out cscope.out cscope.po.out *~
 DISTCLEANFILES		= Makefile.in
 
-AM_CFLAGS		= -ggdb -fstrict-aliasing -fpie -Wall -Wextra \
-			  -pedantic -Wformat=2 -Wstrict-aliasing=2 \
-			  -Wp,-D_FORTIFY_SOURCE=2
+AM_CFLAGS		= -ggdb -fstrict-aliasing -fPIC \
+			  -Wall -Wextra -pedantic -Wformat=2 \
+			  -Wstrict-aliasing=2 -Wp,-D_FORTIFY_SOURCE=2
 AM_CPPFLAGS		= -I. -I$(top_srcdir)/src/include
diff --git a/src/libparser/Makefile.am b/src/libparser/Makefile.am
index 2ef8549..75b43e9 100644
--- a/src/libparser/Makefile.am
+++ b/src/libparser/Makefile.am
@@ -23,13 +23,13 @@ 
 ##	http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
 ##
 
-noinst_LIBRARIES	= libparser.a
-libparser_a_SOURCES	= parse_opt.c token.c
+noinst_LTLIBRARIES	= libparser.la
+libparser_la_SOURCES	= parse_opt.c token.c
 
 CLEANFILES		= cscope.in.out cscope.out cscope.po.out *~
 DISTCLEANFILES		= Makefile.in
 
-AM_CFLAGS		= -ggdb -fstrict-aliasing -fpie -Wall -Wextra \
-			  -pedantic -Wformat=2 -Wstrict-aliasing=2 \
-			  -Wp,-D_FORTIFY_SOURCE=2
+AM_CFLAGS		= -ggdb -fstrict-aliasing -fPIC \
+			  -Wall -Wextra -pedantic -Wformat=2 \
+			  -Wstrict-aliasing=2 -Wp,-D_FORTIFY_SOURCE=2
 AM_CPPFLAGS		= -I. -I$(top_srcdir)/src/include
diff --git a/src/libsi/Makefile.am b/src/libsi/Makefile.am
index af9fe8c..e270d4a 100644
--- a/src/libsi/Makefile.am
+++ b/src/libsi/Makefile.am
@@ -23,13 +23,13 @@ 
 ##	http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
 ##
 
-noinst_LIBRARIES	= libsi.a
-libsi_a_SOURCES		= getsrvinfo.c
+noinst_LTLIBRARIES	= libsi.la
+libsi_la_SOURCES	= getsrvinfo.c
 
 CLEANFILES		= cscope.in.out cscope.out cscope.po.out *~
 DISTCLEANFILES		= Makefile.in
 
-AM_CFLAGS		= -ggdb -fstrict-aliasing -fpie -Wall -Wextra \
-			  -pedantic -Wformat=2 -Wstrict-aliasing=2 \
-			  -Wp,-D_FORTIFY_SOURCE=2
+AM_CFLAGS		= -ggdb -fstrict-aliasing -fPIC \
+			  -Wall -Wextra -pedantic -Wformat=2 \
+			  -Wstrict-aliasing=2 -Wp,-D_FORTIFY_SOURCE=2
 AM_CPPFLAGS		= -I. -I$(top_srcdir)/src/include
diff --git a/src/libxlog/Makefile.am b/src/libxlog/Makefile.am
index 677e7b8..1e85fa6 100644
--- a/src/libxlog/Makefile.am
+++ b/src/libxlog/Makefile.am
@@ -23,13 +23,13 @@ 
 ##	http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
 ##
 
-noinst_LIBRARIES	= libxlog.a
-libxlog_a_SOURCES	= xlog.c
+noinst_LTLIBRARIES	= libxlog.la
+libxlog_la_SOURCES	= xlog.c
 
 CLEANFILES		= cscope.in.out cscope.out cscope.po.out *~
 DISTCLEANFILES		= Makefile.in
 
-AM_CFLAGS		= -ggdb -fstrict-aliasing -fpie -Wall -Wextra \
-			  -pedantic -Wformat=2 -Wstrict-aliasing=2 \
-			  -Wp,-D_FORTIFY_SOURCE=2
+AM_CFLAGS		= -ggdb -fstrict-aliasing -fPIC \
+			  -Wall -Wextra -pedantic -Wformat=2 \
+			  -Wstrict-aliasing=2 -Wp,-D_FORTIFY_SOURCE=2
 AM_CPPFLAGS		= -I $(top_srcdir)/src/include
diff --git a/src/mount/Makefile.am b/src/mount/Makefile.am
index 7dbab03..7b00b4a 100644
--- a/src/mount/Makefile.am
+++ b/src/mount/Makefile.am
@@ -28,17 +28,16 @@  root_sbin_PROGRAMS	= mount.fedfs
 sbin_PROGRAMS		= fedfs-map-nfs4
 fedfs_map_nfs4_SOURCES	= fedfs-map-nfs4.c
 fedfs_map_nfs4_LDADD	= $(LIBRESOLV) \
-			  $(top_builddir)/src/libsi/libsi.a
+			  $(top_builddir)/src/libsi/libsi.la
 mount_fedfs_SOURCES	= main.c
 # mount.fedfs must never link against libraries in /usr
 mount_fedfs_LDADD	= $(LIBRESOLV) \
-			  $(top_builddir)/src/libsi/libsi.a
+			  $(top_builddir)/src/libsi/libsi.la
 
 CLEANFILES		= cscope.in.out cscope.out cscope.po.out *~
 DISTCLEANFILES		= Makefile.in
 
-AM_CFLAGS		= -ggdb -fstrict-aliasing -fpie -Wall -Wextra \
-			  -pedantic -Wformat=2 -Wstrict-aliasing=2 \
-			  -Wp,-D_FORTIFY_SOURCE=2
+AM_CFLAGS		= -ggdb -fstrict-aliasing -fPIE \
+			  -Wall -Wextra -pedantic -Wformat=2 \
+			  -Wstrict-aliasing=2 -Wp,-D_FORTIFY_SOURCE=2
 AM_CPPFLAGS		= -I. -I$(top_srcdir)/src/include
-AM_LDFLAGS		= -fPIC
diff --git a/src/nsdbc/Makefile.am b/src/nsdbc/Makefile.am
index 9dfb642..a52d91c 100644
--- a/src/nsdbc/Makefile.am
+++ b/src/nsdbc/Makefile.am
@@ -30,15 +30,14 @@  sbin_PROGRAMS		= nsdb-annotate nsdb-describe nsdb-list \
 			  nsdb-create-fsl nsdb-delete-fsl nsdb-update-fsl
 LDADD			= $(LIBLDAP) $(LIBLBER) \
 			  $(LIBSQLITE3) $(LIBIDN) $(LIBUUID) \
-			  $(top_builddir)/src/libnsdb/libnsdb.a \
-			  $(top_builddir)/src/libxlog/libxlog.a \
-			  $(top_builddir)/src/libjunction/libjunction.a
+			  $(top_builddir)/src/libnsdb/libnsdb.la \
+			  $(top_builddir)/src/libxlog/libxlog.la \
+			  $(top_builddir)/src/libjunction/libjunction.la
 
 CLEANFILES		= cscope.in.out cscope.out cscope.po.out *~
 DISTCLEANFILES		= Makefile.in
 
-AM_CFLAGS		= -ggdb -fstrict-aliasing -fpie -Wall -Wextra \
-			  -pedantic -Wformat=2 -Wstrict-aliasing=2 \
-			  -Wp,-D_FORTIFY_SOURCE=2
+AM_CFLAGS		= -ggdb -fstrict-aliasing -fPIE \
+			  -Wall -Wextra -pedantic -Wformat=2 \
+			  -Wstrict-aliasing=2 -Wp,-D_FORTIFY_SOURCE=2
 AM_CPPFLAGS		= -I$(top_srcdir)/src/include -I/usr/include/tirpc
-AM_LDFLAGS		= -fPIC
diff --git a/src/nsdbparams/Makefile.am b/src/nsdbparams/Makefile.am
index 2109c87..b21220e 100644
--- a/src/nsdbparams/Makefile.am
+++ b/src/nsdbparams/Makefile.am
@@ -28,15 +28,14 @@  sbin_PROGRAMS		= nsdbparams
 nsdbparams_SOURCES	= delete.c list.c main.c show.c update.c
 LDADD			= $(LIBLDAP) $(LIBLBER) \
 			  $(LIBSQLITE3) $(LIBIDN) $(LIBUUID) $(LIBCAP) \
-			  $(top_builddir)/src/libnsdb/libnsdb.a \
-			  $(top_builddir)/src/libjunction/libjunction.a \
-			  $(top_builddir)/src/libxlog/libxlog.a
+			  $(top_builddir)/src/libnsdb/libnsdb.la \
+			  $(top_builddir)/src/libjunction/libjunction.la \
+			  $(top_builddir)/src/libxlog/libxlog.la
 
 CLEANFILES		= cscope.in.out cscope.out cscope.po.out *~
 DISTCLEANFILES		= Makefile.in
 
-AM_CFLAGS		= -ggdb -fstrict-aliasing -fpie -Wall -Wextra \
-			  -pedantic -Wformat=2 -Wstrict-aliasing=2 \
-			  -Wp,-D_FORTIFY_SOURCE=2
+AM_CFLAGS		= -ggdb -fstrict-aliasing -fPIE \
+			  -Wall -Wextra -pedantic -Wformat=2 \
+			  -Wstrict-aliasing=2 -Wp,-D_FORTIFY_SOURCE=2
 AM_CPPFLAGS		= -I. -I$(top_srcdir)/src/include -I/usr/include/tirpc
-AM_LDFLAGS		= -fPIC
diff --git a/src/resolve-junction/Makefile.am b/src/resolve-junction/Makefile.am
index ec5f5a7..323a1d9 100644
--- a/src/resolve-junction/Makefile.am
+++ b/src/resolve-junction/Makefile.am
@@ -29,16 +29,15 @@  sbin_PROGRAMS		= resolve-junction
 resolve_junction_SOURCES = main.c privilege.c privilege.h
 LDADD			= $(LIBLDAP) $(LIBLBER) \
 			  $(LIBSQLITE3) $(LIBIDN) $(LIBUUID) $(LIBCAP) \
-			  $(top_builddir)/src/libadmin/libadmin.a \
-			  $(top_builddir)/src/libnsdb/libnsdb.a \
-			  $(top_builddir)/src/libjunction/libjunction.a \
-			  $(top_builddir)/src/libxlog/libxlog.a
+			  $(top_builddir)/src/libadmin/libadmin.la \
+			  $(top_builddir)/src/libnsdb/libnsdb.la \
+			  $(top_builddir)/src/libjunction/libjunction.la \
+			  $(top_builddir)/src/libxlog/libxlog.la
 
 CLEANFILES		= cscope.in.out cscope.out cscope.po.out *~
 DISTCLEANFILES		= Makefile.in
 
-AM_CFLAGS		= -ggdb -fstrict-aliasing -fpie -Wall -Wextra \
-			  -pedantic -Wformat=2 -Wstrict-aliasing=2 \
-			  -Wp,-D_FORTIFY_SOURCE=2
+AM_CFLAGS		= -ggdb -fstrict-aliasing -fPIE \
+			  -Wall -Wextra -pedantic -Wformat=2 \
+			  -Wstrict-aliasing=2 -Wp,-D_FORTIFY_SOURCE=2
 AM_CPPFLAGS		= -I. -I$(top_srcdir)/src/include -I/usr/include/tirpc
-AM_LDFLAGS		= -fPIC