Skip to content

Commit

Permalink
Merge pull request #439 from koreader/chrox-master
Browse files Browse the repository at this point in the history
fix position independent executables (PIE) error on Android L
  • Loading branch information
houqp committed Jun 30, 2016
2 parents 1e7c9ca + 22e44f8 commit ed0afd1
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 3 deletions.
17 changes: 16 additions & 1 deletion Makefile.third
Original file line number Diff line number Diff line change
Expand Up @@ -297,23 +297,33 @@ $(OUTPUT_DIR)/sdcv: $(if $(ANDROID),$(GLIB_STATIC),$(GLIB)) $(ZLIB_STATIC) $(THI
-DLIBS="$(if $(ANDROID),$(GLIB_STATIC),) \
$(if $(ANDROID),,-lpthread -lrt) \
$(ZLIB_STATIC) \
$(if $(ANDROID),-static,) \
-static-libgcc -static-libstdc++" \
$(CURDIR)/$(THIRDPARTY_DIR)/sdcv && \
$(MAKE)
cp $(SDCV_DIR)/src/sdcv $(OUTPUT_DIR)/
ifdef ANDROID
readelf -d $@ | grep "no dynamic" \
|| echo "warning: Android L+ support only PIE binary and can't run this"
endif

# ===========================================================================
# tar: tar package for zsync

$(OUTPUT_DIR)/tar: $(THIRDPARTY_DIR)/tar/CMakeLists.txt
install -d $(TAR_BUILD_DIR)
cd $(TAR_BUILD_DIR) && \
$(CMAKE) -DCC="$(CC)" -DLIBS="$(if $(or $(ANDROID),$(WIN32)),,-lrt)" \
$(CMAKE) -DCC="$(CC)" \
-DLIBS="$(if $(or $(ANDROID),$(WIN32)),,-lrt) $(if $(ANDROID),-static,)" \
$(if $(LEGACY),-DDISABLE_LARGEFILE:BOOL=ON -DDISABLE_FORTIFY:BOOL=ON,) \
-DCHOST="$(if $(EMULATE_READER),,$(CHOST))" \
$(CURDIR)/$(THIRDPARTY_DIR)/tar && \
$(MAKE)
cp $(TAR_DIR)/src/tar $(OUTPUT_DIR)/
ifdef ANDROID
readelf -d $@ | grep "no dynamic" \
|| echo "warning: Android L+ support only PIE binary and can't run this"
endif

# ===========================================================================
# zsync: rsync over HTTP
Expand All @@ -322,9 +332,14 @@ $(OUTPUT_DIR)/zsync: $(THIRDPARTY_DIR)/zsync/CMakeLists.txt
install -d $(ZSYNC_BUILD_DIR)
cd $(ZSYNC_BUILD_DIR) && \
$(CMAKE) -DHOST="$(if $(EMULATE_READER),,$(CHOST))" -DCC="$(CC)" \
-DLIBS="$(if $(ANDROID),-static,)" \
$(CURDIR)/$(THIRDPARTY_DIR)/zsync && \
$(MAKE)
cp $(ZSYNC_DIR)/zsync $(OUTPUT_DIR)/
ifdef ANDROID
readelf -d $@ | grep "no dynamic" \
|| echo "warning: Android L+ support only PIE binary and can't run this"
endif

# ===========================================================================
# common lua library for networking
Expand Down
2 changes: 1 addition & 1 deletion thirdparty/tar/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ep_get_source_dir(SOURCE_DIR)
ep_get_binary_dir(BINARY_DIR)

set(CFG_ENV_VAR "CC=\"${CC} -DHAVE_MKFIFO=1\"")
set(CFG_OPTS "-q LIBS=${LIBS} --host=\"${CHOST}\"")
set(CFG_OPTS "-q LIBS=\"${LIBS}\" --host=\"${CHOST}\"")

if(${DISABLE_LARGEFILE})
set(CFG_OPTS "${CFG_OPTS} --disable-largefile")
Expand Down
3 changes: 2 additions & 1 deletion thirdparty/zsync/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@ enable_language(C)

assert_var_defined(CC)
assert_var_defined(HOST)
assert_var_defined(LIBS)

ep_get_source_dir(SOURCE_DIR)
ep_get_binary_dir(BINARY_DIR)

set(RECONF_CMD sh -c "cd c && autoreconf -fi")
set(CFG_OPTS "-q --prefix=${BINARY_DIR} --host=\"${HOST}\"")
set(CFG_CMD sh -c "CC=\"${CC}\" CFLAGS=\"$(CFLAGS) -I${SOURCE_DIR}/c\" ${SOURCE_DIR}/c/configure ${CFG_OPTS}")
set(CFG_CMD sh -c "CC=\"${CC}\" CFLAGS=\"$(CFLAGS) -I${SOURCE_DIR}/c\" LIBS=\"${LIBS}\" ${SOURCE_DIR}/c/configure ${CFG_OPTS}")
# don't check missing definition of in_port_t in NDK <netinet/in.h>
set(PATCH_CMD1 sh -c "patch -N -p1 < ${CMAKE_CURRENT_SOURCE_DIR}/zsync.patch || true")
# fix "rename: Invalid cross-device link" error for Android
Expand Down

0 comments on commit ed0afd1

Please sign in to comment.