treebird/premake4.lua
nekobit 7634b3df93 Fully switch to premake (a little more sane to write and maintain)
FossilOrigin-Name: fe55e222e21c7ba224ea4c584f727fcb827b7d4aeaff910a2befcd3f3d90f203
2023-03-26 06:31:33 +00:00

104 lines
2.1 KiB
Lua

premake.gcc.cc = os.getenv("CC") or 'cc';
if not os.isfile('config.h') then
print("Note: `config.h' not found, until a new Treebird release comes out,");
print(" please copy `config.def.h' and edit it.");
os.exit(1);
end
solution "Treebird";
configurations { "Debug", "Release" };
local c_files = {
'main.c',
'types.c',
'cookie.c',
'easprintf.c',
'error.c',
'memory.c',
'helpers.c',
'key.c',
'local_config.c',
'local_config_set.c',
'query.c',
'string.c',
'string_helpers.c',
'request.c',
'session.c',
'path.c',
'mime.c'
};
-- Not actually real 'pages', but the ones we compile in / create definitions
local pages = {
'about.c',
'account.c',
'applications.c',
'attachments.c',
'base_page.c',
'conversations.c',
'emoji.c',
'emoji_reaction.c',
'global_cache.c',
'global_perl.c',
'hashtag.c',
'http.c',
'index.c',
'lists.c',
-- 'login.c',
-- 'memory_page.c',
-- 'notifications.c',
-- 'page_config.c',
-- 'scrobble.c',
-- 'search.c',
-- 'status.c',
-- 'timeline.c',
};
local definitions = {};
-- Create definitions for page enabling
for i=1, table.getn(pages) do
local def = 'CMP_ENABLE_' .. string.upper(string.sub(pages[i], 0, -3));
table.insert(definitions, def);
end
-- Prepend with 'src/'
for i=1, table.getn(c_files) do c_files[i] = 'src/'.. c_files[i] end
for i=1, table.getn(pages) do pages[i] = 'src/'.. pages[i] end
-- BEGIN Mastodont project
project("treebird");
kind("ConsoleApp");
language("C");
--files { table.unpack(c_files), table.unpack(pages) };
files(c_files);
files(pages);
includedirs { "include/" };
defines(definitions);
configuration { "linux", "bsd", "gmake" };
linkoptions { "`pkg-config --libs mastodont`" };
-- TODO figure out perl...
configuration { "Debug" };
defines { "DEBUG" };
flags("Symbols");
configuration { "Release" };
defines { "NDEBUG" };
flags("Optimize");
-- END Mastodont-c
local prefix = os.getenv("PREFIX") or "/usr/local";
newaction {
trigger = "install",
description = "install binary",
execute = function()
os.copyfile("treebird", prefix .. "/bin");
os.mkdir(prefix .. "/share/treebird");
os.execute("install -d dist/ " .. prefix .. "/share/treebird");
end
}