├── .gitmodules ├── Makefile ├── README.md ├── libuv-v1.44.2_linux.mk ├── libuv_linux.mk ├── libuv_mingw.mk ├── licenses.txt ├── lpeg.mk ├── lpeglabel.mk ├── lsqlite3.mk ├── lua-buffer.mk ├── lua-exif.mk ├── lua-jpeg.mk ├── lua-linux.mk ├── lua-llthreads2.mk ├── lua-openssl.mk ├── lua-struct.mk ├── lua-webview.mk ├── lua-win32.mk ├── lua-zlib.mk ├── luabt.mk ├── luachild.mk ├── luaexpat.mk ├── luafilesystem.mk ├── luaserial.mk ├── luv_linux.mk ├── luv_mingw.mk ├── main_linux.mk ├── main_mingw.mk ├── tools ├── addlibs.c ├── addlibs.lua ├── addwebview.lua ├── changemain.c ├── changemain.lua ├── compat.lua ├── luaunit-patch.lua ├── pkg-config.sh └── versions.lua ├── winapi.mk ├── wlua.ico ├── wlua.rc └── zlib.mk /.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "luasocket"] 2 | path = luasocket 3 | url = https://github.com/diegonehab/luasocket.git 4 | [submodule "luafilesystem"] 5 | path = luafilesystem 6 | url = https://github.com/keplerproject/luafilesystem.git 7 | [submodule "lua-cjson"] 8 | path = lua-cjson 9 | url = https://github.com/javalikescript/lua-cjson.git 10 | [submodule "luaunit"] 11 | path = luaunit 12 | url = https://github.com/bluebird75/luaunit.git 13 | [submodule "luv"] 14 | path = luv 15 | url = https://github.com/luvit/luv.git 16 | [submodule "lua-zlib"] 17 | path = lua-zlib 18 | url = https://github.com/brimworks/lua-zlib 19 | [submodule "zlib"] 20 | path = zlib 21 | url = https://github.com/madler/zlib.git 22 | [submodule "lua"] 23 | path = lua 24 | url = https://github.com/javalikescript/lua.git 25 | [submodule "luabt"] 26 | path = luabt 27 | url = https://github.com/javalikescript/luabt.git 28 | [submodule "luaserial"] 29 | path = luaserial 30 | url = https://github.com/javalikescript/luaserial.git 31 | [submodule "lpeg"] 32 | path = lpeg 33 | url = https://github.com/javalikescript/lpeg.git 34 | [submodule "lua-openssl"] 35 | path = lua-openssl 36 | url = https://github.com/zhaozg/lua-openssl.git 37 | [submodule "openssl"] 38 | path = openssl 39 | url = https://github.com/openssl/openssl.git 40 | [submodule "dkjson"] 41 | path = dkjson 42 | url = https://github.com/javalikescript/dkjson.git 43 | [submodule "luajls"] 44 | path = luajls 45 | url = https://github.com/javalikescript/luajls.git 46 | [submodule "lua-buffer"] 47 | path = lua-buffer 48 | url = https://github.com/javalikescript/lua-buffer.git 49 | [submodule "lua-jpeg"] 50 | path = lua-jpeg 51 | url = https://github.com/javalikescript/lua-jpeg.git 52 | [submodule "lua-exif"] 53 | path = lua-exif 54 | url = https://github.com/javalikescript/lua-exif.git 55 | [submodule "winapi"] 56 | path = winapi 57 | url = https://github.com/stevedonovan/winapi.git 58 | [submodule "lua-webview"] 59 | path = lua-webview 60 | url = https://github.com/javalikescript/lua-webview.git 61 | [submodule "lua-win32"] 62 | path = lua-win32 63 | url = https://github.com/javalikescript/lua-win32.git 64 | [submodule "lua-llthreads2"] 65 | path = lua-llthreads2 66 | url = https://github.com/moteus/lua-llthreads2.git 67 | [submodule "xml2lua"] 68 | path = xml2lua 69 | url = https://github.com/manoelcampos/xml2lua.git 70 | [submodule "LDoc"] 71 | path = LDoc 72 | url = https://github.com/lunarmodules/LDoc.git 73 | [submodule "Penlight"] 74 | path = Penlight 75 | url = https://github.com/lunarmodules/Penlight.git 76 | [submodule "lua-linux"] 77 | path = lua-linux 78 | url = https://github.com/javalikescript/lua-linux.git 79 | [submodule "luacov"] 80 | path = luacov 81 | url = https://github.com/keplerproject/luacov.git 82 | [submodule "lua-cbor"] 83 | path = lua-cbor 84 | url = https://github.com/Zash/lua-cbor.git 85 | [submodule "lpeglabel"] 86 | path = lpeglabel 87 | url = https://github.com/sqmedeiros/lpeglabel.git 88 | [submodule "DumbLuaParser"] 89 | path = DumbLuaParser 90 | url = https://github.com/ReFreezed/DumbLuaParser.git 91 | [submodule "bitop-lua"] 92 | path = bitop-lua 93 | url = https://github.com/AlberTajuelo/bitop-lua.git 94 | [submodule "luachild"] 95 | path = luachild 96 | url = https://github.com/javalikescript/luachild.git 97 | [submodule "lua-struct"] 98 | path = lua-struct 99 | url = https://github.com/javalikescript/lua-struct.git 100 | [submodule "luaexpat"] 101 | path = luaexpat 102 | url = https://github.com/lunarmodules/luaexpat.git 103 | [submodule "lua-periphery"] 104 | path = lua-periphery 105 | url = https://github.com/javalikescript/lua-periphery.git 106 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | 2 | GCC_NAME ?= $(shell $(CROSS_PREFIX)gcc -dumpmachine) 3 | 4 | ifdef HOST 5 | CROSS_PREFIX ?= $(HOST)- 6 | CROSS_SUFFIX = -cross 7 | ARCH_NAME := $(HOST) 8 | else 9 | ARCH_NAME := $(GCC_NAME) 10 | endif 11 | 12 | ifneq (,$(findstring x86_64,$(ARCH_NAME))) 13 | ARCH = x86_64 14 | else ifneq (,$(findstring x86,$(ARCH_NAME))) 15 | ARCH = x86 16 | else ifneq (,$(findstring arm,$(ARCH_NAME))) 17 | ARCH = arm 18 | else ifneq (,$(findstring aarch64,$(ARCH_NAME))) 19 | ARCH = aarch64 20 | else 21 | $(error Unknown architecture name $(ARCH_NAME)) 22 | endif 23 | 24 | ifeq ($(ARCH),x86_64) 25 | WEBVIEW_ARCH ?= x64 26 | else 27 | WEBVIEW_ARCH ?= $(ARCH) 28 | endif 29 | 30 | UNAME_S := $(shell uname -s) 31 | MK_PATH := $(abspath $(lastword $(MAKEFILE_LIST))) 32 | ifeq ($(UNAME_S),Linux) 33 | PLAT ?= linux 34 | else 35 | PLAT ?= windows 36 | MK_PATH := $(subst /c/,C:/,$(MK_PATH)) 37 | endif 38 | 39 | 40 | MAIN_TARGET = core 41 | 42 | LUA_PATH := lua 43 | LUA_LIB := lua54 44 | 45 | MK_DIR := $(dir $(MK_PATH)) 46 | LUA_DIST := dist 47 | LUA_CDIST = $(LUA_DIST) 48 | LUA_EDIST = $(LUA_CDIST) 49 | LUAJLS := luajls 50 | JLSDOC_DIR := $(LUA_DIST)-doc 51 | LDOC_DIR := ../$(JLSDOC_DIR) 52 | 53 | SO_windows=dll 54 | EXE_windows=.exe 55 | MK_windows=main_mingw.mk 56 | ZIP_windows=.zip 57 | 58 | SO_linux=so 59 | EXE_linux= 60 | MK_linux=main_linux.mk 61 | ZIP_linux=.tar.gz 62 | 63 | SO := $(SO_$(PLAT)) 64 | EXE := $(EXE_$(PLAT)) 65 | MAIN_MK := $(MK_$(PLAT)) 66 | ZIP := $(ZIP_$(PLAT)) 67 | 68 | DIST_TARGET = $(subst w64-mingw32,windows,$(GCC_NAME))$(RELEASE_SUFFIX) 69 | LUA_APP = $(LUA_PATH)/src/lua$(EXE) 70 | RELEASE_DATE = $(shell date '+%Y%m%d') 71 | LUA_VERSION = $(shell $(LUA_APP) -e "print(string.sub(_VERSION, 5))") 72 | RELEASE_NAME ?= -$(LUA_VERSION)-$(DIST_TARGET).$(RELEASE_DATE) 73 | TAR_OPTIONS := --group=jls --owner=jls 74 | 75 | EXPAT=expat-2.5.0 76 | LSQLITE=lsqlite3_v096 77 | 78 | 79 | STATIC_NAME := luajls 80 | 81 | STATIC_CORE_LIBNAMES := zlib luv cjson buffer 82 | STATIC_CORE_LIBS := $(LUA_PATH)/src/liblua.a \ 83 | lua-zlib/lua_zlib.o zlib/libz.a \ 84 | luv/src/luv.o luv/deps/libuv/libuv.a \ 85 | lua-cjson/lua_cjson.o lua-cjson/fpconv.o lua-cjson/strbuf.o \ 86 | lua-buffer/buffer.o 87 | 88 | WEBVIEW_LIBNAMES:=webview 89 | WEBVIEW_LIBS_windows=lua-webview/MemoryModule/MemoryModule.o 90 | WEBVIEW_LIBS=lua-webview/webview.o $(WEBVIEW_LIBS_$(PLAT)) 91 | WEBVIEW_DEP_LIBS_linux=$(shell pkg-config --libs gtk+-3.0 webkit2gtk-4.0) 92 | WEBVIEW_DEP_LIBS_windows=-lole32 -lcomctl32 -loleaut32 -luuid -lgdi32 93 | WEBVIEW_DEP_LIBS=$(WEBVIEW_DEP_LIBS_$(PLAT)) 94 | WEBVIEW_RESOURCES_windows=lua-webview/webview-c/ms.webview2/$(WEBVIEW_ARCH)/WebView2Loader.dll 95 | WEBVIEW_RESOURCES=$(WEBVIEW_RESOURCES_$(PLAT)) 96 | 97 | STATIC_LUAS := $(LUAJLS)/jls DumbLuaParser/dumbParser.lua 98 | STATIC_LIBNAMES := $(STATIC_CORE_LIBNAMES) lxp serial 99 | STATIC_LIBS := $(STATIC_CORE_LIBS) \ 100 | luaexpat/src/lxplib.o $(EXPAT)/lib/.libs/libexpat.a \ 101 | luaserial/luaserial.o 102 | 103 | STATIC_OPENSSL_LIBNAMES:=openssl 104 | STATIC_OPENSSL_LIBS:=lua-openssl/libopenssl.a openssl/libssl.a openssl/libcrypto.a 105 | STATIC_OPENSSL:=Y 106 | ifneq ($(STATIC_OPENSSL),Y) 107 | STATIC_OPENSSL_LIBNAMES:= 108 | STATIC_OPENSSL_LIBS:= 109 | endif 110 | 111 | LUV_DEP_LIBS_linux=-lrt -pthread -lpthread 112 | LUV_DEP_LIBS_windows=-lws2_32 -lpsapi -liphlpapi -lshell32 -luserenv -luser32 -ldbghelp -lole32 -luuid 113 | LUAW32_DEP_LIBS=-lcomdlg32 114 | WINAPI_DEP_LIBS=-lkernel32 -luser32 -lpsapi -ladvapi32 -lshell32 -lMpr 115 | 116 | STATIC_DEP_CORE_LIBS_linux=-ldl $(LUV_DEP_LIBS_linux) 117 | STATIC_DEP_CORE_LIBS_windows=$(LUV_DEP_LIBS_windows) $(LUAW32_DEP_LIBS) $(WINAPI_DEP_LIBS) 118 | STATIC_DEP_CORE_LIBS=$(STATIC_DEP_CORE_LIBS_$(PLAT)) 119 | 120 | STATIC_OS_LIBNAMES_linux=linux 121 | STATIC_OS_LIBNAMES_windows=win32 winapi 122 | STATIC_OS_LIBNAMES=$(STATIC_OS_LIBNAMES_$(PLAT)) 123 | 124 | STATIC_OS_LIBS_linux=lua-linux/linux.o 125 | STATIC_OS_LIBS_windows=lua-win32\win32.o winapi\winapi.o winapi\wutils.o 126 | STATIC_OS_LIBS=$(STATIC_OS_LIBS_$(PLAT)) 127 | 128 | STATIC_FLAGS_windows=lua/src/wlua.res 129 | STATIC_FLAGS_linux= 130 | STATIC_FLAGS=$(STATIC_FLAGS_$(PLAT)) 131 | 132 | # in case of cross compilation, we need to use host lua for doc generation and disable lua for tests 133 | 134 | ifdef HOST 135 | LUA_VERSION = $(shell echo $(LUA_LIB) | sed 's/^[^0-9]*\([0-9]\)/\1./') 136 | endif 137 | 138 | ifneq ($(LUA_OPENSSL_LINKING),dynamic) 139 | LUA_OPENSSL_LINKING = static 140 | endif 141 | 142 | LUAJLS_TESTS := $(patsubst $(LUAJLS)/%.lua,%.lua,$(wildcard $(LUAJLS)/tests/*/*.lua)) 143 | LUAJLS_CMD := LUA_PATH=$(MK_DIR)$(LUA_DIST)/?.lua LUA_CPATH=$(MK_DIR)$(LUA_DIST)/?.$(SO) LD_LIBRARY_PATH=$(MK_DIR)$(LUA_DIST) $(MK_DIR)$(LUA_DIST)/lua$(EXE) 144 | LUATEST_CMD := LUA_PATH="$(MK_DIR)/luaunit/?.lua;$(MK_DIR)$(LUA_DIST)/?.lua" LUA_CPATH=$(MK_DIR)$(LUA_DIST)/?.$(SO) LD_LIBRARY_PATH=$(MK_DIR)$(LUA_DIST) $(MK_DIR)$(LUA_DIST)/lua$(EXE) 145 | LUADOC_CMD := LUA_PATH="$(MK_DIR)LDoc/?.lua;$(MK_DIR)Penlight/lua/?.lua;$(MK_DIR)$(LUA_DIST)/?.lua" LUA_CPATH=$(MK_DIR)/luafilesystem/?.$(SO) $(MK_DIR)$(LUA_DIST)/lua$(EXE) $(MK_DIR)LDoc/ldoc.lua 146 | MD_CMD := LUA_PATH=$(MK_DIR)$(LUA_DIST)/?.lua $(MK_DIR)$(LUA_DIST)/lua$(EXE) $(MK_DIR)LDoc/ldoc/markdown.lua 147 | 148 | main: main-$(PLAT) 149 | 150 | all: full 151 | 152 | core quick full extras show-main configure configure-libjpeg configure-libexif configure-openssl configure-libexpat: $(EXPAT) 153 | @$(MAKE) PLAT=$(PLAT) MAIN_TARGET=$@ main 154 | 155 | lsqlite3: $(LSQLITE) 156 | @$(MAKE) PLAT=$(PLAT) MAIN_TARGET=$@ main 157 | 158 | lua lua-buffer luasocket luafilesystem lua-cjson luv lpeg luaserial luabt lua-zlib openssl lua-openssl lua-jpeg lua-exif lua-webview winapi lua-win32 lua-llthreads2 lua-linux luachild lua-struct lpeglabel luaexpat lua-periphery: 159 | @$(MAKE) PLAT=$(PLAT) MAIN_TARGET=$@ main 160 | 161 | help: 162 | @echo Main targets \(MAIN_TARGET\): full core quick extras 163 | @echo Other targets: arm linux windows configure clean clean-all dist help 164 | @echo Available platforms \(PLAT\): linux windows 165 | @echo Available architecture \(ARCH\): x86_64 arm aarch64 166 | 167 | echo show: 168 | @echo Make command goals: $(MAKECMDGOALS) 169 | @echo TARGET: $@ 170 | @echo ARCH: $(ARCH) 171 | @echo HOST: $(HOST) 172 | @echo PLAT: $(PLAT) 173 | @echo DIST_TARGET: $(DIST_TARGET) 174 | @echo GCC_NAME: $(GCC_NAME) 175 | @echo LUA_LIB: $(LUA_LIB) 176 | @echo LUA_PATH: $(LUA_PATH) 177 | @echo LUA_VERSION: $(LUA_VERSION) 178 | @echo RELEASE_DATE: $(RELEASE_DATE) 179 | @echo RELEASE_NAME: $(RELEASE_NAME) 180 | @echo Library extension: $(SO) 181 | @echo CC: $(CC) 182 | @echo AR: $(AR) 183 | @echo RANLIB: $(RANLIB) 184 | @echo LD: $(LD) 185 | @echo MK_DIR: $(MK_DIR) 186 | 187 | versions-dist: 188 | @$(LUAJLS_CMD) -v tools/versions.lua 189 | 190 | versions-cross: 191 | @printf "cc\t" 192 | @$(CROSS_PREFIX)gcc -dumpversion 193 | @printf "platform\t" 194 | @echo $(PLAT) 195 | @printf "target\t" 196 | @echo $(DIST_TARGET) 197 | @printf "gcc-target\t" 198 | @echo $(GCC_NAME) 199 | @printf "os\t" 200 | -@uname -s -r 201 | 202 | versions: versions-dist versions-cross 203 | 204 | arm linux-arm: 205 | @$(MAKE) main ARCH=arm HOST=arm-linux-gnueabihf PLAT=linux MAIN_TARGET=$(MAIN_TARGET) 206 | 207 | aarch64 linux-aarch64: 208 | @$(MAKE) main ARCH=aarch64 HOST=aarch64-linux-gnu PLAT=linux MAIN_TARGET=$(MAIN_TARGET) 209 | 210 | win32 windows linux mingw: main 211 | 212 | MAIN_VARS = PLAT=$(PLAT) \ 213 | LUA_LIB=$(LUA_LIB) \ 214 | LUA_PATH=$(LUA_PATH) \ 215 | SO=$(SO) \ 216 | ARCH=$(ARCH) \ 217 | HOST=$(HOST) 218 | 219 | main-linux: 220 | @$(MAKE) -f $(MAIN_MK) \ 221 | $(MAIN_VARS) \ 222 | CC=$(CROSS_PREFIX)gcc \ 223 | AR=$(CROSS_PREFIX)ar \ 224 | RANLIB=$(CROSS_PREFIX)ranlib \ 225 | LD=$(CROSS_PREFIX)gcc \ 226 | $(MAIN_TARGET) 227 | 228 | main-windows: 229 | @$(MAKE) -f $(MAIN_MK) \ 230 | $(MAIN_VARS) \ 231 | $(MAIN_TARGET) 232 | 233 | 234 | expat-2.5.0: 235 | wget -q --no-check-certificate https://github.com/libexpat/libexpat/releases/download/R_2_5_0/expat-2.5.0.tar.gz 236 | tar -xf expat-2.5.0.tar.gz 237 | rm expat-2.5.0.tar.gz 238 | 239 | lsqlite3_v096: 240 | wget -q --no-check-certificate http://lua.sqlite.org/index.cgi/zip/lsqlite3_v096.zip 241 | unzip -q lsqlite3_v096.zip 242 | rm lsqlite3_v096.zip 243 | 244 | 245 | test: $(LUAJLS_TESTS) 246 | @echo $(words $(LUAJLS_TESTS)) test files passed 247 | 248 | $(LUAJLS_TESTS): 249 | @echo Testing $@ 250 | -@cd $(LUAJLS) && $(LUATEST_CMD) $@ 251 | 252 | test-cross: 253 | 254 | 255 | static: static-full static-test 256 | rm addlibs.o tools/addlibs-custom.c tools/addlibs-main.c 257 | 258 | static-test: 259 | $(MAKE) LUATEST_CMD="LUA_PATH=$(MK_DIR)/luaunit/?.lua LUA_CPATH=./?.no $(MK_DIR)$(LUA_DIST)/$(STATIC_NAME)$(EXE)" test 260 | 261 | # bundling webview is problematic on Linux as it requires gtk-webkit2 to be available even is not used adding more than 100 dependencies 262 | static-full: 263 | LUA_PATH=$(LUA_DIST)/?.lua LUA_CPATH=$(LUA_DIST)/?.$(SO) $(LUA_APP) tools/addlibs.lua -pp \ 264 | -l $(STATIC_LUAS) -p tools/addwebview.lua \ 265 | -r $(WEBVIEW_RESOURCES) $(STATIC_RESOURCES) \ 266 | -c $(STATIC_LIBNAMES) $(STATIC_OS_LIBNAMES) $(STATIC_OPENSSL_LIBNAMES) $(WEBVIEW_LIBNAMES) > tools/addlibs-custom.c 267 | $(LUA_APP) tools/changemain.lua $(LUA_PATH)/src/lua.c "$(STATIC_EXECUTE)" > tools/addlibs-main.c 268 | $(CC) -c -Os tools/addlibs.c -I$(LUA_PATH)/src -Izlib -o addlibs.o 269 | $(CC) -std=gnu99 -static-libgcc -o $(LUA_DIST)/$(STATIC_NAME)$(EXE) -s $(STATIC_FLAGS) addlibs.o \ 270 | tools/addlibs-main.c $(STATIC_LIBS) $(STATIC_OPENSSL_LIBS) $(WEBVIEW_LIBS) \ 271 | $(STATIC_OS_LIBS) -lm -Ilua/src $(STATIC_DEP_CORE_LIBS) $(WEBVIEW_DEP_LIBS) 272 | 273 | static-example: 274 | @echo "print('You could rename this executable to, or create a link with, the name of an example to run it.')" > $(MK_DIR)/example.lua 275 | @echo "print('Examples: $(patsubst $(LUAJLS)/examples/%.lua,%,$(wildcard $(LUAJLS)/examples/*.lua))')" >> $(MK_DIR)/example.lua 276 | LUA_PATH=$(LUA_DIST)/?.lua LUA_CPATH=$(LUA_DIST)/?.$(SO) $(LUA_APP) tools/addlibs.lua \ 277 | -l $(LUAJLS)/jls xml2lua/XmlParser.lua -L $(LUAJLS)/examples -l example.lua \ 278 | -c $(STATIC_CORE_LIBNAMES) > tools/addlibs-custom.c 279 | $(RM) example.lua 280 | $(LUA_APP) tools/changemain.lua $(LUA_PATH)/src/lua.c "require((function() for i=-1,-99,-1 do if not arg[i] then return (string.gsub(string.gsub(arg[i+1], '^.*[/\\\\]', ''), '%.exe$$', '')); end; end; end)())" > tools/addlibs-main.c 281 | $(CC) -c -Os tools/addlibs.c -I$(LUA_PATH)/src -Izlib -o addlibs.o 282 | $(CC) -std=gnu99 -static-libgcc -o $(LUA_DIST)/example$(EXE) -s $(STATIC_FLAGS) addlibs.o \ 283 | tools/addlibs-main.c $(STATIC_CORE_LIBS) -lm -Ilua/src $(STATIC_DEP_CORE_LIBS) 284 | 285 | 286 | clean-lua: 287 | -$(RM) ./$(LUA_PATH)/src/*.o ./$(LUA_PATH)/src/*.a 288 | -$(RM) ./lua/src/*.$(SO) ./$(LUA_PATH)/src/lua$(EXE) ./lua/src/luac$(EXE) 289 | 290 | clean-luv: 291 | -$(RM) ./luv/src/*.o ./luv/*.$(SO) 292 | 293 | clean-lua-openssl: 294 | -$(RM) ./lua-openssl/src/*.o ./lua-openssl/deps/auxiliar/*.o ./lua-openssl/*.$(SO) 295 | 296 | clean-lua-libs: clean-luv clean-lua-openssl 297 | -$(RM) ./lua-cjson/*.o ./lua-cjson/*.$(SO) 298 | -$(RM) ./lua-buffer/*.o ./lua-buffer/*.$(SO) 299 | -$(RM) ./luafilesystem/src/*.o ./luafilesystem/*.$(SO) 300 | -$(RM) ./luasocket/src/*.o ./luasocket/src/*.$(SO) 301 | -$(RM) ./lua-zlib/*.o ./lua-zlib/*.$(SO) 302 | -$(RM) ./luaexpat/src/*.o ./luaexpat/*.$(SO) 303 | -$(RM) ./lpeg/*.o ./lpeg/*.$(SO) 304 | -$(RM) ./lpeglabel/*.o ./lpeglabel/*.$(SO) 305 | -$(RM) ./luaserial/*.o ./luaserial/*.$(SO) 306 | -$(RM) ./luabt/*.o ./luabt/*.$(SO) 307 | -$(RM) ./lua-jpeg/*.o ./lua-jpeg/*.$(SO) 308 | -$(RM) ./lua-exif/*.o ./lua-exif/*.$(SO) 309 | -$(RM) ./lua-webview/*.o ./lua-webview/*.$(SO) 310 | -$(RM) ./winapi/*.o ./winapi/*.$(SO) 311 | -$(RM) ./lua-llthreads2/src/*.o ./lua-llthreads2/src/*.$(SO) 312 | -$(RM) ./lua-win32/*.o ./lua-win32/*.$(SO) 313 | -$(RM) ./luachild/*.o ./luachild/*.$(SO) 314 | -$(RM) ./lua-struct/*.o ./lua-struct/*.$(SO) 315 | -$(RM) ./$(LSQLITE)/*.o ./$(LSQLITE)/*.$(SO) 316 | -$(RM) ./lua-periphery/c-periphery/obj/*.o ./lua-periphery/c-periphery/periphery.a ./lua-periphery/periphery.$(SO) 317 | 318 | clean-libuv: 319 | -$(RM) ./luv/deps/libuv/*.a ./luv/deps/libuv/src/*.o 320 | -$(RM) ./luv/deps/libuv/src/unix/*.o ./luv/deps/libuv/src/win/*.o 321 | 322 | clean-libs: clean-libuv 323 | -$(MAKE) -C openssl clean 324 | -$(RM) ./openssl/*/*.$(SO) 325 | -$(RM) ./zlib/*.o ./zlib/*.lo ./zlib/*.a ./zlib/*.$(SO)* 326 | -$(RM) ./lua-webview/*.o ./lua-webview/MemoryModule/*.o 327 | -$(MAKE) -C $(EXPAT) clean 328 | -$(MAKE) -C lua-jpeg/libjpeg clean 329 | -$(MAKE) -C lua-exif/libexif clean 330 | 331 | clean-linux: 332 | 333 | clean-windows: 334 | -$(RM) ./$(LUA_PATH)/src/wlua.exe ./lua/src/wlua.res 335 | 336 | clean: clean-lua clean-lua-libs clean-$(PLAT) 337 | 338 | clean-all: clean-lua clean-libs clean-lua-libs 339 | 340 | 341 | dist-clean: 342 | rm -rf $(LUA_DIST) 343 | 344 | dist-prepare: 345 | -mkdir $(LUA_DIST) 346 | 347 | dist-copy-openssl-dynamic-linux: 348 | -cp -uP openssl/libcrypto.$(SO)* $(LUA_CDIST)/ 349 | -cp -uP openssl/libssl.$(SO)* $(LUA_CDIST)/ 350 | 351 | dist-copy-openssl-dynamic-windows: 352 | -cp -u openssl/libcrypto*.$(SO) $(LUA_CDIST)/ 353 | -cp -u openssl/libssl*.$(SO) $(LUA_CDIST)/ 354 | 355 | dist-copy-openssl-static-linux dist-copy-openssl-static-windows: 356 | 357 | dist-copy-linux: 358 | -cp -u lua-linux/linux.$(SO) $(LUA_CDIST)/ 359 | -cp -u lua-periphery/periphery.$(SO) $(LUA_CDIST)/ 360 | 361 | dist-copy-windows: 362 | -cp -u $(LUA_PATH)/src/lua*.$(SO) $(LUA_CDIST)/ 363 | -cp -u $(LUA_PATH)/src/wlua$(EXE) $(LUA_CDIST)/ 364 | -cp -u winapi/winapi.$(SO) $(LUA_CDIST)/ 365 | -cp -u lua-win32/win32.$(SO) $(LUA_CDIST)/ 366 | -cp -u lua-webview/webview-c/ms.webview2/$(WEBVIEW_ARCH)/WebView2Loader.dll $(LUA_CDIST)/ 367 | 368 | dist-dup-copy: 369 | cp -u luafilesystem/lfs.$(SO) $(LUA_CDIST)/ 370 | cp -u dkjson/dkjson.lua $(LUA_DIST)/ 371 | cp -u luachild/luachild.$(SO) $(LUA_CDIST)/ 372 | cp -u lua-llthreads2/src/llthreads.$(SO) $(LUA_CDIST)/ 373 | mkdir $(LUA_CDIST)/mime 374 | mkdir $(LUA_DIST)/socket 375 | -mkdir $(LUA_CDIST)/socket 376 | cp -u luasocket/src/mime-*.$(SO) $(LUA_CDIST)/mime/core.$(SO) 377 | cp -u luasocket/src/socket-*.$(SO) $(LUA_CDIST)/socket/core.$(SO) 378 | cp -u luasocket/src/ltn12.lua luasocket/src/mime.lua luasocket/src/socket.lua $(LUA_DIST)/ 379 | cp -u luasocket/src/ftp.lua luasocket/src/headers.lua luasocket/src/http.lua \ 380 | luasocket/src/smtp.lua luasocket/src/tp.lua luasocket/src/url.lua $(LUA_DIST)/socket/ 381 | 382 | dist-ext-copy: 383 | -cp -u lua-struct/struct.$(SO) $(LUA_CDIST)/ 384 | mkdir $(LUA_DIST)/bitop 385 | -cp -u bitop-lua/src/bitop/funcs.lua $(LUA_DIST)/bitop/ 386 | mkdir $(LUA_DIST)/luacov 387 | -cp -u luacov/src/luacov.lua $(LUA_DIST)/ 388 | -cp -u luacov/src/luacov/*.lua $(LUA_DIST)/luacov/ 389 | -cp -u lua-cbor/cbor.lua $(LUA_DIST)/ 390 | -cp -u lpeglabel/lpeglabel.$(SO) $(LUA_CDIST)/ 391 | -cp -u $(LSQLITE)/lsqlite3.$(SO) $(LUA_CDIST)/ 392 | 393 | dist-copy: dist-copy-$(PLAT) dist-copy-openssl-$(LUA_OPENSSL_LINKING)-$(PLAT) 394 | cp -u licenses.txt $(LUA_DIST)/ 395 | cp -u $(LUA_PATH)/src/lua$(EXE) $(LUA_PATH)/src/luac$(EXE) $(LUA_EDIST)/ 396 | cp -u lua-cjson/cjson.$(SO) $(LUA_CDIST)/ 397 | cp -u luv/luv.$(SO) $(LUA_CDIST)/ 398 | cp -u lua-zlib/zlib.$(SO) $(LUA_CDIST)/ 399 | cp -u xml2lua/xml2lua.lua $(LUA_DIST)/ 400 | cp -u xml2lua/XmlParser.lua $(LUA_DIST)/ 401 | cp -u DumbLuaParser/dumbParser.lua $(LUA_DIST)/ 402 | cp -u luaunit/luaunit.lua $(LUA_DIST)/ 403 | -cp -u luaexpat/lxp.$(SO) $(LUA_CDIST)/ 404 | -cp -u lpeg/lpeg.$(SO) $(LUA_CDIST)/ 405 | -cp -u lpeg/re.lua $(LUA_DIST)/ 406 | -cp -u luaserial/serial.$(SO) $(LUA_CDIST)/ 407 | -cp -u lua-openssl/openssl.$(SO) $(LUA_CDIST)/ 408 | -cp -u lua-webview/webview.$(SO) lua-webview/webview-launcher.lua $(LUA_CDIST)/ 409 | -cp -u lua-jpeg/jpeg.$(SO) $(LUA_CDIST)/ 410 | -cp -u lua-exif/exif.$(SO) $(LUA_CDIST)/ 411 | -cp -u lua-buffer/buffer.$(SO) $(LUA_CDIST)/ 412 | -cp -u luabt/bt.$(SO) $(LUA_CDIST)/ 413 | 414 | dist-min: dist-clean dist-prepare dist-copy 415 | 416 | dist-all: dist-clean dist-prepare dist-copy dist-dup-copy dist-ext-copy 417 | 418 | 419 | ldoc: 420 | mkdir $(JLSDOC_DIR) 421 | -cd $(LUAJLS) && $(LUADOC_CMD) -i --date "" -d $(LDOC_DIR) . 422 | 423 | ldoc-dev-content: 424 | grep -E "^##* .*$$" ../$(LUAJLS)/doc_topics/manual.md 425 | grep -E "^## .*$$" ../$(LUAJLS)/doc_topics/manual.md | sed -E 's/^##* *//g' | \ 426 | sed 's/[^A-Za-z][^A-Za-z]*/_/g' | sed 's/_$$//g' | sed -E 's/^(.*)$$/@{manual.md.\1|\1}/g' 427 | 428 | ldoc-dev: 429 | rm -rf ../$(LUAJLS)/doc 430 | cd ../$(LUAJLS) && $(LUADOC_CMD) -i --date "" -d doc . 431 | 432 | md-ldoc: 433 | $(MD_CMD) LDoc/doc/doc.md 434 | mv LDoc/doc/doc.html $(JLSDOC_DIR)/ldoc.html 435 | -$(MD_CMD) luaunit/doc/index.md 436 | -mv luaunit/doc/index.html $(JLSDOC_DIR)/luaunit.html 437 | 438 | ldoc-clean: 439 | rm -rf $(JLSDOC_DIR) 440 | 441 | ldoc-all: ldoc-clean ldoc md-ldoc 442 | mkdir $(JLSDOC_DIR)/lua 443 | cp -ur $(LUA_PATH)/doc/* $(JLSDOC_DIR)/lua/ 444 | mkdir $(JLSDOC_DIR)/luacov 445 | cp -ur luacov/docs/* $(JLSDOC_DIR)/luacov/ 446 | 447 | dist-doc: ldoc-all 448 | rm -f $(LUA_DIST)/docs.zip 449 | cd $(JLSDOC_DIR) && zip -r ../$(LUA_DIST)/docs.zip * 450 | 451 | dist-doc-cross: 452 | 453 | dist-jls-lua51: 454 | mv $(LUA_DIST)/luaunit.lua $(LUA_DIST)/luaunit-.lua 455 | cp -u tools/luaunit-patch.lua $(LUA_DIST)/luaunit.lua 456 | mkdir $(LUA_DIST)/luvit 457 | printf "return require('uv')" > $(LUA_DIST)/luvit/luv.lua 458 | LUA_PATH="$(LUAJLS)/?.lua;$(LUA_DIST)/?.lua" LUA_CPATH=$(LUA_DIST)/?.$(SO) $(LUA_APP) \ 459 | tools/compat.lua -pretty "-t=$(LUA_DIST)" $(LUAJLS)/jls 460 | echo "export LUA_PATH=\"$(MK_DIR)$(LUA_DIST)/luvit/?.lua;$(MK_DIR)$(LUA_DIST)/?.lua\"" 461 | 462 | dist-jls-lua54: 463 | cp -ur $(LUAJLS)/jls $(LUA_DIST)/ 464 | 465 | dist-jls-do: dist-jls-$(LUA_LIB) 466 | cp -ur $(LUAJLS)/examples $(LUA_DIST)/ 467 | 468 | dist-jls: dist-min dist-jls-do 469 | 470 | dist-versions: 471 | -@$(MAKE) --quiet versions$(CROSS_SUFFIX) >$(LUA_DIST)/versions.txt 472 | 473 | dist: dist-all dist-jls-do dist-versions 474 | 475 | 476 | luajls.tar.gz: 477 | cd $(LUA_DIST) && tar $(TAR_OPTIONS) -zcvf luajls$(RELEASE_NAME).tar.gz * 478 | 479 | luajls.zip: 480 | cd $(LUA_DIST) && zip -r luajls$(RELEASE_NAME).zip * 481 | 482 | luajls-archive: luajls$(ZIP) 483 | 484 | dist-archive: luajls-archive 485 | 486 | 487 | release-do: dist-versions dist-doc$(CROSS_SUFFIX) test$(CROSS_SUFFIX) luajls-archive 488 | 489 | release-all: dist-all dist-jls-do release-do 490 | 491 | release-min: dist-jls release-do 492 | 493 | release: release-all 494 | 495 | 496 | STATIC_FILES := docs.zip examples licenses.txt versions.txt 497 | 498 | static.tar.gz: 499 | cd $(LUA_DIST) && tar $(TAR_OPTIONS) -zcvf luajls-static$(RELEASE_NAME).tar.gz lua$(EXE) $(STATIC_FILES) 500 | 501 | static.zip: 502 | cd $(LUA_DIST) && zip -r luajls-static$(RELEASE_NAME).zip lua$(EXE) $(STATIC_FILES) 503 | 504 | static-pre: 505 | mv $(LUA_DIST)/lua$(EXE) $(LUA_DIST)/lua-pre$(EXE) 506 | mv $(LUA_DIST)/$(STATIC_NAME)$(EXE) $(LUA_DIST)/lua$(EXE) 507 | 508 | static-post: 509 | mv $(LUA_DIST)/lua$(EXE) $(LUA_DIST)/$(STATIC_NAME)$(EXE) 510 | mv $(LUA_DIST)/lua-pre$(EXE) $(LUA_DIST)/lua$(EXE) 511 | 512 | static-release: static static-pre static$(ZIP) static-post 513 | 514 | static-release-cross: 515 | 516 | 517 | releases: release static-release$(CROSS_SUFFIX) 518 | 519 | 520 | lua-5.1.5: 521 | wget -q --no-check-certificate https://www.lua.org/ftp/lua-5.1.5.tar.gz 522 | tar -xf lua-5.1.5.tar.gz 523 | rm lua-5.1.5.tar.gz 524 | 525 | release-5.1: lua-5.1.5 clean 526 | $(MAKE) LUA_PATH=lua-5.1.5 LUA_LIB=lua51 LUA_DIST=dist-5.1 LUAJLS=$(LUAJLS) all release clean 527 | 528 | sync-git: 529 | git fetch 530 | git rebase 531 | git submodule update --init --recursive 532 | 533 | sync-5.1: sync-git 534 | $(MAKE) release-5.1 all releases 535 | 536 | sync: sync-git 537 | $(MAKE) all releases 538 | 539 | 540 | .PHONY: dist release clean linux mingw windows win32 arm test ldoc full quick extras \ 541 | lua lua-buffer luasocket luafilesystem lua-cjson libuv luv lpeg lpeglabel zlib lua-zlib \ 542 | openssl lua-openssl luaserial luabt libjpeg lua-jpeg libexif lua-exif lua-webview \ 543 | winapi lua-win32 lua-llthreads2 lua-linux luachild lua-struct luaexpat lua-periphery lsqlite3 544 | 545 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | ## Overview 3 | 4 | luaclibs provides the dependent modules used by [luajls](https://github.com/javalikescript/luajls). 5 | 6 | This repository contains [Lua](http://www.lua.org/) 5.4, selected Lua modules and associated makefiles. 7 | The targeted operating systems are Linux and Windows. The targeted architectures are x86, x86-64 and ARM. 8 | 9 | You could find information and download binaries on the [luajls releases](https://github.com/javalikescript/luajls/releases) page. 10 | 11 | ## How to setup? 12 | 13 | This repository mainly contains submodule and so needs to be initialized before it can be used 14 | 15 | ```bash 16 | git submodule update --init --recursive 17 | ``` 18 | 19 | The OpenSSL, Expat, JPEG and EXIF libraries need to be configured prior the build. 20 | 21 | Some dependent modules are retrieved using wget without checking the certificate, it is recommended to download these dependencies manually using an up-to-date browser. 22 | 23 | ## How to build? 24 | 25 | Prerequisites 26 | 27 | You need make and gcc tools 28 | 29 | Build core modules 30 | ```bash 31 | make 32 | ``` 33 | 34 | Configure then make all modules 35 | ```bash 36 | make configure 37 | make all 38 | ``` 39 | 40 | Create a distribution folder containing the binaries 41 | ```bash 42 | make dist 43 | ``` 44 | 45 | Clean the build files 46 | ```bash 47 | make clean-all 48 | ``` 49 | 50 | 51 | ### How to build on Windows (MinGW)? 52 | 53 | Prerequisites 54 | 55 | Install [msys2](https://www.msys2.org/) 56 | 57 | Install make and mingw gcc 58 | ```bash 59 | pacman -S make mingw-w64-x86_64-gcc 60 | ``` 61 | 62 | Install additional stuff for OpenSSL and webview 63 | ```bash 64 | pacman -S perl libtool texinfo zip pkg-config 65 | ``` 66 | 67 | Set mingw64 and msys in the beginning of your path using: 68 | ``` 69 | SET PATH=...\msys64\mingw64\bin;...\msys64\usr\bin;%PATH% 70 | ``` 71 | 72 | ### How to build on Linux? 73 | 74 | Prerequisites 75 | 76 | Install the Bluetooth library and gtk-webkit2 77 | 78 | ```bash 79 | sudo apt-get install libbluetooth-dev libgtk-3-dev libwebkit2gtk-4.0-dev 80 | ``` 81 | 82 | ### How to build for Raspberry Pi (ARM)? 83 | 84 | Prerequisites 85 | 86 | You need to install a specific gcc for cross compilation 87 | 88 | ```bash 89 | # 32-bits 90 | sudo apt-get install gcc-arm-linux-gnueabihf 91 | # 64-bits: 92 | sudo apt-get install gcc-aarch64-linux-gnu 93 | ``` 94 | 95 | You could also get a standalone toolchain from [abhiTronix](https://github.com/abhiTronix/raspberry-pi-cross-compilers). 96 | 97 | Then export the following variables prior running make 98 | 99 | ```bash 100 | # 32-bits 101 | export HOST=arm-linux-gnueabihf 102 | # 64-bits: 103 | export HOST=aarch64-linux-gnu 104 | export CC=${HOST}-gcc 105 | ``` 106 | 107 | You could also get the Bluetooth library from your Raspberry Pi and set it using the `LIBBT` environment variable. 108 | -------------------------------------------------------------------------------- /libuv-v1.44.2_linux.mk: -------------------------------------------------------------------------------- 1 | 2 | CC ?= gcc 3 | AR ?= ar 4 | ARFLAGS ?= rc 5 | RANLIB ?= ranlib 6 | 7 | ifdef CLIBS_DEBUG 8 | CFLAGS += -g 9 | else 10 | CFLAGS += -O2 11 | endif 12 | 13 | ifdef CLIBS_NDEBUG 14 | CFLAGS += -DNDEBUG 15 | endif 16 | 17 | CFLAGS += -fPIC \ 18 | -pedantic \ 19 | -Iinclude \ 20 | -Isrc \ 21 | -Isrc/unix \ 22 | -std=gnu89 \ 23 | -D_GNU_SOURCE \ 24 | -D_POSIX_C_SOURCE=200112 \ 25 | -Wall \ 26 | -Wextra \ 27 | -Wno-unused-parameter \ 28 | -Wstrict-prototypes \ 29 | -pthread 30 | 31 | INCLUDES = include/uv.h \ 32 | include/uv/errno.h \ 33 | include/uv/threadpool.h \ 34 | include/uv/version.h 35 | 36 | INCLUDES += include/uv/unix.h \ 37 | include/uv/linux.h 38 | 39 | INCLUDES += src/heap-inl.h \ 40 | src/idna.h \ 41 | src/queue.h \ 42 | src/strscpy.h \ 43 | src/strtok.h \ 44 | src/uv-common.h \ 45 | src/unix/atomic-ops.h \ 46 | src/unix/internal.h \ 47 | src/unix/spinlock.h \ 48 | src/unix/linux-syscalls.h 49 | 50 | OBJS = src/fs-poll.o \ 51 | src/idna.o \ 52 | src/inet.o \ 53 | src/random.o \ 54 | src/strscpy.o \ 55 | src/strtok.o \ 56 | src/threadpool.o \ 57 | src/timer.o \ 58 | src/uv-data-getter-setters.o \ 59 | src/uv-common.o \ 60 | src/version.o 61 | 62 | OBJS += src/unix/async.o \ 63 | src/unix/core.o \ 64 | src/unix/dl.o \ 65 | src/unix/fs.o \ 66 | src/unix/getaddrinfo.o \ 67 | src/unix/getnameinfo.o \ 68 | src/unix/loop-watcher.o \ 69 | src/unix/loop.o \ 70 | src/unix/pipe.o \ 71 | src/unix/poll.o \ 72 | src/unix/process.o \ 73 | src/unix/random-devurandom.o \ 74 | src/unix/signal.o \ 75 | src/unix/stream.o \ 76 | src/unix/tcp.o \ 77 | src/unix/thread.o \ 78 | src/unix/tty.o \ 79 | src/unix/udp.o 80 | 81 | OBJS += src/unix/linux-core.o \ 82 | src/unix/linux-inotify.o \ 83 | src/unix/linux-syscalls.o \ 84 | src/unix/procfs-exepath.o \ 85 | src/unix/proctitle.o \ 86 | src/unix/random-getrandom.o \ 87 | src/unix/random-sysctl-linux.o \ 88 | src/unix/epoll.o 89 | 90 | all: libuv.a 91 | 92 | clean: 93 | -$(RM) $(OBJS) libuv.a libuv.so 94 | 95 | libuv.a: $(OBJS) 96 | $(AR) $(ARFLAGS) $@ $^ 97 | 98 | libuv.so: $(OBJS) 99 | $(CC) -shared $^ -o $@ 100 | 101 | $(OBJS): %.o : %.c 102 | $(CC) $(CFLAGS) -c -o $@ $< 103 | -------------------------------------------------------------------------------- /libuv_linux.mk: -------------------------------------------------------------------------------- 1 | 2 | CC ?= gcc 3 | AR ?= ar 4 | ARFLAGS ?= rc 5 | #ARFLAGS ?= crs 6 | RANLIB ?= ranlib 7 | 8 | ifdef CLIBS_DEBUG 9 | CFLAGS += -g 10 | else 11 | CFLAGS += -O2 12 | endif 13 | 14 | ifdef CLIBS_NDEBUG 15 | CFLAGS += -DNDEBUG 16 | endif 17 | 18 | CFLAGS += -fPIC \ 19 | -pedantic \ 20 | -Iinclude \ 21 | -Isrc \ 22 | -Isrc/unix \ 23 | -std=gnu89 \ 24 | -D_GNU_SOURCE \ 25 | -D_POSIX_C_SOURCE=200112 \ 26 | -Wall \ 27 | -Wextra \ 28 | -Wno-unused-parameter \ 29 | -Wstrict-prototypes \ 30 | -pthread 31 | 32 | #-static-libgcc 33 | 34 | ##LIBS = -lrt -lpthread -lnsl -ldl 35 | 36 | #CFLAGS += -pthreads 37 | #LDFLAGS = -no-undefined -version-info 1:0:0 38 | 39 | INCLUDES = include/uv.h \ 40 | include/uv/errno.h \ 41 | include/uv/threadpool.h \ 42 | include/uv/version.h 43 | 44 | INCLUDES += include/uv/unix.h \ 45 | include/uv/linux.h 46 | 47 | INCLUDES += src/heap-inl.h \ 48 | src/idna.h \ 49 | src/queue.h \ 50 | src/strscpy.h \ 51 | src/strtok.h \ 52 | src/uv-common.h \ 53 | src/unix/atomic-ops.h \ 54 | src/unix/internal.h \ 55 | src/unix/spinlock.h \ 56 | src/unix/linux-syscalls.h 57 | 58 | OBJS = src/fs-poll.o \ 59 | src/idna.o \ 60 | src/inet.o \ 61 | src/random.o \ 62 | src/strscpy.o \ 63 | src/strtok.o \ 64 | src/thread-common.o \ 65 | src/threadpool.o \ 66 | src/timer.o \ 67 | src/uv-data-getter-setters.o \ 68 | src/uv-common.o \ 69 | src/version.o 70 | 71 | OBJS += src/unix/async.o \ 72 | src/unix/core.o \ 73 | src/unix/dl.o \ 74 | src/unix/fs.o \ 75 | src/unix/getaddrinfo.o \ 76 | src/unix/getnameinfo.o \ 77 | src/unix/loop-watcher.o \ 78 | src/unix/loop.o \ 79 | src/unix/pipe.o \ 80 | src/unix/poll.o \ 81 | src/unix/process.o \ 82 | src/unix/random-devurandom.o \ 83 | src/unix/signal.o \ 84 | src/unix/stream.o \ 85 | src/unix/tcp.o \ 86 | src/unix/thread.o \ 87 | src/unix/tty.o \ 88 | src/unix/udp.o 89 | 90 | OBJS += src/unix/linux.o \ 91 | src/unix/procfs-exepath.o \ 92 | src/unix/proctitle.o \ 93 | src/unix/random-getrandom.o \ 94 | src/unix/random-sysctl-linux.o 95 | 96 | all: libuv.a 97 | 98 | clean: 99 | -$(RM) $(OBJS) libuv.a libuv.so 100 | 101 | libuv.a: $(OBJS) 102 | $(AR) $(ARFLAGS) $@ $^ 103 | 104 | #$(RANLIB) $@ 105 | #-@ ($(RANLIB) $@ || true) >/dev/null 2>&1 106 | #$(AR) crs $@ $^ 107 | 108 | libuv.so: $(OBJS) 109 | $(CC) -shared $^ -o $@ 110 | 111 | # ar qc libuv.a $(OBJS) 112 | # ranlib libuv.a 113 | 114 | $(OBJS): %.o : %.c 115 | $(CC) $(CFLAGS) -c -o $@ $< 116 | -------------------------------------------------------------------------------- /libuv_mingw.mk: -------------------------------------------------------------------------------- 1 | 2 | CC ?= gcc 3 | 4 | ifdef CLIBS_DEBUG 5 | CFLAGS += -g 6 | else 7 | CFLAGS += -O 8 | endif 9 | 10 | ifdef CLIBS_NDEBUG 11 | CFLAGS += -DNDEBUG 12 | endif 13 | 14 | CFLAGS += -Wall \ 15 | -Wextra \ 16 | -Wno-unused-parameter \ 17 | -Wstrict-prototypes \ 18 | -Iinclude \ 19 | -Isrc \ 20 | -Isrc/win \ 21 | -DWIN32_LEAN_AND_MEAN \ 22 | -D_WIN32_WINNT=0x0602 23 | 24 | INCLUDES = include/uv.h \ 25 | include/uv/errno.h \ 26 | include/uv/threadpool.h \ 27 | include/uv/version.h 28 | 29 | INCLUDES += include/uv/win.h \ 30 | include/uv/tree.h 31 | 32 | INCLUDES += src/heap-inl.h \ 33 | src/idna.h \ 34 | src/queue.h \ 35 | src/strscpy.h \ 36 | src/strtok.h \ 37 | src/uv-common.h \ 38 | src/win/atomicops-inl.h \ 39 | src/win/handle-inl.h \ 40 | src/win/internal.h \ 41 | src/win/req-inl.h \ 42 | src/win/stream-inl.h \ 43 | src/win/winapi.h \ 44 | src/win/winsock.h 45 | 46 | OBJS = src/fs-poll.o \ 47 | src/idna.o \ 48 | src/inet.o \ 49 | src/random.o \ 50 | src/strscpy.o \ 51 | src/strtok.o \ 52 | src/thread-common.o \ 53 | src/threadpool.o \ 54 | src/timer.o \ 55 | src/uv-data-getter-setters.o \ 56 | src/uv-common.o \ 57 | src/version.o 58 | 59 | OBJS += src/win/async.o \ 60 | src/win/core.o \ 61 | src/win/detect-wakeup.o \ 62 | src/win/dl.o \ 63 | src/win/error.o \ 64 | src/win/fs-event.o \ 65 | src/win/fs.o \ 66 | src/win/getaddrinfo.o \ 67 | src/win/getnameinfo.o \ 68 | src/win/handle.o \ 69 | src/win/loop-watcher.o \ 70 | src/win/pipe.o \ 71 | src/win/poll.o \ 72 | src/win/process-stdio.o \ 73 | src/win/process.o \ 74 | src/win/signal.o \ 75 | src/win/stream.o \ 76 | src/win/tcp.o \ 77 | src/win/thread.o \ 78 | src/win/tty.o \ 79 | src/win/udp.o \ 80 | src/win/util.o \ 81 | src/win/winapi.o \ 82 | src/win/winsock.o 83 | 84 | all: libuv.a 85 | 86 | clean: 87 | -$(RM) $(OBJS) libuv.a 88 | 89 | libuv.a: $(OBJS) 90 | $(AR) crs $@ $^ 91 | 92 | $(OBJS): %.o : %.c $(INCLUDES) 93 | $(CC) $(CFLAGS) -c -o $@ $< 94 | -------------------------------------------------------------------------------- /licenses.txt: -------------------------------------------------------------------------------- 1 | Lua 2 | Copyright © 1994–2023 Lua.org, PUC-Rio 3 | MIT license 4 | https://www.lua.org/about.html 5 | 6 | lua-zlib 7 | Copyright (c) 2009 Brian Maher 8 | MIT License 9 | https://github.com/brimworks/lua-zlib 10 | 11 | zlib 12 | (C) 1995-2022 Jean-loup Gailly and Mark Adler 13 | Licence zlib 14 | https://github.com/madler/zlib 15 | 16 | luv 17 | Copyright 2014 The Luvit Authors 18 | Apache-2.0 license 19 | https://github.com/luvit/luv 20 | 21 | libuv 22 | Copyright (c) 2015-present libuv project contributors 23 | MIT License 24 | https://github.com/libuv/libuv 25 | 26 | lua-cjson 27 | Copyright (c) 2010-2012 Mark Pulford 28 | MIT License 29 | https://github.com/mpx/lua-cjson 30 | 31 | lua-openssl 32 | Copyright (c) 2011 - 2023 zhaozg, zhaozg(at)gmail.com 33 | MIT License 34 | https://github.com/zhaozg/lua-openssl 35 | 36 | openssl 37 | Copyright (c) 1998-2019 The OpenSSL Project 38 | OpenSSL and SSLeay license 39 | https://github.com/openssl/openssl 40 | 41 | webview-c 42 | Copyright (c) 2017 Serge Zaitsev 43 | MIT License 44 | https://github.com/javalikescript/webview-c 45 | 46 | MemoryModule 47 | Copyright (c) 2004-2015 by Joachim Bauch 48 | Mozilla Public License 2.0 49 | https://github.com/fancycode/MemoryModule 50 | 51 | winapi 52 | Copyright (C) 2011 Steve Donovan 53 | MIT License 54 | https://github.com/stevedonovan/winapi 55 | 56 | xml2lua 57 | Copyright (c) 2016 Manoel Campos da Silva Filho 58 | MIT License 59 | https://github.com/manoelcampos/xml2lua 60 | 61 | luaexpat 62 | Copyright (c) 2003-2007 The Kepler Project, 2013-2022 Matthew Wild. 63 | MIT License 64 | https://lunarmodules.github.io/luaexpat 65 | 66 | Expat 67 | Copyright (c) 1998-2000 Thai Open Source Software Center Ltd and Clark Cooper 68 | Copyright (c) 2001-2022 Expat maintainers 69 | MIT License 70 | https://libexpat.github.io/ 71 | 72 | DumbLuaParser 73 | Copyright (c) 2020-2021 Marcus 'ReFreezed' Thunström 74 | MIT License 75 | https://github.com/ReFreezed/DumbLuaParser 76 | 77 | WebView2 78 | Copyright (C) Microsoft Corporation 79 | https://www.nuget.org/packages/Microsoft.Web.WebView2/1.0.2045.28/License 80 | 81 | lua-llthreads2 82 | Copyright (c) 2013-2017 Alexey Melnichuk 83 | MIT License 84 | https://github.com/moteus/lua-llthreads2 85 | 86 | luasocket 87 | Copyright (C) 2004-2022 Diego Nehab 88 | MIT License 89 | https://github.com/lunarmodules/luasocket 90 | 91 | luafilesystem 92 | Copyright (c) 2010-2022 The LuaFileSystem authors 93 | MIT License 94 | https://github.com/lunarmodules/luafilesystem 95 | 96 | luachild 97 | Copyright 2007 Mark Edgar 98 | MIT and Unlicense license 99 | https://github.com/pocomane/luachild 100 | 101 | luajls 102 | Copyright 2018-2024 SPYL, javalikescript@free.fr 103 | MIT License 104 | https://github.com/javalikescript/luajls 105 | -------------------------------------------------------------------------------- /lpeg.mk: -------------------------------------------------------------------------------- 1 | LIBNAME = lpeg 2 | LUADIR = ../lua/ 3 | 4 | ifdef CLIBS_DEBUG 5 | COPT = -g 6 | else 7 | COPT = -O2 8 | endif 9 | 10 | ifdef CLIBS_NDEBUG 11 | COPT += -DNDEBUG 12 | endif 13 | 14 | CWARNS = -Wall -Wextra -pedantic \ 15 | -Waggregate-return \ 16 | -Wcast-align \ 17 | -Wcast-qual \ 18 | -Wdisabled-optimization \ 19 | -Wpointer-arith \ 20 | -Wshadow \ 21 | -Wsign-compare \ 22 | -Wundef \ 23 | -Wwrite-strings \ 24 | -Wbad-function-cast \ 25 | -Wdeclaration-after-statement \ 26 | -Wmissing-prototypes \ 27 | -Wnested-externs \ 28 | -Wstrict-prototypes \ 29 | # -Wunreachable-code \ 30 | 31 | 32 | CFLAGS = $(CWARNS) $(COPT) -std=c99 -I$(LUADIR) -fPIC 33 | CC = gcc 34 | 35 | FILES = lpvm.o lpcap.o lptree.o lpcode.o lpprint.o 36 | 37 | # For Linux 38 | linux: 39 | $(MAKE) lpeg.so "DLLFLAGS = -shared -fPIC" 40 | 41 | # For Mac OS 42 | macosx: 43 | $(MAKE) lpeg.so "DLLFLAGS = -bundle -undefined dynamic_lookup" 44 | 45 | lpeg.so: $(FILES) 46 | env $(CC) $(DLLFLAGS) $(FILES) -o lpeg.so 47 | 48 | # For Windows 49 | lpeg.dll: $(FILES) 50 | $(CC) $(DLLFLAGS) $(FILES) -o lpeg.dll 51 | 52 | $(FILES): makefile 53 | 54 | test: test.lua re.lua lpeg.so 55 | ./test.lua 56 | 57 | clean: 58 | rm -f $(FILES) lpeg.so 59 | 60 | 61 | lpcap.o: lpcap.c lpcap.h lptypes.h 62 | lpcode.o: lpcode.c lptypes.h lpcode.h lptree.h lpvm.h lpcap.h 63 | lpprint.o: lpprint.c lptypes.h lpprint.h lptree.h lpvm.h lpcap.h 64 | lptree.o: lptree.c lptypes.h lpcap.h lpcode.h lptree.h lpvm.h lpprint.h 65 | lpvm.o: lpvm.c lpcap.h lptypes.h lpvm.h lpprint.h lptree.h 66 | 67 | -------------------------------------------------------------------------------- /lpeglabel.mk: -------------------------------------------------------------------------------- 1 | LIBNAME = lpeglabel 2 | LUADIR = ../lua/ 3 | 4 | ifdef CLIBS_DEBUG 5 | COPT = -g 6 | else 7 | COPT = -O2 8 | endif 9 | 10 | ifdef CLIBS_NDEBUG 11 | COPT += -DNDEBUG 12 | endif 13 | 14 | CWARNS = -Wall -Wextra -pedantic \ 15 | -Waggregate-return \ 16 | -Wcast-align \ 17 | -Wcast-qual \ 18 | -Wdisabled-optimization \ 19 | -Wpointer-arith \ 20 | -Wshadow \ 21 | -Wsign-compare \ 22 | -Wundef \ 23 | -Wwrite-strings \ 24 | -Wbad-function-cast \ 25 | -Wdeclaration-after-statement \ 26 | -Wmissing-prototypes \ 27 | -Wnested-externs \ 28 | -Wstrict-prototypes \ 29 | # -Wunreachable-code \ 30 | 31 | 32 | CFLAGS = $(CWARNS) $(COPT) -std=c99 -I$(LUADIR) -fPIC 33 | CC = gcc 34 | 35 | FILES = lplvm.o lplcap.o lpltree.o lplcode.o lplprint.o 36 | 37 | # For Linux 38 | linux: 39 | $(MAKE) lpeg.so "DLLFLAGS = -shared -fPIC" 40 | 41 | # For Mac OS 42 | macosx: 43 | $(MAKE) lpeg.so "DLLFLAGS = -bundle -undefined dynamic_lookup" 44 | 45 | $(LIBNAME).so: $(FILES) 46 | env $(CC) $(DLLFLAGS) $(FILES) -o $(LIBNAME).so 47 | 48 | # For Windows 49 | $(LIBNAME).dll: $(FILES) 50 | $(CC) $(DLLFLAGS) $(FILES) -o $(LIBNAME).dll 51 | 52 | $(FILES): makefile 53 | 54 | clean: 55 | rm -f $(FILES) $(LIBNAME).so 56 | 57 | 58 | lplcap.o: lplcap.c lplcap.h lpltypes.h 59 | lplcode.o: lplcode.c lpltypes.h lplcode.h lpltree.h lplvm.h lplcap.h 60 | lplprint.o: lplprint.c lpltypes.h lplprint.h lpltree.h lplvm.h lplcap.h 61 | lpltree.o: lpltree.c lpltypes.h lplcap.h lplcode.h lpltree.h lplvm.h lplprint.h 62 | lplvm.o: lplvm.c lplcap.h lpltypes.h lplvm.h lplprint.h lpltree.h 63 | -------------------------------------------------------------------------------- /lsqlite3.mk: -------------------------------------------------------------------------------- 1 | CC ?= gcc 2 | 3 | LIBEXT ?= dll 4 | LIBNAME = lsqlite3 5 | TARGET = $(LIBNAME).$(LIBEXT) 6 | LUA_PATH = lua 7 | LUA_LIB = lua54 8 | 9 | LIBOPT_dll = -O \ 10 | -shared \ 11 | -Wl,-s \ 12 | -L..\$(LUA_PATH)\src -l$(LUA_LIB) 13 | 14 | CFLAGS_dll = -Wall \ 15 | -Wextra \ 16 | -Wno-unused-parameter \ 17 | -Wstrict-prototypes \ 18 | -I../$(LUA_PATH)/src 19 | 20 | LIBOPT_so = -O \ 21 | -shared \ 22 | -static-libgcc \ 23 | -Wl,-s \ 24 | -L..\$(LUA_PATH)\src 25 | 26 | CFLAGS_so = -pedantic \ 27 | -fPIC \ 28 | -Wall \ 29 | -Wextra \ 30 | -Wno-unused-parameter \ 31 | -Wstrict-prototypes \ 32 | -I../$(LUA_PATH)/src 33 | 34 | LIBOPT = $(LIBOPT_$(LIBEXT)) 35 | 36 | CFLAGS += $(CFLAGS_$(LIBEXT)) 37 | 38 | SOURCES = lsqlite3.c sqlite3.c sqlite3.h 39 | 40 | OBJS = lsqlite3.o sqlite3.o 41 | 42 | lib: $(TARGET) 43 | 44 | $(TARGET): $(OBJS) 45 | $(CC) $(OBJS) $(LIBOPT) -o $(TARGET) 46 | 47 | clean: 48 | -$(RM) $(OBJS) $(TARGET) 49 | 50 | $(OBJS): %.o : %.c $(SOURCES) 51 | $(CC) $(CFLAGS) -c -o $@ $< 52 | -------------------------------------------------------------------------------- /lua-buffer.mk: -------------------------------------------------------------------------------- 1 | CC ?= gcc 2 | 3 | LIBEXT ?= dll 4 | LIBNAME = buffer 5 | TARGET = $(LIBNAME).$(LIBEXT) 6 | LUA_PATH = lua 7 | LUA_LIB = lua54 8 | 9 | LIBOPT_dll = -O \ 10 | -shared \ 11 | -Wl,-s \ 12 | -L..\$(LUA_PATH)\src -l$(LUA_LIB) \ 13 | -lkernel32 14 | 15 | CFLAGS_dll = -Wall \ 16 | -Wextra \ 17 | -Wno-unused-parameter \ 18 | -Wstrict-prototypes \ 19 | -I../$(LUA_PATH)/src 20 | 21 | LIBOPT_so = -O \ 22 | -shared \ 23 | -pthread \ 24 | -lpthread \ 25 | -static-libgcc \ 26 | -Wl,-s \ 27 | -L..\$(LUA_PATH)\src 28 | 29 | CFLAGS_so = -pedantic \ 30 | -fPIC \ 31 | -pthread \ 32 | -Wall \ 33 | -Wextra \ 34 | -Wno-unused-parameter \ 35 | -Wstrict-prototypes \ 36 | -I../$(LUA_PATH)/src 37 | 38 | LIBOPT = $(LIBOPT_$(LIBEXT)) 39 | 40 | ifdef CLIBS_DEBUG 41 | CFLAGS += -g 42 | else 43 | CFLAGS += -O 44 | endif 45 | 46 | ifdef CLIBS_NDEBUG 47 | CFLAGS += -DNDEBUG 48 | endif 49 | 50 | #-DNO_MUTEX=1 51 | #-DUSE_SOFT_MUTEX=1 52 | CFLAGS += $(CFLAGS_$(LIBEXT)) 53 | 54 | SOURCES = buffer.c mutex.c ../lua-buffer.mk 55 | 56 | OBJS = buffer.o 57 | 58 | lib: $(TARGET) 59 | 60 | $(TARGET): $(OBJS) 61 | $(CC) $(OBJS) $(LIBOPT) -o $(TARGET) 62 | 63 | clean: 64 | -$(RM) $(OBJS) $(TARGET) 65 | 66 | $(OBJS): %.o : %.c $(SOURCES) 67 | $(CC) $(CFLAGS) -c -o $@ $< 68 | -------------------------------------------------------------------------------- /lua-exif.mk: -------------------------------------------------------------------------------- 1 | CC ?= gcc 2 | 3 | LUA_PATH = lua 4 | LUA_LIB = lua53 5 | 6 | LIBEXIF_HOME = libexif 7 | LIBEXIF = $(LIBEXIF_HOME)/libexif/.libs/libexif.a 8 | 9 | LIBEXT=dll 10 | #LIBEXT=so 11 | LIBNAME=exif 12 | TARGET=$(LIBNAME).$(LIBEXT) 13 | 14 | LIBOPT_dll = -O \ 15 | -shared \ 16 | -Wl,-s \ 17 | -L..\$(LUA_PATH)\src -l$(LUA_LIB) \ 18 | $(LIBEXIF) 19 | 20 | CFLAGS_dll = -Wall \ 21 | -Wextra \ 22 | -Wno-unused-parameter \ 23 | -Wstrict-prototypes \ 24 | -I../$(LUA_PATH)/src \ 25 | -I$(LIBEXIF_HOME) 26 | 27 | LIBOPT_so = -O \ 28 | -shared \ 29 | -static-libgcc \ 30 | -Wl,-s \ 31 | -L..\$(LUA_PATH)\src \ 32 | $(LIBEXIF) 33 | 34 | CFLAGS_so = -pedantic \ 35 | -fPIC \ 36 | -Wall \ 37 | -Wextra \ 38 | -Wno-unused-parameter \ 39 | -Wstrict-prototypes \ 40 | -I../$(LUA_PATH)/src \ 41 | -I$(LIBEXIF_HOME) 42 | 43 | LIBOPT = $(LIBOPT_$(LIBEXT)) 44 | 45 | CFLAGS += $(CFLAGS_$(LIBEXT)) 46 | 47 | SOURCES = exif.c lua-compat/luamod.h lua-compat/compat.h 48 | 49 | OBJS = exif.o 50 | 51 | lib: $(TARGET) 52 | 53 | $(TARGET): $(OBJS) 54 | $(CC) $(OBJS) $(LIBOPT) -o $(TARGET) 55 | 56 | clean: 57 | -$(RM) $(OBJS) $(TARGET) 58 | 59 | $(OBJS): %.o : %.c $(SOURCES) 60 | $(CC) $(CFLAGS) -c -o $@ $< 61 | -------------------------------------------------------------------------------- /lua-jpeg.mk: -------------------------------------------------------------------------------- 1 | CC ?= gcc 2 | 3 | LUA_PATH = lua 4 | LUA_LIB = lua53 5 | 6 | LIBJPEG_HOME = libjpeg 7 | LIBJPEG = $(LIBJPEG_HOME)/.libs/libjpeg.a 8 | 9 | LIBEXT=dll 10 | #LIBEXT=so 11 | LIBNAME=jpeg 12 | TARGET=$(LIBNAME).$(LIBEXT) 13 | 14 | LIBOPT_dll = -O \ 15 | -shared \ 16 | -Wl,-s \ 17 | -L..\$(LUA_PATH)\src -l$(LUA_LIB) \ 18 | $(LIBJPEG) 19 | 20 | CFLAGS_dll = -Wall \ 21 | -Wextra \ 22 | -Wno-unused-parameter \ 23 | -Wstrict-prototypes \ 24 | -I../$(LUA_PATH)/src \ 25 | -I$(LIBJPEG_HOME) 26 | 27 | LIBOPT_so = -O \ 28 | -shared \ 29 | -static-libgcc \ 30 | -Wl,-s \ 31 | -L..\$(LUA_PATH)\src \ 32 | $(LIBJPEG) 33 | 34 | CFLAGS_so = -pedantic \ 35 | -fPIC \ 36 | -Wall \ 37 | -Wextra \ 38 | -Wno-unused-parameter \ 39 | -Wstrict-prototypes \ 40 | -I../$(LUA_PATH)/src \ 41 | -I$(LIBJPEG_HOME) 42 | 43 | LIBOPT = $(LIBOPT_$(LIBEXT)) 44 | 45 | CFLAGS += $(CFLAGS_$(LIBEXT)) 46 | 47 | SOURCES = jpeg.c lua-compat/luamod.h lua-compat/compat.h 48 | 49 | OBJS = jpeg.o 50 | 51 | lib: $(TARGET) 52 | 53 | $(TARGET): $(OBJS) 54 | $(CC) $(OBJS) $(LIBOPT) -o $(TARGET) 55 | 56 | clean: 57 | -$(RM) $(OBJS) $(TARGET) 58 | 59 | $(OBJS): %.o : %.c $(SOURCES) 60 | $(CC) $(CFLAGS) -c -o $@ $< 61 | -------------------------------------------------------------------------------- /lua-linux.mk: -------------------------------------------------------------------------------- 1 | CC ?= gcc 2 | 3 | LIBEXT ?= so 4 | LIBNAME = linux 5 | SRCNAME = $(LIBNAME) 6 | TARGET = $(LIBNAME).$(LIBEXT) 7 | 8 | LUA_PATH = lua 9 | 10 | LIBOPT = -O \ 11 | -shared \ 12 | -static-libgcc \ 13 | -Wl,-s \ 14 | -L..\$(LUA_PATH)\src 15 | 16 | CFLAGS += -pedantic \ 17 | -fPIC \ 18 | -Wall \ 19 | -Wextra \ 20 | -Wno-unused-parameter \ 21 | -Wstrict-prototypes \ 22 | -I../$(LUA_PATH)/src 23 | 24 | OBJS = $(SRCNAME).o 25 | 26 | SRCS = $(SRCNAME).c 27 | 28 | lib: $(TARGET) 29 | 30 | $(TARGET): $(OBJS) 31 | $(CC) $(OBJS) $(LIBOPT) -o $(TARGET) 32 | 33 | clean: 34 | -$(RM) $(OBJS) $(TARGET) 35 | 36 | $(OBJS): %.o : %.c $(SRCS) 37 | $(CC) $(CFLAGS) -c -o $@ $< 38 | -------------------------------------------------------------------------------- /lua-llthreads2.mk: -------------------------------------------------------------------------------- 1 | CC ?= gcc 2 | 3 | LUA_PATH = lua 4 | LUA_LIB = lua53 5 | 6 | LIBEXT ?= dll 7 | LIBNAME = llthreads 8 | TARGET = $(LIBNAME).$(LIBEXT) 9 | 10 | LIBOPT_dll = -O \ 11 | -shared \ 12 | -Wl,-s \ 13 | -L../../$(LUA_PATH)\src -l$(LUA_LIB) 14 | 15 | CFLAGS_dll = -Wall \ 16 | -Wextra \ 17 | -Wno-unused-parameter \ 18 | -Wstrict-prototypes \ 19 | -I../../$(LUA_PATH)/src 20 | 21 | LIBOPT_so = -O \ 22 | -shared \ 23 | -pthread \ 24 | -lpthread \ 25 | -static-libgcc \ 26 | -Wl,-s \ 27 | -L../../$(LUA_PATH)\src \ 28 | $(LIBS) 29 | 30 | CFLAGS_so = -pedantic \ 31 | -fPIC \ 32 | -pthread \ 33 | -Wall \ 34 | -Wextra \ 35 | -Wno-unused-parameter \ 36 | -Wstrict-prototypes \ 37 | -I../../$(LUA_PATH)/src 38 | 39 | LIBOPT = $(LIBOPT_$(LIBEXT)) 40 | 41 | CFLAGS += $(CFLAGS_$(LIBEXT)) 42 | 43 | SOURCES = l52util.c llthread.c 44 | 45 | OBJS = l52util.o llthread.o 46 | 47 | lib: $(TARGET) 48 | 49 | $(TARGET): $(OBJS) 50 | $(CC) $(OBJS) $(LIBOPT) -o $(TARGET) 51 | 52 | clean: 53 | -$(RM) $(OBJS) $(TARGET) 54 | 55 | $(OBJS): %.o : %.c $(SOURCES) 56 | $(CC) $(CFLAGS) -c -o $@ $< 57 | -------------------------------------------------------------------------------- /lua-openssl.mk: -------------------------------------------------------------------------------- 1 | CC ?= gcc 2 | 3 | # make -f ../luaclibs/lua-openssl.mk OPENSSL_STATIC=1 OPENSSLDIR=../luaclibs/openssl LUADIR=../luaclibs/lua/src && cp openssl.dll ..\luaclibs\dist 4 | 5 | LUA_PATH = lua 6 | LUA_LIB = lua54 7 | 8 | PLAT ?= windows 9 | 10 | OPENSSLDIR = ../openssl 11 | LUADIR = ../$(LUA_PATH)/src 12 | 13 | LIBNAME = openssl 14 | 15 | AUXDIR = deps/auxiliar 16 | 17 | LIBOPT_OPENSSL_SHARED = -L$(OPENSSLDIR) -lssl -lcrypto 18 | LIBOPT_OPENSSL_STATIC = $(OPENSSLDIR)/libssl.a $(OPENSSLDIR)/libcrypto.a 19 | 20 | ifeq ($(PLAT),linux) 21 | LIBOPT_OPENSSL_SHARED = -L$(OPENSSLDIR) -lssl -lcrypto -ldl 22 | endif 23 | 24 | ifeq ($(PLAT),windows) 25 | LIBOPT_OPENSSL_STATIC = $(OPENSSLDIR)/libssl.a $(OPENSSLDIR)/libcrypto.a -lws2_32 -lgdi32 -lcrypt32 26 | endif 27 | 28 | ifdef OPENSSL_STATIC 29 | LIBOPT_OPENSSL ?= $(LIBOPT_OPENSSL_STATIC) 30 | else 31 | LIBOPT_OPENSSL ?= $(LIBOPT_OPENSSL_SHARED) 32 | endif 33 | 34 | # pkg-config openssl --static --libs 35 | 36 | LIBEXT_windows = dll 37 | LIBOPT_windows = -O \ 38 | -shared \ 39 | -Wl,-s \ 40 | $(LIBOPT_OPENSSL) \ 41 | -L$(LUADIR) -l$(LUA_LIB) 42 | CFLAGS_windows = -Wall \ 43 | -Wextra \ 44 | -Wno-unused-parameter \ 45 | -Wstrict-prototypes \ 46 | -I$(OPENSSLDIR)/include \ 47 | -Ideps/lua-compat/c-api \ 48 | -I$(AUXDIR) \ 49 | -I$(LUADIR) 50 | 51 | LIBEXT_linux = so 52 | # -m32 -Wa,--noexecstack -Wall -fomit-frame-pointer 53 | LIBOPT_linux = -O3 \ 54 | -shared \ 55 | -fPIC \ 56 | -static-libgcc \ 57 | -Wl,-s \ 58 | $(LIBOPT_OPENSSL) 59 | CFLAGS_linux = -pedantic \ 60 | -fPIC \ 61 | -Wall \ 62 | -Wextra \ 63 | -std=gnu99 \ 64 | -DLUA_USE_DLOPEN \ 65 | -DLUA_LIB \ 66 | -I$(OPENSSLDIR)/include \ 67 | -Ideps/lua-compat/c-api \ 68 | -I$(AUXDIR) \ 69 | -I$(LUADIR) 70 | 71 | # -Wno-unused-parameter \ 72 | # -Wstrict-prototypes \ 73 | 74 | TARGET = $(LIBNAME).$(LIBEXT_$(PLAT)) 75 | LIBOPT = $(LIBOPT_$(PLAT)) 76 | CFLAGS += $(CFLAGS_$(PLAT)) 77 | LIBS=$(LIBS_$(PLAT)) 78 | 79 | OBJS=$(AUXDIR)/auxiliar.o $(AUXDIR)/subsidiar.o src/asn1.o src/bio.o src/cipher.o src/cms.o src/compat.o src/crl.o src/csr.o src/dh.o src/digest.o src/dsa.o src/ec.o \ 80 | src/engine.o src/hmac.o src/kdf.o src/lbn.o src/lhash.o src/mac.o src/misc.o src/param.o src/ocsp.o src/openssl.o src/ots.o src/pkcs12.o src/pkcs7.o src/pkey.o \ 81 | src/rsa.o src/srp.o src/ssl.o src/th-lock.o src/util.o src/x509.o src/xattrs.o src/xexts.o src/xname.o src/xstore.o src/xalgor.o src/callback.o 82 | 83 | SRCS=$(AUXDIR)/auxiliar.c $(AUXDIR)/subsidiar.c src/asn1.c src/bio.c src/cipher.c src/cms.c src/compat.c src/crl.c src/csr.c src/dh.c src/digest.c src/dsa.c src/ec.c \ 84 | src/engine.c src/hmac.c src/kdf.c src/lbn.c src/lhash.c src/mac.c src/misc.c src/param.c src/ocsp.c src/openssl.c src/ots.c src/pkcs12.c src/pkcs7.c src/pkey.c \ 85 | src/rsa.c src/srp.c src/ssl.c src/th-lock.c src/util.c src/x509.c src/xattrs.c src/xexts.c src/xname.c src/xstore.c src/xalgor.c src/callback.c 86 | 87 | lib: $(TARGET) lib$(LIBNAME).a 88 | 89 | lib$(LIBNAME).a: $(OBJS) 90 | $(AR) rcs lib$(LIBNAME).a $(OBJS) 91 | 92 | #$(TARGET)NO: lib$(LIBNAME).a 93 | # $(CC) -o $(TARGET) src/$(LIBNAME).o -L. -l$(LIBNAME) -L$(LUADIR) -llua 94 | # -L$(OPENSSLDIR) -lssl -lcrypto -Wl,--no-undefined -fpic -lrt -ldl -lm -shared -ldl -pthread 95 | 96 | $(TARGET): $(OBJS) 97 | $(CC) $(OBJS) $(LIBOPT) -o $(TARGET) 98 | 99 | clean: 100 | -$(RM) $(OBJS) $(TARGET) 101 | 102 | $(OBJS): %.o : %.c $(SRCS) 103 | $(CC) $(CFLAGS) -c -o $@ $< 104 | 105 | 106 | -------------------------------------------------------------------------------- /lua-struct.mk: -------------------------------------------------------------------------------- 1 | CC ?= gcc 2 | 3 | LIBEXT ?= dll 4 | LIBNAME = struct 5 | TARGET = $(LIBNAME).$(LIBEXT) 6 | LUA_PATH = lua 7 | LUA_LIB = lua54 8 | 9 | LIBOPT_dll = -O \ 10 | -shared \ 11 | -Wl,-s \ 12 | -L..\$(LUA_PATH)\src -l$(LUA_LIB) 13 | 14 | CFLAGS_dll = -Wall \ 15 | -Wextra \ 16 | -Wno-unused-parameter \ 17 | -Wstrict-prototypes \ 18 | -I../$(LUA_PATH)/src 19 | 20 | LIBOPT_so = -O \ 21 | -shared \ 22 | -static-libgcc \ 23 | -Wl,-s \ 24 | -L..\$(LUA_PATH)\src 25 | 26 | CFLAGS_so = -pedantic \ 27 | -fPIC \ 28 | -Wall \ 29 | -Wextra \ 30 | -Wno-unused-parameter \ 31 | -Wstrict-prototypes \ 32 | -I../$(LUA_PATH)/src 33 | 34 | LIBOPT = $(LIBOPT_$(LIBEXT)) 35 | 36 | CFLAGS += $(CFLAGS_$(LIBEXT)) 37 | 38 | SOURCES = struct.c 39 | 40 | OBJS = struct.o 41 | 42 | lib: $(TARGET) 43 | 44 | $(TARGET): $(OBJS) 45 | $(CC) $(OBJS) $(LIBOPT) -o $(TARGET) 46 | 47 | clean: 48 | -$(RM) $(OBJS) $(TARGET) 49 | 50 | $(OBJS): %.o : %.c $(SOURCES) 51 | $(CC) $(CFLAGS) -c -o $@ $< 52 | -------------------------------------------------------------------------------- /lua-webview.mk: -------------------------------------------------------------------------------- 1 | CC ?= gcc 2 | 3 | LIBEXT ?= dll 4 | LIBNAME = webview 5 | TARGET = $(LIBNAME).$(LIBEXT) 6 | 7 | LUA_PATH = lua 8 | LUA_LIB = lua53 9 | 10 | WEBVIEW_C = webview-c 11 | MS_WEBVIEW2 = $(WEBVIEW_C)/ms.webview2 12 | MEMMODULE = MemoryModule 13 | 14 | GCC_NAME ?= $(shell $(CC) -dumpmachine) 15 | 16 | WEBVIEW_ARCH = x64 17 | ifeq (,$(findstring x86_64,$(GCC_NAME))) 18 | WEBVIEW_ARCH = x86 19 | endif 20 | 21 | WOPTS = -w 22 | #WOPTS = -Wall -Wextra -Wno-unused-parameter -Wstrict-prototypes 23 | 24 | LIBOPT_dll = -O \ 25 | -shared \ 26 | -static-libgcc \ 27 | -Wl,-s \ 28 | -L../$(LUA_PATH)/src -l$(LUA_LIB) \ 29 | -lole32 -lcomctl32 -loleaut32 -luuid -lgdi32 30 | 31 | CFLAGS_dll = $(WOPTS) \ 32 | -I$(WEBVIEW_C) \ 33 | -I$(MEMMODULE) \ 34 | -I$(MS_WEBVIEW2)/include \ 35 | -I../$(LUA_PATH)/src \ 36 | -DWEBVIEW2_MEMORY_MODULE=1 \ 37 | -DWEBVIEW_WIN32_ICON_RES=0 \ 38 | -DWEBVIEW_WINAPI=1 39 | 40 | LIBOPT_so = -O \ 41 | -shared \ 42 | -static-libgcc \ 43 | -Wl,-s \ 44 | -L../$(LUA_PATH)/src \ 45 | $(shell pkg-config --libs gtk+-3.0 webkit2gtk-4.0) 46 | 47 | CFLAGS_so = -pedantic \ 48 | -fPIC \ 49 | $(WOPTS) \ 50 | -I$(WEBVIEW_C) \ 51 | -I../$(LUA_PATH)/src \ 52 | -DWEBVIEW_GTK=1 \ 53 | $(shell pkg-config --cflags gtk+-3.0 webkit2gtk-4.0) 54 | 55 | SOURCES_dll=$(MEMMODULE)/MemoryModule.c 56 | SOURCES_so= 57 | 58 | OBJS_dll=$(MEMMODULE)/MemoryModule.o 59 | OBJS_so= 60 | 61 | LIBOPT = $(LIBOPT_$(LIBEXT)) 62 | 63 | CFLAGS += $(CFLAGS_$(LIBEXT)) 64 | 65 | SOURCES = webview.c $(SOURCES_$(LIBEXT)) 66 | 67 | OBJS = webview.o $(OBJS_$(LIBEXT)) 68 | 69 | SRCS = $(WEBVIEW_C)/webview.h \ 70 | $(WEBVIEW_C)/webview-cocoa.c \ 71 | $(WEBVIEW_C)/webview-gtk.c \ 72 | $(WEBVIEW_C)/webview-win32.c \ 73 | $(WEBVIEW_C)/webview-win32-edge.c \ 74 | $(WEBVIEW_C)/ms.webview2/include/WebView2.h \ 75 | $(WEBVIEW_C)/ms.webview2/include/WebView2EnvironmentOptions.h 76 | 77 | lib: $(TARGET) 78 | 79 | $(TARGET): $(OBJS) 80 | $(CC) $(OBJS) $(LIBOPT) -o $(TARGET) 81 | 82 | clean: 83 | -$(RM) $(OBJS) $(TARGET) 84 | 85 | $(OBJS): %.o : %.c $(SOURCES) $(SRCS) 86 | $(CC) $(CFLAGS) -c -o $@ $< 87 | -------------------------------------------------------------------------------- /lua-win32.mk: -------------------------------------------------------------------------------- 1 | CC ?= gcc 2 | 3 | LIBEXT ?= dll 4 | LIBNAME = win32 5 | SRCNAME = $(LIBNAME) 6 | TARGET = $(LIBNAME).$(LIBEXT) 7 | 8 | LUA_PATH = lua 9 | LUA_LIB = lua54 10 | 11 | LIBOPT = -O \ 12 | -shared \ 13 | -static-libgcc \ 14 | -Wl,-s \ 15 | -L..\$(LUA_PATH)\src -l$(LUA_LIB) \ 16 | -lcomdlg32 17 | 18 | # -lkernel32 -luser32 -lpsapi -ladvapi32 -lshell32 -lgdi32 -lcomctl32 -lcomdlg32 -luxtheme -lpowrprof -lMpr 19 | 20 | CFLAGS += -Wall \ 21 | -Wextra \ 22 | -Wno-unused-parameter \ 23 | -Wstrict-prototypes \ 24 | -I../$(LUA_PATH)/src 25 | 26 | OBJS = $(SRCNAME).o 27 | 28 | SRCS = $(SRCNAME).c 29 | 30 | lib: $(TARGET) 31 | 32 | $(TARGET): $(OBJS) 33 | $(CC) $(OBJS) $(LIBOPT) -o $(TARGET) 34 | 35 | clean: 36 | -$(RM) $(OBJS) $(TARGET) 37 | 38 | $(OBJS): %.o : %.c $(SRCS) 39 | $(CC) $(CFLAGS) -c -o $@ $< 40 | -------------------------------------------------------------------------------- /lua-zlib.mk: -------------------------------------------------------------------------------- 1 | LUA_PATH = lua 2 | LUA_LIB = lua53 3 | 4 | INCDIR ?= -I../$(LUA_PATH)/src -I../zlib 5 | LIBDIR ?= -L../$(LUA_PATH)/src 6 | 7 | PLAT = windows 8 | 9 | LIBNAME = zlib 10 | 11 | TARGET=$(LIBNAME).$(LIBEXT_$(PLAT)) 12 | 13 | SRCS = lua_zlib.c 14 | OBJS = lua_zlib.o 15 | 16 | LIBS = ../zlib/libz.a 17 | WARN = -Wall -pedantic 18 | 19 | LIBEXT_linux = so 20 | CFLAGS_linux = -O2 -fPIC $(WARN) $(INCDIR) $(DEFS) 21 | LDFLAGS_linux = -O -shared -fPIC -Wl,-s 22 | 23 | LIBEXT_windows = dll 24 | CFLAGS_windows = -O2 -fPIC $(WARN) $(INCDIR) $(DEFS) 25 | LDFLAGS_windows = -O -shared -fPIC -Wl,-s -l$(LUA_LIB) 26 | 27 | CC = gcc 28 | LD = gcc 29 | CFLAGS += $(CFLAGS_$(PLAT)) 30 | LDFLAGS = $(LDFLAGS_$(PLAT)) 31 | 32 | .PHONY: all clean none linux windows 33 | 34 | lib: $(TARGET) 35 | 36 | clean: 37 | rm -f $(OBJS) $(TARGET) 38 | 39 | .c.o: 40 | $(CC) -c $(CFLAGS) $(DEFS) $(INCDIR) -o $@ $< 41 | 42 | $(TARGET): $(OBJS) 43 | $(LD) $(LDFLAGS) $(LIBDIR) $(OBJS) $(LIBS) -o $@ 44 | -------------------------------------------------------------------------------- /luabt.mk: -------------------------------------------------------------------------------- 1 | CC ?= gcc 2 | 3 | LUA_PATH = lua 4 | LUA_LIB = lua53 5 | 6 | LIBEXT ?= dll 7 | LIBNAME = bt 8 | TARGET = $(LIBNAME).$(LIBEXT) 9 | 10 | LIBOPT_dll = -O \ 11 | -shared \ 12 | -Wl,-s \ 13 | -L..\$(LUA_PATH)\src -l$(LUA_LIB) -lBthprops -lws2_32 14 | 15 | CFLAGS_dll = -Wall \ 16 | -Wextra \ 17 | -Wno-unused-parameter \ 18 | -Wstrict-prototypes \ 19 | -I../$(LUA_PATH)/src 20 | 21 | LIBOPT_so = -O \ 22 | -shared \ 23 | -static-libgcc \ 24 | -Wl,-s \ 25 | -L..\$(LUA_PATH)\src \ 26 | -lbluetooth 27 | 28 | CFLAGS_so = -pedantic \ 29 | -fPIC \ 30 | -Wall \ 31 | -Wextra \ 32 | -Wno-unused-parameter \ 33 | -Wstrict-prototypes \ 34 | -I../$(LUA_PATH)/src 35 | 36 | LIBOPT = $(EXTRA_LIBOPT) $(LIBOPT_$(LIBEXT)) 37 | 38 | CFLAGS = $(EXTRA_CFLAGS) $(CFLAGS_$(LIBEXT)) 39 | 40 | SOURCES = luabt.c luabt_windows.c luabt_linux.c 41 | 42 | OBJS = luabt.o 43 | 44 | lib: $(TARGET) 45 | 46 | $(TARGET): $(OBJS) 47 | $(CC) $(OBJS) $(LIBOPT) -o $(TARGET) 48 | 49 | clean: 50 | -$(RM) $(OBJS) $(TARGET) 51 | 52 | $(OBJS): %.o : %.c $(SOURCES) 53 | $(CC) $(CFLAGS) -c -o $@ $< 54 | -------------------------------------------------------------------------------- /luachild.mk: -------------------------------------------------------------------------------- 1 | CC ?= gcc 2 | 3 | LUA_PATH = lua 4 | LUA_LIB = lua53 5 | 6 | LIBEXT ?= dll 7 | LIBNAME = luachild 8 | TARGET = $(LIBNAME).$(LIBEXT) 9 | 10 | LIBOPT_dll = -O \ 11 | -shared \ 12 | -Wl,-s \ 13 | -L../$(LUA_PATH)\src -l$(LUA_LIB) 14 | 15 | CFLAGS_dll = -O2 -std=gnu99 -fPIC -g -Wall -Wextra \ 16 | -Wno-missing-field-initializers -Wno-override-init -Wno-unused \ 17 | -D_REENTRANT -D_THREAD_SAFE -D_GNU_SOURCE \ 18 | -DUSE_WINDOWS \ 19 | -I../$(LUA_PATH)/src 20 | 21 | LIBOPT_so = -O \ 22 | -shared \ 23 | -static-libgcc \ 24 | -lrt -lm \ 25 | -Wl,-s \ 26 | -L..\$(LUA_PATH)\src 27 | 28 | CFLAGS_so = -O2 -std=gnu99 -fPIC -g -Wall -Wextra \ 29 | -Wno-missing-field-initializers -Wno-override-init -Wno-unused \ 30 | -D_REENTRANT -D_THREAD_SAFE -D_GNU_SOURCE \ 31 | -DUSE_POSIX \ 32 | -I../$(LUA_PATH)/src 33 | 34 | LIBOPT = $(LIBOPT_$(LIBEXT)) 35 | 36 | CFLAGS += $(CFLAGS_$(LIBEXT)) 37 | 38 | HDRS = luachild.h 39 | 40 | SRCS = luachild_common.c luachild_posix.c luachild_windows.c 41 | 42 | ifeq ($(LUA_LIB),lua51) 43 | SRCS += luachild_lua_5_1.c 44 | else 45 | SRCS += luachild_lua_5_3.c 46 | endif 47 | 48 | OBJS = ${SRCS:.c=.o} 49 | 50 | lib: $(TARGET) 51 | 52 | $(TARGET): $(OBJS) 53 | $(CC) $(OBJS) $(LIBOPT) -o $(TARGET) 54 | 55 | clean: 56 | -$(RM) $(OBJS) $(TARGET) 57 | 58 | $(OBJS): %.o : %.c $(SRCS) $(HDRS) 59 | $(CC) $(CFLAGS) -c -o $@ $< 60 | 61 | -------------------------------------------------------------------------------- /luaexpat.mk: -------------------------------------------------------------------------------- 1 | CC ?= gcc 2 | 3 | LIBEXT ?= dll 4 | LIBNAME = lxp 5 | TARGET = $(LIBNAME).$(LIBEXT) 6 | 7 | LUA_PATH = lua 8 | LUA_LIB = lua54 9 | 10 | EXPAT=expat-2.5.0 11 | 12 | LIBOPT_dll = -O \ 13 | -shared \ 14 | -static-libgcc \ 15 | -Wl,-s \ 16 | -L..\$(LUA_PATH)\src -l$(LUA_LIB) \ 17 | $(EXPAT)/lib/.libs/libexpat.a 18 | 19 | CFLAGS_dll = -Wall \ 20 | -Wextra \ 21 | -Wno-unused-parameter \ 22 | -Wstrict-prototypes \ 23 | -I../$(LUA_PATH)/src \ 24 | -I$(EXPAT) \ 25 | -I$(EXPAT)/lib 26 | 27 | LIBOPT_so = -O \ 28 | -shared \ 29 | -static-libgcc \ 30 | -Wl,-s \ 31 | -L..\$(LUA_PATH)\src \ 32 | $(EXPAT)/lib/.libs/libexpat.a 33 | 34 | CFLAGS_so = -pedantic \ 35 | -fPIC \ 36 | -Wall \ 37 | -Wextra \ 38 | -Wno-unused-parameter \ 39 | -Wstrict-prototypes \ 40 | -I../$(LUA_PATH)/src \ 41 | -I$(EXPAT) \ 42 | -I$(EXPAT)/lib 43 | 44 | LIBOPT = $(LIBOPT_$(LIBEXT)) 45 | 46 | CFLAGS += $(CFLAGS_$(LIBEXT)) 47 | 48 | SOURCES = src/lxplib.c 49 | 50 | OBJS = src/lxplib.o 51 | 52 | SRCS = src/lxplib.c src/lxplib.h 53 | 54 | lib: $(TARGET) 55 | 56 | $(TARGET): $(OBJS) 57 | $(CC) $(OBJS) $(LIBOPT) -o $(TARGET) 58 | 59 | clean: 60 | -$(RM) $(OBJS) $(TARGET) 61 | 62 | $(OBJS): %.o : %.c $(SRCS) 63 | $(CC) $(CFLAGS) -c -o $@ $< 64 | -------------------------------------------------------------------------------- /luafilesystem.mk: -------------------------------------------------------------------------------- 1 | CC ?= gcc 2 | 3 | LIBEXT=dll 4 | #LIBEXT=so 5 | LIBNAME=lfs 6 | TARGET=$(LIBNAME).$(LIBEXT) 7 | 8 | LUA_PATH = lua 9 | LUA_LIB = lua53 10 | 11 | LIBOPT_dll = -O \ 12 | -shared \ 13 | -Wl,-s \ 14 | -L..\$(LUA_PATH)\src -l$(LUA_LIB) 15 | 16 | CFLAGS_dll = -Wall -Wextra -Wno-unused-parameter -Wstrict-prototypes \ 17 | -I../$(LUA_PATH)/src 18 | 19 | LIBOPT_so = -O \ 20 | -shared \ 21 | -static-libgcc \ 22 | -Wl,-s \ 23 | -L../$(LUA_PATH)/src \ 24 | $(LIBS) 25 | 26 | CFLAGS_so = -O2 -pedantic -fPIC -shared \ 27 | -Wall -W -Waggregate-return -Wcast-align -Wmissing-prototypes -Wnested-externs -Wshadow -Wwrite-strings \ 28 | -I../$(LUA_PATH)/src 29 | 30 | ##gcc -O2 -Wall -fPIC -W -Waggregate-return -Wcast-align -Wmissing-prototypes -Wnested-externs -Wshadow -Wwrite-strings -pedantic -I../$(LUA_PATH)/src -c -o src/lfs.o src/lfs.c 31 | ##gcc -shared -o src/lfs.so src/lfs.o 32 | 33 | LIBOPT = $(LIBOPT_$(LIBEXT)) 34 | 35 | CFLAGS += $(CFLAGS_$(LIBEXT)) 36 | 37 | SOURCES = src/lfs.c src/lfs.h 38 | 39 | OBJS = src/lfs.o 40 | 41 | lib: $(TARGET) 42 | 43 | $(TARGET): $(OBJS) 44 | $(CC) $(OBJS) $(LIBOPT) -o $(TARGET) 45 | 46 | clean: 47 | -$(RM) $(OBJS) $(TARGET) 48 | 49 | $(OBJS): %.o : %.c $(SOURCES) 50 | $(CC) $(CFLAGS) -c -o $@ $< 51 | -------------------------------------------------------------------------------- /luaserial.mk: -------------------------------------------------------------------------------- 1 | CC ?= gcc 2 | 3 | LUA_PATH = lua 4 | LUA_LIB = lua53 5 | 6 | LIBEXT ?= dll 7 | LIBNAME = serial 8 | TARGET = $(LIBNAME).$(LIBEXT) 9 | 10 | LIBOPT_dll = -O \ 11 | -shared \ 12 | -Wl,-s \ 13 | -L..\$(LUA_PATH)\src -l$(LUA_LIB) 14 | 15 | CFLAGS_dll = -Wall \ 16 | -Wextra \ 17 | -Wno-unused-parameter \ 18 | -Wstrict-prototypes \ 19 | -I../$(LUA_PATH)/src 20 | 21 | LIBOPT_so = -O \ 22 | -shared \ 23 | -static-libgcc \ 24 | -Wl,-s \ 25 | -L..\$(LUA_PATH)\src \ 26 | $(LIBS) 27 | 28 | CFLAGS_so = -pedantic \ 29 | -fPIC \ 30 | -Wall \ 31 | -Wextra \ 32 | -Wno-unused-parameter \ 33 | -Wstrict-prototypes \ 34 | -I../$(LUA_PATH)/src 35 | 36 | LIBOPT = $(LIBOPT_$(LIBEXT)) 37 | 38 | CFLAGS += $(CFLAGS_$(LIBEXT)) 39 | 40 | SOURCES = luaserial.c luaserial_windows.c luaserial_linux.c lua-compat/luamod.h lua-compat/compat.h 41 | 42 | OBJS = luaserial.o 43 | 44 | lib: $(TARGET) 45 | 46 | $(TARGET): $(OBJS) 47 | $(CC) $(OBJS) $(LIBOPT) -o $(TARGET) 48 | 49 | clean: 50 | -$(RM) $(OBJS) $(TARGET) 51 | 52 | $(OBJS): %.o : %.c $(SOURCES) 53 | $(CC) $(CFLAGS) -c -o $@ $< 54 | -------------------------------------------------------------------------------- /luv_linux.mk: -------------------------------------------------------------------------------- 1 | CC ?= gcc 2 | 3 | LIB_UV_PATH = deps/libuv 4 | LIB_UV_LIB = $(LIB_UV_PATH)/libuv.a 5 | 6 | LUA_PATH = lua 7 | 8 | ifndef CLIBS_DEBUG 9 | LIB_OPTION += -O2 10 | endif 11 | 12 | LIB_OPTION += -shared \ 13 | -lrt \ 14 | -pthread \ 15 | -lpthread \ 16 | -static-libgcc \ 17 | -L../$(LUA_PATH)/src \ 18 | -fPIC -Wl,-s 19 | 20 | ifdef CLIBS_DEBUG 21 | CFLAGS += -g 22 | else 23 | CFLAGS += -O2 24 | endif 25 | 26 | ifdef CLIBS_NDEBUG 27 | CFLAGS += -DNDEBUG 28 | endif 29 | 30 | CFLAGS += -fPIC \ 31 | -Isrc \ 32 | -I../$(LUA_PATH)/src \ 33 | -I$(LIB_UV_PATH)/include \ 34 | -Ideps/lua-compat-5.3/c-api \ 35 | -std=gnu99 \ 36 | -DBUILDING_UV_SHARED \ 37 | -D_FILE_OFFSET_BITS=64 \ 38 | -D_GNU_SOURCE \ 39 | -D_LARGEFILE_SOURCE \ 40 | -DLUA_USE_DLOPEN \ 41 | -DLUA_LIB \ 42 | -Dluv_EXPORTS \ 43 | -pthread 44 | 45 | INCLUDES = src/lhandle.h \ 46 | src/lreq.h \ 47 | src/lthreadpool.h \ 48 | src/luv.h \ 49 | src/util.h 50 | 51 | OBJS = src/luv.o 52 | 53 | HDRS = src/lhandle.h \ 54 | src/lreq.h \ 55 | src/lthreadpool.h \ 56 | src/luv.h \ 57 | src/private.h \ 58 | src/util.h 59 | 60 | SRCS = src/async.c \ 61 | src/check.c \ 62 | src/constants.c \ 63 | src/dns.c \ 64 | src/fs.c \ 65 | src/fs_event.c \ 66 | src/fs_poll.c \ 67 | src/handle.c \ 68 | src/idle.c \ 69 | src/lhandle.c \ 70 | src/loop.c \ 71 | src/lreq.c \ 72 | src/metrics.c \ 73 | src/misc.c \ 74 | src/pipe.c \ 75 | src/poll.c \ 76 | src/prepare.c \ 77 | src/process.c \ 78 | src/req.c \ 79 | src/schema.c \ 80 | src/signal.c \ 81 | src/stream.c \ 82 | src/tcp.c \ 83 | src/thread.c \ 84 | src/timer.c \ 85 | src/tty.c \ 86 | src/udp.c \ 87 | src/util.c \ 88 | src/work.c 89 | 90 | TARGET = luv.so 91 | 92 | lib: $(TARGET) 93 | 94 | $(TARGET): $(OBJS) $(LIB_UV_LIB) 95 | $(LD) $(LIB_OPTION) $(OBJS) $(LIB_UV_LIB) -o $@ 96 | 97 | clean: 98 | -$(RM) $(OBJS) $(TARGET) 99 | 100 | $(OBJS): %.o : %.c $(INCLUDES) $(HDRS) $(SRCS) 101 | $(CC) $(CFLAGS) -c -o $@ $< 102 | 103 | -------------------------------------------------------------------------------- /luv_mingw.mk: -------------------------------------------------------------------------------- 1 | CC ?= gcc 2 | 3 | LIB_UV_PATH = deps/libuv 4 | LIB_UV_LIB = $(LIB_UV_PATH)/libuv.a 5 | 6 | LUA_PATH = lua 7 | LUA_LIB = lua53 8 | 9 | ifndef CLIBS_DEBUG 10 | LIB_OPTION += -O 11 | endif 12 | 13 | LIB_OPTION += -shared \ 14 | -static-libgcc \ 15 | -Wl,-s \ 16 | -L..\$(LUA_PATH)\src -l$(LUA_LIB) \ 17 | $(LIB_UV_LIB) \ 18 | -lws2_32 -lpsapi -liphlpapi -lshell32 -luserenv -luser32 -ldbghelp -lole32 -luuid 19 | 20 | ##-lws2_32 -lpsapi -liphlpapi -luserenv 21 | 22 | # -L..\libuv -luv \ 23 | # -Wl,--output-def,luv.def,--out-implib,luv.a 24 | 25 | # WARN= -O2 -Wall -fPIC -W -Waggregate-return -Wcast-align -Wmissing-prototypes -Wnested-externs -Wshadow -Wwrite-strings -pedantic 26 | 27 | ifdef CLIBS_DEBUG 28 | CFLAGS += -g 29 | else 30 | CFLAGS += -O 31 | endif 32 | 33 | ifdef CLIBS_NDEBUG 34 | CFLAGS += -DNDEBUG 35 | endif 36 | 37 | CFLAGS += -Wall \ 38 | -Wextra \ 39 | -Wno-unused-parameter \ 40 | -Wstrict-prototypes \ 41 | -fpic \ 42 | -Isrc \ 43 | -I../$(LUA_PATH)/src \ 44 | -I$(LIB_UV_PATH)/include \ 45 | -Ideps/lua-compat-5.3/c-api \ 46 | -D_WIN32_WINNT=0x0600 \ 47 | -DLUA_USE_DLOPEN \ 48 | -DBUILDING_UV_SHARED \ 49 | -DLUA_BUILD_AS_DLL \ 50 | -DLUA_LIB \ 51 | -Dluv_EXPORTS 52 | 53 | INCLUDES = src/lhandle.h \ 54 | src/lreq.h \ 55 | src/lthreadpool.h \ 56 | src/luv.h \ 57 | src/util.h 58 | 59 | OBJS = src/luv.o 60 | 61 | HDRS = src/lhandle.h \ 62 | src/lreq.h \ 63 | src/lthreadpool.h \ 64 | src/luv.h \ 65 | src/private.h \ 66 | src/util.h 67 | 68 | SRCS = src/async.c \ 69 | src/check.c \ 70 | src/constants.c \ 71 | src/dns.c \ 72 | src/fs.c \ 73 | src/fs_event.c \ 74 | src/fs_poll.c \ 75 | src/handle.c \ 76 | src/idle.c \ 77 | src/lhandle.c \ 78 | src/loop.c \ 79 | src/lreq.c \ 80 | src/metrics.c \ 81 | src/misc.c \ 82 | src/pipe.c \ 83 | src/poll.c \ 84 | src/prepare.c \ 85 | src/process.c \ 86 | src/req.c \ 87 | src/schema.c \ 88 | src/signal.c \ 89 | src/stream.c \ 90 | src/tcp.c \ 91 | src/thread.c \ 92 | src/timer.c \ 93 | src/tty.c \ 94 | src/udp.c \ 95 | src/util.c \ 96 | src/work.c 97 | 98 | lib: luv.dll 99 | 100 | luv.dll: $(OBJS) $(LIB_UV_LIB) 101 | $(CC) $(OBJS) $(LIB_OPTION) -o luv.dll 102 | 103 | clean: 104 | -$(RM) $(OBJS) luv.dll 105 | 106 | $(OBJS): %.o : %.c $(INCLUDES) $(HDRS) $(SRCS) 107 | $(CC) $(CFLAGS) -c -o $@ $< 108 | 109 | -------------------------------------------------------------------------------- /main_linux.mk: -------------------------------------------------------------------------------- 1 | 2 | PLAT ?= linux 3 | SO ?= so 4 | CC ?= gcc 5 | 6 | LUA_PATH = lua 7 | 8 | LUA_VARS = LUA_PATH=$(LUA_PATH) 9 | 10 | ifeq ($(ARCH),arm) 11 | ARCH_SUFFIX ?= arm 12 | else ifeq ($(ARCH),aarch64) 13 | ARCH_SUFFIX ?= aarch64 14 | else 15 | ARCH_SUFFIX ?= default 16 | endif 17 | 18 | ifdef CLIBS_DEBUG 19 | LUA_MYCFLAGS = -g -DLUA_USE_APICHECK 20 | endif 21 | 22 | ifdef CLIBS_NDEBUG 23 | LUA_MYCFLAGS += -DNDEBUG 24 | endif 25 | 26 | ifeq ($(LUA_OPENSSL_LINKING),dynamic) 27 | LUA_OPENSSL_VARS = 28 | else 29 | LUA_OPENSSL_VARS = OPENSSL_STATIC=1 30 | endif 31 | 32 | ifeq ($(RELEASE_SUFFIX),-wd) 33 | LIB_UV_TAG := v1.44.2 34 | LIB_UV_TARGET := tag 35 | else 36 | LIB_UV_TARGET := dep 37 | endif 38 | 39 | EXPAT=expat-2.5.0 40 | LSQLITE=lsqlite3_v096 41 | 42 | ifeq ($(LIBBT),) 43 | BT_OPTS = 44 | else 45 | INCBT ?= $(LIBBT)/../../include 46 | BT_OPTS = EXTRA_CFLAGS=-I$(INCBT) EXTRA_LIBOPT=-L$(LIBBT) 47 | endif 48 | 49 | 50 | ifeq ($(OS),Windows_NT) 51 | NULL := NUL 52 | else 53 | NULL := /dev/null 54 | endif 55 | 56 | OPT_BLUETOOTH = $(shell env echo -e "\x23include "| $(CC) -E - >$(NULL) 2>&1 || echo -NA-) 57 | OPT_LINUX_GPIO = $(shell env echo -e "\x23include " | $(CC) -E - >$(NULL) 2>&1 && test -d lua-periphery || echo -NA-) 58 | OPT_WEBKIT2GTK = $(shell pkg-config gtk+-3.0 webkit2gtk-4.0 >$(NULL) 2>&1 || echo -NA-) 59 | 60 | all any: full 61 | 62 | core: lua lua-buffer luasocket luafilesystem lua-cjson luv lpeg lua-zlib lua-llthreads2 luachild lpeglabel lua-struct 63 | 64 | quick: core luaserial lua-jpeg lua-exif luaexpat 65 | 66 | extras: lua-linux lua-periphery$(OPT_LINUX_GPIO) lua-webview$(OPT_WEBKIT2GTK) luabt$(OPT_BLUETOOTH) 67 | 68 | full: quick lua-openssl extras 69 | 70 | %-NA-: 71 | @echo Ignoring $@ 72 | 73 | configure: configure-$(ARCH_SUFFIX) 74 | 75 | configure-default: configure-libjpeg configure-libexif configure-openssl configure-libexpat-default 76 | 77 | configure-arm: configure-libjpeg-arm configure-libexif-arm configure-openssl-arm configure-libexpat-arm 78 | 79 | configure-aarch64: configure-libjpeg-aarch64 configure-libexif-aarch64 configure-openssl-aarch64 configure-libexpat-aarch64 80 | 81 | show: 82 | @echo Make command goals: $(MAKECMDGOALS) 83 | @echo TARGET: $@ 84 | @echo ARCH: $(ARCH) 85 | @echo HOST: $(HOST) 86 | @echo PLAT: $(PLAT) 87 | @echo SO: $(SO) 88 | @echo CC: $(CC) 89 | @echo AR: $(AR) 90 | @echo RANLIB: $(RANLIB) 91 | @echo LD: $(LD) 92 | 93 | lua: $(LUA_LIB) 94 | 95 | lua51: 96 | $(MAKE) -C $(LUA_PATH)/src all \ 97 | CC="$(CC) -std=gnu99" \ 98 | AR="$(AR) rcu" \ 99 | RANLIB=$(RANLIB) \ 100 | MYCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN $(LUA_MYCFLAGS)" \ 101 | MYLIBS="-Wl,-E -ldl" \ 102 | SYSLIBS="-Wl,-E -ldl" 103 | 104 | lua54: 105 | $(MAKE) -C $(LUA_PATH)/src all \ 106 | CC="$(CC) -std=gnu99" \ 107 | AR="$(AR) rcu" \ 108 | RANLIB=$(RANLIB) \ 109 | SYSCFLAGS="-DLUA_USE_POSIX -DLUA_USE_DLOPEN" \ 110 | MYCFLAGS="$(LUA_MYCFLAGS)" \ 111 | SYSLIBS="-Wl,-E -ldl" 112 | 113 | lua-cjson: lua 114 | $(MAKE) -C lua-cjson LUA_INCLUDE_DIR=../$(LUA_PATH)/src CC=$(CC) 115 | 116 | luasocket: lua 117 | $(MAKE) -C luasocket linux LUAINC_linux=../../$(LUA_PATH)/src \ 118 | LUALIB_linux=../../$(LUA_PATH)/src/liblua.a \ 119 | CC_linux=$(CC) \ 120 | LD_linux=$(LD) \ 121 | LDFLAGS_linux="-O -fpic -shared -o" 122 | 123 | lpeg: lua 124 | $(MAKE) -C lpeg lpeg.$(SO) LUADIR=../$(LUA_PATH)/src/ DLLFLAGS="-shared -fPIC" 125 | 126 | lpeglabel: lua 127 | $(MAKE) -C lpeglabel lpeglabel.$(SO) LUADIR=../$(LUA_PATH)/src/ DLLFLAGS="-shared -fPIC" 128 | 129 | libuv-$(LIB_UV_TAG): 130 | git clone --depth 1 --branch $(LIB_UV_TAG) https://github.com/libuv/libuv libuv-$(LIB_UV_TAG) 131 | 132 | libuv-tag: libuv-$(LIB_UV_TAG) 133 | $(MAKE) -C libuv-$(LIB_UV_TAG) -f ../libuv-$(LIB_UV_TAG)_linux.mk CC=$(CC) 134 | 135 | libuv-dep: 136 | $(MAKE) -C luv/deps/libuv -f ../../../libuv_linux.mk CC=$(CC) 137 | 138 | libuv: libuv-$(LIB_UV_TARGET) 139 | 140 | luv-tag: 141 | $(MAKE) -C luv -f ../luv_linux.mk CC=$(CC) LIB_UV_PATH=../libuv-$(LIB_UV_TAG) $(LUA_VARS) 142 | 143 | luv-dep: 144 | $(MAKE) -C luv -f ../luv_linux.mk CC=$(CC) $(LUA_VARS) 145 | 146 | luv: lua libuv luv-$(LIB_UV_TARGET) 147 | 148 | luafilesystem lua-buffer luaserial lua-webview lua-linux luachild lua-struct: lua 149 | $(MAKE) -C $@ -f ../$@.mk CC=$(CC) LIBEXT=$(SO) $(LUA_VARS) 150 | 151 | lsqlite3: lua 152 | $(MAKE) -C $(LSQLITE) -f ../$@.mk CC=$(CC) LIBEXT=$(SO) $(LUA_VARS) 153 | 154 | luabt: lua 155 | $(MAKE) -C luabt -f ../luabt.mk CC=$(CC) LIBEXT=$(SO) $(BT_OPTS) $(LUA_VARS) 156 | 157 | lua-llthreads2: lua 158 | $(MAKE) -C $@/src -f ../../$@.mk CC=$(CC) LIBEXT=$(SO) $(LUA_VARS) 159 | 160 | zlib: 161 | $(MAKE) -C zlib -f ../zlib.mk CC=$(CC) 162 | 163 | lua-zlib: lua zlib 164 | $(MAKE) -C lua-zlib -f ../lua-zlib.mk PLAT=$(PLAT) CC=$(CC) LD=$(LD) AR=$(AR) RANLIB=$(RANLIB) $(LUA_VARS) 165 | 166 | ## perl Configure --cross-compile-prefix=arm-linux-gnueabihf- no-threads linux-armv4 -Wl,-rpath=. 167 | ## perl Configure no-threads linux-x86_64 -Wl,-rpath=. 168 | ## perl Configure no-threads linux-x86 -Wl,-rpath=. 169 | configure-openssl: 170 | cd openssl && perl Configure no-threads linux-$(ARCH) -Wl,-rpath=. 171 | 172 | configure-openssl-arm: 173 | cd openssl && perl Configure --cross-compile-prefix=$(HOST)- no-threads linux-armv4 -Wl,-rpath=. 174 | 175 | configure-openssl-aarch64: 176 | cd openssl && perl Configure --cross-compile-prefix=$(HOST)- no-threads linux-aarch64 -Wl,-rpath=. 177 | 178 | openssl: 179 | $(MAKE) -C openssl CC=$(CC) LD=$(LD) AR="$(AR)" 180 | 181 | lua-openssl: openssl 182 | $(MAKE) -C lua-openssl -f ../lua-openssl.mk PLAT=$(PLAT) OPENSSLDIR=../openssl CC=$(CC) LD=$(LD) AR=$(AR) $(LUA_OPENSSL_VARS) $(LUA_VARS) 183 | 184 | configure-libexpat-default: 185 | cd $(EXPAT) && sh configure 186 | 187 | configure-libexpat-arm configure-libexpat-aarch64: 188 | cd $(EXPAT) && sh configure --host=$(HOST) CC=$(HOST)-gcc LD=$(HOST)-gcc 189 | 190 | configure-libexpat: configure-libexpat-$(ARCH_SUFFIX) 191 | 192 | libexpat: 193 | $(MAKE) -C $(EXPAT)/lib 194 | 195 | luaexpat: lua libexpat 196 | $(MAKE) -C $@ -f ../$@.mk CC=$(CC) LIBEXT=$(SO) EXPAT=../$(EXPAT) $(LUA_VARS) 197 | 198 | lua-periphery: 199 | CROSS_COMPILE=$(HOST) $(MAKE) -C $@ LUA_INCDIR=../lua/src $(LUA_VARS) 200 | 201 | configure-libjpeg: 202 | cd lua-jpeg/libjpeg && sh configure CFLAGS='-O2 -fPIC' 203 | 204 | configure-libjpeg-arm configure-libjpeg-aarch64: 205 | cd lua-jpeg/libjpeg && sh configure --host=$(HOST) CC=$(HOST)-gcc LD=$(HOST)-gcc CFLAGS='-O2 -fPIC' 206 | 207 | libjpeg: 208 | $(MAKE) -C lua-jpeg/libjpeg libjpeg.la 209 | 210 | lua-jpeg: lua libjpeg 211 | $(MAKE) -C lua-jpeg -f ../lua-jpeg.mk CC=$(CC) LIBEXT=$(SO) $(LUA_VARS) 212 | 213 | configure-libexif: 214 | cd lua-exif/libexif && sh configure CFLAGS='-O2 -fPIC' 215 | 216 | configure-libexif-arm configure-libexif-aarch64: 217 | cd lua-exif/libexif && sh configure --host=$(HOST) CC=$(HOST)-gcc LD=$(HOST)-gcc CFLAGS='-O2 -fPIC' 218 | 219 | libexif: 220 | $(MAKE) -C lua-exif/libexif 221 | 222 | lua-exif: lua libexif 223 | $(MAKE) -C lua-exif -f ../lua-exif.mk CC=$(CC) LIBEXT=$(SO) $(LUA_VARS) 224 | 225 | 226 | .PHONY: full quick extras lua lua-buffer lua-cjson luafilesystem luasocket libuv luv lpeg luaexpat luaserial luabt \ 227 | zlib lua-zlib openssl lua-openssl libjpeg lua-jpeg libexif lua-exif lua-webview lua-llthreads2 lua-linux luachild lpeglabel lua-periphery lsqlite3 228 | 229 | -------------------------------------------------------------------------------- /main_mingw.mk: -------------------------------------------------------------------------------- 1 | 2 | PLAT = windows 3 | SO = so 4 | CC = gcc 5 | 6 | LUA_PATH = lua 7 | LUA_LIB = lua54 8 | 9 | LUA_VARS = LUA_LIB=$(LUA_LIB) LUA_PATH=$(LUA_PATH) 10 | 11 | ifdef CLIBS_DEBUG 12 | LUA_MYCFLAGS = -g -DLUA_USE_APICHECK 13 | endif 14 | 15 | ifdef CLIBS_NDEBUG 16 | LUA_MYCFLAGS += -DNDEBUG 17 | endif 18 | 19 | ifeq ($(LUA_OPENSSL_LINKING),dynamic) 20 | LUA_OPENSSL_VARS = 21 | else 22 | LUA_OPENSSL_VARS = OPENSSL_STATIC=1 23 | endif 24 | 25 | EXPAT=expat-2.5.0 26 | LSQLITE=lsqlite3_v096 27 | 28 | all any: full 29 | 30 | core: lua lua-buffer luasocket luafilesystem lua-cjson luv lpeg lua-zlib lua-llthreads2 luachild lpeglabel lua-struct 31 | 32 | quick: core luaserial lua-jpeg lua-exif luaexpat 33 | 34 | extras: winapi lua-win32 lua-webview luabt 35 | 36 | full: quick lua-openssl extras 37 | 38 | configure: configure-libjpeg configure-libexif configure-openssl configure-libexpat 39 | 40 | show show-main: 41 | @echo Make command goals: $(MAKECMDGOALS) 42 | @echo TARGET: $@ 43 | @echo ARCH: $(ARCH) 44 | @echo HOST: $(HOST) 45 | @echo PLAT: $(PLAT) 46 | @echo LUA_LIB: $(LUA_LIB) 47 | @echo LUA_PATH: $(LUA_PATH) 48 | @echo SO: $(SO) 49 | @echo CC: $(CC) 50 | @echo AR: $(AR) 51 | @echo RANLIB: $(RANLIB) 52 | @echo LD: $(LD) 53 | 54 | wlua.res: wlua.rc 55 | windres wlua.rc -O coff -o $(LUA_PATH)/src/wlua.res 56 | 57 | lua: wlua.res 58 | $(MAKE) -C $(LUA_PATH)/src "LUA_A=$(LUA_LIB).dll" "LUA_T=lua.exe" \ 59 | "AR=$(CC) -static-libgcc -shared -o" "RANLIB=strip --strip-unneeded" \ 60 | "SYSCFLAGS=-DLUA_BUILD_AS_DLL" "SYSLIBS=" "SYSLDFLAGS=-s" lua.exe 61 | $(MAKE) -C $(LUA_PATH)/src "LUAC_T=luac.exe" luac.exe 62 | $(MAKE) -C $(LUA_PATH)/src MYCFLAGS="$(LUA_MYCFLAGS)" "LUA_A=$(LUA_LIB).dll" "LUA_T=wlua.exe" "LIBS=wlua.res" \ 63 | "SYSCFLAGS=-DLUA_BUILD_AS_DLL" "SYSLIBS=" "SYSLDFLAGS=-s -mwindows" wlua.exe 64 | 65 | lua-cjson: lua 66 | $(MAKE) -C lua-cjson TARGET=cjson.$(SO) \ 67 | CJSON_CFLAGS=-DDISABLE_INVALID_NUMBERS \ 68 | "CJSON_LDFLAGS=-O -shared -Wl,-s -static-libgcc -L../$(LUA_PATH)/src -l$(LUA_LIB)" \ 69 | LUA_BIN_SUFFIX=.lua \ 70 | LUA_INCLUDE_DIR=../$(LUA_PATH)/src CC=$(CC) 71 | 72 | luasocket: lua 73 | $(MAKE) -C luasocket mingw LUAINC_mingw=../../$(LUA_PATH)/src \ 74 | DEF_mingw="-DLUASOCKET_NODEBUG -DWINVER=0x0501" \ 75 | LUALIB_mingw="-L../../$(LUA_PATH)/src -l$(LUA_LIB)" 76 | 77 | lpeg: lua 78 | $(MAKE) -C lpeg -f ../lpeg.mk lpeg.$(SO) \ 79 | LUADIR=../$(LUA_PATH)/src/ \ 80 | DLLFLAGS="-O -shared -fPIC -Wl,-s -static-libgcc -L../$(LUA_PATH)/src -l$(LUA_LIB)" 81 | 82 | lpeglabel: lua 83 | $(MAKE) -C lpeglabel -f ../lpeglabel.mk lpeglabel.$(SO) \ 84 | LUADIR=../$(LUA_PATH)/src/ \ 85 | DLLFLAGS="-O -shared -fPIC -Wl,-s -static-libgcc -L../$(LUA_PATH)/src -l$(LUA_LIB)" 86 | 87 | libuv: 88 | $(MAKE) -C luv/deps/libuv -f ../../../libuv_mingw.mk CC=$(CC) 89 | 90 | luv: lua libuv 91 | $(MAKE) -C luv -f ../luv_mingw.mk $(LUA_VARS) 92 | 93 | luafilesystem lua-webview lua-buffer lua-win32 luaserial luabt winapi luachild lua-struct: lua 94 | $(MAKE) -C $@ -f ../$@.mk CC=$(CC) LIBEXT=$(SO) $(LUA_VARS) 95 | 96 | lsqlite3: lua 97 | $(MAKE) -C $(LSQLITE) -f ../$@.mk CC=$(CC) LIBEXT=$(SO) $(LUA_VARS) 98 | 99 | lua-llthreads2: lua 100 | $(MAKE) -C $@/src -f ../../$@.mk CC=$(CC) LIBEXT=$(SO) $(LUA_VARS) 101 | 102 | zlib: 103 | $(MAKE) -C zlib -f ../zlib.mk 104 | 105 | lua-zlib: lua zlib 106 | $(MAKE) -C lua-zlib -f ../lua-zlib.mk PLAT=$(PLAT) $(LUA_VARS) 107 | 108 | configure-openssl- configure-openssl-i686: 109 | cd openssl && perl Configure no-threads mingw 110 | 111 | configure-openssl-x86_64: 112 | cd openssl && perl Configure no-threads mingw64 113 | 114 | configure-openssl: configure-openssl-$(ARCH) 115 | 116 | openssl: 117 | $(MAKE) -C openssl LD=$(LD) 118 | 119 | lua-openssl: lua openssl 120 | $(MAKE) -C lua-openssl -f ../lua-openssl.mk $(LUA_OPENSSL_VARS) PLAT=$(PLAT) $(LUA_VARS) 121 | 122 | configure-libexpat: 123 | cd $(EXPAT) && sh configure 124 | 125 | libexpat: 126 | $(MAKE) -C $(EXPAT) 127 | 128 | luaexpat: lua libexpat 129 | $(MAKE) -C $@ -f ../$@.mk CC=$(CC) LIBEXT=$(SO) EXPAT=../$(EXPAT) $(LUA_VARS) 130 | 131 | configure-libjpeg: 132 | cd lua-jpeg/libjpeg && sh configure CFLAGS='-O2 -fPIC' 133 | 134 | libjpeg: 135 | $(MAKE) -C lua-jpeg/libjpeg 136 | 137 | lua-jpeg: lua libjpeg 138 | $(MAKE) -C lua-jpeg -f ../lua-jpeg.mk CC=$(CC) LIBEXT=$(SO) $(LUA_VARS) 139 | 140 | configure-libexif: 141 | cd lua-exif/libexif && sh configure CFLAGS='-O2 -fPIC' 142 | 143 | libexif: 144 | $(MAKE) -C lua-exif/libexif 145 | 146 | lua-exif: lua libexif 147 | $(MAKE) -C lua-exif -f ../lua-exif.mk CC=$(CC) LIBEXT=$(SO) $(LUA_VARS) 148 | 149 | .PHONY: full quick extras lua lua-buffer luasocket luafilesystem lua-cjson libuv luv lpeg \ 150 | luaexpat luaserial luabt zlib lua-zlib openssl lua-openssl libjpeg \ 151 | lua-jpeg libexif lua-exif lua-webview winapi lua-win32 lua-llthreads2 luachild lpeglabel lsqlite3 152 | -------------------------------------------------------------------------------- /tools/addlibs.c: -------------------------------------------------------------------------------- 1 | // see addlibs.lua 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #ifdef JLS_LUA_MOD_TRACE 11 | #include 12 | #define trace(...) printf(__VA_ARGS__) 13 | #else 14 | #define trace(...) ((void)0) 15 | #endif 16 | 17 | struct custom_preload { 18 | unsigned char *name; 19 | int index; 20 | int size; 21 | }; 22 | 23 | #include "addlibs-custom.c" 24 | 25 | static unsigned char* inflate_chunk(const unsigned char* deflated, int deflated_size, int inflated_size) { 26 | int ret; 27 | z_stream strm; 28 | unsigned char* inflated; 29 | 30 | strm.zalloc = Z_NULL; 31 | strm.zfree = Z_NULL; 32 | strm.opaque = Z_NULL; 33 | strm.avail_in = 0; 34 | strm.next_in = Z_NULL; 35 | 36 | ret = inflateInit2(&strm, WINDOW_BITS); 37 | if ((ret != Z_OK) && (ret != Z_STREAM_END)) { 38 | return NULL; 39 | } 40 | 41 | inflated = malloc(inflated_size + 1); 42 | 43 | strm.avail_in = deflated_size; 44 | strm.next_in = (unsigned char*) deflated; 45 | 46 | strm.avail_out = inflated_size; 47 | strm.next_out = inflated; 48 | 49 | ret = inflate(&strm, Z_NO_FLUSH); 50 | if (ret != Z_STREAM_END) { 51 | free(inflated); 52 | return NULL; 53 | } 54 | (void) inflateEnd(&strm); 55 | 56 | return inflated; 57 | } 58 | 59 | static void load_deflated_chunk(lua_State *L, const char *name, const unsigned char* deflated, int deflated_size, int inflated_size) { 60 | int ret; 61 | unsigned char* inflated; 62 | 63 | inflated = inflate_chunk(deflated, deflated_size, inflated_size); 64 | if (inflated == NULL) { 65 | luaL_error(L, "inflate error!"); 66 | return; 67 | } 68 | ret = luaL_loadbuffer(L, (const char*)inflated, inflated_size, name); 69 | free(inflated); 70 | if (ret != LUA_OK) { 71 | lua_pop(L, 1); /* the error message */ 72 | luaL_error(L, "unable to load chunk!!"); 73 | return; 74 | } 75 | } 76 | 77 | static int preload_custom_rawget(lua_State *L, int index, const char *name, int nresults) { 78 | if ((index < 0) || (index > PRELOADS_INDEX)) { 79 | luaL_error(L, "invalid preload index!"); 80 | return 0; 81 | } 82 | const struct custom_preload* cp = custom_preloads + index; 83 | const struct custom_preload* cpn = cp + 1; 84 | trace("preload_custom_rawget(%d, '%s', %d) at %d, size: %d - %d\n", index, name, nresults, cp->index, cpn->index - cp->index, cp->size); 85 | load_deflated_chunk(L, name, custom_chunk_preloads + cp->index, cpn->index - cp->index, cp->size); 86 | lua_pushstring(L, name); 87 | lua_call(L, 1, nresults); 88 | return nresults; 89 | } 90 | 91 | static int preload_custom_find(const char *name, int from) { 92 | const struct custom_preload* cp; 93 | int index; 94 | for (index = from; ; index++) { 95 | cp = custom_preloads + index; 96 | if (cp->name == NULL) { 97 | break; 98 | } 99 | if (strcmp(name, cp->name) == 0) { 100 | return index; 101 | } 102 | } 103 | return -1; 104 | } 105 | 106 | static int preload_custom_get(lua_State *L) { 107 | const char *name = luaL_checkstring(L, 1); 108 | int index = preload_custom_find(name, 0); 109 | trace("preload_custom_get('%s') => %d\n", name, index); 110 | return preload_custom_rawget(L, index, name, 1); 111 | } 112 | 113 | #ifdef RESOURCES_INDEX 114 | static int preload_custom_res(lua_State *L) { 115 | const struct custom_preload* cp; 116 | const struct custom_preload* cpn; 117 | unsigned char* inflated; 118 | const char *name = luaL_checkstring(L, 1); 119 | int index = preload_custom_find(name, RESOURCES_INDEX); 120 | trace("preload_custom_res('%s') => %d\n", name, index); 121 | if (index > 0) { 122 | cp = custom_preloads + index; 123 | cpn = cp + 1; 124 | inflated = inflate_chunk(custom_chunk_preloads + cp->index, cpn->index - cp->index, cp->size); 125 | if (inflated) { 126 | lua_pushlstring(L, inflated, cp->size); 127 | free(inflated); 128 | return 1; 129 | } 130 | } 131 | return 0; 132 | } 133 | #endif 134 | 135 | /* override Lua openlibs to add user libraries */ 136 | 137 | static const luaL_Reg loadedlibs[] = { 138 | {LUA_GNAME, luaopen_base}, 139 | {LUA_LOADLIBNAME, luaopen_package}, 140 | {LUA_COLIBNAME, luaopen_coroutine}, 141 | {LUA_TABLIBNAME, luaopen_table}, 142 | {LUA_IOLIBNAME, luaopen_io}, 143 | {LUA_OSLIBNAME, luaopen_os}, 144 | {LUA_STRLIBNAME, luaopen_string}, 145 | {LUA_MATHLIBNAME, luaopen_math}, 146 | {LUA_UTF8LIBNAME, luaopen_utf8}, 147 | {LUA_DBLIBNAME, luaopen_debug}, 148 | {NULL, NULL} 149 | }; 150 | 151 | LUALIB_API void luaL_openlibs(lua_State *L) { 152 | const struct custom_preload* cp; 153 | const struct custom_preload* cpn; 154 | unsigned char* inflated; 155 | const char **pname; 156 | const luaL_Reg *lib; 157 | char *env; 158 | for (lib = loadedlibs; lib->func; lib++) { 159 | luaL_requiref(L, lib->name, lib->func, 1); 160 | lua_pop(L, 1); 161 | } 162 | /* custom part */ 163 | env = getenv("JLS_STATIC_PRELOADS"); 164 | #ifdef RESOURCES_INDEX 165 | if (env == NULL || strstr(env, "res")) { 166 | lua_getglobal(L, "package"); 167 | luaL_getsubtable(L, -1, "resource"); 168 | for (cp = custom_preloads + RESOURCES_INDEX; cp->name; cp++) { 169 | trace("preload resource '%s'\n", cp->name); 170 | lua_pushcfunction(L, preload_custom_res); 171 | lua_setfield(L, -2, cp->name); 172 | } 173 | lua_pop(L, 2); 174 | } 175 | #endif 176 | if (env == NULL || strstr(env, "lib")) { 177 | luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_PRELOAD_TABLE); 178 | for (lib = custom_libs; lib->func; lib++) { 179 | trace("preload lib '%s'\n", lib->name); 180 | lua_pushcfunction(L, lib->func); 181 | lua_setfield(L, -2, lib->name); 182 | } 183 | lua_pop(L, 1); 184 | } 185 | if (env == NULL || strstr(env, "lua")) { 186 | luaL_getsubtable(L, LUA_REGISTRYINDEX, LUA_PRELOAD_TABLE); 187 | for (cp = custom_preloads; cp->name; cp++) { 188 | trace("preload lua '%s'\n", cp->name); 189 | lua_pushcfunction(L, preload_custom_get); 190 | lua_setfield(L, -2, cp->name); 191 | } 192 | lua_pop(L, 1); 193 | preload_custom_rawget(L, PRELOADS_INDEX, ":preloads:", 0); 194 | } 195 | if (env != NULL && strstr(env, "show")) { 196 | printf("--[[\npreload C modules:\n"); 197 | for (lib = custom_libs; lib->func; lib++) { 198 | printf(" \"%s\"\n", lib->name); 199 | } 200 | printf("]]\n"); 201 | for (cp = custom_preloads; cp->name; cp++) { 202 | printf("package.preload[\"%s\"] = function(...)\n", cp->name); 203 | cpn = cp + 1; 204 | inflated = inflate_chunk(custom_chunk_preloads + cp->index, cpn->index - cp->index, cp->size); 205 | if (inflated) { 206 | fwrite(inflated, cp->size, 1, stdout); 207 | fflush(stdout); 208 | free(inflated); 209 | } 210 | printf("\nend\n"); 211 | } 212 | } 213 | /* end custom part */ 214 | } 215 | -------------------------------------------------------------------------------- /tools/addlibs.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | This Lua script generates the content of the "addlibs-custom.c" file. 3 | The syntax is "-c ... -l|-L ... -r|-R ...". 4 | The "addlibs-custom.c" file is used in conjonction with the "addlibs.c" C file to add custom Lua loaders. 5 | The Lua function "luaL_openlibs" is overrided in order to add loaders in the table "package.preload". 6 | The loaders consists in C functions available in the executable and external Lua files. 7 | The resources, if any, are added to the table "package.resource". 8 | 9 | The Lua application open standard libraries, create table "arg", execute arguments "-e" and "-l", execute main script. 10 | It is possible to run a preloaded Lua script with the following arguments: 11 | -e "require('')" NUL 12 | -l /dev/null 13 | ]] 14 | 15 | local lz = require('zlib') 16 | local fs = require('lfs') 17 | local dumbParser = require('dumbParser') 18 | 19 | local windowBits = -15 20 | local minDeflatedSize = 512 21 | 22 | -- helper functions 23 | 24 | local function compareByName(a, b) 25 | return a.name < b.name 26 | end 27 | 28 | local function charToHex(c) 29 | return string.format('0x%02x, ', string.byte(c)) 30 | end 31 | 32 | local function stringToHex(s) 33 | return (string.gsub(s, '.', charToHex)) 34 | end 35 | 36 | local function deflate(data) 37 | return lz.deflate(lz.BEST_COMPRESSION, windowBits)(data, 'finish') 38 | end 39 | 40 | local function getFilename(filename) 41 | return (string.gsub(filename, '^.*[/\\]', '', 1)) 42 | end 43 | 44 | local function getBaseName(filename) 45 | local n, e = string.match(filename, '^(.+)%.([^/\\%.]*)$') 46 | return n or filename, e 47 | end 48 | 49 | local function forEach(filename, fn, dirPath, recursive, sep, path) 50 | local mode = fs.attributes(filename, 'mode') 51 | if path and path ~= '' then 52 | path = path..(sep or '.') 53 | else 54 | path = '' 55 | end 56 | local fname = getFilename(filename) 57 | if mode == 'file' then 58 | local bname, ext = getBaseName(fname) 59 | fn(filename, path..bname, ext) 60 | elseif mode == 'directory' and (recursive or path == '') then 61 | if path ~= '' or dirPath then 62 | path = path..fname 63 | end 64 | for n in fs.dir(filename) do 65 | if n ~= '.' and n ~= '..' then 66 | forEach(filename..'/'..n, fn, dirPath, recursive, sep, path) 67 | end 68 | end 69 | end 70 | end 71 | 72 | local function stripLua(lua) 73 | if lua then 74 | local tree = assert(dumbParser.parse(lua)) 75 | if tree then 76 | return dumbParser.toLua(tree) 77 | end 78 | end 79 | end 80 | 81 | local function readFile(filename) 82 | local data 83 | local f = io.open(filename, 'rb') 84 | if f then 85 | data = f:read('*a') 86 | f:close() 87 | end 88 | return data 89 | end 90 | 91 | -- collect arguments 92 | 93 | local luasubnames = {} 94 | local libnames = {} 95 | local luanames = {} 96 | local resnames = {} 97 | local ressubnames = {} 98 | local prenames = {} 99 | local printPreloads = false 100 | local l = libnames 101 | for _, value in ipairs(arg) do 102 | if value == '-c' then 103 | l = libnames 104 | elseif value == '-l' then 105 | l = luanames 106 | elseif value == '-L' then 107 | l = luasubnames 108 | elseif value == '-r' then 109 | l = resnames 110 | elseif value == '-R' then 111 | l = ressubnames 112 | elseif value == '-p' then 113 | l = prenames 114 | elseif value == '-pp' then 115 | printPreloads = not printPreloads 116 | else 117 | table.insert(l, value) 118 | end 119 | end 120 | 121 | local luafiles = {} 122 | local function addLuaFile(file, name, ext) 123 | if ext == 'lua' then 124 | table.insert(luafiles, {file = file, name = name}) 125 | end 126 | end 127 | local resfiles = {} 128 | local function addResFile(file, name, ext) 129 | if ext ~= 'lua' then 130 | table.insert(resfiles, {file = file, name = name..'.'..ext}) 131 | end 132 | end 133 | for _, luaname in ipairs(luanames) do 134 | forEach(luaname, addLuaFile, true, true) 135 | end 136 | for _, luaname in ipairs(luasubnames) do 137 | forEach(luaname, addLuaFile) 138 | end 139 | for _, luaname in ipairs(resnames) do 140 | forEach(luaname, addResFile, false, false, '/') 141 | end 142 | for _, luaname in ipairs(ressubnames) do 143 | forEach(luaname, addResFile, true, true, '/') 144 | end 145 | table.sort(luafiles, compareByName) 146 | table.sort(resfiles, compareByName) 147 | 148 | local lines = {} 149 | 150 | table.insert(lines, '// Generated custom preloads\n\n') 151 | 152 | -- list C libraries 153 | 154 | for _, libname in ipairs(libnames) do 155 | table.insert(lines, string.format('int luaopen_%s(lua_State *L);\n', libname)) 156 | end 157 | 158 | table.insert(lines, [[ 159 | 160 | static const luaL_Reg custom_libs[] = { 161 | ]]) 162 | for _, libname in ipairs(libnames) do 163 | table.insert(lines, string.format(' {"%s", luaopen_%s},\n', libname, libname)) 164 | end 165 | table.insert(lines, [[ 166 | {NULL, NULL} 167 | }; 168 | 169 | ]]) 170 | 171 | -- list preloads 172 | 173 | local preloads = {} 174 | local luaPreloads = {} 175 | local index, deflateIndex, total = 0, 0, 0 176 | 177 | local function addDeflated(item, data) 178 | local deflated = assert(deflate(data)) 179 | table.insert(lines, string.format(' {"%s", %d, %d},\n', item.name, deflateIndex, #data)) 180 | table.insert(preloads, deflated) 181 | index = index + 1 182 | deflateIndex = deflateIndex + #deflated 183 | total = total + #data 184 | end 185 | 186 | table.insert(lines, 'static const struct custom_preload custom_preloads[] = {\n') 187 | 188 | for _, item in ipairs(luafiles) do 189 | local lua = stripLua(readFile(item.file)) 190 | if lua and #lua > 0 then 191 | if #lua > minDeflatedSize then 192 | addDeflated(item, lua) 193 | else 194 | table.insert(luaPreloads, string.format('package.preload["%s"] = function(...)\n', item.name)) 195 | table.insert(luaPreloads, lua) 196 | table.insert(luaPreloads, '\nend\n') 197 | end 198 | end 199 | end 200 | 201 | local preloadsIndex = index 202 | for _, prename in ipairs(prenames) do 203 | local lua = readFile(prename) 204 | if lua then 205 | table.insert(luaPreloads, lua) 206 | table.insert(luaPreloads, '\n') 207 | end 208 | end 209 | local lua = stripLua(table.concat(luaPreloads)) 210 | local deflated = assert(deflate(lua)) 211 | table.insert(lines, string.format(' {NULL, %d, %d},\n', deflateIndex, #lua)) 212 | table.insert(preloads, deflated) 213 | index = index + 1 214 | deflateIndex = deflateIndex + #deflated 215 | total = total + #lua 216 | 217 | local resIndex = 0 218 | if #resfiles > 0 then 219 | table.insert(lines, string.format(' {NULL, %d, %d},\n', deflateIndex, 0)) 220 | index = index + 1 221 | resIndex = index 222 | for _, item in ipairs(resfiles) do 223 | local res = readFile(item.file) 224 | if res and #res > 0 then 225 | addDeflated(item, res) 226 | end 227 | end 228 | end 229 | 230 | table.insert(lines, string.format(' {NULL, %d, %d}\n', deflateIndex, 0)) 231 | table.insert(lines, '};\n\n') 232 | 233 | table.insert(lines, string.format('#define WINDOW_BITS %d\n', windowBits)) 234 | if resIndex > 0 then 235 | table.insert(lines, string.format('#define RESOURCES_INDEX %d\n', resIndex)) 236 | end 237 | table.insert(lines, string.format('#define PRELOADS_INDEX %d\n', preloadsIndex)) 238 | 239 | -- print preloads as comment 240 | 241 | if printPreloads then 242 | table.insert(lines, '\n/*\n') 243 | for _, preload in ipairs(luaPreloads) do 244 | table.insert(lines, (string.gsub(preload, '%*/', '* /'))) 245 | end 246 | table.insert(lines, '\n*/\n') 247 | end 248 | 249 | -- generate preloads blob 250 | 251 | table.insert(lines, '\nstatic const unsigned char custom_chunk_preloads[] = {\n') 252 | for _, preload in ipairs(preloads) do 253 | table.insert(lines, stringToHex(preload)) 254 | end 255 | table.insert(lines, '\n};\n') 256 | 257 | -- write generated file 258 | 259 | for _, line in ipairs(lines) do 260 | io.stdout:write(line) 261 | end 262 | 263 | io.stderr:write(string.format('addlibs generated, deflate ratio is %s for %d modules, using %d kbytes\n', (total * 10 // deflateIndex) / 10, index, deflateIndex // 1024)) 264 | -------------------------------------------------------------------------------- /tools/addwebview.lua: -------------------------------------------------------------------------------- 1 | if type(package.resource) == 'table' then 2 | local wp = package.preload['webview'] 3 | local wr = package.resource['WebView2Loader.dll'] 4 | if type(wp) == 'function' and type(wr) == 'function' then 5 | package.preload['webview'] = function(name) 6 | local wv = wp(name) 7 | local wl = wr('WebView2Loader.dll') 8 | if wl and wv and wv.loadWebView2Dll then 9 | wv.loadWebView2Dll(wl) 10 | end 11 | return wv 12 | end 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /tools/changemain.c: -------------------------------------------------------------------------------- 1 | // see changemain.lua 2 | 3 | #if defined(_WIN32) 4 | #define NULL_SCRIPT "NUL" 5 | #else 6 | #define NULL_SCRIPT "/dev/null" 7 | #endif 8 | 9 | int main (int argc, char **argv) { 10 | int status; 11 | char **rargv; 12 | int rargc; 13 | char **parg; 14 | char *papp; 15 | char *pscr; 16 | int lapp; 17 | if (argv[0] == NULL) { 18 | return 1; // not supported 19 | } 20 | #if defined(_WIN32) 21 | papp = strrchr(argv[0], '\\'); 22 | #else 23 | papp = strrchr(argv[0], '/'); 24 | #endif 25 | if (papp == NULL) { 26 | papp = argv[0]; 27 | } 28 | pscr = getenv("JLS_LUA_PROGNAME"); 29 | if (pscr == NULL) { 30 | pscr = LUA_PROGNAME; 31 | } 32 | if (strstr(papp, pscr) != NULL) { 33 | return base_main(argc, argv); 34 | } 35 | rargv = malloc(sizeof(char *) * (argc + 6)); 36 | if (rargv == NULL) { 37 | return 12; 38 | } 39 | rargc = 0; 40 | rargv[rargc++] = argv[0]; 41 | #if defined(CUSTOM_EXECUTE) 42 | pscr = NULL; 43 | rargv[rargc++] = "-e"; 44 | rargv[rargc++] = CUSTOM_EXECUTE; 45 | rargv[rargc++] = NULL_SCRIPT; 46 | #else 47 | lapp = strlen(argv[0]); 48 | pscr = malloc(sizeof(char) * (lapp + 5)); 49 | if (pscr == NULL) { 50 | free(rargv); 51 | return 12; 52 | } 53 | #if defined(_WIN32) 54 | if (lapp > 4 && strcmp(argv[0] + lapp - 4, ".exe") == 0) { 55 | strcpy(pscr, argv[0]); 56 | strcpy(pscr + lapp - 4, ".lua"); 57 | } else { 58 | sprintf(pscr, "%s.lua", argv[0]); 59 | } 60 | #else 61 | sprintf(pscr, "%s.lua", argv[0]); 62 | #endif 63 | rargv[rargc++] = pscr; 64 | #endif 65 | for (parg = argv + 1; *parg; parg++) { 66 | rargv[rargc++] = *parg; 67 | } 68 | rargv[rargc] = NULL; 69 | //for (int i = 0; rargv[i]; i++) printf("%d:\t%s\n", i, rargv[i]); 70 | status = base_main(rargc, rargv); 71 | free(rargv); 72 | free(pscr); 73 | return status; 74 | } 75 | -------------------------------------------------------------------------------- /tools/changemain.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | This Lua script generates a C file on the standard output. 3 | The syntax is "/src/lua.c [Lua code to execute]". 4 | The generated file is used in conjonction with the "changemain.c" C file to override 5 | the Lua main function in order to execute Lua code. 6 | 7 | If the executable name contains "lua" then the default Lua syntax is preserved. 8 | If a Lua code to execute is provided then the executable will only executes this code. 9 | Otherwise, if the executable name is "example" then the script "example.lua" is executed. 10 | ]] 11 | 12 | local function charToHex(c) 13 | return string.format('0x%02x, ', string.byte(c)) 14 | end 15 | local function stringToHex(s) 16 | return (string.gsub(s, '.', charToHex)) 17 | end 18 | 19 | local function readFile(filename) 20 | local data 21 | local f = io.open(filename, 'r') 22 | if f then 23 | data = f:read('a') 24 | f:close() 25 | end 26 | return data 27 | end 28 | 29 | local function replace(s, p, r, n) 30 | local rs, rn = string.gsub(s, p, r, n) 31 | assert(rn == n, 'unable to replace') 32 | return rs 33 | end 34 | 35 | 36 | local luac = arg[1] or 'lua/src/lua.c' 37 | local execute = arg[2] 38 | 39 | local cc = assert(readFile(luac)) 40 | cc = replace(cc, '\n *int +main *%(', '\nstatic int base_main (', 1) 41 | if execute and execute ~= '' then 42 | io.stdout:write(string.format([[ 43 | 44 | #define CUSTOM_EXECUTE custom_execute 45 | 46 | static char custom_execute[] = {%s0x00}; 47 | 48 | ]], stringToHex(execute))) 49 | cc = replace(cc, '\n *static +int +handle_script *%(', [[ 50 | 51 | static int handle_script (lua_State *L, char **argv) { 52 | return LUA_OK; 53 | } 54 | 55 | static int base_handle_script(]], 1) 56 | end 57 | 58 | io.stdout:write(cc) 59 | 60 | io.stdout:write([[ 61 | 62 | #include "changemain.c" 63 | 64 | ]]) 65 | -------------------------------------------------------------------------------- /tools/compat.lua: -------------------------------------------------------------------------------- 1 | --[[ 2 | This Lua script transpiles Lua files from the latest version, 5.4, to an oldest, 5.1 3 | The syntax is "-t= [-pretty] ...". 4 | ]] 5 | 6 | local fs = require('lfs') 7 | local ast = require('jls.util.ast') 8 | 9 | local function getFilename(filename) 10 | return (string.gsub(filename, '^.*[/\\]', '', 1)) 11 | end 12 | 13 | local function getBaseName(filename) 14 | local n, e = string.match(filename, '^(.+)%.([^/\\%.]*)$') 15 | return n or filename, e 16 | end 17 | 18 | local function forEach(filename, onFile, onDir, path) 19 | local mode = fs.attributes(filename, 'mode') 20 | if path then 21 | path = path..'/' 22 | else 23 | path = '' 24 | end 25 | local fname = getFilename(filename) 26 | if mode == 'file' then 27 | local _, ext = getBaseName(fname) 28 | if ext == 'lua' then 29 | onFile(filename, path..fname) 30 | end 31 | elseif mode == 'directory' then 32 | path = path..fname 33 | if onDir then 34 | onDir(path) 35 | end 36 | for n in fs.dir(filename) do 37 | if n ~= '.' and n ~= '..' then 38 | forEach(filename..'/'..n, onFile, onDir, path) 39 | end 40 | end 41 | end 42 | end 43 | 44 | local function readFile(filename) 45 | local data 46 | local f = io.open(filename, 'r') 47 | if f then 48 | data = f:read('*a') 49 | f:close() 50 | end 51 | return data 52 | end 53 | 54 | local function mkDir(path) 55 | if fs.attributes(path, 'mode') == 'directory' then 56 | return true 57 | end 58 | print(string.format('creating directory "%s"', path)) 59 | return fs.mkdir(path) 60 | end 61 | 62 | local luanames = {} 63 | local pretty = false 64 | local target 65 | for _, value in ipairs(arg) do 66 | if value == '-pretty' then 67 | pretty = true 68 | else 69 | local k, v = string.match(value, '^%-(%w+)[=:](.*)$') 70 | if k == 't' then 71 | target = v 72 | else 73 | table.insert(luanames, value) 74 | end 75 | end 76 | end 77 | 78 | assert(mkDir(target)) 79 | 80 | local count = 0 81 | for _, luaname in ipairs(luanames) do 82 | forEach(luaname, function(filename, path) 83 | local targetPath = target..'/'..path 84 | --print(string.format('processing "%s" to "%s"', filename, targetPath)) 85 | local content = readFile(filename) 86 | local tree = assert(ast.parse(content)) 87 | local fd = assert(io.open(targetPath, 'wb')) 88 | if path ~= 'jls/util/compat.lua' then 89 | local _, updated = ast.traverse(tree, ast.toLua51) 90 | if updated then 91 | fd:write('local compat = require("jls.util.compat");') 92 | if pretty then 93 | fd:write('\n') 94 | end 95 | end 96 | end 97 | if pretty then 98 | tree.pretty = true 99 | end 100 | local cc = ast.generate(tree) 101 | fd:write(cc) 102 | fd:close() 103 | count = count + 1 104 | end, function(path) 105 | assert(mkDir(target..'/'..path)) 106 | end) 107 | end 108 | 109 | print(string.format('%d Lua files processed to "%s"', count, target)) 110 | -------------------------------------------------------------------------------- /tools/luaunit-patch.lua: -------------------------------------------------------------------------------- 1 | ---@diagnostic disable: deprecated, undefined-global 2 | 3 | if not arg and process and type(process.argv) == 'table' then 4 | local status, shiftArguments = pcall(require, 'jls.lang.shiftArguments') 5 | if status then 6 | _G.arg = shiftArguments(process.argv, 1) 7 | end 8 | end 9 | 10 | local M = require('luaunit-') 11 | 12 | if jit and process and getfenv then 13 | local oldRun = M.LuaUnit.run 14 | function M.LuaUnit.run(...) 15 | for k, v in pairs(getfenv(2)) do 16 | if type(k) == 'string' and k:sub(1, 4):lower() == 'test' then 17 | _G[k] = v 18 | end 19 | end 20 | return oldRun(...) 21 | end 22 | end 23 | 24 | return M -------------------------------------------------------------------------------- /tools/pkg-config.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | 3 | # Naive pkg-config helper for cross compilation 4 | # This script extracts the configurations, headers and libraries from the target then simulates pkg-config on the compile host. 5 | 6 | # On the target, the following command creates a zip, 'pkg-config.zip', containing the config, headers and libraries for all the listed packages 7 | # pkg-config.sh --config --archive 8 | 9 | # On the compile host, unzip 'pkg-config.zip' to a 'pkg' folder 10 | # then export the environment variable 'PKG_HOME' with the full path of the 'pkg' folder 11 | # then create a link 'pkg-config' on the path to 'pkg-config.sh' 12 | 13 | PKG_HOME="${PKG_HOME:-}" 14 | 15 | ZIP_NAME="${ZIP_NAME:-pkg-config.zip}" 16 | CFG_NAME="${CFG_NAME:-pkg-config.txt}" 17 | if test -n "$PKG_HOME" 18 | then 19 | ZIP_PATH="$PKG_HOME/$ZIP_NAME" 20 | CFG_PATH="$PKG_HOME/$CFG_NAME" 21 | else 22 | ZIP_PATH="$ZIP_NAME" 23 | CFG_PATH="$CFG_NAME" 24 | fi 25 | 26 | # Collect options and packages from arguments 27 | OPTS="" 28 | PKGS="" 29 | ADD_LIBS="" 30 | ADD_FILES="" 31 | for ARG in "$@" 32 | do 33 | case "$ARG" in 34 | --help) 35 | echo "$0 [--cflags|--libs|--config|--archive] [package ...]" 1>&2 36 | exit 0 37 | ;; 38 | --*) 39 | OPTS="$OPTS $ARG" 40 | ;; 41 | bluetooth) 42 | ADD_FILES="$ADD_FILES /usr/include/$ARG" 43 | ADD_LIBS="$ADD_LIBS $ARG" 44 | ;; 45 | *) 46 | PKGS="$PKGS $ARG" 47 | ;; 48 | esac 49 | done 50 | 51 | # When there is no option, indicates if the packages are availables 52 | if test ! -n "$OPTS" 53 | then 54 | for PKG in $PKGS 55 | do 56 | if ! grep -q "pkg-$PKG--" $CFG_PATH 57 | then 58 | exit 1 59 | fi 60 | done 61 | exit 0 62 | fi 63 | 64 | CFG_OUT="" 65 | 66 | # Process the options 67 | for OPT in $OPTS 68 | do 69 | case "$OPT" in 70 | --cflags|--libs) 71 | # root is $CC -print-sysroot 72 | if test "$OPT" = "--libs" -a -n "$PKG_HOME" 73 | then 74 | GCC_ARCH=`$CC -dumpmachine` 75 | CFG_OUT="$CFG_OUT -L$PKG_HOME/usr/lib/$GCC_ARCH" 76 | fi 77 | for PKG in $PKGS 78 | do 79 | if grep -q "pkg-$PKG--" $CFG_PATH 80 | then 81 | CFG=`grep "pkg-$PKG$OPT=" $CFG_PATH | sed 's/^[^=]*=//'` 82 | CFG_OUT="$CFG_OUT $CFG" 83 | else 84 | echo "Package not found '$PKG'" 1>&2 85 | exit 1 86 | fi 87 | done 88 | ;; 89 | --config|--txt) 90 | for PKG in $PKGS 91 | do 92 | if ! pkg-config $PKG 93 | then 94 | echo "Package not found '$PKG'" 1>&2 95 | exit 1 96 | fi 97 | done 98 | for PKG in $PKGS 99 | do 100 | printf "pkg-$PKG--cflags=" 101 | pkg-config --cflags $PKG 102 | printf "pkg-$PKG--libs=" 103 | pkg-config --libs $PKG 104 | done > $CFG_PATH 105 | ;; 106 | --archive|--zip|--list) 107 | CFG=`pkg-config --cflags --libs $PKGS` 108 | FILES=`echo $CFG | tr ' ' '\n' | grep "^-I" | sed 's/^-I//' | xargs` 109 | LIBS=`echo $CFG | tr ' ' '\n' | grep "^-l" | sed 's/^-l//' | xargs` 110 | if test -n "$ADD_FILES" 111 | then 112 | FILES="$FILES $ADD_FILES" 113 | fi 114 | if test -n "$ADD_LIBS" 115 | then 116 | LIBS="$LIBS $ADD_LIBS" 117 | fi 118 | LIB_DIRS=`echo $CFG | tr ' ' '\n' | grep "^-L" | sed 's/^-L//' | xargs` 119 | GCC_ARCH=`gcc -print-multiarch` 120 | LIB_DIRS="$LIB_DIRS /usr/lib/$GCC_ARCH /usr/lib /lib" 121 | for LIB in $LIBS 122 | do 123 | LIBNAME="lib$LIB.so" 124 | for LIB_DIR in $LIB_DIRS 125 | do 126 | if test -e "$LIB_DIR/$LIBNAME" 127 | then 128 | FILES="$FILES $LIB_DIR/$LIBNAME" 129 | break 130 | fi 131 | done 132 | done 133 | if test -f "$CFG_PATH" 134 | then 135 | FILES="$FILES $CFG_PATH" 136 | fi 137 | if test "$OPT" = "--list" 138 | then 139 | echo $FILES 140 | exit 0 141 | fi 142 | zip -r $ZIP_PATH $FILES 143 | ;; 144 | *) 145 | echo "Unknown option '$OPT'" 1>&2 146 | exit 1 147 | ;; 148 | esac 149 | done 150 | 151 | if test -n "$CFG_OUT" 152 | then 153 | if test -n "$PKG_HOME" 154 | then 155 | echo "$CFG_OUT" | sed "s: -I: -I$PKG_HOME:g" 156 | else 157 | echo "$CFG_OUT" 158 | fi 159 | fi 160 | -------------------------------------------------------------------------------- /tools/versions.lua: -------------------------------------------------------------------------------- 1 | 2 | local function printVersion(name, key) 3 | local status, m = pcall(require, name) 4 | if status then 5 | if key == nil then 6 | key = '_VERSION' 7 | end 8 | local version = '?' 9 | if type(key) == 'function' then 10 | version = key(m, name) 11 | elseif type(key) == 'string' then 12 | local value = m[key] 13 | if type(value) == 'function' then 14 | version = value() 15 | elseif type(value) == 'string' then 16 | version = value 17 | end 18 | end 19 | print(name, version) 20 | end 21 | end 22 | 23 | local bits 24 | if string.pack then 25 | bits = #string.pack('T', 0) * 8 26 | else 27 | bits = 0xfffffffff == 0xfffffffff and 64 or 32 28 | end 29 | print(_VERSION, tostring(bits)..' bits') 30 | 31 | printVersion('lfs') 32 | printVersion('socket') 33 | printVersion('cjson') 34 | printVersion('zlib') 35 | printVersion('luv', 'version_string') 36 | printVersion('openssl', 'version') 37 | printVersion('lpeg', 'version') 38 | printVersion('lpeglabel', 'version') 39 | printVersion('luaunit') 40 | printVersion('dumbParser', 'VERSION') 41 | printVersion('lxp') -- LuaExpat 42 | printVersion('lxp', '_EXPAT_VERSION') 43 | printVersion('xml2lua') -- XmlParser 44 | printVersion('webview') 45 | printVersion('llthreads') 46 | --printVersion('luachild') -- not available 47 | printVersion('sha1') 48 | printVersion('luacov.runner', 'version') 49 | --printVersion('struct') -- not available 1.8 50 | printVersion('dkjson', 'version') 51 | --printVersion('winapi') -- not available 52 | printVersion('periphery', 'version') 53 | 54 | printVersion('exif') 55 | printVersion('jpeg') 56 | printVersion('serial') 57 | printVersion('win32') 58 | printVersion('linux') 59 | printVersion('buffer') 60 | -------------------------------------------------------------------------------- /winapi.mk: -------------------------------------------------------------------------------- 1 | CC ?= gcc 2 | 3 | LUA_PATH = lua 4 | LUA_LIB = lua53 5 | 6 | LIBEXT=dll 7 | LIBNAME=winapi 8 | TARGET=$(LIBNAME).$(LIBEXT) 9 | 10 | # test 11 | # lua -e "print(require('winapi').show_message('Message', 'stuff\nand nonsense', 'yes-no', 'warning'))" 12 | # lua -e "print(require('winapi').show_message('Message', 'arguments\n'..table.concat(arg, ' ')))" 13 | 14 | LIBOPT = -shared \ 15 | -Wl,-s \ 16 | -L..\$(LUA_PATH)\src -l$(LUA_LIB) \ 17 | -static-libgcc \ 18 | -lkernel32 -luser32 -lpsapi -ladvapi32 -lshell32 -lMpr 19 | 20 | ## -lmsvcr80 21 | 22 | CFLAGS = -Wall \ 23 | -Wextra \ 24 | -Wno-unused-parameter \ 25 | -Wstrict-prototypes \ 26 | -DPSAPI_VERSION=1 \ 27 | -I../$(LUA_PATH)/src 28 | 29 | ## -g -O1 -DWIN32=1 30 | 31 | SOURCES = winapi.c wutils.c wutils.h 32 | 33 | OBJS = winapi.o wutils.o 34 | 35 | lib: $(TARGET) 36 | 37 | $(TARGET): $(OBJS) 38 | $(CC) $(OBJS) $(LIBOPT) -o $(TARGET) 39 | 40 | clean: 41 | -$(RM) $(OBJS) $(TARGET) 42 | 43 | $(OBJS): %.o : %.c $(SOURCES) 44 | $(CC) $(CFLAGS) -c -o $@ $< 45 | -------------------------------------------------------------------------------- /wlua.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/javalikescript/luaclibs/95deb7a5be9117a82abb5925db6365e26e8d96c3/wlua.ico -------------------------------------------------------------------------------- /wlua.rc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | /* 4 | https://docs.microsoft.com/en-us/windows/win32/menurc/versioninfo-resource 5 | https://docs.microsoft.com/en-us/windows/win32/menurc/stringfileinfo-block 6 | */ 7 | 8 | 0 ICON "wlua.ico" 9 | 10 | VS_VERSION_INFO VERSIONINFO 11 | FILEVERSION 5,4,3,0 12 | PRODUCTVERSION 5,4,3,0 13 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 14 | FILEFLAGS (VS_FF_PRIVATEBUILD|VS_FF_PRERELEASE) 15 | BEGIN 16 | BLOCK "StringFileInfo" 17 | BEGIN 18 | BLOCK "040904E4" 19 | BEGIN 20 | VALUE "Comments", "www.lua.org" 21 | VALUE "CompanyName", "Lua.org" 22 | VALUE "FileDescription", "Lua Windows Standalone Interpreter" 23 | VALUE "FileVersion", "5.4.3" 24 | VALUE "LegalCopyright", "Copyright (C) 1994-2021 Lua.org, PUC-Rio" 25 | VALUE "OriginalFilename", "wlua.exe" 26 | VALUE "ProductName", "Lua - The Programming Language" 27 | VALUE "ProductVersion", "5.4.3" 28 | VALUE "PrivateBuild", "Build for luajls" 29 | END 30 | END 31 | BLOCK "VarFileInfo" 32 | BEGIN 33 | VALUE "Translation", 0x409, 1252 34 | END 35 | END 36 | -------------------------------------------------------------------------------- /zlib.mk: -------------------------------------------------------------------------------- 1 | CC=gcc 2 | 3 | ifdef CLIBS_DEBUG 4 | CFLAGS = -g -DZLIB_DEBUG 5 | else 6 | CFLAGS = -O3 7 | endif 8 | 9 | ifdef CLIBS_NDEBUG 10 | CFLAGS += -DNDEBUG 11 | endif 12 | 13 | 14 | CFLAGS += -fPIC -D_LARGEFILE64_SOURCE=1 15 | 16 | #CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \ 17 | # -Wstrict-prototypes -Wmissing-prototypes 18 | 19 | SFLAGS = $(CFLAGS) 20 | LDFLAGS= 21 | #SLA#LDFLAGS=-O -shared -fPIC -Wl,-s 22 | TEST_LDFLAGS=-L. libz.a 23 | LDSHARED=$(CC) -shared 24 | CPP=$(CC) -E 25 | 26 | STATICLIB=libz.a 27 | SHAREDLIB=libz.so 28 | SHAREDLIBV=libz.so.1.2.11 29 | SHAREDLIBM=libz.so.1 30 | LIBS=$(STATICLIB) $(SHAREDLIBV) 31 | 32 | AR=ar 33 | ARFLAGS=rc 34 | RANLIB=ranlib 35 | LDCONFIG=ldconfig 36 | #LDSHAREDLIBC=-lc 37 | LDSHAREDLIBC=-static-libgcc 38 | TAR=tar 39 | SHELL=/bin/sh 40 | EXE= 41 | 42 | prefix =/usr/local 43 | exec_prefix =${prefix} 44 | libdir =${exec_prefix}/lib 45 | sharedlibdir =${libdir} 46 | includedir =${prefix}/include 47 | mandir =${prefix}/share/man 48 | man3dir = ${mandir}/man3 49 | pkgconfigdir = ${libdir}/pkgconfig 50 | SRCDIR= 51 | ZINC= 52 | ZINCOUT=-I. 53 | 54 | OBJZ = adler32.o crc32.o deflate.o infback.o inffast.o inflate.o inftrees.o trees.o zutil.o 55 | OBJG = compress.o uncompr.o gzclose.o gzlib.o gzread.o gzwrite.o 56 | OBJC = $(OBJZ) $(OBJG) 57 | 58 | PIC_OBJZ = adler32.lo crc32.lo deflate.lo infback.lo inffast.lo inflate.lo inftrees.lo trees.lo zutil.lo 59 | PIC_OBJG = compress.lo uncompr.lo gzclose.lo gzlib.lo gzread.lo gzwrite.lo 60 | PIC_OBJC = $(PIC_OBJZ) $(PIC_OBJG) 61 | 62 | # to use the asm code: make OBJA=match.o, PIC_OBJA=match.lo 63 | OBJA = 64 | PIC_OBJA = 65 | 66 | OBJS = $(OBJC) $(OBJA) 67 | 68 | PIC_OBJS = $(PIC_OBJC) $(PIC_OBJA) 69 | 70 | #all: static shared all64 71 | all: $(SHAREDLIB) 72 | 73 | static: example$(EXE) minigzip$(EXE) 74 | 75 | shared: examplesh$(EXE) minigzipsh$(EXE) 76 | 77 | all64: example64$(EXE) minigzip64$(EXE) 78 | 79 | check: test 80 | 81 | test: all teststatic testshared test64 82 | 83 | teststatic: static 84 | @TMPST=tmpst_$$; \ 85 | if echo hello world | ./minigzip | ./minigzip -d && ./example $$TMPST ; then \ 86 | echo ' *** zlib test OK ***'; \ 87 | else \ 88 | echo ' *** zlib test FAILED ***'; false; \ 89 | fi; \ 90 | rm -f $$TMPST 91 | 92 | testshared: shared 93 | @LD_LIBRARY_PATH=`pwd`:$(LD_LIBRARY_PATH) ; export LD_LIBRARY_PATH; \ 94 | LD_LIBRARYN32_PATH=`pwd`:$(LD_LIBRARYN32_PATH) ; export LD_LIBRARYN32_PATH; \ 95 | DYLD_LIBRARY_PATH=`pwd`:$(DYLD_LIBRARY_PATH) ; export DYLD_LIBRARY_PATH; \ 96 | SHLIB_PATH=`pwd`:$(SHLIB_PATH) ; export SHLIB_PATH; \ 97 | TMPSH=tmpsh_$$; \ 98 | if echo hello world | ./minigzipsh | ./minigzipsh -d && ./examplesh $$TMPSH; then \ 99 | echo ' *** zlib shared test OK ***'; \ 100 | else \ 101 | echo ' *** zlib shared test FAILED ***'; false; \ 102 | fi; \ 103 | rm -f $$TMPSH 104 | 105 | test64: all64 106 | @TMP64=tmp64_$$; \ 107 | if echo hello world | ./minigzip64 | ./minigzip64 -d && ./example64 $$TMP64; then \ 108 | echo ' *** zlib 64-bit test OK ***'; \ 109 | else \ 110 | echo ' *** zlib 64-bit test FAILED ***'; false; \ 111 | fi; \ 112 | rm -f $$TMP64 113 | 114 | infcover.o: $(SRCDIR)test/infcover.c $(SRCDIR)zlib.h zconf.h 115 | $(CC) $(CFLAGS) $(ZINCOUT) -c -o $@ $(SRCDIR)test/infcover.c 116 | 117 | infcover: infcover.o libz.a 118 | $(CC) $(CFLAGS) -o $@ infcover.o libz.a 119 | 120 | cover: infcover 121 | rm -f *.gcda 122 | ./infcover 123 | gcov inf*.c 124 | 125 | libz.a: $(OBJS) 126 | $(AR) $(ARFLAGS) $@ $(OBJS) 127 | -@ ($(RANLIB) $@ || true) >/dev/null 2>&1 128 | 129 | match.o: match.S 130 | $(CPP) match.S > _match.s 131 | $(CC) -c _match.s 132 | mv _match.o match.o 133 | rm -f _match.s 134 | 135 | match.lo: match.S 136 | $(CPP) match.S > _match.s 137 | $(CC) -c -fPIC _match.s 138 | mv _match.o match.lo 139 | rm -f _match.s 140 | 141 | example.o: $(SRCDIR)test/example.c $(SRCDIR)zlib.h zconf.h 142 | $(CC) $(CFLAGS) $(ZINCOUT) -c -o $@ $(SRCDIR)test/example.c 143 | 144 | minigzip.o: $(SRCDIR)test/minigzip.c $(SRCDIR)zlib.h zconf.h 145 | $(CC) $(CFLAGS) $(ZINCOUT) -c -o $@ $(SRCDIR)test/minigzip.c 146 | 147 | example64.o: $(SRCDIR)test/example.c $(SRCDIR)zlib.h zconf.h 148 | $(CC) $(CFLAGS) $(ZINCOUT) -D_FILE_OFFSET_BITS=64 -c -o $@ $(SRCDIR)test/example.c 149 | 150 | minigzip64.o: $(SRCDIR)test/minigzip.c $(SRCDIR)zlib.h zconf.h 151 | $(CC) $(CFLAGS) $(ZINCOUT) -D_FILE_OFFSET_BITS=64 -c -o $@ $(SRCDIR)test/minigzip.c 152 | 153 | 154 | adler32.o: $(SRCDIR)adler32.c 155 | $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)adler32.c 156 | 157 | crc32.o: $(SRCDIR)crc32.c 158 | $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)crc32.c 159 | 160 | deflate.o: $(SRCDIR)deflate.c 161 | $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)deflate.c 162 | 163 | infback.o: $(SRCDIR)infback.c 164 | $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)infback.c 165 | 166 | inffast.o: $(SRCDIR)inffast.c 167 | $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)inffast.c 168 | 169 | inflate.o: $(SRCDIR)inflate.c 170 | $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)inflate.c 171 | 172 | inftrees.o: $(SRCDIR)inftrees.c 173 | $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)inftrees.c 174 | 175 | trees.o: $(SRCDIR)trees.c 176 | $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)trees.c 177 | 178 | zutil.o: $(SRCDIR)zutil.c 179 | $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)zutil.c 180 | 181 | compress.o: $(SRCDIR)compress.c 182 | $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)compress.c 183 | 184 | uncompr.o: $(SRCDIR)uncompr.c 185 | $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)uncompr.c 186 | 187 | gzclose.o: $(SRCDIR)gzclose.c 188 | $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)gzclose.c 189 | 190 | gzlib.o: $(SRCDIR)gzlib.c 191 | $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)gzlib.c 192 | 193 | gzread.o: $(SRCDIR)gzread.c 194 | $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)gzread.c 195 | 196 | gzwrite.o: $(SRCDIR)gzwrite.c 197 | $(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)gzwrite.c 198 | 199 | 200 | adler32.lo: $(SRCDIR)adler32.c 201 | $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o adler32.lo $(SRCDIR)adler32.c 202 | 203 | crc32.lo: $(SRCDIR)crc32.c 204 | $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o crc32.lo $(SRCDIR)crc32.c 205 | 206 | deflate.lo: $(SRCDIR)deflate.c 207 | $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o deflate.lo $(SRCDIR)deflate.c 208 | 209 | infback.lo: $(SRCDIR)infback.c 210 | $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o infback.lo $(SRCDIR)infback.c 211 | 212 | inffast.lo: $(SRCDIR)inffast.c 213 | $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o inffast.lo $(SRCDIR)inffast.c 214 | 215 | inflate.lo: $(SRCDIR)inflate.c 216 | $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o inflate.lo $(SRCDIR)inflate.c 217 | 218 | inftrees.lo: $(SRCDIR)inftrees.c 219 | $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o inftrees.lo $(SRCDIR)inftrees.c 220 | 221 | trees.lo: $(SRCDIR)trees.c 222 | $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o trees.lo $(SRCDIR)trees.c 223 | 224 | zutil.lo: $(SRCDIR)zutil.c 225 | $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o zutil.lo $(SRCDIR)zutil.c 226 | 227 | compress.lo: $(SRCDIR)compress.c 228 | $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o compress.lo $(SRCDIR)compress.c 229 | 230 | uncompr.lo: $(SRCDIR)uncompr.c 231 | $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o uncompr.lo $(SRCDIR)uncompr.c 232 | 233 | gzclose.lo: $(SRCDIR)gzclose.c 234 | $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o gzclose.lo $(SRCDIR)gzclose.c 235 | 236 | gzlib.lo: $(SRCDIR)gzlib.c 237 | $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o gzlib.lo $(SRCDIR)gzlib.c 238 | 239 | gzread.lo: $(SRCDIR)gzread.c 240 | $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o gzread.lo $(SRCDIR)gzread.c 241 | 242 | gzwrite.lo: $(SRCDIR)gzwrite.c 243 | $(CC) $(SFLAGS) $(ZINC) -DPIC -c -o gzwrite.lo $(SRCDIR)gzwrite.c 244 | 245 | placebo $(SHAREDLIB): $(PIC_OBJS) libz.a 246 | $(LDSHARED) $(SFLAGS) -o $@ $(PIC_OBJS) $(LDSHAREDLIBC) $(LDFLAGS) 247 | 248 | #placebo $(SHAREDLIBV): $(PIC_OBJS) libz.a 249 | # $(LDSHARED) $(SFLAGS) -o $@ $(PIC_OBJS) $(LDSHAREDLIBC) $(LDFLAGS) 250 | # rm -f $(SHAREDLIB) $(SHAREDLIBM) 251 | # ln -s $@ $(SHAREDLIB) 252 | # ln -s $@ $(SHAREDLIBM) 253 | # -@rmdir objs 254 | 255 | example$(EXE): example.o $(STATICLIB) 256 | $(CC) $(CFLAGS) -o $@ example.o $(TEST_LDFLAGS) 257 | 258 | minigzip$(EXE): minigzip.o $(STATICLIB) 259 | $(CC) $(CFLAGS) -o $@ minigzip.o $(TEST_LDFLAGS) 260 | 261 | examplesh$(EXE): example.o $(SHAREDLIBV) 262 | $(CC) $(CFLAGS) -o $@ example.o -L. $(SHAREDLIBV) 263 | 264 | minigzipsh$(EXE): minigzip.o $(SHAREDLIBV) 265 | $(CC) $(CFLAGS) -o $@ minigzip.o -L. $(SHAREDLIBV) 266 | 267 | example64$(EXE): example64.o $(STATICLIB) 268 | $(CC) $(CFLAGS) -o $@ example64.o $(TEST_LDFLAGS) 269 | 270 | minigzip64$(EXE): minigzip64.o $(STATICLIB) 271 | $(CC) $(CFLAGS) -o $@ minigzip64.o $(TEST_LDFLAGS) 272 | 273 | install-libs: $(LIBS) 274 | -@if [ ! -d $(DESTDIR)$(exec_prefix) ]; then mkdir -p $(DESTDIR)$(exec_prefix); fi 275 | -@if [ ! -d $(DESTDIR)$(libdir) ]; then mkdir -p $(DESTDIR)$(libdir); fi 276 | -@if [ ! -d $(DESTDIR)$(sharedlibdir) ]; then mkdir -p $(DESTDIR)$(sharedlibdir); fi 277 | -@if [ ! -d $(DESTDIR)$(man3dir) ]; then mkdir -p $(DESTDIR)$(man3dir); fi 278 | -@if [ ! -d $(DESTDIR)$(pkgconfigdir) ]; then mkdir -p $(DESTDIR)$(pkgconfigdir); fi 279 | rm -f $(DESTDIR)$(libdir)/$(STATICLIB) 280 | cp $(STATICLIB) $(DESTDIR)$(libdir) 281 | chmod 644 $(DESTDIR)$(libdir)/$(STATICLIB) 282 | -@($(RANLIB) $(DESTDIR)$(libdir)/libz.a || true) >/dev/null 2>&1 283 | -@if test -n "$(SHAREDLIBV)"; then \ 284 | rm -f $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBV); \ 285 | cp $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir); \ 286 | echo "cp $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)"; \ 287 | chmod 755 $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBV); \ 288 | echo "chmod 755 $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBV)"; \ 289 | rm -f $(DESTDIR)$(sharedlibdir)/$(SHAREDLIB) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBM); \ 290 | ln -s $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIB); \ 291 | ln -s $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBM); \ 292 | ($(LDCONFIG) || true) >/dev/null 2>&1; \ 293 | fi 294 | rm -f $(DESTDIR)$(man3dir)/zlib.3 295 | cp $(SRCDIR)zlib.3 $(DESTDIR)$(man3dir) 296 | chmod 644 $(DESTDIR)$(man3dir)/zlib.3 297 | rm -f $(DESTDIR)$(pkgconfigdir)/zlib.pc 298 | cp zlib.pc $(DESTDIR)$(pkgconfigdir) 299 | chmod 644 $(DESTDIR)$(pkgconfigdir)/zlib.pc 300 | # The ranlib in install is needed on NeXTSTEP which checks file times 301 | # ldconfig is for Linux 302 | 303 | install: install-libs 304 | -@if [ ! -d $(DESTDIR)$(includedir) ]; then mkdir -p $(DESTDIR)$(includedir); fi 305 | rm -f $(DESTDIR)$(includedir)/zlib.h $(DESTDIR)$(includedir)/zconf.h 306 | cp $(SRCDIR)zlib.h zconf.h $(DESTDIR)$(includedir) 307 | chmod 644 $(DESTDIR)$(includedir)/zlib.h $(DESTDIR)$(includedir)/zconf.h 308 | 309 | uninstall: 310 | cd $(DESTDIR)$(includedir) && rm -f zlib.h zconf.h 311 | cd $(DESTDIR)$(libdir) && rm -f libz.a; \ 312 | if test -n "$(SHAREDLIBV)" -a -f $(SHAREDLIBV); then \ 313 | rm -f $(SHAREDLIBV) $(SHAREDLIB) $(SHAREDLIBM); \ 314 | fi 315 | cd $(DESTDIR)$(man3dir) && rm -f zlib.3 316 | cd $(DESTDIR)$(pkgconfigdir) && rm -f zlib.pc 317 | 318 | docs: zlib.3.pdf 319 | 320 | zlib.3.pdf: $(SRCDIR)zlib.3 321 | groff -mandoc -f H -T ps $(SRCDIR)zlib.3 | ps2pdf - $@ 322 | 323 | zconf.h.cmakein: $(SRCDIR)zconf.h.in 324 | -@ TEMPFILE=zconfh_$$; \ 325 | echo "/#define ZCONF_H/ a\\\\\n#cmakedefine Z_PREFIX\\\\\n#cmakedefine Z_HAVE_UNISTD_H\n" >> $$TEMPFILE &&\ 326 | sed -f $$TEMPFILE $(SRCDIR)zconf.h.in > $@ &&\ 327 | touch -r $(SRCDIR)zconf.h.in $@ &&\ 328 | rm $$TEMPFILE 329 | 330 | zconf: $(SRCDIR)zconf.h.in 331 | cp -p $(SRCDIR)zconf.h.in zconf.h 332 | 333 | mostlyclean: clean 334 | clean: 335 | rm -f *.o *.lo *~ \ 336 | example$(EXE) minigzip$(EXE) examplesh$(EXE) minigzipsh$(EXE) \ 337 | example64$(EXE) minigzip64$(EXE) \ 338 | infcover \ 339 | libz.* foo.gz so_locations \ 340 | _match.s maketree contrib/infback9/*.o 341 | rm -rf objs 342 | rm -f *.gcda *.gcno *.gcov 343 | rm -f contrib/infback9/*.gcda contrib/infback9/*.gcno contrib/infback9/*.gcov 344 | 345 | maintainer-clean: distclean 346 | distclean: clean zconf zconf.h.cmakein docs 347 | rm -f Makefile zlib.pc configure.log 348 | -@rm -f .DS_Store 349 | @if [ -f Makefile.in ]; then \ 350 | printf 'all:\n\t-@echo "Please use ./configure first. Thank you."\n' > Makefile ; \ 351 | printf '\ndistclean:\n\tmake -f Makefile.in distclean\n' >> Makefile ; \ 352 | touch -r $(SRCDIR)Makefile.in Makefile ; fi 353 | @if [ ! -f zconf.h.in ]; then rm -f zconf.h zconf.h.cmakein ; fi 354 | @if [ ! -f zlib.3 ]; then rm -f zlib.3.pdf ; fi 355 | 356 | tags: 357 | etags $(SRCDIR)*.[ch] 358 | 359 | adler32.o zutil.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h 360 | gzclose.o gzlib.o gzread.o gzwrite.o: $(SRCDIR)zlib.h zconf.h $(SRCDIR)gzguts.h 361 | compress.o example.o minigzip.o uncompr.o: $(SRCDIR)zlib.h zconf.h 362 | crc32.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)crc32.h 363 | deflate.o: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h 364 | infback.o inflate.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR)inflate.h $(SRCDIR)inffast.h $(SRCDIR)inffixed.h 365 | inffast.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR)inflate.h $(SRCDIR)inffast.h 366 | inftrees.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h 367 | trees.o: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)trees.h 368 | 369 | adler32.lo zutil.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h 370 | gzclose.lo gzlib.lo gzread.lo gzwrite.lo: $(SRCDIR)zlib.h zconf.h $(SRCDIR)gzguts.h 371 | compress.lo example.lo minigzip.lo uncompr.lo: $(SRCDIR)zlib.h zconf.h 372 | crc32.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)crc32.h 373 | deflate.lo: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h 374 | infback.lo inflate.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR)inflate.h $(SRCDIR)inffast.h $(SRCDIR)inffixed.h 375 | inffast.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR)inflate.h $(SRCDIR)inffast.h 376 | inftrees.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h 377 | trees.lo: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)trees.h 378 | --------------------------------------------------------------------------------