ffigen/ffigen

47 lines
1.3 KiB
Plaintext
Raw Normal View History

2023-05-19 04:11:48 -04:00
#!/bin/sh
#
# Copyright (C) 1996 The University of Oregon. All rights reserved.
#
# This file may be freely redistributed in its entirety with or without
# modification provided that this copyright notice is not removed. It
# may not be sold for profit or incorporated in commercial software
# products without the prior written permission of the copyright holder.
LCCHOME=/home/users/lth/net/lcc
ARCH=sparc/solaris
TMP=/tmp/ffitmp.$$
2023-05-19 04:13:22 -04:00
DEFINES="-D__STDC__ -D_NO_LONGLONG"
2023-05-19 04:11:48 -04:00
output=""
2023-05-19 04:13:22 -04:00
INCLUDES="-I/usr/include -I."
#INCLUDES="-I$LCCHOME/include/$ARCH -I/usr/include -I."
2023-05-19 04:11:48 -04:00
VERBOSE=1
if [ $# -lt 1 ]; then
echo "Usage: $0 filename ..."
exit 1
fi
for i
do
case $i in
-q) VERBOSE=0 ;;
-I*) INCLUDES="$i $INCLUDES" ;;
-D*) DEFINES="$DEFINES $i" ;;
# -U*) DEFINES="$DEFINES $i" ;; # WRONG
*) output=`basename $i .h`.ffi
if [ $VERBOSE -eq 1 ]; then echo "preprocessing $i"; fi
$LCCHOME/lib/fficpp.bin $INCLUDES $DEFINES $i > $TMP
if [ $? -ne 0 ]; then echo "Aborted!"; exit; fi
if [ $VERBOSE -eq 1 ]; then echo "parsing $i"; fi
$LCCHOME/lib/ffigen.bin -target=null < $TMP > $output
if [ $? -ne 0 ]; then echo "Aborted!"; exit; fi
if [ $VERBOSE -eq 1 ]; then echo "postprocessing $i"; fi
awk '/#pragma macro/ {print "(macro " $3 " \"" $4 "\" \"" $5 "\")"}'\
$TMP >> $output
rm -f $TMP
;;
esac
done
exit 0