]> wimlib.net Git - wimlib/blob - build-aux/nasm_lt.sh
v1.7.4
[wimlib] / build-aux / nasm_lt.sh
1 #! /bin/sh
2 command=""
3 infile=""
4 o_opt=no
5 pic=no
6 while [ $# -gt 0 ]; do
7     case "$1" in
8         -DPIC|-fPIC|-fpic|-Kpic|-KPIC)
9             if [ "$pic" != "yes" ] ; then
10                 command="$command -DPIC"
11                 pic=yes
12             fi
13             ;;
14         -f|-fbin|-faout|-faoutb|-fcoff|-felf|-felf64|-fas86| \
15         -fobj|-fwin32|-fwin64|-frdf|-fieee|-fmacho|-fmacho64)
16             # 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
49 done
50 if [ "$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"
55 fi
56 echo $command
57 exec $command