]> git.saurik.com Git - apple/libc.git/blame - xcodescripts/manpages.sh
Libc-997.1.1.tar.gz
[apple/libc.git] / xcodescripts / manpages.sh
CommitLineData
ad3c9f2a
A
1#!/bin/bash -e
2
3if [ "$ACTION" = installhdrs ]; then exit 0; fi
4if [ "$PLATFORM_NAME" = iphoneos ]; then exit 0; fi
5if [ "$PLATFORM_NAME" = iphonesimulator ]; then exit 0; fi
6
7UNIFDEF_FLAGS=`${SRCROOT}/xcodescripts/generate_features.pl --unifdef`
8MANPAGES_LIST="${SRCROOT}/man/manpages.lst"
9FILES=$(find -E ${SRCROOT} -regex '.*/[^.]+\.[0-9]' -type f)
10
11cat ${MANPAGES_LIST} | grep -v -E '(^#|^\s*$)' | while read first solid rest; do
12 SOURCE=$(grep -E "/${first}$"<<EOF
13${FILES}
14EOF
15)
6465356a
A
16
17 # This is a subshell, the real exit is after the loop.
18 if [ -z "${SOURCE}" ]; then
19 echo "Error: ${first} not found"
20 exit 1
21 fi
22
ad3c9f2a
A
23 SECTION=$(echo ${first} | tail -c 2)
24
25 DESTDIR=${DSTROOT}/usr/share/man/man${SECTION}
26 DEST=${DESTDIR}/${solid}
27
28 mkdir -p ${DSTROOT}/usr/share/man/man${SECTION}
29
30 # cat is used to keep bash happy, unifdef returns non-zero in some success cases
31 cmd="unifdef -t ${UNIFDEF_FLAGS} < ${SOURCE} | cat > ${DEST}"
32 echo ${cmd}
33 eval ${cmd}
34
35 for link in ${rest}; do
36 cmd="ln -sf ${first} ${DESTDIR}/${link}"
37 echo ${cmd}
38 eval ${cmd}
39 done
40done
41
6465356a
A
42if [ $? -ne 0 ]; then
43 echo "Exiting due to previous error(s)."
44 exit 1
45fi
46
ad3c9f2a
A
47# grrr, uuid special case
48for page in libuuid.3 uuid_clear.3 uuid_compare.3 uuid_copy.3 uuid_generate.3 uuid_is_null.3 uuid_parse.3 uuid_unparse.3; do
49 SECTION=$(echo ${page} | tail -c 2)
50 DESTDIR=${DSTROOT}/usr/share/man/man${SECTION}
51 DEST=${DESTDIR}/${page}
52
53 # libuuid.3 -> uuid.3
54 [[ "${page}" == "libuuid.3" ]] && DEST=${DESTDIR}/uuid.3
55
56 sed -f ${SRCROOT}/uuid/uuidman.sed ${SRCROOT}/uuid/uuidsrc/${page}.in > ${DEST}
57done
58
59# and because uuid pages are special cased, so are the links
60for link in uuid_generate_random.3 uuid_generate_time.3; do
61 SECTION=$(echo ${link} | tail -c 2)
62 ln -sf uuid_generate.3 ${DSTROOT}/usr/share/man/man${SECTION}/${link}
63done
64
65for link in uuid_unparse_lower.3 uuid_unparse_upper.3; do
66 SECTION=$(echo ${link} | tail -c 2)
67 ln -sf uuid_unparse.3 ${DSTROOT}/usr/share/man/man${SECTION}/${link}
68done