Skip to content

Commit

Permalink
Merge pull request #255 from chewi/fail-mbr-automake
Browse files Browse the repository at this point in the history
Move compile-mbr.sh script into fail-mbr's automake
  • Loading branch information
Thomas-Tsai authored Dec 16, 2024
2 parents fd5cbbb + 1ceddc0 commit 95527c2
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 59 deletions.
9 changes: 8 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ AC_MSG_RESULT([$fuse_version])
fi

AC_CHECK_LIB([pthread], [pthread_create], [], AC_MSG_ERROR([*** pthread library (libpthread) not found]))
AC_PATH_PROG(OBJCOPY, objcopy, ,)

##ext2/3##
AC_ARG_ENABLE([extfs],
Expand Down Expand Up @@ -491,6 +490,14 @@ PKG_CHECK_VAR([bashcompletiondir], [bash-completion], [completionsdir], [],
[bashcompletiondir="${sysconfdir}/bash_completion.d"])
AC_SUBST(bashcompletiondir)

##fail-mbr
AC_CHECK_TOOL([OBJCOPY], [objcopy])
AC_CHECK_TOOL([OBJDUMP], [objdump])
AM_CONDITIONAL(X86, [case $host_cpu in
x86_64|i[0-9]86) true ;;
*) false ;;
esac])

AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([
Makefile
Expand Down
33 changes: 31 additions & 2 deletions fail-mbr/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,34 @@ clean-local:

distclean-local: clean-local

fail-mbr.bin:
sh $(srcdir)/compile-mbr.sh
if X86
fail-mbr.image: fail-mbr.S
$(CC) -c "$<" -o "$@"

fail-mbr.bin: fail-mbr.image
$(OBJCOPY) -O binary --strip-unneeded -R .note -R .comment -R .note.gnu.build-id -R .note.gnu.property -R .reginfo -R .rel.dyn "$<" "$@"

## Check that this file is the same as the original fail-mbr:
@echo "Checking the file:"
$(OBJDUMP) -D -b binary -mi386 -Maddr16,data16 "$@" > f1.obj
$(OBJDUMP) -D -b binary -mi386 -Maddr16,data16 "$(srcdir)/[email protected]" > f2.obj

## The regular expression is used to reject lines which contain either:
## - the name of the file, "fail-mbr"
## - a line separator output by diff, "---"
## - the OP code "xor %ax,%ax" which may begin by 0x31 or 0x33
## - a numerical offset output by diff, ^[a-f0-9]*$
@if diff f1.obj f2.obj | grep -qEv 'fail-mbr|---|xor %ax,%ax|^[a-f0-9]*$$'; then \
echo "files $@ and [email protected] differ significantly:"; \
diff f1.obj f2.obj; \
exit 1; \
else \
echo "'[email protected]' and '[email protected]' have no significant differences."; \
rm f1.obj f2.obj; \
exit 0; \
fi
else
fail-mbr.bin: fail-mbr.bin.orig
@echo "The architecture is not x86, so the file '$@' is not compiled"
cp -vp "$<" "$@"
endif
56 changes: 0 additions & 56 deletions fail-mbr/compile-mbr.sh

This file was deleted.

0 comments on commit 95527c2

Please sign in to comment.