diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile | 17 | ||||
-rw-r--r-- | src/anylike.c | 2 | ||||
-rwxr-xr-x | src/configure | 1 | ||||
-rw-r--r-- | src/main_loop.lua | 8 |
4 files changed, 18 insertions, 10 deletions
diff --git a/src/Makefile b/src/Makefile index 9b139bf..b450a8e 100644 --- a/src/Makefile +++ b/src/Makefile @@ -32,20 +32,22 @@ EXECUTABLE := anylike # sig_handler.o \ # sysexec.o \ -OBJ := log.o \ +C_OBJS := log.o \ l_log.o \ options.o \ string_list.o \ l_crypt.o \ anylike.o +LUA_OBJS := main_loop.lc -SRC := $(OBJ:%.o=%.c) +C_SRC := $(C_OBJS:%.o=%.c) +LUA_SRC := &(LUA_OBJS:%.lc=%lua) .PHONY: clean cleanall distclean manpage install install-bin install-etc install-man uninstall remove purge -all: $(EXECUTABLE) +all: $(EXECUTABLE) $(LUA_OBJS) %.d: %.c @set -e; rm -f $@; \ @@ -54,15 +56,17 @@ all: $(EXECUTABLE) rm -f $@.$$$$; echo '(re)building $@' ifneq ($(MAKECMDGOALS),distclean) --include $(SRC:%.c=%.d) +-include $(C_SRC:%.c=%.d) endif -$(EXECUTABLE): $(OBJ) - $(CC) $(OBJ) -o $@ $(LDFLAGS) +$(EXECUTABLE): $(C_OBJS) + $(CC) $(C_OBJS) -o $@ $(LDFLAGS) %.o: %.c $(CC) $(CFLAGS) -c $< +%.lc: %.lua + $(LUAC) -o $@ $< strip: $(EXECUTABLE) $(STRIP) -s $(EXECUTABLE) @@ -77,6 +81,7 @@ clean: rm -f *.o rm -f *.d rm -f *.d.* + rm -f *.lc rm -f $(EXECUTABLE) cleanall: clean diff --git a/src/anylike.c b/src/anylike.c index 91088b8..93990a0 100644 --- a/src/anylike.c +++ b/src/anylike.c @@ -74,7 +74,7 @@ int init_libgcrypt() #endif -#define LUA_MAIN_LOOP_FILE "main_loop.lua" +#define LUA_MAIN_LOOP_FILE "main_loop.lc" #define LUA_MAIN_LOOP_FUNC "main_loop" static const luaL_Reg anylike_lualibs[] = { diff --git a/src/configure b/src/configure index 239208d..c4c0f81 100755 --- a/src/configure +++ b/src/configure @@ -157,6 +157,7 @@ TARGET := $TARGET CC := gcc CFLAGS := $CFLAGS LDFLAGS := $LDFLAGS +LUAC := luac STRIP := strip INSTALL := install diff --git a/src/main_loop.lua b/src/main_loop.lua index 5de973a..b78ec89 100644 --- a/src/main_loop.lua +++ b/src/main_loop.lua @@ -43,20 +43,22 @@ function main_loop(opt) local ret, err = udp:setsockname(ip, port) if(ret == nil) then - log.print("ERROR", "sendto(" .. ip .. "," .. port .. " failed: " .. err) + log.print("ERROR", "setsockname(" .. ip .. "," .. port .. ") failed: " .. err) return -1 end + + log.print("NOTICE", "echo server listening on " .. ip .. ":" .. port); while true do local dgrm, from_ip, from_port = udp:receivefrom() if(ret == nil) then - log.print("ERROR", "receivefrom(" .. ip .. "," .. port .. " failed: " .. from_ip) + log.print("ERROR", "receivefrom(" .. ip .. "," .. port .. ") failed: " .. from_ip) return -1 end local ret, err = udp:sendto(dgrm, from_ip, from_port) if(ret == nil) then - log.print("ERROR", "sendto(" .. ip .. "," .. port .. " failed: " .. err) + log.print("ERROR", "sendto(" .. ip .. "," .. port .. ") failed: " .. err) return -1 end |