From 94e41bbc4bac438a34fe63a091a99c34fb7ebadc Mon Sep 17 00:00:00 2001 From: =?utf8?q?Vladim=C3=ADr=20=C4=8Cun=C3=A1t?= Date: Mon, 24 Jul 2017 19:39:30 +0200 Subject: [PATCH] kresc WIP: mainly client.mk fixes Note: I chose to install into sbin/kresc, just as with the C implementation. --- Makefile | 5 +---- client/client.mk | 21 ++++++++++++++------- client/kresc.lua.in | 2 +- lib/kresc.c | 2 ++ lib/lib.mk | 2 ++ 5 files changed, 20 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 37a291801..c2ce95ef4 100644 --- a/Makefile +++ b/Makefile @@ -10,9 +10,6 @@ clean: contrib-clean lib-clean daemon-clean client-clean modules-clean \ doc: doc-html .PHONY: all install check clean doc info -#FIXME: implement these -.PHONY: client client-install client-clean - # Options ifdef COVERAGE BUILD_CFLAGS += --coverage @@ -50,7 +47,7 @@ ifeq ($(libknot_SONAME),) $(error "Unable to resolve libknot_SONAME, update find_soname in platform.mk") endif ifeq ($(libzscanner_SONAME),) - $(error "Unable to resolve libzscanner_SONAME, update find_some in platform.mk") + $(error "Unable to resolve libzscanner_SONAME, update find_soname in platform.mk") endif # Find Go version and platform diff --git a/client/client.mk b/client/client.mk index c74dbd896..c97aeed99 100644 --- a/client/client.mk +++ b/client/client.mk @@ -1,11 +1,18 @@ -client_SOURCES := kresc.lua -client: - # Install luarocks modules because I do not know how to do it properly - luarocks install ljlinenoise --local; +client: client/kresc + @# Install luarocks modules because I do not know how to do it properly + @# TODO: try to detect this somehow + @echo "make sure ljlinenoise is installed, e.g. via:" + @echo "$ luarocks install ljlinenoise --local" -client/kresc.lua: client/kresc.lua.in +client/kresc: client/kresc.lua.in @$(call quiet,SED,$<) -e "s/@libkres_SONAME@/$(libkres_SONAME)/" $< > $@ - + +client-install: client + $(INSTALL) -D client/kresc $(DESTDIR)$(SBINDIR) + client-clean: - @$(call quiet,RM,modules/version/version.lua) client/client.lua \ No newline at end of file + @$(call quiet,RM,client/kresc) client/kresc + +.PHONY: client client-install client-clean + diff --git a/client/kresc.lua.in b/client/kresc.lua.in index 1b457383c..5dbc5f511 100644 --- a/client/kresc.lua.in +++ b/client/kresc.lua.in @@ -6,7 +6,7 @@ function init() int kr_init_tty(const char *path); char *kr_run_cmd(const char *cmd, size_t * out_len); ]] - kresc = ffi.load(@libkres_SONAME@) -- FIXME in makefile + kresc = ffi.load('@libkres_SONAME@') kresc.kr_init_tty(arg[1]) end diff --git a/lib/kresc.c b/lib/kresc.c index 3ceb00484..f9b55d143 100644 --- a/lib/kresc.c +++ b/lib/kresc.c @@ -36,6 +36,8 @@ FILE *g_tty = NULL; //!< connection to the daemon //! Initialize connection to the daemon; return 0 on success. KR_EXPORT int kr_init_tty(const char *path) { + if (!path) + return 1; int fd = socket(AF_UNIX, SOCK_STREAM, 0); if (fd < 0) return 1; diff --git a/lib/lib.mk b/lib/lib.mk index 31cbca274..2761ef714 100644 --- a/lib/lib.mk +++ b/lib/lib.mk @@ -80,6 +80,8 @@ else $(eval $(call make_lib,libkres,lib,yes,$(ABIVER))) endif +libkres_SONAME := libkres$(call SOVER_EXT,$(ABIVER)) + # Generate pkg-config file libkres.pc: @echo 'prefix='$(PREFIX) > $@ -- 2.47.2