Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[submodule "openssl"]
path = openssl
path = _openssl
url = https://github.com/openssl/openssl.git
[submodule "libevent"]
path = libevent
Expand Down
38 changes: 22 additions & 16 deletions build.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,18 +19,23 @@ import (
"strings"
)

var verbose bool
var host string
var autopointPath string
var folders = []string{"openssl", "libevent", "zlib", "xz", "tor"}
var absCurrDir = getAbsCurrDir()
var numJobs = fmt.Sprintf("-j%d", runtime.NumCPU())
var (
verbose bool
host string
autopointPath string
folders = []string{"_openssl", "libevent", "zlib", "xz", "tor"}
absCurrDir = getAbsCurrDir()
numJobsInt = runtime.NumCPU()
numJobs = ""
)

func main() {
flag.BoolVar(&verbose, "verbose", false, "Whether to show command output")
flag.StringVar(&host, "host", "", "Host option, useful for cross-compilation")
flag.StringVar(&autopointPath, "autopoint-path", "/usr/local/opt/gettext/bin", "OSX: Directory that contains autopoint binary")
flag.IntVar(&numJobsInt, "j", runtime.NumCPU(), "Number of jobs to run in parallel")
flag.Parse()
numJobs = fmt.Sprintf("-j%d", numJobsInt)
if len(flag.Args()) != 1 {
log.Fatal("Missing command. Can be build-all, build-<folder>, clean-all, clean-<folder>, show-libs, or package-libs")
}
Expand Down Expand Up @@ -109,7 +114,7 @@ func build(folder string) error {
}
}
return nil
case "openssl":
case "_openssl":
prefix := pwd + "/dist"
cmds := [][]string{
{"sh", "./config", "--prefix=" + prefix, "--openssldir=" + prefix, "no-shared", "no-dso", "no-zlib"},
Expand Down Expand Up @@ -158,7 +163,7 @@ func build(folder string) error {
{"sh", "-l", "./autogen.sh"},
{"sh", "./configure", "--prefix=" + pwd + "/dist",
"--disable-shared", "--enable-static", "--with-pic", "--disable-samples", "--disable-libevent-regress",
"CPPFLAGS=-I../openssl/dist/include", "LDFLAGS=-L../openssl/dist/lib"},
"CPPFLAGS=-I../_openssl/dist/include", "LDFLAGS=-L../_openssl/dist/lib"},
{"make", numJobs},
{"make", "install"},
}
Expand Down Expand Up @@ -186,7 +191,7 @@ func build(folder string) error {
env = []string{"PATH=" + autopointPath + ":" + os.Getenv("PATH")}
}
cmds := [][]string{
{"sh", "-l", "./autogen.sh"},
{"sh", "-l", "./autogen.sh", "--no-po4a"},
{"sh", "./configure", "--prefix=" + pwd + "/dist", "--disable-shared", "--enable-static",
"--disable-doc", "--disable-scripts", "--disable-xz", "--disable-xzdec", "--disable-lzmadec",
"--disable-lzmainfo", "--disable-lzma-links"},
Expand All @@ -206,9 +211,10 @@ func build(folder string) error {
torConf = []string{"sh", "./configure", "--prefix=" + pwd + "/dist",
"--disable-gcc-hardening", "--disable-system-torrc", "--disable-asciidoc",
"--enable-static-libevent", "--with-libevent-dir=" + pwd + "/../libevent/dist",
"--enable-static-openssl", "--with-openssl-dir=" + pwd + "/../openssl/dist",
"--enable-static-openssl", "--with-openssl-dir=" + pwd + "/../_openssl/dist",
"--enable-static-zlib", "--with-zlib-dir=" + pwd + "/../zlib/dist",
"--disable-systemd", "--disable-lzma", "--disable-seccomp"}
"--disable-systemd", "--disable-lzma", "--disable-seccomp",
"--disable-html-manual", "--disable-manpage"}

if host != "" {
torConf = append(torConf, "--host="+host)
Expand All @@ -235,7 +241,7 @@ func build(folder string) error {
{"make", "install"},
})
default:
return fmt.Errorf("Unrecognized folder: %v", folder)
return fmt.Errorf("unrecognized folder: %v", folder)
}
}

Expand All @@ -255,9 +261,9 @@ func clean(folder string) (err error) {
makefile := "Makefile"
switch folder {
// OpenSSL needs to have the dist folder removed first
case "openssl":
if err := os.RemoveAll("openssl/dist/lib"); err != nil {
return fmt.Errorf("Unable to remove openssl/dist/lib: %v", err)
case "_openssl":
if err := os.RemoveAll("_openssl/dist/lib"); err != nil {
return fmt.Errorf("unable to remove _openssl/dist/lib: %v", err)
}
// Zlib needs to have a prefix and needs a special windows makefile
case "zlib":
Expand Down Expand Up @@ -334,7 +340,7 @@ func getLibSets() ([]*libSet, error) {
&libSet{"libevent/dist/lib", []string{"event"}},
&libSet{"xz/dist/lib", []string{"lzma"}},
&libSet{"zlib/dist/lib", []string{"z"}},
&libSet{"openssl/dist/lib", []string{"ssl", "crypto"}},
&libSet{"_openssl/dist/lib", []string{"ssl", "crypto"}},
)
return libSets, nil
}
Expand Down
11 changes: 11 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module github.com/cretz/tor-static

go 1.22.4

require github.com/cretz/bine v0.2.0

require (
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a // indirect
golang.org/x/net v0.0.0-20210525063256-abc453219eb5 // indirect
golang.org/x/sys v0.0.0-20210423082822-04245dca01da // indirect
)
24 changes: 24 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
github.com/cretz/bine v0.2.0 h1:8GiDRGlTgz+o8H9DSnsl+5MeBK4HsExxgl6WgzOCuZo=
github.com/cretz/bine v0.2.0/go.mod h1:WU4o9QR9wWp8AVKtTM1XD5vUHkEqnf2vVSo6dBqbetI=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a h1:kr2P4QFmQr29mSLA43kwrOcgcReGTfbE9N577tCTuBc=
golang.org/x/crypto v0.0.0-20210513164829-c07d793c2f9a/go.mod h1:P+XmwS30IXTQdn5tA2iutPOUgjI07+tq3H3K9MVA1s8=
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
golang.org/x/net v0.0.0-20210525063256-abc453219eb5 h1:wjuX4b5yYQnEQHzd+CBcrcC6OVR2J1CN6mUy0oSxIPo=
golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da h1:b3NXsE2LusjYGGjL5bxEVZZORm/YEFFrWFjR8eFrw/c=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=