blob: b97e84cef19721d1bbd7b7594663442da3cb7e84 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
#!/bin/sh
TOPDIR=$(dirname $0)
. ${TOPDIR}/mk.sh
DEPS=${TOPDIR}/.deps
SRCDIR=${TOPDIR}/src
find_all() {
rm -rf "${DEPS}"
mkdir -p "${DEPS}"
find "${SRCDIR}" -name \*.c > "${DEPS}/all.c"
find "${SRCDIR}" -name \*.ref > "${DEPS}/all.ref"
grep '#include <.*>' $(cat "${DEPS}/all.c" "${DEPS}/all.ref") |
sed 's/^.*<\(.*\.h\)>.*/\1/' | sort -u > "${DEPS}/all.h"
}
version_sources() {
for file in $(cat "${DEPS}/all.c" "${DEPS}/all.ref"); do
printf '%s\n' "$file"
c_version=$(stdc_base "${file}")
p_version=$(posix_base "${file}")
x_version=$(xopen_base "${file}")
if [ -n "${c_version}" ]; then
mkdir -p "${DEPS}/c.${c_version}"
echo "$file" >> "${DEPS}/c.${c_version}/sources"
fi
if [ -n "${p_version}" ]; then
mkdir -p "${DEPS}/p.${p_version}"
echo "$file" >> "${DEPS}/p.${p_version}/sources"
fi
if [ -n "${x_version}" ]; then
mkdir -p "${DEPS}/x.${x_version}"
echo "$file" >> "${DEPS}/x.${x_version}/sources"
fi
done
}
make_headers_mk() {
rm -f "${TOPDIR}/.headers.mk"
printf '.POSIX:\n.DEFAULT: headers\ninclude config.mk\n\n' > "${TOPDIR}/.headers.mk"
for header in $(cat "${DEPS}/all.h"); do
printf 'Building dependencies for <%s>\n' "$header"
printf '$(INCDIR)/%s: ' "$header" >> "${TOPDIR}/.headers.mk"
#printf '$(INCDIR)/%s: $$(grep -l "#include <%s>" $$(cat %s/all.c %s/all.ref)\n' "$header" "$header" "${DEPS}" "${DEPS}" >> "${TOPDIR}/.headers.mk"
grep -l "#include <${header}>" $(cat "${DEPS}/all.c" "${DEPS}/all.ref") | sed -e "s#${SRCDIR}#\$(SRCDIR)#" | tr '\n' ' ' >> "${TOPDIR}/.headers.mk"
printf '\n\tsh mkh.sh $@\n\n' >> "${TOPDIR}/.headers.mk"
done
printf 'headers: ' >> "${TOPDIR}/.headers.mk"
for header in $(cat "${DEPS}/all.h"); do
printf ' \\\n\t$(INCDIR)/%s' "$header" >> "${TOPDIR}/.headers.mk"
done
printf '\n' >> "${TOPDIR}/.headers.mk"
}
make_deps_mk() {
rm -f "${TOPDIR}/.deps.mk"
echo 'all:;@echo ok\n' > "${TOPDIR}/.deps.mk"
}
make_deps_mk
|