Changes to allow cross-compilation of pngtest
MODIFY
frida_mode/test/png/GNUmakefile
frida_mode/test/png/GNUmakefile
@@ -2,10 +2,17 @@ PWD:=$(shell pwd)/
ROOT:=$(PWD)../../../
BUILD_DIR:=$(PWD)build/
+LIBZ_BUILD_DIR:=$(BUILD_DIR)libz/
LIBPNG_BUILD_DIR:=$(BUILD_DIR)libpng/
HARNESS_BUILD_DIR:=$(BUILD_DIR)harness/
PNGTEST_BUILD_DIR:=$(BUILD_DIR)pngtest/
+LIBZ_FILE:=$(LIBZ_BUILD_DIR)zlib-1.2.12.tar.gz
+LIBZ_URL:=http://www.zlib.net/zlib-1.2.12.tar.gz
+LIBZ_DIR:=$(LIBZ_BUILD_DIR)zlib-1.2.12/
+LIBZ_PC:=$(ZLIB_DIR)zlib.pc
+LIBZ_LIB:=$(LIBZ_DIR)libz.a
+
LIBPNG_FILE:=$(LIBPNG_BUILD_DIR)libpng-1.2.56.tar.gz
LIBPNG_URL:=https://downloads.sourceforge.net/project/libpng/libpng12/older-releases/1.2.56/libpng-1.2.56.tar.gz
LIBPNG_DIR:=$(LIBPNG_BUILD_DIR)libpng-1.2.56/
@@ -32,11 +39,16 @@ FRIDA_OUT:=$(BUILD_DIR)frida-out
.PHONY: all clean qemu frida
+ARCH?=""
+
all: $(TEST_BIN)
make -C $(ROOT)frida_mode/
32:
- CFLAGS="-m32" LDFLAGS="-m32" ARCH="x86" make all
+ CFLAGS="-m32" LDFLAGS="-m32" make $(TEST_BIN)
+
+arm:
+ ARCH="arm" CC="arm-linux-gnueabihf-gcc" CXX="arm-linux-gnueabihf-g++" make $(TEST_BIN)
$(BUILD_DIR):
mkdir -p $@
@@ -51,6 +63,8 @@ $(HARNESS_FILE): | $(HARNESS_BUILD_DIR)
$(HARNESS_OBJ): $(HARNESS_FILE)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ -c $<
+harness: $(HARNESS_OBJ)
+
######### PNGTEST ########
$(PNGTEST_BUILD_DIR): | $(BUILD_DIR)
@@ -62,6 +76,34 @@ $(PNGTEST_FILE): | $(PNGTEST_BUILD_DIR)
$(PNGTEST_OBJ): $(PNGTEST_FILE) | $(LIBPNG_DIR)
$(CXX) $(CFLAGS) $(LDFLAGS) -std=c++11 -I $(LIBPNG_DIR) -o $@ -c $<
+pngtest: $(PNGTEST_OBJ)
+
+######### LIBZ ########
+
+$(LIBZ_BUILD_DIR): | $(BUILD_DIR)
+ mkdir -p $@
+
+$(LIBZ_FILE): | $(LIBZ_BUILD_DIR)
+ wget -O $@ $(LIBZ_URL)
+
+$(LIBZ_DIR): $(LIBZ_FILE)
+ tar zxvf $(LIBZ_FILE) -C $(LIBZ_BUILD_DIR)
+
+$(LIBZ_PC): | $(LIBZ_DIR)
+ cd $(LIBZ_DIR) && \
+ CFLAGS="$(CFLAGS) -fPIC" \
+ ./configure \
+ --static \
+ --archs="$(ARCH)"
+
+$(LIBZ_LIB): $(LIBZ_PC)
+ CFLAGS="$(CFLAGS) -fPIC" \
+ make \
+ -C $(LIBZ_DIR) \
+ -j
+
+libz: $(LIBZ_LIB)
+
######### LIBPNG ########
$(LIBPNG_BUILD_DIR): | $(BUILD_DIR)
@@ -73,11 +115,21 @@ $(LIBPNG_FILE): | $(LIBPNG_BUILD_DIR)
$(LIBPNG_DIR): $(LIBPNG_FILE)
tar zxvf $(LIBPNG_FILE) -C $(LIBPNG_BUILD_DIR)
-$(LIBPNG_MAKEFILE): | $(LIBPNG_DIR)
- cd $(LIBPNG_DIR) && ./configure
+$(LIBPNG_MAKEFILE): $(LIBZ_LIB) | $(LIBPNG_DIR)
+ cd $(LIBPNG_DIR) && \
+ CFLAGS="$(CFLAGS) -I$(LIBZ_DIR)" \
+ LDFLAGS="-L$(LIBZ_DIR)" \
+ ./configure \
+ --host="$(ARCH)"
$(LIBPNG_LIB): $(LIBPNG_MAKEFILE)
- make -C $(LIBPNG_DIR)
+ CFLAGS="$(CFLAGS) -I$(LIBZ_DIR)" \
+ LDFLAGS="-L$(LIBZ_DIR)" \
+ make \
+ -C $(LIBPNG_DIR) \
+ -j
+
+png: $(LIBPNG_LIB)
######### TEST ########
@@ -86,11 +138,21 @@ $(TEST_BIN): $(HARNESS_OBJ) $(PNGTEST_OBJ) $(LIBPNG_LIB)
$(CFLAGS) \
$(LDFLAGS) \
-o $@ \
- $(HARNESS_OBJ) $(PNGTEST_OBJ) $(LIBPNG_LIB) \
- -lz \
+ $(HARNESS_OBJ) $(PNGTEST_OBJ) $(LIBPNG_LIB) $(LIBZ_LIB) \
$(TEST_BIN_LDFLAGS) \
+test_bin: $(TEST_BIN)
+
+dowload: $(LIBZ_FILE) $(LIBPNG_FILE) $(HARNESS_FILE) $(PNGTEST_FILE)
+
clean:
+ rm -rf $(LIBZ_DIR)
+ rm -rf $(LIBPNG_DIR)
+ rm -f $(HARNESS_OBJ)
+ rm -f $(PNGTEST_OBJ)
+ rm -f $(TEST_BIN)
+
+clean_all:
rm -rf $(BUILD_DIR)
qemu: $(TEST_BIN)

Changes to allow cross-compilation of pngtest