]> git.ipfire.org Git - thirdparty/gcc.git/blob - fixincludes/mkfixinc.sh
Fix stdlib.h for mingw.
[thirdparty/gcc.git] / fixincludes / mkfixinc.sh
1 #! /bin/sh
2
3 if [ $# -ne 1 ]
4 then
5 echo "Usage: $0 <target-mach-triplet>"
6 exit 1
7 fi
8
9 machine=$1
10 target=fixinc.sh
11
12 # Check for special fix rules for particular targets
13 case $machine in
14 alpha*-dec-*vms* | \
15 i?86-moss-msdos* | \
16 i?86-*-pe | \
17 i?86-*-cygwin* | \
18 i?86-*-interix* | \
19 *-*-vxworks* | \
20 powerpc-*-eabisim* | \
21 powerpc-*-eabi* | \
22 powerpc-*-rtems* | \
23 powerpcle-*-eabisim* | \
24 powerpcle-*-eabi* )
25 # IF there is no include fixing,
26 # THEN create a no-op fixer and exit
27 (echo "#! /bin/sh" ; echo "exit 0" ) > ${target}
28 ;;
29
30 i?86-*-mingw32* | \
31 x86_64-*-mingw32*)
32 # We only want to fix stdlib.h in mingw.
33 # FIXME: Is SED available on mingw?
34 (cat > ${target} << EOF
35 #! /bin/sh
36
37 OUTPUT_DIR=\$1
38 if [ "x\$OUTPUT_DIR" = "x" ]; then
39 echo fixincludes: no output directory specified
40 exit 1
41 fi
42
43 if [ ! -d \$OUTPUT_DIR ]; then
44 echo fixincludes: output dir \"\$OUTPUT_DIR\" is an invalid directory
45 exit 1
46 fi
47
48 INPUT_DIR=\$2
49 if [ "x\$INPUT_DIR" = "x" ]; then
50 echo fixincludes: no input directory specified
51 exit 1
52 fi
53
54 if [ ! -d \$INPUT_DIR ]; then
55 echo fixincludes: input dir \"\$INPUT_DIR\" is an invalid directory
56 exit 1
57 fi
58
59 INPUT_STDLIB_H=\$INPUT_DIR/stdlib.h
60 if [ ! -f \$INPUT_STDLIB_H ]; then
61 echo fixincludes: \"stdlib.h\" is an invalid file
62 exit 1
63 fi
64
65 OUTPUT_STDLIB_H=\$OUTPUT_DIR/stdlib.h
66 sed -e "s/\(.*_rotl.*\)/#if __GNUC__ < 4 || (__GNUC__ == 4 \&\& __GNUC_MINOR__ < 5)\n\1/" \
67 -e "s/\(.*_lrotr.*\)/\1\n#else\n\#include <x86intrin.h>\n#endif/" \
68 \$INPUT_STDLIB_H > \$OUTPUT_STDLIB_H
69
70 exit 0
71 EOF
72 )
73 ;;
74
75 *)
76 cat < ${srcdir}/fixinc.in > ${target} || exit 1
77 ;;
78 esac
79 chmod 755 ${target}