531551
From 097c66ef2dd4779e01d13ad4a5f9733334fa9d1a Mon Sep 17 00:00:00 2001
531551
From: Karel Zak <kzak@redhat.com>
531551
Date: Tue, 27 Aug 2013 10:02:04 +0200
531551
Subject: [PATCH 60/84] build-sys: add CFLAGS and LDFLAGS for daemons and
531551
 shared libs
531551
531551
This is necessary for paranoid security guys who believe that things
531551
like "-Wl,-z,relro" or "-Wl,-z,bind_now" is a way how to make the
531551
world a safer place...
531551
531551
[rhel7: add also SOLIB_* to libfdisk]
531551
531551
Upstream: http://github.com/karelzak/util-linux/commit/03d00d495f3b505d9cae967c629fb38aca301e01
531551
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1092520
531551
Signed-off-by: Karel Zak <kzak@redhat.com>
531551
---
531551
 Documentation/howto-compilation.txt | 10 +++++-----
531551
 configure.ac                        | 10 ++++++++++
531551
 libblkid/src/Makemodule.am          |  2 ++
531551
 libfdisk/src/Makemodule.am          |  3 +++
531551
 libmount/src/Makemodule.am          |  2 ++
531551
 libuuid/src/Makemodule.am           |  7 ++++++-
531551
 misc-utils/Makemodule.am            |  3 ++-
531551
 7 files changed, 30 insertions(+), 7 deletions(-)
531551
531551
diff --git a/Documentation/howto-compilation.txt b/Documentation/howto-compilation.txt
531551
index bebe0d2..4b39246 100644
531551
--- a/Documentation/howto-compilation.txt
531551
+++ b/Documentation/howto-compilation.txt
531551
@@ -27,12 +27,12 @@ Compiling
531551
 	The SUID_* feature is currently supported for chfn, chsh,
531551
 	newgrp, su, write, mount, and umount.
531551
 
531551
-	Preferred compilation options for developers, when
531551
-	using gcc, are:
531551
+	Use DAEMON_CFLAGS and DAEMON_LDFLAGS when you want to define
531551
+	special compiler options for daemons; supported for uuidd.
531551
 
531551
-	export CFLAGS="-Wmissing-parameter-type -Wsign-compare
531551
-	-Wtype-limits -Wuninitialized -Wunused-parameter
531551
-	-Wunused-but-set-parameter -fno-common"
531551
+	Use SOLIB_CFLAGS and SOLIB_LDFLAGS when you want to define
531551
+	special compiler options for shared libraries; supported for
531551
+	libmount, libblkid and libuuid.
531551
 
531551
 	FIXME: add notes about klib and uClib.
531551
 
