diff --git a/README.md b/README.md index f2b8bc8..7372800 100644 --- a/README.md +++ b/README.md @@ -5,11 +5,11 @@ This project helps compile Tor into a static lib for use in other projects. The dependencies are in this repository as submodules so this repository needs to be cloned with `--recursive`. The submodules are: -* [OpenSSL](https://github.com/openssl/openssl/) - Checked out at tag `OpenSSL_1_0_2o` +* [OpenSSL](https://github.com/openssl/openssl/) - Checked out at tag `OpenSSL_1_0_2p` * [Libevent](https://github.com/libevent/libevent) - Checked out at tag `release-2.1.8-stable` * [zlib](https://github.com/madler/zlib) - Checked out at tag `v1.2.11` * [XZ Utils](https://git.tukaani.org/?p=xz.git) - Checked out at tag `v5.2.4` -* [Tor](https://github.com/torproject/tor) - Checked out at tag `tor-0.3.3.7` +* [Tor](https://github.com/torproject/tor) - Checked out at tag `tor-0.3.5.7` Many many bugs and quirks were hit while deriving these steps. Also many other repos, mailing lists, etc were leveraged to get some of the pieces right. They are not listed here for brevity reasons. @@ -73,21 +73,13 @@ are being run, add `-verbose` before the command. ## Using -Once the libs have been compiled, they can be used to link with your program. Below is the list of each dir (relative to -this repository root) and the library names inside the dirs. Library names are just the filenames without the "lib" -prefix of ".a" extension. When using something like `ld` or `LDFLAGS`, the directories (i.e. `-L`) and the libs -(i.e. `-l`) must be given in the order below: - -* `tor/src/or` - `tor` -* `tor/src/common` - `or`, `or-crypto`, `curve25519_donna`, `or-ctime`, and `or-event` -* `tor/src/trunnel` - `or-trunnel` -* `tor/src/ext/keccak-tiny` - `keccak-tiny` -* `tor/src/ext/ed25519/ref10` - `ed25519_ref10` -* `tor/src/ext/ed25519/donna` - `ed25519_donna` -* `libevent/dist/lib` - `event` -* `xz/dist/lib` - `lzma` -* `zlib/dist/lib` - `z` -* `openssl/dist/lib` - `ssl`, and `crypto` +Once the libs have been compiled, they can be used to link with your program. Due to recent refactorings within the Tor +source, the libraries are not listed here but instead listed when executing: + + go run build.go show-libs + +This lists directories (relative, prefixed with `-L`) followed by lib names (file sans `lib` prefix and sans `.a` +extension, prefixed with `-l`) as might be used in `ld`. The OS-specific system libs that have to be referenced (i.e. `-l`) are: diff --git a/build.go b/build.go index e8e4f05..fb387a6 100644 --- a/build.go +++ b/build.go @@ -24,7 +24,7 @@ func main() { flag.StringVar(&autopointPath, "autopoint-path", "/usr/local/opt/gettext/bin", "OSX: Directory that contains autopoint binary") flag.Parse() if len(flag.Args()) != 1 { - log.Fatal("Missing command. Can be build-all, build-, clean-all, or clean-") + log.Fatal("Missing command. Can be build-all, build-, clean-all, clean-, or show-libs") } if err := run(flag.Args()[0]); err != nil { log.Fatal(err) @@ -39,8 +39,10 @@ func run(cmd string) error { return build(cmd[6:]) } else if strings.HasPrefix(cmd, "clean-") { return clean(cmd[6:]) + } else if cmd == "show-libs" { + return showLibs() } - return fmt.Errorf("Invalid command: %v. Should be build-all, build-, clean-all, or clean-", cmd) + return fmt.Errorf("Invalid command: %v. Should be build-all, build-, clean-all, clean-, or show-libs", cmd) } func getAbsCurrDir() string { @@ -145,7 +147,7 @@ func build(folder string) error { var env = []string{"LDFLAGS=-s"} var torConf []string if runtime.GOOS == "windows" { - env = append(env, "LIBS=-lcrypt32") + env = append(env, "LIBS=-lcrypt32 -lgdi32") } torConf = []string{"sh", "./configure", "--prefix=" + pwd + "/dist", "--disable-gcc-hardening", "--disable-system-torrc", "--disable-asciidoc", @@ -228,3 +230,47 @@ func runCmd(folder string, env []string, cmd string, args ...string) error { } return c.Run() } + +func showLibs() error { + // Ask Tor for their libs + cmd := exec.Command("make", "show-libs") + cmd.Dir = "tor" + out, err := cmd.CombinedOutput() + if err != nil { + return fmt.Errorf("Failed 'make show-libs' in tor: %v", err) + } + // Key is dir + libSets := [][]string{} + for _, lib := range strings.Split(strings.TrimSpace(string(out)), " ") { + dir, file := path.Split(lib) + dir = path.Join("tor", dir) + file = strings.TrimPrefix(strings.TrimSuffix(file, ".a"), "lib") + found := false + for i, libSet := range libSets { + if libSet[0] == dir { + libSets[i] = append(libSets[i], file) + found = true + break + } + } + if !found { + libSets = append(libSets, []string{dir, file}) + } + } + // Add the rest of the known libs + libSets = append(libSets, + []string{"libevent/dist/lib", "event"}, + []string{"xz/dist/lib", "lzma"}, + []string{"zlib/dist/lib", "z"}, + []string{"openssl/dist/lib", "ssl", "crypto"}, + ) + // Dump em + for _, libSet := range libSets { + fmt.Print("-L" + libSet[0]) + for _, lib := range libSet[1:] { + fmt.Print(" -l" + lib) + } + fmt.Println() + } + return nil +} diff --git a/openssl b/openssl index 3ce7bc4..e71ebf2 160000 --- a/openssl +++ b/openssl @@ -1 +1 @@ -Subproject commit 3ce7bc40a3c48da1c96c2d04c10045bd797c6aa3 +Subproject commit e71ebf275da66dfd601c92e0e80a35114c32f6f8 diff --git a/tor b/tor index 035a351..9beb085 160000 --- a/tor +++ b/tor @@ -1 +1 @@ -Subproject commit 035a35178c92da94400c13767a265053ff6c8413 +Subproject commit 9beb085c10562a257c08abcee43434533d4fa96e