summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans de Goede <hdegoede@redhat.com>2013-07-03 11:16:20 +0200
committerHans de Goede <hdegoede@redhat.com>2013-07-03 11:16:20 +0200
commit71b8e75c6f1bc6c482d28cf29b82643d6b38cf34 (patch)
tree1786ff2e7073b5ac677535a6423d6bf96c242393
parent43cde1cbedc56138a857100f634e7cb644477e7e (diff)
downloadvd_agent-71b8e75c6f1bc6c482d28cf29b82643d6b38cf34.tar.gz
vd_agent-71b8e75c6f1bc6c482d28cf29b82643d6b38cf34.tar.xz
vd_agent-71b8e75c6f1bc6c482d28cf29b82643d6b38cf34.zip
buildsys: Build vdagentd as pie + relro when possible
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
-rw-r--r--Makefile.am6
-rw-r--r--configure.ac32
2 files changed, 36 insertions, 2 deletions
diff --git a/Makefile.am b/Makefile.am
index fa2803a..74cc313 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -8,8 +8,10 @@ src_spice_vdagent_CFLAGS = $(X_CFLAGS) $(SPICE_CFLAGS) $(GLIB2_CFLAGS)
src_spice_vdagent_LDADD = $(X_LIBS) $(SPICE_LIBS) $(GLIB2_LIBS)
src_spice_vdagent_SOURCES = src/vdagent.c src/vdagent-x11.c src/vdagent-x11-randr.c src/vdagent-file-xfers.c src/udscs.c
-src_spice_vdagentd_CFLAGS = $(DBUS_CFLAGS) $(LIBSYSTEMD_LOGIN_CFLAGS) $(PCIACCESS_CFLAGS) $(SPICE_CFLAGS) $(GLIB2_CFLAGS)
-src_spice_vdagentd_LDADD = $(DBUS_LIBS) $(LIBSYSTEMD_LOGIN_LIBS) $(PCIACCESS_LIBS) $(SPICE_LIBS) $(GLIB2_LIBS)
+src_spice_vdagentd_CFLAGS = $(DBUS_CFLAGS) $(LIBSYSTEMD_LOGIN_CFLAGS) \
+ $(PCIACCESS_CFLAGS) $(SPICE_CFLAGS) $(GLIB2_CFLAGS) $(PIE_CFLAGS)
+src_spice_vdagentd_LDADD = $(DBUS_LIBS) $(LIBSYSTEMD_LOGIN_LIBS) \
+ $(PCIACCESS_LIBS) $(SPICE_LIBS) $(GLIB2_LIBS) $(PIE_LDFLAGS)
src_spice_vdagentd_SOURCES = src/vdagentd.c \
src/vdagentd-uinput.c \
src/vdagentd-xorg-conf.c \
diff --git a/configure.ac b/configure.ac
index 91a24ff..a1ce6c0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -141,6 +141,37 @@ if test "$ac_test_CFLAGS" != set; then
done
fi
+AC_ARG_ENABLE([pie],
+ AS_HELP_STRING([--enable-pie=@<:@auto/yes/no@:>@],
+ [Enable position-independent-executable support (for spice-vdagentd)@<:@default=auto@:>@]),
+ [],
+ [enable_pie="auto"])
+
+if test "x$enable_pie" != "xno"; then
+ save_CFLAGS="$CFLAGS"
+ save_LDFLAGS="$LDFLAGS"
+ CFLAGS="$CFLAGS -fPIE"
+ LDFLAGS="$LDFLAGS -pie -Wl,-z,relro -Wl,-z,now"
+ AC_MSG_CHECKING([for PIE support])
+ AC_LINK_IFELSE([AC_LANG_SOURCE([int main () { return 0; }])],
+ [have_pie=yes],
+ [have_pie=no])
+ AC_MSG_RESULT([$have_pie])
+ if test "x$have_pie" = "xno" && test "x$enable_pie" = "xyes"; then
+ AC_MSG_ERROR([pie support explicitly requested, but your toolchain does not support it])
+ fi
+ if test "x$have_pie" = "xyes"; then
+ PIE_CFLAGS="-fPIE"
+ PIE_LDFLAGS="-pie -Wl,-z,relro -Wl,-z,now"
+ AC_SUBST(PIE_CFLAGS)
+ AC_SUBST(PIE_LDFLAGS)
+ fi
+ CFLAGS="$save_CFLAGS"
+ LDFLAGS="$save_LDFLAGS"
+else
+ have_pie=no
+fi
+
AC_CONFIG_FILES([
Makefile
data/spice-vdagent.1
@@ -160,6 +191,7 @@ AC_MSG_NOTICE([
session-info: ${with_session_info}
pciaccess: ${enable_pciaccess}
static uinput: ${enable_static_uinput}
+ vdagentd pie + relro: ${have_pie}
install RH initscript: ${init_redhat}
install systemd service: ${init_systemd}