From 0faba8af4df89bf6b2d3b3d4ea7923b242bfec27 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Thu, 5 May 2016 17:00:09 +0200 Subject: [PATCH] build system: allow to use PIC instead PIE (ARM?) --- Makefile | 5 +++++ Makefile.ffmpeg | 27 ++++++++++++++++++--------- Makefile.hdhomerun | 6 ++++++ configure | 1 + support/patches/libx265.pic.diff | 19 +++++++++++++++++++ 5 files changed, 49 insertions(+), 9 deletions(-) create mode 100644 support/patches/libx265.pic.diff diff --git a/Makefile b/Makefile index 29c85b0f1..af0f897ee 100644 --- a/Makefile +++ b/Makefile @@ -29,6 +29,11 @@ LANGUAGES ?= bg cs da de en_US en_GB es et fa fi fr he hr hu it lv nl pl pt ru s # CFLAGS += -g -O2 -fPIE +ifeq ($(CONFIG_PIE),yes) +CFLAGS += -fPIE +else +CFLAGS += -fPIC +endif ifeq ($(CONFIG_W_UNUSED_RESULT),yes) CFLAGS += -Wunused-result endif diff --git a/Makefile.ffmpeg b/Makefile.ffmpeg index 4eb0cc6e9..5d74f7986 100644 --- a/Makefile.ffmpeg +++ b/Makefile.ffmpeg @@ -56,7 +56,11 @@ LIBX265 = x265_1.9 LIBX265_TB = $(LIBX265).tar.gz LIBX265_URL = http://ftp.videolan.org/pub/videolan/x265/$(LIBX265_TB) LIBX265_SHA1 = 8c9aa3b87b0f0a418bbb9782e9354d112d75e003 +ifeq ($(CONFIG_PIE),yes) LIBX265_DIFFS = libx265.pie.diff +else +LIBX265_DIFFS = libx265.pic.diff +endif LIBVPX = libvpx-1.5.0 LIBVPX_TB = $(LIBVPX).tar.bz2 @@ -115,16 +119,21 @@ build: $(LIB_ROOT)/$(FFMPEG)/.tvh_build export PATH := $(LIB_ROOT)/build/ffmpeg/bin:$(PATH) +ifeq ($(CONFIG_PIE),yes) +CFLAGS_PI = -fPIE +else +CFLAGS_PI = -fPIC +endif + EBUILDIR := $(LIB_ROOT)/build EPREFIX := $(EBUILDIR)/ffmpeg -ECFLAGS := -I$(EPREFIX)/include -fPIE +ECFLAGS := -I$(EPREFIX)/include $(CFLAGS_PI) ELIBS := -L$(EPREFIX)/lib -ldl CONFIGURE := FFMPEG_PREFIX=$(EPREFIX) \ PKG_CONFIG=$(ROOTDIR)/support/pkg-config.ffmpeg \ ./configure --prefix=/ffmpeg --enable-static --disable-shared - # ############################################################################## # YASM # @@ -177,7 +186,7 @@ $(LIB_ROOT)/$(LIBX264)/.tvh_build: \ $(LIB_ROOT)/$(LIBX264)/.tvh_download cd $(LIB_ROOT)/$(LIBX264) && $(CONFIGURE) \ --extra-asflags="-DPIC" \ - --extra-cflags="-fPIE" \ + --extra-cflags="$(CFLAGS_PI)" \ --disable-cli \ --disable-swscale \ --disable-lavf \ @@ -275,7 +284,7 @@ $(LIB_ROOT)/$(LIBVPX)/.tvh_build: \ $(LIB_ROOT)/$(LIBVPX)/.tvh_download cd $(LIB_ROOT)/$(LIBVPX) && \ ASFLAGS="-DENABLE_PIC=1 -DPIC=1" $(CONFIGURE) \ - --extra-cflags="-fPIE" \ + --extra-cflags="$(CFLAGS_PI)" \ --disable-examples \ --disable-docs \ --disable-unit-tests \ @@ -311,7 +320,7 @@ $(LIB_ROOT)/$(LIBOGG)/.tvh_download: $(LIB_ROOT)/$(LIBOGG)/.tvh_build: \ $(LIB_ROOT)/$(YASM)/.tvh_build \ $(LIB_ROOT)/$(LIBOGG)/.tvh_download - cd $(LIB_ROOT)/$(LIBOGG) && CFLAGS="-fPIE" $(CONFIGURE) + cd $(LIB_ROOT)/$(LIBOGG) && CFLAGS="$(CFLAGS_PI)" $(CONFIGURE) DESTDIR=$(EBUILDIR) \ $(MAKE) -C $(LIB_ROOT)/$(LIBOGG) install @touch $@ @@ -349,7 +358,7 @@ $(LIB_ROOT)/$(LIBTHEORA)/.tvh_build: \ $(LIB_ROOT)/$(LIBOGG)/.tvh_build \ $(LIB_ROOT)/$(LIBTHEORA)/.tvh_download cd $(LIB_ROOT)/$(LIBTHEORA) && \ - CFLAGS="-fPIE" $(CONFIGURE) \ + CFLAGS="$(CFLAGS_PI)" $(CONFIGURE) \ --with-ogg=$(EPREFIX) \ --disable-examples \ $(LIBTHEORA_HOST) @@ -395,7 +404,7 @@ $(LIB_ROOT)/$(LIBVORBIS)/.tvh_build: \ $(LIB_ROOT)/$(LIBOGG)/.tvh_build \ $(LIB_ROOT)/$(LIBVORBIS)/.tvh_download cd $(LIB_ROOT)/$(LIBVORBIS) && \ - CFLAGS="-fPIE" $(CONFIGURE) \ + CFLAGS="$(CFLAGS_PI)" $(CONFIGURE) \ --with-ogg=$(EPREFIX) DESTDIR=$(EBUILDIR) \ $(MAKE) -C $(LIB_ROOT)/$(LIBVORBIS) install @@ -436,7 +445,7 @@ $(LIB_ROOT)/$(LIBFDKAAC)/.tvh_download: $(LIB_ROOT)/$(LIBFDKAAC)/.tvh_build: \ $(LIB_ROOT)/$(LIBFDKAAC)/.tvh_download cd $(LIB_ROOT)/$(LIBFDKAAC) && \ - CXXFLAGS="-fPIE" CFLAGS="-fPIE" $(CONFIGURE) + CXXFLAGS="$(CFLAGS_PI)" CFLAGS="$(CFLAGS_PI)" $(CONFIGURE) DESTDIR=$(EBUILDIR) \ $(MAKE) -C $(LIB_ROOT)/$(LIBFDKAAC) install @touch $@ @@ -490,7 +499,7 @@ $(LIB_ROOT)/$(LIBMFX)/.tvh_download: $(LIB_ROOT)/$(LIBMFX)/.tvh_build: \ $(LIB_ROOT)/$(LIBMFX)/.tvh_download cd $(LIB_ROOT)/$(LIBMFX) && autoreconf -i && \ - CXXFLAGS="-fPIE" CFLAGS="-fPIE" $(CONFIGURE) \ + CXXFLAGS="$(CFLAGS_PI)" CFLAGS="$(CFLAGS_PI)" $(CONFIGURE) \ --with-libva_x11 \ --with-libva_drm DESTDIR=$(EBUILDIR) \ diff --git a/Makefile.hdhomerun b/Makefile.hdhomerun index 4722bbe28..a7f8f81fa 100644 --- a/Makefile.hdhomerun +++ b/Makefile.hdhomerun @@ -22,6 +22,12 @@ include $(DIR)/.config.mk unexport CFLAGS unexport LDFLAGS +ifeq ($(CONFIG_PIE),yes) +CFLAGS += -fPIE +else +CFLAGS += -fPIC +endif + # ########################################################################### # Upstream Packages # ########################################################################### diff --git a/configure b/configure index be3d2e223..a01be5748 100755 --- a/configure +++ b/configure @@ -17,6 +17,7 @@ test -z "$PKG_CONFIG" && PKG_CONFIG=pkg-config # OPTIONS=( + "pie:yes" "cwc:yes" "capmt:yes" "constcw:yes" diff --git a/support/patches/libx265.pic.diff b/support/patches/libx265.pic.diff new file mode 100644 index 000000000..7aaec3874 --- /dev/null +++ b/support/patches/libx265.pic.diff @@ -0,0 +1,19 @@ +--- source/CMakeLists.txt.old 2016-05-05 16:49:17.373993257 +0200 ++++ source/CMakeLists.txt 2016-05-05 16:50:25.259801461 +0200 +@@ -100,11 +100,11 @@ + endif(NO_ATOMICS) + endif(UNIX) + +-if(X64 AND NOT WIN32) +- option(ENABLE_PIC "Enable Position Independent Code" ON) +-else() +- option(ENABLE_PIC "Enable Position Independent Code" OFF) +-endif(X64 AND NOT WIN32) ++#if(X64 AND NOT WIN32) ++option(ENABLE_PIC "Enable Position Independent Code" ON) ++#else() ++# option(ENABLE_PIC "Enable Position Independent Code" OFF) ++#endif(X64 AND NOT WIN32) + + # Compiler detection + if(CMAKE_GENERATOR STREQUAL "Xcode") -- 2.47.3