summaryrefslogtreecommitdiffstats
path: root/assembler/b43-asm
blob: 5d6b54e8573c52c83258c6aa49d95306021746e9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/sh
#
#  b43-asm preprocessing frontend
#
#  Copyright (c) 2010 Michael Buesch <m@bues.ch>
#  Licensed under the GNU/GPL version 2.
#


# The b43-asm backend binary
B43_ASM="b43-asm.bin"
# The C preprocessor binary
CPP="gcc -E"


# This variable is changed by the installer scripts.
installed=0
if [ $installed -eq 0 ] && [ -x "./$B43_ASM" ]; then
	B43_ASM="./$B43_ASM"
fi

# Probe the CPP binary
$CPP --help >/dev/null 2>&1
if [ $? -ne 0 ]; then
	echo "ERROR: Failed to execute the C preprocessor \"$CPP\""
	exit 1
fi
# Probe the b43-asm binary
$B43_ASM a b --help >/dev/null 2>&1
if [ $? -ne 0 ]; then
	echo "ERROR: Failed to execute the b43-asm binary \"$B43_ASM\""
	exit 2
fi

if [ $# -lt 2 ]; then
	$B43_ASM --help
	exit 3
fi
infile="$1"
shift
outfile="$1"
shift

cpp_args=
if [ "$1" = "--cpp-args" ]; then
	shift
	while [ "$1" != "--" ]; do
		if [ $# -eq 0 ]; then
			echo "ERROR: --cpp-args must be terminated by --"
			exit 4
		fi
		cpp_args="$cpp_args $1"
		shift
	done
	shift
fi

if [ "$infile" != "-" ]; then
	if ! [ -r "$infile" ]; then
		echo "ERROR: Can not read input file \"$infile\""
		exit 5
	fi
fi

$CPP -x c++ -traditional-cpp $cpp_args "$infile" | $B43_ASM "-" "$outfile" --__real_infile "$infile" $@
bues.ch cgit interface