xref: /netbsd-src/external/mpl/bind/dist/util/check-make-install.in (revision 4f645668ed707e1f969c546666f8c8e45e6f8888)
1#!/bin/sh
2#
3# Copyright (C) Internet Systems Consortium, Inc. ("ISC")
4#
5# SPDX-License-Identifier: MPL-2.0
6#
7# This Source Code Form is subject to the terms of the Mozilla Public
8# License, v. 2.0. If a copy of the MPL was not distributed with this
9# file, you can obtain one at https://mozilla.org/MPL/2.0/.
10#
11# See the COPYRIGHT file distributed with this work for additional
12# information regarding copyright ownership.
13
14abs_top_srcdir=@abs_top_srcdir@
15abs_builddir=@abs_builddir@
16prefix=@prefix@
17includedir=@includedir@
18install_dir="${DESTDIR}@prefix@"
19
20headers_to_install() {
21	find "${abs_top_srcdir}/lib" -name "*.h" -or -name "*.h.in" |
22		grep -v -F /win32/ |
23		sed -n \
24		    -e "s|\.h\.in$|\.h|" \
25		    -e "s|.*include/|${DESTDIR}${includedir}/|p" |
26		sort -u
27}
28
29status=0
30
31for header in $(headers_to_install); do
32	if [ ! -f "${header}" ]; then
33		echo "Missing $header"
34		status=1
35	fi
36done
37
38named_binary_path="${install_dir}/sbin/named"
39if [ ! -x "${named_binary_path}" ]; then
40	echo "ERROR: ${named_binary_path} does not exist or is not executable"
41	status=1
42fi
43
44named_man_page_path="${install_dir}/share/man/man8/named.8"
45if [ ! -f "${named_man_page_path}" ]; then
46	echo "ERROR: ${named_man_page_path} does not exist"
47	status=1
48fi
49
50if [ -n "${DESTDIR}" ]; then
51	for expected_subdir in bin etc include lib sbin share; do
52		echo "${install_dir}/${expected_subdir}" >> "${abs_builddir}/expected_dirs"
53	done
54	find "${install_dir}" -maxdepth 1 -mindepth 1 -type d | sort > "${abs_builddir}/existing_dirs"
55	if ! diff -u "${abs_builddir}/expected_dirs" "${abs_builddir}/existing_dirs"; then
56		echo "ERROR: Contents of DESTDIR do not match expectations"
57		status=1
58	fi
59	rm -f "${abs_builddir}/expected_dirs" "${abs_builddir}/existing_dirs"
60fi
61
62exit $status
63