X-Git-Url: https://jxself.org/git/?p=b43-tools.git;a=blobdiff_plain;f=assembler%2Fb43-asm;h=9585b1c2a34805715ad7d8449706d922b087cb40;hp=ec6fa6e46c872aef30b044cefb4cb8a076b21a75;hb=7ff7a760aa92b63ed4af8aabddb621cc9483e67f;hpb=3691c9a3b75851b1ff57b1fbf78aa067358e8a09 diff --git a/assembler/b43-asm b/assembler/b43-asm index ec6fa6e..9585b1c 100755 --- a/assembler/b43-asm +++ b/assembler/b43-asm @@ -1,27 +1,65 @@ -#!/bin/sh +#!/bin/bash +# +# b43-asm preprocessing frontend +# +# Copyright (c) 2007 Michael Buesch +# Licensed under the GNU/GPL version 2. +# -installed=0 -if [ -z "$B43_ASM" ]; then - if [ $installed -eq 0 ] && [ -x "./b43-asm.bin" ]; then - B43_ASM="./b43-asm.bin" - else - B43_ASM="b43-asm.bin" - fi +# 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 -if [ -z "$CPP" ]; then - CPP="cpp" +# 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 1 + exit 3 fi - infile="$1" shift outfile="$1" shift -cat "$infile" | $CPP -traditional-cpp | $B43_ASM "-" "$outfile" $@ +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" $@