Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

Commit

Permalink
nacl: build tweaks
Browse files Browse the repository at this point in the history
Closes #50429.

Signed-off-by: Dominyk Tiller <[email protected]>
  • Loading branch information
DomT4 committed Mar 26, 2016
1 parent 037fb0e commit 681419a
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions Library/Formula/nacl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ class Nacl < Formula
end

def install
# Print the build to stdout rather than the default logfile.
# Logfile makes it hard to debug and spot hangs. Applied by Debian:
# https://sources.debian.net/src/nacl/20110221-4.1/debian/patches/output-while-building/
# Also, like Debian, inreplace the hostname because it isn't used outside
# build process and adds an unpredictable factor.
inreplace "do" do |s|
s.gsub! 'exec >"$top/log"', 'exec | tee "$top/log"'
s.gsub! /^shorthostname=`.*$/, "shorthostname=brew"
end

system "./do" # This takes a while since it builds *everything*

# NaCL has an odd compilation model (software by djb, who'da thunk it?)
Expand All @@ -26,17 +36,16 @@ def install
# It also builds both x86 and x86_64 copies if your compiler can
# handle it. Here we only install one copy, based on if you're a
# 64bit system or not. A --universal could come later though I guess.
archstr = Hardware.is_64_bit? ? "amd64" : "x86"
hoststr = `hostname | sed 's/\\..*//' | tr -cd '[a-z][A-Z][0-9]'`.strip
archstr = Hardware.is_64_bit? ? "amd64" : "x86"

# Don't include cpucycles.h
include.install Dir["build/#{hoststr}/include/#{archstr}/crypto_*.h"]
include.install "build/#{hoststr}/include/#{archstr}/randombytes.h"
include.install Dir["build/brew/include/#{archstr}/crypto_*.h"]
include.install "build/brew/include/#{archstr}/randombytes.h"

# Add randombytes.o to the libnacl.a archive - I have no idea why it's separated,
# but plenty of the key generation routines depend on it. Users shouldn't have to
# know this.
nacl_libdir = "build/#{hoststr}/lib/#{archstr}"
nacl_libdir = "build/brew/lib/#{archstr}"
system "ar", "-r", "#{nacl_libdir}/libnacl.a", "#{nacl_libdir}/randombytes.o"
lib.install "#{nacl_libdir}/libnacl.a"
end
Expand Down

0 comments on commit 681419a

Please sign in to comment.