mirror of
https://github.com/uselessd/alcove.git
synced 2026-04-15 01:04:41 +00:00
Support building with rebar3 and rebar2 using the makefile generated from "rebar3 new cmake". Do a straightforward port of the compiler options from the rebar port compiler. The optimizations/warnings can be re-enabled later. Use the fancy pants incremental building of each compilation unit from the template. It's a lot slower than compiling in one go but is slightly faster when running any rebar command (rebar runs make on each command which recreates the target. The Makefile needs to be fixed).
57 lines
1.5 KiB
Plaintext
57 lines
1.5 KiB
Plaintext
Setns = fun(CONFIG) -> case os:type() of
|
|
{unix,linux} ->
|
|
Prog = "
|
|
#define _GNU_SOURCE
|
|
#include <sched.h>
|
|
int main(int argc, char *argv[]) {
|
|
(void)setns(0,0);
|
|
return 0;
|
|
}",
|
|
file:write_file("test/test_setns.c", Prog),
|
|
Retval = os:cmd("${CC-cc} -o /dev/null test/test_setns.c > /dev/null 2>&1; printf \"%d\" $?"),
|
|
file:delete("test/test_setns.c"),
|
|
case Retval of
|
|
"0" ->
|
|
Cflags = os:getenv("ALCOVE_CFLAGS", "") ++ " -DHAVE_SETNS",
|
|
os:putenv("ALCOVE_CFLAGS", Cflags);
|
|
_ ->
|
|
true
|
|
end;
|
|
_ ->
|
|
true
|
|
end,
|
|
CONFIG
|
|
end,
|
|
Seccomp = fun(CONFIG) -> case os:type() of
|
|
{unix,linux} ->
|
|
Prog = "
|
|
#include <linux/seccomp.h>
|
|
int main(int argc, char *argv[]) {
|
|
#ifdef SECCOMP_MODE_FILTER
|
|
return 0;
|
|
#else
|
|
return 1;
|
|
#endif
|
|
}",
|
|
file:write_file("test/test_seccomp.c", Prog),
|
|
Retval = os:cmd("${CC-cc} -o /dev/null test/test_seccomp.c > /dev/null 2>&1; printf \"%d\" $?"),
|
|
file:delete("test/test_seccomp.c"),
|
|
case Retval of
|
|
"0" ->
|
|
Cflags = os:getenv("ALCOVE_CFLAGS", "") ++ " -DHAVE_SECCOMP",
|
|
os:putenv("ALCOVE_CFLAGS", Cflags);
|
|
_ ->
|
|
true
|
|
end;
|
|
_ ->
|
|
true
|
|
end,
|
|
CONFIG
|
|
end,
|
|
lists:foldl(fun(Fun, Cfg) ->
|
|
Fun(Cfg)
|
|
end,
|
|
CONFIG,
|
|
[Setns, Seccomp]
|
|
).
|