4 exec_prefix
=@exec_prefix@
7 fd2inlinedir
=${datadir}/fd2inline
8 FD2INLINE
=${bindir}/fd2inline
9 SPLITASM
="awk -f ${fd2inlinedir}/splitasm.awk"
26 if [ -z "$STUBS" ]; then
27 echo "Usage: $0 [--include] [--lib]"
31 if [ "${STUBS}" = "yes" ]; then
32 build_dir
=`mktemp -qd /tmp/gg-fix-includes.XXXXXX`
34 if [ -z "${build_dir}" ]; then
35 echo "Error: Unable to create temporary directory."
40 for gcc
in ${bindir}/*-*-gcc; do
41 target
=`echo "${gcc}" | sed -e "s,.*/\(.*\)-gcc,\1,"`
43 if test -d ${prefix}/${target}; then
46 CC
="${target}-gcc -Os -fomit-frame-pointer"
49 FD2INLINE_OS
="ix86be-amithlon"
50 FIXINCLUDE
="perl ${fd2inlinedir}/geninclude.pl"
53 CC
="${target}-gcc -Os -fomit-frame-pointer"
56 FD2INLINE_OS
="${target}"
60 CC
="${target}-gcc -Os -fomit-frame-pointer"
63 FD2INLINE_OS
="${target}"
64 FIXINCLUDE
="perl ${fd2inlinedir}/geninclude.pl"
73 if test "$FD2INLINE_OS" == "X"; then
74 echo -e "${target}: Unsupported target."
77 echo -e "${INFO}*** Target ${target}${ERROR}"
79 if [ "${STUBS}" = "no" ]; then
80 rm -r ${prefix}/${target}/sys-include
81 echo "The sys-include directory is automatically generated. Do no edit!" > ${prefix}/${target}/sys-include.readme
82 mkdir
${prefix}/${target}/sys-include
83 mkdir
${prefix}/${target}/sys-include
/inline
84 mkdir
${prefix}/${target}/sys-include
/proto
86 rm ${prefix}/${target}/lib
/libamigastubs.a
89 for fd_dir
in ${prefix}/os-lib
/fd
/*; do
90 package
=`echo "${fd_dir}" | sed -e "s,.*/,,"`
92 if test -d ${fd_dir}; then
93 echo -e "${INFO} *** Package ${package}${ERROR}"
95 if [ "${STUBS}" = "no" ]; then
96 echo -e "${INFO} *** Patching and installing header files${ERROR}"
98 for dir
in `cd ${prefix}/os-include/${package} &&
100 -and -not -ipath "ppcinline*" \
101 -and -not -ipath "ppcpragma*" \
102 -and -not -ipath "ppcproto*" \
103 -and -not -ipath "inline*" \
104 -and -not -ipath "pragma*" \
105 -and -not -ipath "proto*"`; do
106 test -d ${prefix}/${target}/sys-include/${dir} || \
107 mkdir
${prefix}/${target}/sys-include/${dir}
110 for header
in `cd ${prefix}/os-include/${package} &&
111 find * -iname "*.h" -and -type f \
112 -and -not -ipath "ppcinline*" \
113 -and -not -ipath "ppcpragma*" \
114 -and -not -ipath "ppcproto*" \
115 -and -not -ipath "inline*" \
116 -and -not -ipath "pragma*" \
117 -and -not -ipath "proto*"`; do
118 echo -ne "${NORMAL}[${header}] ${ERROR}"
119 ${FIXINCLUDE} ${prefix}/os-include/${package}/${header} \
120 > ${prefix}/${target}/sys-include/${header}
124 echo -e "${INFO} *** Generating inlines and proto files${ERROR}"
126 for fd
in ${fd_dir}/*_
*.
[Ff
][Dd
]; do
127 base
=`echo "${fd}" | sed -e "s,${fd_dir}/\(.*\)_\(.*\)\...,\1,"`
128 clib
="${prefix}/os-include/${package}/clib/${base}_protos.h"
130 if test ! -r ${clib}; then
131 echo "Warning: ${clib} is missing."
133 echo -ne "${NORMAL}[${base}] ${ERROR}"
134 ${FD2INLINE} --quiet --new --target=${FD2INLINE_OS} ${fd} ${clib} \
135 -o ${prefix}/${target}/sys-include/inline/${base}.h
137 ${FD2INLINE} --quiet --proto --target=${FD2INLINE_OS} ${fd} \
138 -o ${prefix}/${target}/sys-include/proto/${base}.h
142 cp ${fd2inlinedir}/stubs.h ${fd2inlinedir}/${FD2INLINE_OS}/* \
143 ${prefix}/${target}/sys-include
/inline
/
147 echo -e "${INFO} *** Generating stub libraries${ERROR}"
149 # Note that we cannot compile the stubs until inlines and prototypes
150 # has been generated!
152 for fd
in ${fd_dir}/*_
*.
[Ff
][Dd
]; do
153 base
=`echo "${fd}" | sed -e "s,${fd_dir}/\(.*\)_\(.*\)\...,\1,"`
154 clib
="${prefix}/os-include/${package}/clib/${base}_protos.h"
156 if test ! -r ${clib}; then
157 echo "Warning: ${clib} is missing."
159 echo -ne "${NORMAL}[${base}] ${ERROR}"
160 ${FD2INLINE} --quiet --stubs --target=${FD2INLINE_OS} ${fd} ${clib} \
161 -o ${build_dir}/-stubs.c
163 ${CC} -D__CLIB_TYPES__ -S ${build_dir}/-stubs.c \
164 -o ${build_dir}/-stubs.s ||
exit
166 ${SPLITASM} -v dest=${build_dir} ${build_dir}/-stubs.s
175 if [ "${STUBS}" = "yes" ]; then
176 rm ${build_dir}/-stubs.s
${build_dir}/-stubs.c
178 echo -e "${INFO} *** Assembling files${ERROR}"
180 for stub
in ${build_dir}/*.s
; do
181 base
=`basename ${stub} .s`
182 ${AS} $stub -o ${build_dir}/${base}.o
184 echo -ne "${NORMAL}[${base}] ${ERROR}"
189 # This line can get pretty long, so we get rid of the path at least ...
190 ( cd ${build_dir} && ${AR} -rs ${prefix}/${target}/lib
/libamigastubs.a
*.o
; \
197 if [ "${STUBS}" = "yes" ]; then
201 echo -e "${INFO}Done!${NORMAL}"