From c3e21a522832903875fd3e0daa8ae7e98b58d567 Mon Sep 17 00:00:00 2001 From: Andrew Pamment Date: Tue, 16 Oct 2018 13:48:47 +1000 Subject: [PATCH] Add support for MUSL on Linux --- GNUmakefile | 6 +++++- deps/jamlib/Makefile.linux-musl | 29 +++++++++++++++++++++++++++++ src/GNUmakefile.common | 2 +- src/GNUmakefile.linux-musl | 13 +++++++++++++ utils/filecenter/Makefile | 6 +++++- 5 files changed, 53 insertions(+), 3 deletions(-) create mode 100644 deps/jamlib/Makefile.linux-musl create mode 100644 src/GNUmakefile.linux-musl diff --git a/GNUmakefile b/GNUmakefile index 8e3c262..83e8fb4 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -1,4 +1,8 @@ -OS:= $(shell uname -s | tr '[A-Z]' '[a-z]' | sed 's/darwin/osx/') +ifdef MUSL + OS=linux-musl +else + OS=$(shell uname -s | tr '[A-Z]' '[a-z]' | sed 's/darwin/osx/') +endif all: magicka diff --git a/deps/jamlib/Makefile.linux-musl b/deps/jamlib/Makefile.linux-musl new file mode 100644 index 0000000..9bfa20a --- /dev/null +++ b/deps/jamlib/Makefile.linux-musl @@ -0,0 +1,29 @@ +CC = cc $(CPPFLAGS) $(CFLAGS) -D__LINUX__ $(LDFLAGS) -Wall +AR = ar -ru +RM = rm -f + +OBJS = crc32.o mbase.o message.o lastread.o subpack.o structrw.o + +jamlib.a : $(OBJS) + $(AR) jamlib.a $(OBJS) + +crc32.o: crc32.c jam.h + $(CC) -c crc32.c -o crc32.o + +mbase.o: mbase.c jam.h + $(CC) -c mbase.c -o mbase.o -D__MUSL__=1 + +message.o: message.c jam.h + $(CC) -c message.c -o message.o + +lastread.o: lastread.c jam.h + $(CC) -c lastread.c -o lastread.o + +subpack.o: subpack.c jam.h + $(CC) -c subpack.c -o subpack.o + +structrw.o: structrw.c jam.h + $(CC) -c structrw.c -o structrw.o + +clean: + $(RM) *.o *.a diff --git a/src/GNUmakefile.common b/src/GNUmakefile.common index 665d452..c1961ff 100644 --- a/src/GNUmakefile.common +++ b/src/GNUmakefile.common @@ -89,7 +89,7 @@ magichat: ${JSMN} cd ${UTILSDIR}/magichat && ${MAKE} filecenter: ${CDK} - cd ${UTILSDIR}/filecenter && ${MAKE} + cd ${UTILSDIR}/filecenter && ${MAKE} ${FTSLIB} dosbox_shim: cd ${UTILSDIR}/dosbox_shim && ${MAKE} diff --git a/src/GNUmakefile.linux-musl b/src/GNUmakefile.linux-musl new file mode 100644 index 0000000..518983f --- /dev/null +++ b/src/GNUmakefile.linux-musl @@ -0,0 +1,13 @@ +CC:= cc +CFLAGS:= -std=gnu99 -I/usr/local/include +LIBS:= -L/usr/local/lib -lsqlite3 -lutil -lm -ldl -lssl -lcrypto -lssh -lmosquitto -lfts +EXTRAOBJS:= strlcpy/strlcpy.o strlcpy/strlcat.o + +LIBTOOLIZE:= libtoolize + +DEPS_LUA_TARGET:= linux +DEPS_JAMLIB_MAKEFILE:= Makefile.linux-musl + +FTSLIB:= FTSLIB=1 + +include GNUmakefile.common diff --git a/utils/filecenter/Makefile b/utils/filecenter/Makefile index 3d47c84..1c30cc4 100644 --- a/utils/filecenter/Makefile +++ b/utils/filecenter/Makefile @@ -23,7 +23,11 @@ endif ifeq ($(OS), Linux) CC=gcc CFLAGS= - LDFLAGS=-lsqlite3 -lncurses + ifdef FTSLIB + LDFLAGS=-lsqlite3 -lncurses -lfts + else + LDFLAGS=-lsqlite3 -lncurses + endif endif ifeq ($(OS), Darwin) CC=cc