b43-asm: Add an option to print the code sizes after assembling.
[b43-tools.git] / assembler / b43-asm
1 #!/bin/bash
2 #
3 #  b43-asm preprocessing frontend
4 #
5 #  Copyright (c) 2007 Michael Buesch <mb@bu3sch.de>
6 #  Licensed under the GNU/GPL version 2.
7 #
8
9
10 # The b43-asm backend binary
11 B43_ASM="b43-asm.bin"
12 # The C preprocessor binary
13 CPP="cpp"
14
15
16 # This variable is changed by the installer scripts.
17 installed=0
18 if [ $installed -eq 0 ] && [ -x "./$B43_ASM" ]; then
19         B43_ASM="./$B43_ASM"
20 fi
21
22 # Probe the CPP binary
23 $CPP --help >/dev/null 2>&1
24 if [ $? -ne 0 ]; then
25         echo "ERROR: Failed to execute the C preprocessor \"$CPP\""
26         exit 1
27 fi
28 # Probe the b43-asm binary
29 $B43_ASM a b --help >/dev/null 2>&1
30 if [ $? -ne 0 ]; then
31         echo "ERROR: Failed to execute the b43-asm binary \"$B43_ASM\""
32         exit 2
33 fi
34
35 if [ $# -lt 2 ]; then
36         $B43_ASM --help
37         exit 3
38 fi
39 infile="$1"
40 shift
41 outfile="$1"
42 shift
43
44 if [ "$infile" != "-" ]; then
45         if ! [ -r "$infile" ]; then
46                 echo "ERROR: Can not read input file \"$infile\""
47                 exit 4
48         fi
49 fi
50
51 $CPP -x c++ -traditional-cpp "$infile" | $B43_ASM "-" "$outfile" $@