]> git.karo-electronics.de Git - karo-tx-uboot.git/blob - board/xilinx/ml300/sw_services/uboot_v1_00_a/data/Ltypes
Initial revision
[karo-tx-uboot.git] / board / xilinx / ml300 / sw_services / uboot_v1_00_a / data / Ltypes
1 #!/bin/bash
2
3 if [ $# -ne 1 ]
4 then
5     echo "usage: Ltypes filename" >&2
6     exit 2
7 fi
8
9 FILE="$1"
10 #TMPFILE='mktemp "${FILE}.XXXXXX"' || exit 1
11 TMPFILE=${FILE}.`date "+%s"`
12 touch $TMPFILE || exit 1
13
14 # Change all the Xilinx types to Linux types and put the result into a temp file
15 sed     \
16         -e 's/\bXTRUE\b/TRUE/g' \
17         -e 's/\bXFALSE\b/FALSE/g' \
18         -e 's/\bXNULL\b/NULL/g' \
19         -e 's/"xenv.h"/<asm\/delay.h>/g' \
20         -e 's/\bXENV_USLEEP\b/udelay/g' \
21         -e 's/\bXuint8\b/u8/g' \
22         -e 's/\bXuint16\b/u16/g' \
23         -e 's/\bXuint32\b/u32/g' \
24         -e 's/\bXint8\b/s8/g' \
25         -e 's/\bXint16\b/s16/g' \
26         -e 's/\bXint32\b/s32/g' \
27         -e 's/\bXboolean\b/u32/g' \
28         "${FILE}" > "${TMPFILE}"
29
30 # Overlay the original file with the temp file
31 mv "${TMPFILE}" "${FILE}"
32
33 # Are we doing xbasic_types.h?
34 if [ "${FILE##*/}" = xbasic_types.h ]
35 then
36     # Remember as you're reading this that we've already gone through the prior
37     # sed script.  We need to do some other things to xbasic_types.h:
38     #   1) Add ifndefs around TRUE and FALSE defines
39     #   2) Remove definition of NULL as NULL
40     #   3) Replace most of the primitive types section with a #include
41     sed \
42         -e '/u32 true/,/#define false/Ic\
43 #ifndef TRUE\
44 #define TRUE 1\
45 #endif\
46 #ifndef FALSE\
47 #define FALSE 0\
48 #endif' \
49         -e '/#define[[:space:]][[:space:]]*NULL[[:space:]][[:space:]]*NULL/d' \
50         -e '/typedef[[:space:]][[:space:]]*unsigned[[:space:]][[:space:]]*char[[:space:]][[:space:]]*u8/,/typedef[[:space:]][[:space:]]*unsigned[[:space:]][[:space:]]*long[[:space:]][[:space:]]*u32.*boolean/c\
51 #include <linux/types.h>' \
52         "${FILE}" > "${TMPFILE}"
53
54     mv "${TMPFILE}" "${FILE}"
55 fi