xref: /netbsd-src/external/mpl/bind/dist/util/check-make-install.in (revision 9689912e6b171cbda866ec33f15ae94a04e2c02d)
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		sed -n \
23		    -e "s|\.h\.in$|\.h|" \
24		    -e "s|.*include/|${DESTDIR}${includedir}/|p" |
25		sort -u
26}
27
28status=0
29
30for header in $(headers_to_install); do
31	if [ ! -f "${header}" ]; then
32		echo "Missing $header"
33		status=1
34	fi
35done
36
37named_binary_path="${install_dir}/sbin/named"
38if [ ! -x "${named_binary_path}" ]; then
39	echo "ERROR: ${named_binary_path} does not exist or is not executable"
40	status=1
41fi
42
43named_man_page_path="${install_dir}/share/man/man8/named.8"
44if [ ! -f "${named_man_page_path}" ]; then
45	echo "ERROR: ${named_man_page_path} does not exist"
46	status=1
47fi
48
49if [ -n "${DESTDIR}" ]; then
50	for expected_subdir in bin include lib sbin share; do
51		echo "${install_dir}/${expected_subdir}" >> "${abs_builddir}/expected_dirs"
52	done
53	find "${install_dir}" -maxdepth 1 -mindepth 1 -type d | sort > "${abs_builddir}/existing_dirs"
54	if ! diff -u "${abs_builddir}/expected_dirs" "${abs_builddir}/existing_dirs"; then
55		echo "ERROR: Contents of DESTDIR do not match expectations"
56		status=1
57	fi
58	rm -f "${abs_builddir}/expected_dirs" "${abs_builddir}/existing_dirs"
59fi
60
61exit $status
62