Skip to content

Commit

Permalink
omnibus: lmdb: allow overriding build/install environment & use commo…
Browse files Browse the repository at this point in the history
…n env/flags

This allows us to just `make install` instead of manually copying every files
around. It also allows for modifying the compiler we use
We can now also modify the build environment if needed
  • Loading branch information
chouquette committed Dec 11, 2023
1 parent bc41561 commit 6d9ead9
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
22 changes: 22 additions & 0 deletions omnibus/config/patches/lmdb/allow-makefile-override-vars.diff
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--- a/Makefile 2023-12-06 12:09:29.871461460 +0100
+++ b/Makefile 2023-12-06 12:10:29.907352846 +0100
@@ -18,16 +18,16 @@
# There may be other macros in mdb.c of interest. You should
# read mdb.c before changing any of them.
#
-CC = gcc
-AR = ar
+CC ?= gcc
+AR ?= ar
W = -W -Wall -Wno-unused-parameter -Wbad-function-cast -Wuninitialized
THREADS = -pthread
OPT = -O2 -g
CFLAGS = $(THREADS) $(OPT) $(W) $(XCFLAGS)
LDLIBS =
SOLIBS =
SOEXT = .so
-prefix = /usr/local
+prefix ?= /usr/local
exec_prefix = $(prefix)
bindir = $(exec_prefix)/bin
libdir = $(exec_prefix)/lib
18 changes: 5 additions & 13 deletions omnibus/config/software/lmdb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@
build do
license "OpenLDAP Public License"
license_file "https://raw.githubusercontent.com/LMDB/lmdb/LMDB_#{version}/libraries/liblmdb/COPYRIGHT"
env = {
"LDFLAGS" => "-L#{install_dir}/embedded/lib -I#{install_dir}/embedded/include",
"CFLAGS" => "-L#{install_dir}/embedded/lib -I#{install_dir}/embedded/include",
"LD_RUN_PATH" => "#{install_dir}/embedded/lib",
}
patch source: "allow-makefile-override-vars.diff"
env = with_standard_compiler_flags(with_embedded_path)
env["prefix"] = "#{install_dir}/embedded/"
env["XCFLAGS"] = env["CFLAGS"]

# https://www.linuxfromscratch.org/blfs/view/8.3/server/lmdb.html
command "make -j #{workers}", :env => env
Expand All @@ -24,13 +23,6 @@
else
command "sed -i 's| liblmdb.a||' Makefile", :env => env
end

# We have to manually move the files into the correct directories because the Makefile for lmdb hardcodes the install directory to `/usr/local`, although we need this to be `#{install_dir}/embedded`
copy "liblmdb.so", "#{install_dir}/embedded/lib/liblmdb.so"
copy "lmdb.h", "#{install_dir}/embedded/include/lmdb.h"
copy "mdb_stat", "#{install_dir}/embedded/bin/mdb_stat"
copy "mdb_copy", "#{install_dir}/embedded/bin/mdb_copy"
copy "mdb_dump", "#{install_dir}/embedded/bin/mdb_dump"
copy "mdb_load", "#{install_dir}/embedded/bin/mdb_load"
command "make install", :env => env

end

0 comments on commit 6d9ead9

Please sign in to comment.