41a6b2
diff -uap subversion-1.7.0/build/generator/gen_base.py.pie subversion-1.7.0/build/generator/gen_base.py
5f612c
--- subversion-1.8.0/build/generator/gen_base.py.pie
5f612c
+++ subversion-1.8.0/build/generator/gen_base.py
5f612c
@@ -409,7 +409,7 @@ class TargetLinked(Target):
d9d021
     self.install = options.get('install')
d9d021
     self.compile_cmd = options.get('compile-cmd')
d9d021
     self.sources = options.get('sources', '*.c *.cpp')
d9d021
-    self.link_cmd = options.get('link-cmd', '$(LINK)')
d9d021
+    self.link_cmd = options.get('link-cmd', '$(LINK_LIB)')
d9d021
 
d9d021
     self.external_lib = options.get('external-lib')
d9d021
     self.external_project = options.get('external-project')
5f612c
@@ -465,6 +465,11 @@ class TargetExe(TargetLinked):
d9d021
     self.manpages = options.get('manpages', '')
d9d021
     self.testing = options.get('testing')
d9d021
 
d9d021
+    if self.install == 'test' or self.install == 'bdb-test':
d9d021
+      self.link_cmd = '$(LINK_TEST)'
d9d021
+    else:
d9d021
+      self.link_cmd = '$(LINK_EXE)'
d9d021
+
d9d021
   def add_dependencies(self):
d9d021
     TargetLinked.add_dependencies(self)
d9d021
 
5f612c
@@ -515,8 +520,8 @@ class TargetLib(TargetLinked):
d9d021
     self.msvc_export = options.get('msvc-export', '').split()
d9d021
 
d9d021
     ### hmm. this is Makefile-specific
d9d021
-    if self.link_cmd == '$(LINK)':
d9d021
-      self.link_cmd = '$(LINK_LIB)'
d9d021
+    if self.install == 'test':
d9d021
+       self.link_cmd = '$(LINK_TEST_LIB)'
d9d021
 
d9d021
 class TargetApacheMod(TargetLib):
d9d021
 
5f612c
--- subversion-1.8.0/Makefile.in.pie
5f612c
+++ subversion-1.8.0/Makefile.in
5f612c
@@ -203,6 +203,9 @@ COMPILE_CXXHL_CXX = $(LIBTOOL) $(LTCXXFL
d9d021
 
d9d021
 LINK = $(LIBTOOL) $(LTFLAGS) --mode=link $(CC) $(LT_LDFLAGS) $(CFLAGS) $(LDFLAGS)
41a6b2
 LINK_LIB = $(LINK) $(LT_SO_VERSION) -rpath $(libdir)
d9d021
+LINK_TEST = $(LINK) -no-install
d9d021
+LINK_TEST_LIB = $(LINK) -avoid-version
d9d021
+LINK_EXE = $(LINK) -pie
d9d021
 LINK_CXX = $(LIBTOOL) $(LTCXXFLAGS) --mode=link $(CXX) $(LT_LDFLAGS) $(CXXFLAGS) $(LDFLAGS) -rpath $(libdir)
41a6b2
 LINK_CXX_LIB = $(LINK_CXX) $(LT_SO_VERSION)
d9d021
 
5f612c
@@ -676,7 +679,7 @@ schema-clean:
41a6b2
 	$(PYTHON) $(top_srcdir)/build/transform_sql.py $< $(top_srcdir)/$@
9f9154
 
9f9154
 .c.o:
9f9154
-	$(COMPILE) -o $@ -c $<
9f9154
+	$(COMPILE) -fpie -o $@ -c $<
9f9154
 
9f9154
 .cpp.o:
9f9154
 	$(COMPILE_CXX) -o $@ -c $<