Use system gyp, not bundled one. This mostly involves hand-adding the flags the gyp_chromium wrapper does, but the change also manually sets SHARED_INTERMEDIATE_DIR --- otherwise it seems to be relative in a manner that makes it tricky to get protoc.gypi to work.
diff --git a/debian/control b/debian/control
index e1b05ce..edb44cb 100644
--- a/debian/control
+++ b/debian/control
@@ -4,7 +4,7 @@
Maintainer: Jeff Kaufman <jefftk@google.com>
Build-Depends: debhelper (>= 9), pkg-config, libapr1-dev, apache2-dev, dh-apache2,
libpng-dev, libicu-dev, gperf, libjpeg9-dev, zlib1g-dev, protobuf-compiler, libprotobuf-dev, libwebp-dev,
- libre2-dev, googletest, libgif-dev, libjsoncpp-dev, libgflags-dev, libssl1.0-dev, ca-certificates, dh-exec
+ libre2-dev, googletest, libgif-dev, libjsoncpp-dev, libgflags-dev, libssl1.0-dev, ca-certificates, dh-exec, gyp
Standards-Version: 3.9.8
Homepage: https://developers.google.com/speed/pagespeed/module/
Vcs-Git: https://github.com/pagespeed/mod_pagespeed-debian-packaging.git
diff --git a/debian/patches/gyp-native.patch b/debian/patches/gyp-native.patch
new file mode 100644
index 0000000..b2a31a7
--- /dev/null
+++ b/debian/patches/gyp-native.patch
@@ -0,0 +1,8 @@
+--- a/generate.sh
++++ b/generate.sh
+@@ -16,4 +16,4 @@
+ #
+ # Also, BUILDTYPE=Release can be passed to make (the default is Debug).
+ echo "Generating src/Makefile"
+-src/build/gyp_chromium -D use_system_libs=1 $*
++gyp -I src/build/common.gypi --no-circular-check --toplevel-dir=$(pwd)/src -DSHARED_INTERMEDIATE_DIR=$(pwd)/src/out/gen -D gyp_output_dir=$(pwd)/src/out -D use_system_libs=1 $* src/build/all.gyp
diff --git a/debian/patches/series b/debian/patches/series
index 6657d78..7d907eb 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -18,3 +18,4 @@
disable-mem-debug-cc.patch
proto-crash-fix.patch
test-hacking.patch
+gyp-native.patch