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