#!/usr/bin/make -f

export DEB_BUILD_MAINT_OPTIONS = hardening=+all

# ragel 6.10 regenerates the parse_memc_* state machines with intentional
# fallthroughs ("if (++p == pe) goto _test_eofNN;" right before "case NN:").
# nginx's module build enables -Werror together with -W/-Wextra, so GCC >= 7
# turns -Wimplicit-fallthrough into a hard error.  Disable that one specific
# warning for the module build (the generated fallthroughs are intentional).
export CFLAGS := $(CFLAGS) -Wno-implicit-fallthrough

execute_before_dh_auto_build:
	# rebuild ngx_http_memc_response.c using ragel
	[ -f src/ngx_http_memc_response.c.orig ] || cp src/ngx_http_memc_response.c src/ngx_http_memc_response.c.orig
	ragel -G2 src/ngx_http_memc_response.rl || mv -f src/ngx_http_memc_response.c.orig src/ngx_http_memc_response.c
	diff -u src/ngx_http_memc_response.c.orig src/ngx_http_memc_response.c || :

execute_after_dh_auto_build:
	mv -f src/ngx_http_memc_response.c.orig src/ngx_http_memc_response.c

%:
	dh $@
