Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
"configure" script for platform detection (cossacklabs#611)
* "configure" script for platform detection Move most of the platform detection logic out from the Makefile into a traditional "configure" script, Since the system is unlike to change, this allows to run (costly) platform detection things only once at the first build. Incremental builds during development become much faster. macOS Linux Before After Before After make clean in empty dir 3.196 2.858 0.890 1.166 make all from scratch 11.762 12.183 6.226 6.273 make all again with no changes 3.231 0.504 0.936 0.300 make all with one changed file 3.247 0.816 1.101 0.553 make clean after build 4.564 0.939 0.896 0.328 After a while you get *really* annoyed by every make operation taking usually around three seconds and up to 8 (eight, Carl!) seconds if caches are cold. Lowering it to sub-second range is more tolerable. Why so slow? ------------ The main culprit here is Homebrew that really takes its time to locate OpenSSL installation directory. Thankfully, it does not update the formula database now, but it did before. Some people complained [1] about this simple operation taking enormous amount of time but the maintainer said this is fine and not a bug. [1]: Homebrew/brew#3097 All other scripting languages combined can be treated as accomplices. Each individual version check looks cheap on its own, but doing them altogether takes a couple of seconds. Surprisingly, the "supported" calls to check C compiler flags are fast enough so I did not bother moving them out to ./configure (though it's a task traditionally performed by it). There's also some weird interplay with AFL there, so that's left for the future. On "./configure" ---------------- The script follows GNU conventions expected from it [2] though there is not much configuration involved. We also diverge from the usual approach to out-of-source builds. The traditional way is to call configure from the build directory with --srcdir, but we keep using BUILD_PATH to set the build directory and expect "make" to be call from tree root. [2]: https://www.gnu.org/prep/standards/html_node/Configuration.html Note that it is not necessary to explicitly call ./configure before the build. "make" will check if it has not been called and will configure the build if necessary. So for most of the users the happy path is still make sudo make install But you can use ./configure if, say, you want a different installation prefix: ./configure --prefix=/opt/themis make sudo make install The entire script is an exercise in portable POSIX shell scripting. Don't you dare utter "Au*****ls" in this house. What are those fancy comment sections? -------------------------------------- We're (slowly) unifying the makefile structure across projects. This is the new way™ of doing things. * Run configure after switching PHP versions Since GitHub Actions for PHP install all PHP versions and switch between them for tests, we need to run ./configure after every switch to apply the current default PHP version to the configuration.
- Loading branch information