Makefile
FossilOrigin-Name: 9b32280cb809c26ca511f8dcda5fff3a8bc19a517ff60c095cde46ad3ad606e2
This commit is contained in:
parent
cb11af71f1
commit
e003337b5c
5 changed files with 103 additions and 171 deletions
|
@ -1,4 +1,3 @@
|
|||
Makefile
|
||||
template
|
||||
ctemplate
|
||||
filec
|
||||
|
@ -8,7 +7,6 @@ emojitoc
|
|||
static/*.ctmpl
|
||||
static/*.c
|
||||
mastodont-c
|
||||
treebird.make
|
||||
config.h
|
||||
treebird
|
||||
test/tests
|
||||
|
|
103
Makefile
Normal file
103
Makefile
Normal file
|
@ -0,0 +1,103 @@
|
|||
CC ?= cc
|
||||
MASTODONT_DIR = mastodont-c
|
||||
|
||||
ifneq ($(wildcard $(MASTODONT_DIR)/bin/Release),)
|
||||
MASTODONT = $(MASTODONT_DIR)/bin/Release/
|
||||
else ifneq ($(wildcard $(MASTODONT_DIR)/bin/Debug),)
|
||||
MASTODONT = $(MASTODONT_DIR)/bin/Debug/
|
||||
endif
|
||||
|
||||
|
||||
CFLAGS += -Wall -I $(MASTODONT_DIR)/include/ -Wno-unused-variable -Wno-ignored-qualifiers \
|
||||
-I/usr/include/ -I $(MASTODONT_DIR)/libs $(shell pkg-config --cflags libcurl) \
|
||||
`perl -MExtUtils::Embed -e ccopts` -DDEBUGGING_MSTATS
|
||||
LDFLAGS += -L$(MASTODONT) -lmastodont $(shell pkg-config --libs libcurl) -lfcgi \
|
||||
-lpthread `perl -MExtUtils::Embed -e ldopts` -DDEBUGGING_MSTATS
|
||||
# libpcre2-8 (?)
|
||||
SRC = $(wildcard src/*.c)
|
||||
OBJ = $(patsubst %.c,%.o,$(SRC))
|
||||
HEADERS = $(wildcard src/*.h) config.h
|
||||
TMPL_DIR = templates
|
||||
TMPLS = $(wildcard $(TMPL_DIR)/*.tt)
|
||||
TMPLS_C = $(patsubst %.tt,%.ctt,$(TMPLS))
|
||||
TEST_DIR = test/unit
|
||||
TESTS = $(wildcard $(TEST_DIR)/t*.c)
|
||||
UNIT_TESTS = $(patsubst %.c,%.bin,$(TESTS))
|
||||
DIST = dist/
|
||||
PREFIX ?= /usr/local
|
||||
TARGET = treebird
|
||||
# For tests
|
||||
OBJ_NO_MAIN = $(filter-out src/main.o,$(OBJ))
|
||||
|
||||
MASTODONT_URL = https://fossil.nekobit.net/mastodont-c
|
||||
|
||||
# Not parallel friendly
|
||||
#all: $(MASTODONT_DIR) dep_build $(TARGET)
|
||||
|
||||
|
||||
ifneq ($(strip $(DEBUG)),)
|
||||
CFLAGS += -DDEBUG
|
||||
endif
|
||||
|
||||
all:
|
||||
ifeq ($(wildcard $(MASTODONT_DIR)),)
|
||||
@echo "[ERROR] Mastodont-c/ not found. Link it with ln -s in this directory."
|
||||
@exit 1
|
||||
endif
|
||||
$(MAKE) filec
|
||||
$(MAKE) make_tmpls
|
||||
$(MAKE) $(TARGET)
|
||||
|
||||
install_deps:
|
||||
cpan Template::Toolkit
|
||||
|
||||
$(TARGET): $(HEADERS) $(OBJ)
|
||||
$(CC) -o $(TARGET) $(OBJ) $(PAGES_C_OBJ) $(LDFLAGS)
|
||||
|
||||
filec: src/file-to-c/main.o
|
||||
$(CC) $(LDFLAGS) -o filec $<
|
||||
|
||||
emojitoc: scripts/emoji-to.o
|
||||
$(CC) -o emojitoc $< $(LDFLAGS)
|
||||
./emojitoc meta/emoji.json > src/emoji_codes.h
|
||||
|
||||
$(TMPL_DIR)/%.ctt: $(TMPL_DIR)/%.tt
|
||||
./filec $< data_$(notdir $*)_tt > $@
|
||||
|
||||
make_tmpls: $(TMPLS_C)
|
||||
|
||||
$(MASTODONT_DIR):
|
||||
cd ..; fossil clone $(MASTODONT_URL) || true
|
||||
cd treebird; ln -s ../mastodont-c .
|
||||
|
||||
install: $(TARGET)
|
||||
install -m 755 treebird $(PREFIX)/bin/
|
||||
install -d $(PREFIX)/share/treebird/
|
||||
cp -r dist/ $(PREFIX)/share/treebird/
|
||||
|
||||
test: all $(UNIT_TESTS)
|
||||
@echo " ... Tests ready"
|
||||
@./test/test.pl
|
||||
|
||||
%.o: %.c %.h $(PAGES)
|
||||
$(CC) $(CFLAGS) -c $< -o $@
|
||||
|
||||
# For tests
|
||||
%.bin: %.c
|
||||
@$(CC) $(CFLAGS) $< -o $@ $(OBJ_NO_MAIN) $(PAGES_C_OBJ) $(LDFLAGS)
|
||||
@echo -n " $@"
|
||||
|
||||
clean:
|
||||
rm -f $(OBJ) src/file-to-c/main.o
|
||||
rm -f $(TMPLS_C)
|
||||
rm -f test/unit/*.bin
|
||||
rm -f filec ctemplate
|
||||
rm $(TARGET) || true
|
||||
make -C $(MASTODONT_DIR) clean
|
||||
|
||||
clean_deps:
|
||||
rm -r $(MASTODONT_DIR)
|
||||
|
||||
clean_all: clean clean_deps
|
||||
|
||||
.PHONY: all filec clean update clean clean_deps clean_all test install_deps
|
|
@ -1,37 +0,0 @@
|
|||
# For ease of development, you can enable and disable pages. This is useful if
|
||||
# the code doesn't compile correctly, for which you can do an `#ifdef' with the
|
||||
# C Preprocessor
|
||||
|
||||
function(append_and_def TARGET SCOPE NAME)
|
||||
math(EXPR LEN "${ARGC}-1")
|
||||
foreach(I RANGE 3 ${LEN})
|
||||
list(GET ARGV ${I} filename)
|
||||
# Convert name partto uppercase for the definition
|
||||
get_filename_component(name ${filename} NAME_WE)
|
||||
string(TOUPPER ${name} file_up)
|
||||
|
||||
get_target_property(
|
||||
targ_comp
|
||||
${TARGET}
|
||||
COMPILE_DEFINITIONS
|
||||
)
|
||||
|
||||
if ("${targ_comp}" STREQUAL "targ_comp-NOTFOUND")
|
||||
set_target_properties(
|
||||
${TARGET}
|
||||
PROPERTIES COMPILE_DEFINITIONS "${file_up}"
|
||||
)
|
||||
else()
|
||||
set_target_properties(
|
||||
${TARGET}
|
||||
PROPERTIES COMPILE_DEFINITIONS "${targ_comp};${file_up}"
|
||||
)
|
||||
endif()
|
||||
|
||||
# Will return copy of files
|
||||
list(APPEND out_list ${filename})
|
||||
endforeach()
|
||||
|
||||
# Return
|
||||
set(${NAME} ${out_list} PARENT_SCOPE)
|
||||
endfunction()
|
|
@ -1,2 +0,0 @@
|
|||
# TODO set some FreeBSD bullshit i gotta deal with
|
||||
|
130
premake5.lua
130
premake5.lua
|
@ -1,130 +0,0 @@
|
|||
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
|
||||
|
||||
workspace "Treebird";
|
||||
|
||||
project("file-to-c");
|
||||
kind("ConsoleApp");
|
||||
language("C");
|
||||
files { "src/file-to-c/main.c" };
|
||||
|
||||
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
|
||||
-- This setup is pretty jank, but it helped me transition the Async refactor
|
||||
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, #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, #c_files do c_files[i] = 'src/'.. c_files[i] end
|
||||
for i=1, #pages do pages[i] = 'src/'.. pages[i] end
|
||||
|
||||
-- BEGIN Mastodont project
|
||||
project("treebird");
|
||||
dependson("file-to-c");
|
||||
kind("ConsoleApp");
|
||||
language("C");
|
||||
-- Merge pages into c_files
|
||||
for _, v in ipairs(pages) do
|
||||
table.insert(c_files, v);
|
||||
end
|
||||
files(c_files);
|
||||
includedirs { "include/" };
|
||||
defines(definitions);
|
||||
|
||||
-- For some reason this one doesn't have a pkg-config file
|
||||
local libfcgi = os.findlib("libfcgi");
|
||||
if not libfcgi then
|
||||
print("Couldn't find libfcgi (aka fcgi-devkit). Probably gonna need that.\n");
|
||||
os.exit(1);
|
||||
end
|
||||
|
||||
rule "filec"
|
||||
display "filec"
|
||||
fileextension ".ctt"
|
||||
buildmessage "Building %(filename)"
|
||||
buildcommands 'filec -c "%(FullPath)" -o "%(IntDir)/%(Filename).obj"'
|
||||
buildoutputs '%(IntDir)/%(Filename).obj'
|
||||
|
||||
filter { "action:gmake*" };
|
||||
linkoptions{ "`pkg-config --libs mastodont` `perl -MExtUtils::Embed -e ldopts`" };
|
||||
buildoptions{ "`pkg-config --cflags mastodont` `perl -MExtUtils::Embed -e ccopts`" };
|
||||
links{"fcgi"};
|
||||
|
||||
filter { "toolset:clang" };
|
||||
buildoptions{"-Wno-compound-token-split-by-macro"};
|
||||
|
||||
filter { "configurations:Debug" };
|
||||
defines { "DEBUG" };
|
||||
symbols("On");
|
||||
|
||||
filter { "configurations:Release" };
|
||||
defines { "NDEBUG" };
|
||||
optimize("On");
|
||||
-- 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("cp -r dist/ " .. prefix .. "/share/treebird/dist/");
|
||||
os.execute("cp -r perl/ " .. prefix .. "/share/treebird/perl/");
|
||||
end
|
||||
}
|
Loading…
Reference in a new issue