From 80581e9887ce9968516ec4d7a6a450eeec6e4ade Mon Sep 17 00:00:00 2001
From: Michael Niedermayer <michaelni@gmx.at>
Date: Mon, 27 Jun 2005 00:55:29 +0000
Subject: [PATCH] x86_64 + PIC fix by (Jacob Meuser: jakemsr, jakemsr com)

Originally committed as revision 4397 to svn://svn.ffmpeg.org/ffmpeg/trunk
---
 configure                       | 14 +++++++++++++-
 libavcodec/Makefile             |  4 ++--
 libavcodec/libpostproc/Makefile |  2 +-
 libavformat/Makefile            |  2 +-
 4 files changed, 17 insertions(+), 5 deletions(-)

diff --git a/configure b/configure
index 3ae70513a0b..9e5329b92a5 100755
--- a/configure
+++ b/configure
@@ -197,6 +197,7 @@ netserver="no"
 need_inet_aton="no"
 ffserver="yes"
 ffplay="yes"
+LIBOBJFLAGS=""
 LDFLAGS=-Wl,--warn-common
 FFSLDFLAGS=-Wl,-E
 LDCONFIG="ldconfig"
@@ -276,7 +277,7 @@ bktr="yes"
 audio_oss="yes"
 dv1394="no"
 make="gmake"
-CFLAGS="$CFLAGS \$(PIC)"
+LIBOBJFLAGS="\$(PIC)"
 LDFLAGS="$LDFLAGS -export-dynamic -pthread"
 LDCONFIG="ldconfig -m \$(libdir)"
 extralibs="$extralibs -lossaudio"
@@ -1103,6 +1104,16 @@ if test "$optimize" = "yes"; then
     fi
 fi
 
+# PIC flags for shared library objects where they are needed
+if test "$lshared" = "yes" ; then
+  # LIBOBJFLAGS may have already been set in the OS configuration
+  if test -z "$LIBOBJFLAGS" ; then
+    if test "$cpu" = "x86_64" ; then
+      LIBOBJFLAGS="\$(PIC)"
+    fi
+  fi
+fi
+
 if test x"$bindir" = x""; then
 bindir="${prefix}/bin"
 fi
@@ -1219,6 +1230,7 @@ echo "LDFLAGS=$LDFLAGS" >> config.mak
 echo "LDCONFIG=$LDCONFIG" >> config.mak
 echo "FFSLDFLAGS=$FFSLDFLAGS" >> config.mak
 echo "SHFLAGS=$SHFLAGS" >> config.mak
+echo "LIBOBJFLAGS=$LIBOBJFLAGS" >> config.mak
 echo "BUILDSUF=$BUILDSUF" >> config.mak
 echo "LIBPREF=$LIBPREF" >> config.mak
 echo "LIBSUF=\${BUILDSUF}$LIBSUF" >> config.mak
diff --git a/libavcodec/Makefile b/libavcodec/Makefile
index 9e38eefdc9d..d7c7227d1a1 100644
--- a/libavcodec/Makefile
+++ b/libavcodec/Makefile
@@ -409,10 +409,10 @@ libpostproc/libpostproc.a:
 	$(MAKE) -C libpostproc
 
 %.o: %.c
-	$(CC) $(CFLAGS) -c -o $@ $< 
+	$(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $< 
 
 %.o: %.S
-	$(CC) $(CFLAGS) -c -o $@ $<
+	$(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $<
 
 depend: $(SRCS)
 	$(CC) -MM $(CFLAGS) $^ 1>.depend
diff --git a/libavcodec/libpostproc/Makefile b/libavcodec/libpostproc/Makefile
index 0f4147896ca..a12bc721e1f 100644
--- a/libavcodec/libpostproc/Makefile
+++ b/libavcodec/libpostproc/Makefile
@@ -21,7 +21,7 @@ CFLAGS  = $(OPTFLAGS) $(MLIB_INC) -I. -I.. $(EXTRA_INC)
 # .PHONY: all clean
 
 .c.o:
-	$(CC) -c $(CFLAGS) -I$(SRC_PATH)/libavcodec -I../.. -o $@ $<
+	$(CC) -c $(CFLAGS) $(LIBOBJFLAGS) -I$(SRC_PATH)/libavcodec -I../.. -o $@ $<
 
 all:    $(SWSLIB) $(PPLIB) $(SPPLIB)
 
diff --git a/libavformat/Makefile b/libavformat/Makefile
index c9a8af5ef26..9f2a8f33adf 100644
--- a/libavformat/Makefile
+++ b/libavformat/Makefile
@@ -134,7 +134,7 @@ install-headers:
 	install -m 644 ../libavformat.pc $(libdir)/pkgconfig
 
 %.o: %.c
-	$(CC) $(CFLAGS) -c -o $@ $< 
+	$(CC) $(CFLAGS) $(LIBOBJFLAGS) -c -o $@ $< 
 
 # BeOS: remove -Wall to get rid of all the "multibyte constant" warnings
 %.o: %.cpp
-- 
GitLab