blob: 6cd73294c0617c5d186926f1a7903afbde11044c [file] [log] [blame]
MIYASAKA Masarua2e6a9d2006-02-04 00:00:00 +00001#! /bin/sh
2command=""
3infile=""
4o_opt=no
5pic=no
6while [ $# -gt 0 ]; do
7 case "$1" in
DRC8a26fde2010-02-16 22:34:12 +00008 -DPIC|-fPIC|-fpic|-Kpic|-KPIC)
MIYASAKA Masarua2e6a9d2006-02-04 00:00:00 +00009 if [ "$pic" != "yes" ] ; then
10 command="$command -DPIC"
11 pic=yes
12 fi
13 ;;
DRCcdc8ac32009-06-25 20:38:31 +000014 -f|-fbin|-faout|-faoutb|-fcoff|-felf|-felf64|-fas86| \
DRC8b014d72010-02-18 13:03:41 +000015 -fobj|-fwin32|-fwin64|-frdf|-fieee|-fmacho|-fmacho64)
MIYASAKA Masarua2e6a9d2006-02-04 00:00:00 +000016 # it's a file format specifier for nasm.
17 command="$command $1"
18 ;;
19 -f*)
20 # maybe a code-generation flag for gcc.
21 ;;
22 -[Ii]*)
23 incdir=`echo "$1" | sed 's/^-[Ii]//'`
24 if [ "x$incdir" = x -a "x$2" != x ] ; then
25 case "$2" in
26 -*) ;;
27 *) incdir="$2"; shift;;
28 esac
29 fi
30 if [ "x$incdir" != x ] ; then
31 # In the case of NASM, the trailing slash is necessary.
32 incdir=`echo "$incdir" | sed 's%/*$%/%'`
33 command="$command -I$incdir"
34 fi
35 ;;
36 -o*)
37 o_opt=yes
38 command="$command $1"
39 ;;
40 *.asm)
41 infile=$1
42 command="$command $1"
43 ;;
44 *)
45 command="$command $1"
46 ;;
47 esac
48 shift
49done
50if [ "$o_opt" != yes ] ; then
51 # By default, NASM creates an output file
52 # in the same directory as the input file.
53 outfile="-o `echo $infile | sed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.o"
54 command="$command $outfile"
55fi
56echo $command
57exec $command