[MOD/CI/BUILD] Static builds, via the native tools

This commit is contained in:
LDA 2024-09-12 22:17:35 +02:00
commit 92d33fa641
3 changed files with 50 additions and 26 deletions

View file

@ -412,6 +412,8 @@ main_build(int argc, char *argv[])
char *repo = cmd_stdout("git remote get-url origin");
size_t size, i;
ssize_t nread;
bool with_static = false, with_lmdb = false;
int opt;
str_array_t *sources, *images, *utils, *aya;
if (strchr(repo, '\n'))
@ -419,6 +421,19 @@ main_build(int argc, char *argv[])
*(strchr(repo, '\n')) = '\0';
}
while ((opt = getopt(argc, argv, "sl")) != -1)
{
switch (opt)
{
case 's':
with_static = true;
break;
case 'l':
with_lmdb = with_static;
with_static = true;
break;
}
}
makefile = fopen("Makefile", "w");
fprintf(makefile, "# Autogenerated POSIX Makefile\n");
@ -440,10 +455,20 @@ main_build(int argc, char *argv[])
write_images(makefile, images);
fprintf(makefile, "\n\t");
{
fprintf(makefile, "$(CC) -L $(CYTO_LIB) -lCytoplasm $(LDFLAGS)");
fprintf(makefile, "$(CC) -o $(BINARY)");
if (with_static)
{
fprintf(makefile, " -static");
}
fprintf(makefile, " -L $(CYTO_LIB)");
write_objects(makefile, sources);
write_images(makefile, images);
fprintf(makefile, " -o $(BINARY)\n");
if (with_static)
{
fprintf(makefile, " -lm -lpthread -lssl -lCytoplasm -lssl -lcrypto");
if (with_lmdb) fprintf(makefile, " -llmdb");
}
fprintf(makefile, " -lCytoplasm $(LDFLAGS)\n");
}
/* Write rules for every source */
@ -467,7 +492,7 @@ main_build(int argc, char *argv[])
str_array_free(s);
fprintf(makefile, "\t$(CC) -c -Isrc -Isrc/include -I$(CYTO_INC) ");
fprintf(makefile, "-DVERSION=\"\\\"$(VERDION)\\\"\" ");
fprintf(makefile, "-DVERSION=\"\\\"$(VERSION)\\\"\" ");
fprintf(makefile, "-DNAME=\"\\\"$(NAME)\\\"\" ");
fprintf(makefile, "-DCODE=\"\\\"$(CODE)\\\"\" ");
fprintf(makefile, "-DREPOSITORY=\"\\\"%s\\\"\" ", repo);
@ -523,7 +548,20 @@ main_build(int argc, char *argv[])
fprintf(makefile, "%s: %s\n", obj, src);
{
fprintf(makefile, "\t@mkdir -p tools/out\n");
fprintf(makefile, "\t$(CC) $(CFLAGS) -lCytoplasm $< -o $@\n");
fprintf(makefile, "\t$(CC) -o $@");
if (with_static)
{
fprintf(makefile, " -static");
}
fprintf(makefile, " $<");
fprintf(makefile, " -L $(CYTO_LIB)");
if (with_static)
{
fprintf(makefile, " -lm -lpthread -lssl");
fprintf(makefile, " -lCytoplasm -lssl -lcrypto");
if (with_lmdb) fprintf(makefile, " -llmdb");
}
fprintf(makefile, " -lCytoplasm $(CFLAGS)\n");
}
free(ofl);