NetBSD/compat/build-makefiles

118 lines
2.9 KiB
Bash
Executable File

#! /bin/sh
# generate src/compat/* Makefile's based on SUBDIR values in
# the main source tree
srcdir=/usr/src
rwsrcdir=/home/current/src
MAKE=${MAKE-make}
CHECK_SUBDIRS="gnu/lib gnu/lib/libgcc4 lib lib/csu lib/i18n_module external/bsd/openldap/lib lib/libpam/modules"
# lib/csu is spsecial
# lib/libm needs to be special -- i387
# gnu/lib/libsupc++ -- fails to get NOPROFILE properly
for _dir in ${CHECK_SUBDIRS}; do
if [ ${_dir} = "lib/csu" ]; then
_subdirs="i386_elf sparc_elf"
else
_subdirs=`cd ${srcdir}/${_dir}; ${MAKE} -V SUBDIR`
fi
echo "looking in: $_dir: subdirs $_subdirs"
for _sd in $_subdirs; do
# skip lib/csu --
if [ "$_dir" = "lib" -a "$_sd" = "csu" ]; then
continue
fi
# skip .WAIT --
if [ "$_sd" = ".WAIT" ]; then
continue
fi
_libdplibs="`cd ${srcdir}/${_dir}/${_sd}; ${MAKE} -V LIBDPLIBS`"
echo "creating stuff for subdir: $_sd"
echo " - libdplibs = ${_libdplibs}"
mkdir -p ${rwsrcdir}/compat/${_dir}/${_sd}
(
cat <<'EOF'
# $NetBSD: build-makefiles,v 1.4 2008/10/27 07:17:05 mrg Exp $
NOLINT= # defined
NOMAN= # defined
NONLS= # defined
NOINFO= # defined
NOSHARE= # defined
EOF
# XXX various hacks
case "${_sd}" in
libsupc++4)
echo "NOPROFILE= # defined"
;;
libc)
echo "# XXX"
echo "nsparser.h: nsparser.c"
;;
libpcap)
echo "# XXX"
echo "grammar.h: grammar.c"
;;
libipsec)
echo "# XXX"
echo "policy_parse.h: policy_parse.c"
;;
esac
if [ -n "${_libdplibs}" ]; then
echo "LIBDPLIBS= ${_libdplibs}"
fi
cat <<'EOF'
NOCHECKVER= # defined
.include <bsd.obj.mk>
# Resolve pathnames in variables.
_RESOLVE_VARS= CFLAGS CPPFLAGS DPADD LDADD LIBDPLIBS LIB_ROOT_DIR
.for var in ${_RESOLVE_VARS}
${var}:= ${${var}}
.endfor
_CURDIR:= ${.CURDIR}
EOF
printf ".PATH: \${NETBSDSRCDIR}/${_dir}/${_sd}\n"
printf ".CURDIR:=\${NETBSDSRCDIR}/${_dir}/${_sd}\n\n"
cat <<'EOF'
.include "${NETBSDSRCDIR}/compat/Makefile.compat"
.include "${.CURDIR}/Makefile"
# Resolve pathnames from "real" Makefile, and switch .CURDIR back.
_RESOLVE_VARS= CFLAGS CPPFLAGS DPADD LDADD ARCHDIR COMPATDIR COMPATARCHDIR LIBCDIR RPC_INCS RPC_XDIR LIBEDITDIR MODOBJDIR RUMPTOP
.for var in ${_RESOLVE_VARS}
${var}:= ${${var}}
.endfor
.CURDIR:= ${_CURDIR}
.undef _CURDIR
EOF
) > ${rwsrcdir}/compat/${_dir}/${_sd}/Makefile
done
if [ "${_dir}" = "lib" -a "${_sd}" = "csu" ]; then
(printf '# $'NetBSD'$\n\n'
printf "_CURDIR:= \${.CURDIR}\n\n"
printf ".CURDIR:=\${NETBSDSRCDIR}/${_dir}\n\n"
printf ".include "'"'"\${.CURDIR}/Makefile"'"'"\n\n"
printf ".CURDIR:= \${_CURDIR}\n"
) > ${rwsrcdir}/compat/${_dir}/Makefile
if [ -f "${srcdir}/${_dir}/Makefile.inc" ]; then
(printf '# $'NetBSD'$\n\n'
printf "_CURDIR:= \${.CURDIR}\n\n"
printf ".include "'"'"\${NETBSDSRCDIR}/${_dir}/Makefile.inc"'"'"\n\n"
printf ".CURDIR:= \${_CURDIR}\n"
) > ${rwsrcdir}/compat/${_dir}/Makefile.inc
fi
fi
done