#!/usr/bin/make -f

######################################################################
# BUILD NOTES
#
# ifupdown's written in litprog using noweb. noweb is written in icon.
# icon isn't as portable as one might hope (it needs to have bits recoded
# for each arch and OS it's ported to. ugh).
#
# So. The "upstream" source is made to not include any of the generated
# files. That's neat and tidy. If you want to modify anything, you edit
# the .nw file.
#
# Once you've done all the Debian changes, you run debian/rules binary,
# and get all the .c files and such updated. Once you're done, you
# run debian/rules clean, which leaves the generated .c files around
# for porters. You then generate a .diff.gz, and all should be well.
#
# Useful targets of the toplevel makefile:
# clobber:
#   * gets rid of all the generated files except Makefile,
#     make{c,nw}dep.sh, which are needed to bootstrap
#
# distclean:
#   * removes ALL generated files.  Use with care.
#
# docs: 
#   * builds the documentation. Note that this is not done per
#     default (only executables are built). If this is added to
#     the default build process (which will not be done in the near
#     future since dia requires an X display even if using the -e option) 
#     the 'tetex-base' and 'dia' packages would need to be added to the
#     Build-Dep
#
######################################################################

%:
	dh $@

override_dh_auto_configure:
	chmod a+rx makecdep.sh makenwdep.sh

override_dh_installinit:
	dh_installinit --name=ifupdown-clean --no-start -- start 18 S . start 38 0 6 .
	dh_installinit --name=ifupdown --no-start -- start 39 S .  start 36 0 6 .

override_dh_auto_clean:
	$(MAKE) clean
	$(MAKE) clobber

ifeq ($(DEB_BUILD_GNU_TYPE),$(DEB_HOST_GNU_TYPE))
ifeq (,$(filter nocheck,$(DEB_BUILD_OPTIONS)))
override_dh_auto_test:
	chmod a+rx debian/testbuild
	@echo running debian/testbuild
	@if ! debian/testbuild; then \
	     echo '=================================================='; \
	     echo 'AUTOMATIC TESTS FAILED -- Something built wrong or'; \
	     echo 'there is a bug in the code!!! Either way something'; \
	     echo 'is completely screwed up!!! File a bug!'; \
	     echo ''; \
	     echo 'Aborting build.'; \
	     echo '=================================================='; \
	     exit 1; \
	fi
endif
endif
