diff options
author | Robert Mustacchi <rm@joyent.com> | 2011-07-01 15:29:28 -0700 |
---|---|---|
committer | Robert Mustacchi <rm@joyent.com> | 2011-07-01 15:29:28 -0700 |
commit | be4035d30b9f278490b61ab83d4d80386f3932bd (patch) | |
tree | aac1c400f2c91cb41591fb63adcdbedc6a8c49f5 | |
parent | 33afe2f37503804996aaf48f846030094d9b851b (diff) | |
download | illumos-kvm-be4035d30b9f278490b61ab83d4d80386f3932bd.tar.gz |
HVM-463 Want tool to check header files
-rw-r--r-- | Makefile | 14 | ||||
-rwxr-xr-x | tools/hdrchk | 52 |
2 files changed, 66 insertions, 0 deletions
@@ -14,6 +14,7 @@ CFLAGS += -D_KERNEL -D_MACHDEP -Dx86 -DDEBUG -c -g -DCONFIG_SOLARIS -O2 -fident INCLUDEDIR= -I $(KERNEL_SOURCE)/usr/src/uts/intel -I $(KERNEL_SOURCE)/usr/src/uts/i86pc -I $(KERNEL_SOURCE)/usr/src/uts/common CSTYLE=$(KERNEL_SOURCE)/usr/src/tools/scripts/cstyle +HDRCHK=tools/hdrchk all: kvm kvm.so @@ -89,6 +90,19 @@ install: kvm check: @$(CSTYLE) kvm.c kvm_mdb.c kvm_emulate.c kvm_x86.c kvm_irq.c kvm_lapic.c kvm_i8254.c kvm_mmu.c kvm_iodev.c kvm_ioapic.c kvm_vmx.c kvm_i8259.c kvm_coalesced_mmio.c kvm_irq_comm.c kvm_cache_regs.c kvm_bitops.c $(HEADERS) @./tools/xxxcheck kvm_x86.c kvm.c kvm_irq.c kvm_lapic.c kvm_i8254.c kvm_mmu.c kvm_iodev.c kvm_ioapic.c kvm_vmx.c kvm_i8259.c kvm_coalesced_mmio.c kvm_irq_comm.c kvm_cache_regs.c kvm_bitops.c + @$(HDRCHK) gcc kvm.h + @$(HDRCHK) gcc kvm_bitops.h + @$(HDRCHK) gcc kvm_cpuid.h + @$(HDRCHK) gcc kvm_impl.h + @$(HDRCHK) gcc kvm_iodev.h + @$(HDRCHK) gcc kvm_msidef.h + @$(HDRCHK) gcc kvm_timer.h + @$(HDRCHK) gcc kvm_types.h + @$(HDRCHK) gcc kvm_vmx.h + @$(HDRCHK) gcc kvm_x86.h + @$(HDRCHK) gcc kvm_x86host.h + + load: install @echo "==> Loading kvm module" diff --git a/tools/hdrchk b/tools/hdrchk new file mode 100755 index 0000000..0c8f7c5 --- /dev/null +++ b/tools/hdrchk @@ -0,0 +1,52 @@ +#!/bin/bash +# +# This checks that each header file can be compiled on its own. +# + +sh_cc= +sh_dir= +sh_base=${0##*/} +sh_tmpfile=/tmp/$sh_base-$USER.$$.c +sh_outfile=$sh_tmpfile.out + +cd ${0%/*} +sh_dir=${PWD%/*} + +function fail +{ + local msg="$*" + [[ -z "$msg" ]] && msg="failed" + echo "$sh_base: $msg" >&2 + exit 1 +} + +function check_file +{ + local file res + file=$1 + + cat > $sh_tmpfile <<EOF +#include "$sh_dir/$file" + +int +main(void) +{ + return (0); +} +EOF + [[ $? -eq 0 ]] || fail "can't write to temporary file" + $sh_cc -o $sh_outfile $sh_tmpfile + res=$? + rm $sh_tmpfile $sh_outfile + [[ $? -eq 0 ]] || fail "$file is not clean" +} + +if [[ $# -lt 2 ]]; then + echo "$sh_base: <compiler> <file 0> [file 1] [file n]" +fi +sh_cc=$1 +shift + +for file in "$@"; do + check_file $file +done |