makefile: link Lua objects into libcallisto

Fixes: https://todo.sr.ht/~jeremy/callisto/13
This commit is contained in:
Jeremy Baxter 2024-06-13 11:10:31 +12:00
parent b6cd36ec38
commit 1a0a492215
2 changed files with 21 additions and 11 deletions

View file

@ -14,7 +14,6 @@ LDFLAGS = ${_LDFLAGS}
OBJS = callisto.o lcl.o lenviron.o lextra.o lfs.o ljson.o \
lprocess.o util.o
LIBS = liblua.a
HEADERS = callisto.h \
${LUADIR}/lua.h \
${LUADIR}/luaconf.h \
@ -27,10 +26,10 @@ CJSON_CFLAGS = ${_CFLAGS} -I${LUADIR}
all: csto libcallisto.a
csto: ${LIBS} libcallisto.a csto.o
${CC} -o $@ csto.o libcallisto.a ${LIBS} ${LDFLAGS}
libcallisto.a: liblua.a ${CJSON_OBJS} ${OBJS}
ar cr $@ ${OBJS} ${CJSON_OBJS}
csto: libcallisto.a csto.o
${CC} -o $@ csto.o libcallisto.a ${LDFLAGS}
libcallisto.a: lua ${CJSON_OBJS} ${OBJS}
ar cr $@ ${OBJS} ${CJSON_OBJS} ${_LUAOBJS}
.SUFFIXES: .o
@ -56,14 +55,13 @@ lua_cjson.o: ${CJSON_SRC}/lua_cjson.c
strbuf.o: ${CJSON_SRC}/strbuf.c
${CC} ${CJSON_CFLAGS} -c $<
liblua.a: external/lua/*.c
${MAKE} -Cexternal/lua
mv -f external/lua/liblua.a .
lua:
${MAKE} -C${LUADIR}
clean:
rm -f csto libcallisto.a csto.o ${OBJS} ${CJSON_OBJS} ${LIBS}
rm -f csto libcallisto.a csto.o ${OBJS} ${CJSON_OBJS}
rm -fr include doc/*.html doc/modules
${MAKE} -s -Cexternal/lua clean
${MAKE} -s -C${LUADIR} clean
doc:
ldoc -s . -q . >/dev/null
@ -86,4 +84,4 @@ install:
cp -f libcallisto.a "${DESTDIR}${PREFIX}"/lib/
cp -f man/csto.1 "${DESTDIR}${PREFIX}"/share/man/man1/
.PHONY: all clean doc format gitconfig install
.PHONY: all clean doc format gitconfig install lua

12
configure vendored
View file

@ -130,6 +130,14 @@ gen_LDFLAGS () {
ldflags="$(trim "$ldflags")"
}
## Lua objects
gen_LUAOBJS () {
for obj in $(make -Cexternal/lua -s echo | grep -E '^BASE_O= ' | cut -d " " -f2-); do
luaobjs="$luaobjs external/lua/$obj"
done
luaobjs="$(trim "$luaobjs")"
}
#
## misc. functions
#
@ -197,6 +205,7 @@ cd $(dirname $0)
gen_CC
gen_CFLAGS
gen_LDFLAGS
gen_LUAOBJS
printf '# generated by configure
@ -206,10 +215,13 @@ _CPPFLAGS = %s
_LDFLAGS =%s
_EXT_CPPFLAGS = %s
_LUAOBJS = %s
' \
"$cc" \
"$cflags" \
"$cppflags"\
"$ldflags" \
"$ext_cppflags"\
"$luaobjs"\
>"$mkf"