diff --git a/makefile b/makefile index f6b28d3e..8aef9337 100644 --- a/makefile +++ b/makefile @@ -10,6 +10,7 @@ define mdir endef all: + $(MAKE) nasm-segelf +$(call mdir,fdpp,all) clean: @@ -21,3 +22,7 @@ rpm: fdpp.spec.rpkg install uninstall deb tar: cd fdpp && $(MAKE) srcdir=$(srcdir)/fdpp $@ + +nasm-segelf: + $@ --version 2>/dev/null || \ + brew install $(srcdir)/nasm-segelf.rb diff --git a/nasm-segelf.rb b/nasm-segelf.rb new file mode 100644 index 00000000..fb4a760c --- /dev/null +++ b/nasm-segelf.rb @@ -0,0 +1,34 @@ +class NasmSegelf < Formula + desc "nasm-segelf" + homepage "https://github.com/stsp/nasm" + url "https://github.com/stsp/nasm.git", branch: "elf16" + version "2.17" + sha256 "" + license "BSD-2-Clause" + + depends_on "autoconf" => :build + depends_on "automake" => :build + depends_on "gcc" => :build + depends_on "perl" => :build + depends_on "make" => :build + + def install + system "./autogen.sh" + system "./configure", "--prefix=#{prefix}" + system "make", "install" + end + + test do + (testpath/"foo.s").write <<~EOS + mov eax, 0 + mov ebx, 0 + int 0x80 + EOS + + system "#{bin}/nasm-segelf", "foo.s" + code = File.open("foo", "rb") { |f| f.read.unpack("C*") } + expected = [0x66, 0xb8, 0x00, 0x00, 0x00, 0x00, 0x66, 0xbb, + 0x00, 0x00, 0x00, 0x00, 0xcd, 0x80] + assert_equal expected, code + end +end