Skip to content

Commit

Permalink
add nasm-segelf build recipe [#146]
Browse files Browse the repository at this point in the history
... for homebrew package manager.
  • Loading branch information
stsp committed Nov 10, 2023
1 parent 30b498c commit 2715eed
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
5 changes: 5 additions & 0 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ define mdir
endef

all:
$(MAKE) nasm-segelf
+$(call mdir,fdpp,all)

clean:
Expand All @@ -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
34 changes: 34 additions & 0 deletions nasm-segelf.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 2715eed

Please sign in to comment.