531551
diff --git a/configure.ac b/configure.ac
531551
index f7c27cd..f3c7214 100644
531551
--- a/configure.ac
531551
+++ b/configure.ac
531551
@@ -1538,6 +1538,16 @@ AC_ARG_VAR([SUID_CFLAGS],
531551
 AC_ARG_VAR([SUID_LDFLAGS],
531551
 	   [LDFLAGS used for binaries which are usually with the suid bit])
531551
 
531551
+AC_ARG_VAR([DAEMON_CFLAGS],
531551
+	   [CFLAGS used for binaries which are usually executed as daemons])
531551
+AC_ARG_VAR([DAEMON_LDFLAGS],
531551
+	   [LDFLAGS used for binaries which are usually executed as daemons])
531551
+
531551
+AC_ARG_VAR([SOLIB_CFLAGS],
531551
+	   [CFLAGS used for shared libraries])
531551
+AC_ARG_VAR([SOLIB_LDFLAGS],
531551
+	   [LDFLAGS used for shared libraries])
531551
+
531551
 LIBS=""
531551
 
531551
 
531551
diff --git a/libblkid/src/Makemodule.am b/libblkid/src/Makemodule.am
531551
index 04d8621..1563976 100644
531551
--- a/libblkid/src/Makemodule.am
531551
+++ b/libblkid/src/Makemodule.am
531551
@@ -113,6 +113,7 @@ libblkid_la_LIBADD = libcommon.la
531551
 
531551
 
531551
 libblkid_la_CFLAGS = \
531551
+	$(SOLIB_CFLAGS) \
531551
 	-I$(ul_libblkid_incdir) \
531551
 	-I$(top_srcdir)/libblkid/src
531551
 
531551
@@ -128,6 +129,7 @@ libblkid_la_DEPENDENCIES = \
531551
 	libblkid/src/blkid.h.in
531551
 
531551
 libblkid_la_LDFLAGS = \
531551
+	$(SOLIB_LDFLAGS) \
531551
 	-Wl,--version-script=$(top_srcdir)/libblkid/src/blkid.sym \
531551
 	-version-info $(LIBBLKID_VERSION_INFO)
531551
 
531551
diff --git a/libfdisk/src/Makemodule.am b/libfdisk/src/Makemodule.am
531551
index fbfb1b4..5c50001 100644
531551
--- a/libfdisk/src/Makemodule.am
531551
+++ b/libfdisk/src/Makemodule.am
531551
@@ -25,6 +25,8 @@ nodist_libfdisk_la_SOURCES = libfdisk/src/fdiskP.h
531551
 libfdisk_la_LIBADD = libcommon.la
531551
 
531551
 libfdisk_la_CFLAGS = \
531551
+	$(AM_CFLAGS) \
531551
+	$(SOLIB_CFLAGS) \
531551
 	-I$(ul_libfdisk_incdir) \
531551
 	-I$(top_srcdir)/libfdisk/src
531551
 
531551
@@ -39,6 +41,7 @@ libfdisk_la_CFLAGS += -I$(ul_libuuid_incdir)
531551
 endif
531551
 
531551
 libfdisk_la_DEPENDENCIES = $(libfdisk_la_LIBADD)
531551
+libfdisk_la_LDFLAGS = $(SOLIB_LDFLAGS)
531551
 
531551
 
531551
 check_PROGRAMS += \
531551
diff --git a/libmount/src/Makemodule.am b/libmount/src/Makemodule.am
531551
index 494e02a..8ef07e5 100644
531551
--- a/libmount/src/Makemodule.am
531551
+++ b/libmount/src/Makemodule.am
531551
@@ -33,6 +33,7 @@ nodist_libmount_la_SOURCES = libmount/src/mountP.h
531551
 libmount_la_LIBADD = libcommon.la libblkid.la $(SELINUX_LIBS)
531551
 
531551
 libmount_la_CFLAGS = \
531551
+	$(SOLIB_CFLAGS) \
531551
 	-I$(ul_libblkid_incdir) \
531551
 	-I$(ul_libmount_incdir) \
531551
 	-I$(top_srcdir)/libmount/src
531551
@@ -43,6 +44,7 @@ libmount_la_DEPENDENCIES = \
531551
 	libmount/src/libmount.h.in
531551
 
531551
 libmount_la_LDFLAGS = \
531551
+	$(SOLIB_LDFLAGS) \
531551
 	-Wl,--version-script=$(top_srcdir)/libmount/src/libmount.sym \
531551
 	-version-info $(LIBMOUNT_VERSION_INFO)
531551
 
531551
diff --git a/libuuid/src/Makemodule.am b/libuuid/src/Makemodule.am
531551
index 73f1ba9..a20cb4c 100644
531551
--- a/libuuid/src/Makemodule.am
531551
+++ b/libuuid/src/Makemodule.am
531551
@@ -29,9 +29,14 @@ libuuid_la_SOURCES = \
531551
 
531551
 libuuid_la_DEPENDENCIES = libuuid/src/uuid.sym
531551
 libuuid_la_LIBADD       = $(SOCKET_LIBS)
531551
-libuuid_la_CFLAGS       = -I$(ul_libuuid_incdir) -Ilibuuid/src
531551
+
531551
+libuuid_la_CFLAGS = \
531551
+	 $(SOLIB_CFLAGS) \
531551
+	 -I$(ul_libuuid_incdir) \
531551
+	 -Ilibuuid/src
531551
 
531551
 libuuid_la_LDFLAGS = \
531551
+	$(SOLIB_LDFLAGS) \
531551
 	-Wl,--version-script=$(top_srcdir)/libuuid/src/uuid.sym \
531551
 	-version-info $(LIBUUID_VERSION_INFO)
531551
 
531551
diff --git a/misc-utils/Makemodule.am b/misc-utils/Makemodule.am
531551
index a615047..70a78f2 100644
531551
--- a/misc-utils/Makemodule.am
531551
+++ b/misc-utils/Makemodule.am
531551
@@ -77,7 +77,8 @@ if BUILD_UUIDD
531551
 usrsbin_exec_PROGRAMS += uuidd
531551
 dist_man_MANS += misc-utils/uuidd.8
531551
 uuidd_LDADD = $(LDADD) libuuid.la
531551
-uuidd_CFLAGS = $(AM_CFLAGS) -I$(ul_libuuid_incdir)
531551
+uuidd_CFLAGS = $(DAEMON_CFLAGS) $(AM_CFLAGS) -I$(ul_libuuid_incdir)
531551
+uuidd_LDFLAGS = $(DAEMON_LDFLAGS) $(AM_LDFLAGS)
531551
 uuidd_SOURCES = misc-utils/uuidd.c
531551
 if USE_SOCKET_ACTIVATION
531551
 uuidd_SOURCES += misc-utils/sd-daemon.c misc-utils/sd-daemon.h
531551
-- 
531551
2.7.4
531551