diff --git a/Makefile.luarocks b/Makefile.luarocks new file mode 100644 index 0000000..8206cca --- /dev/null +++ b/Makefile.luarocks @@ -0,0 +1,115 @@ +CFLAGS := -O2 +LDFLAGS := -O2 -lm + +AR ?= ar +LUA ?= luajit/src/luajit + +WINDRES ?= windres + +CFLAGS += -Iluajit/src -Iraylib/src -Iraygui/src -Iphysac/src +LDFLAGS += luajit/src/libluajit.a raylib/src/libraylib.a + +MODULES := raymath rlgl gestures physac raygui rcamera + +# raylib settings +PLATFORM ?= PLATFORM_DESKTOP +GRAPHICS ?= GRAPHICS_API_OPENGL_33 + +CFLAGS += -D$(GRAPHICS) -D$(PLATFORM) + +USE_WAYLAND_DISPLAY ?= FALSE +USE_EXTERNAL_GLFW ?= FALSE + +ifeq ($(OS),Windows_NT) +LDFLAGS += -lopengl32 -lgdi32 -lwinmm -static +LDFLAGS_R += -mwindows +EXTERNAL_FILES := src/res/icon.res +else ifeq ($(shell uname),Darwin) +LDFLAGS += -framework CoreVideo -framework IOKit -framework Cocoa \ +-framework GLUT -framework OpenGL +ifeq ($(shell uname -m),arm64) +# Additional flags for ARM64 on macOS +CFLAGS += -target arm64-apple-macos11 +else +CFLAGS += -Wl,-pagezero_size,10000,-image_base,100000000 +endif +EXTERNAL_FILES := +else +LDFLAGS += -ldl -lpthread +ifeq ($(PLATFORM),PLATFORM_DRM) +LDFLAGS += -ldrm -lGLESv2 -lEGL -lgbm +else +LDFLAGS += -lX11 +endif +EXTERNAL_FILES := +endif + +# Changed order so dependencies are built first +all: build_deps raylua_s raylua_e raylua_r + +build_deps: build_luajit build_raylib + +build_luajit: + cd luajit && $(MAKE) MACOSX_DEPLOYMENT_TARGET=10.13 + +build_raylib: + cd raylib/src && $(MAKE) PLATFORM=$(PLATFORM) GRAPHICS=$(GRAPHICS) + +%.o: %.c + $(CC) -c -o $@ $< $(CFLAGS) + +raylua_s: src/raylua_s.o $(EXTERNAL_FILES) libraylua.a + $(CC) -o $@ $^ $(LDFLAGS) luajit/src/libluajit.a + +raylua_e: src/raylua_e.o src/raylua_self.o src/raylua_builder.o src/lib/miniz.o \ +$(EXTERNAL_FILES) libraylua.a + $(CC) -o $@ $^ $(LDFLAGS) luajit/src/libluajit.a + +raylua_r: src/raylua_e.o src/raylua_self.o src/raylua_builder.o src/lib/miniz.o \ +$(EXTERNAL_FILES) libraylua.a + $(CC) -o $@ $^ $(LDFLAGS) $(LDFLAGS_R) luajit/src/libluajit.a + +src/res/icon.res: src/res/icon.rc + $(WINDRES) $^ -O coff $@ + +libraylua.a: src/raylua.o + $(AR) rcu $@ $^ + +raylua.dll: src/raylua.o + $(CC) -shared -fPIE -o $@ $^ $(LDFLAGS) -llua5.1 + +raylua.so: src/raylua.o + $(CC) -shared -fPIE -o $@ $^ $(LDFLAGS) -llua5.1 + +src/raylua.o: build_deps src/autogen/boot.c src/autogen/bind.c + +src/raylua_builder.o: src/autogen/builder.c + +src/autogen/boot.c: src/raylib.lua src/compat.lua src/raylua.lua + $(LUA) tools/lua2str.lua $@ raylua_boot_lua $^ + +src/autogen/bind.c: + $(LUA) tools/genbind.lua $@ $(MODULES) + +src/autogen/builder.c: src/raylua_builder.lua + $(LUA) tools/lua2str.lua $@ raylua_builder_lua $^ + +clean: + rm -rf raylua_s raylua_e libraylua.a src/raylua_e.o src/raylua_s.o \ + src/raylua.o src/raylua_self.o src/raylua_builder.o src/autogen/*.c \ + src/lib/miniz.o src/res/icon.res + $(MAKE) -C luajit clean + $(MAKE) -C raylib/src clean + rm -f raylib/libraylib.a + +.PHONY: all build_deps build_luajit build_raylib src/autogen/bind.c src/autogen/boot.c raylua_s raylua_e clean + +install: + mkdir -p $(INST_BINDIR) + mkdir -p $(INST_LIBDIR) + mkdir -p $(INST_LUADIR)/raylib + cp raylua_s $(INST_BINDIR)/raylua + cp raylua_e $(INST_BINDIR)/raylua_e + cp raylua_r $(INST_BINDIR)/raylua_r + cp libraylua.a $(INST_LIBDIR)/ + cp src/*.lua $(INST_LUADIR)/raylib/ || true diff --git a/makefile b/makefile index 6073556..11d0b00 100644 --- a/makefile +++ b/makefile @@ -22,11 +22,11 @@ USE_EXTERNAL_GLFW ?= FALSE ifeq ($(OS),Windows_NT) LDFLAGS += -lopengl32 -lgdi32 -lwinmm -static - LDFLAGS_R += -mwindows + LDFLAGS_R += -mwindows EXTERNAL_FILES := src/res/icon.res else ifeq ($(shell uname),Darwin) LDFLAGS += -framework CoreVideo -framework IOKit -framework Cocoa \ - -framework GLUT -framework OpenGL + -framework GLUT -framework OpenGL ifeq ($(shell uname -m),arm64) # Additional flags for ARM64 on macOS CFLAGS += -target arm64-apple-macos11 @@ -45,7 +45,7 @@ else EXTERNAL_FILES := endif -all: raylua_s raylua_e raylua_r luajit raylib +all: luajit raylib raylua_s raylua_e raylua_r %.o: %.c $(CC) -c -o $@ $< $(CFLAGS) diff --git a/raylib-lua-0.1-1.rockspec b/raylib-lua-0.1-1.rockspec new file mode 100644 index 0000000..6ccc886 --- /dev/null +++ b/raylib-lua-0.1-1.rockspec @@ -0,0 +1,28 @@ +package = "raylib-lua" +version = "0.1-1" -- Update version based on your binding's state +source = { + url = "https://github.com/TSnake41/raylib-lua/archive/refs/tags/v0.1.tar.gz", + dir = "raylib-lua-0.1" -- Directory inside the extracted source +} +description = { + summary = "Lua bindings for Raylib", + detailed = [[ + raylib-lua is a Lua binding for Raylib, a simple and easy-to-use library + for game development. This binding allows you to use Raylib in Lua. + ]], + homepage = "https://github.com/TSnake41/raylib-lua", + license = "MIT" +} +dependencies = { + "lua >= 5.1", + "raylib >= 4.0" -- Ensure raylib is installed +} +build = { + type = "builtin", + modules = { + ["raylib"] = { + sources = { "src/raylib.c" }, + libraries = { "raylib" }, + } + } +} diff --git a/raylib-lua-4.5-1.rockspec b/raylib-lua-4.5-1.rockspec new file mode 100644 index 0000000..8b1709b --- /dev/null +++ b/raylib-lua-4.5-1.rockspec @@ -0,0 +1,62 @@ +rockspec_format = "3.0" + +package = "raylib-lua" +version = "4.5-1" -- raylib version +source = { + url = "https://github.com/TSnake41/raylib-lua", + tag = "v4.5a", +} +description = { + summary = "Lua bindings for Raylib", + detailed = [[ + raylib-lua is a Lua binding for Raylib, a simple and easy-to-use library + for game development. This binding allows you to use Raylib in Lua. + ]], + homepage = "https://github.com/TSnake41/raylib-lua", + license = "MIT" +} +dependencies = { + "lua >= 5.1", + +} + +build_dependencies = { + -- Build tools required + -- "luajit >= 2.0", -- Not needed, building from submodule + -- "raylib >= 4.0", -- Not needed, building from submodule +} + + +build = { + type = "command", + build_command = [[ + git submodule update --init --recursive && + $(MAKE) -f Makefile.luarocks all + ]], + install_command = [[ + mkdir -p "$(BINDIR)" && + mkdir -p "$(LIBDIR)" && + mkdir -p "$(LUADIR)/raylib" && + cp raylua_s "$(BINDIR)/raylua" && + cp raylua_e "$(BINDIR)/raylua_e" && + cp raylua_r "$(BINDIR)/raylua_r" && + cp libraylua.a "$(LIBDIR)/" && + cp src/*.lua "$(LUADIR)/raylib/" || true + ]], + variables = { + CFLAGS = "$(CFLAGS)", + LIBFLAG = "$(LIBFLAG)", + LUA_LIBDIR = "$(LUA_LIBDIR)", + LUA_BINDIR = "$(LUA_BINDIR)", + LUA_INCDIR = "$(LUA_INCDIR)", + LUA = "$(LUA)", + PLATFORM = "PLATFORM_DESKTOP", + GRAPHICS = "GRAPHICS_API_OPENGL_33", + MACOSX_DEPLOYMENT_TARGET = "10.13", + INST_PREFIX = "$(PREFIX)", + INST_BINDIR = "$(BINDIR)", + INST_LIBDIR = "$(LIBDIR)", + INST_LUADIR = "$(LUADIR)", + INST_CONFDIR = "$(CONFDIR)" + } +}