-
Notifications
You must be signed in to change notification settings - Fork 178
mv make makeover
- merged to master -
- code complete - January 5, 2016
- development started - January 4, 2016
Basho initially intended to use leveldb purely as a third-party storage library. There was no desire to invest for long term maintenance or development. Therefore there was no need to invest time in adapting Google's "build once" Makefile into something more appropriate to an active development usage model. Yet ongoing development kept creeping into various Riak release plans. This branch is an acknowledgement that Basho is going to continue to invest development time into Google's leveldb. This branch makes the following enhancements to the existing make process:
- Create full dependency files to simplify rebuilds during development
- Add explicit "debug" and "prof" targets to eliminate need to edit the Makefile (and accidentally check the modifications into git)
- Produce the shared and static libraries from same object files to reduce make execution time
- Build the test and tool executables build from libraries to reduce make execution time
- Use static linking of snappy on Linux platforms for tools executables to simplify distribution of the tools with Riak
Have git ignore .d dependency files that this branch now generates on all platforms. Also have git ignore the .dSYM directories now generated on Mac IOS platforms.
The Makefile automatically generates new .d dependency file for any source file or any of a source file's include files. The build_detect_platform script contains a recent change that creates an ldb_config.h file. The ldb_config.h is a dependency of almost every source file. The Makefile previously executed the build_detect_platform script upon every execution. build_detect_platform would therefore create a new db_config.h upon every execution. The new db_config.h would cause every file in the system to rebuild upon every execution. The "ifeq ($(wildcard build_config.mk),)" line makes the execution of build_detect_platform conditional. The script only executes if its prime output, build_config.mk, does not exists. This ends the continual rebuild loop.
The "if ($PLATFORM),OS_LINUX)" line adjusts the linker flags to use static libraries when building on Linux. The syntax used is not supported on OS X, and no other non-Linux platforms received testing. The static library usage is therefore limited to Linux builds which comprise the majority of Riak distributions. This change is only to facilitate easier use of Basho provided leveldb tools. It is not essential to the use of leveldb itself.
The "$(SHARED3)" recipe (construction rule) is reorganized as presented by Richard Hull's pull request:
https://github.com/basho/leveldb/pull/148
This fix reorganized the presentation of "new" objects versus "referenced libraries" on the command line in a manner that corrects how the linker records third-party libraries needed by this library.
The lines "ifneq (
The original Makefile from Google had an independent rule for every executable test program and tool program. New static dependency rules now cover most of the executables. Comments added to the Makefile discuss the various details of how the executables now build. The executables db_bench, db_bench_sqlite3, and db_bench_tree_db still have custom rules. They too might work with static dependency rules given more effort.
The last 3 line of the Makefile load dependency .d files. The $(DEPEND) variable holds a list of dependency file names. Dependency files have the name of the related .cc file as their stem, then followed by .d instead of .cc. Example: db/db_impl.cc source file becomes db/db_impl.d dependency file. The big magic is that the "-include" statement first looks to see if the .d file exists. If not, it will attempt to build the .d file via the earlier rule "%.d: %.cc" and then load the result.
A different pull request removed "so" as the default for the PLATFORM_SHARED_EXT variable. The change helped the make process execute faster by disabling the shared library file's creation. This Makefile now creates the shared library via the same object files that produce the static library. The creation overhead is negligible.
For Linux platforms only, use the static snappy library to build tool and test executables. This makes the tool executables easier to deploy as part of Riak.
Correcting a warning generated on OSX platform.
The eleveldb compile environment adds the "-Wall" compiler flag to leveldb's build environment. This flag caused warnings with the builds of perf_dump.cc and sst_scan.cc. The unused variable removal and transition of "%ull" to "PRIu64" eliminates the warnings.
The build of sst_rewrite.cc on Mac OSX had printf warnings. Transitioned us of "%dl" to "PRIu64" in six places eliminated the warnings.