From b5926be6dd3438c7f98afe7c9ffb28f52fb6a573 Mon Sep 17 00:00:00 2001 From: Hisham Muhammad Date: Fri, 10 Aug 2018 17:34:31 -0300 Subject: Build Windows binaries as .exe in a separate directory --- GNUmakefile | 56 ++++++++++++++++++++++++++----------------------- binary/Makefile.windows | 2 +- binary/all_in_one | 2 +- 3 files changed, 32 insertions(+), 28 deletions(-) diff --git a/GNUmakefile b/GNUmakefile index 45eb38b1..a8e2a01e 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -8,6 +8,7 @@ bindir ?= $(prefix)/bin sysconfdir ?= $(prefix)/etc INSTALL ?= install INSTALL_DATA ?= $(INSTALL) -m 644 +BINARY_PLATFORM ?= unix LUA_INTERPRETER ?= lua ifdef LUA_BINDIR @@ -21,6 +22,8 @@ LUA_VERSION ?= $(shell $(LUA) -e 'print(_VERSION:match(" (5%.[1234])$$"))') rocks_tree ?= $(prefix) luarocksconfdir ?= $(sysconfdir)/luarocks luadir ?= $(datarootdir)/lua/$(LUA_VERSION) +builddir ?= ./build +buildbinarydir ?= ./build-binary LUAROCKS_FILES = $(shell find src/luarocks/ -type f -name '*.lua') @@ -31,7 +34,7 @@ all: build # Base build # ---------------------------------------- -build: luarocks luarocks-admin ./build/luarocks ./build/luarocks-admin +build: luarocks luarocks-admin $(builddir)/luarocks $(builddir)/luarocks-admin config.unix: @echo Please run the "./configure" script before building. @@ -70,7 +73,7 @@ luarocks-admin: config.unix echo 'LUAROCKS_SYSCONFDIR="$(luarocksconfdir)" LUA_PATH="$(CURDIR)/src/?.lua;;" exec "$(LUA)" "$(CURDIR)/src/bin/luarocks-admin" --project-tree="$(CURDIR)/lua_modules" "$$@"' >> luarocks-admin chmod +rx ./luarocks-admin -./build/luarocks: src/bin/luarocks config.unix +$(builddir)/luarocks: src/bin/luarocks config.unix mkdir -p "$(@D)" (printf '$(SHEBANG)\n'\ 'package.loaded["luarocks.core.hardcoded"] = { SYSCONFDIR = [[$(luarocksconfdir)]] }\n'\ @@ -78,7 +81,7 @@ luarocks-admin: config.unix tail -n +2 src/bin/luarocks \ )> "$@" -./build/luarocks-admin: src/bin/luarocks-admin config.unix +$(builddir)/luarocks-admin: src/bin/luarocks-admin config.unix mkdir -p "$(@D)" (printf '$(SHEBANG)\n'\ 'package.loaded["luarocks.core.hardcoded"] = { SYSCONFDIR = [[$(luarocksconfdir)]] }\n'\ @@ -86,6 +89,20 @@ luarocks-admin: config.unix tail -n +2 src/bin/luarocks-admin \ )> "$@" +# ---------------------------------------- +# Base build +# ---------------------------------------- + +binary: luarocks $(buildbinarydir)/luarocks.exe $(buildbinarydir)/luarocks-admin.exe + +$(buildbinarydir)/luarocks.exe: src/bin/luarocks $(LUAROCKS_FILES) + (unset $(LUA_ENV_VARS); \ + "$(LUA)" binary/all_in_one "$<" "$(LUA_DIR)" "^src/luarocks/admin/" "$(luarocksconfdir)" "$(@D)" $(BINARY_PLATFORM) $(CC) $(NM) $(SYSROOT)) + +$(buildbinarydir)/luarocks-admin.exe: src/bin/luarocks-admin $(LUAROCKS_FILES) + (unset $(LUA_ENV_VARS); \ + "$(LUA)" binary/all_in_one "$<" "$(LUA_DIR)" "^src/luarocks/cmd/" "$(luarocksconfdir)" "$(@D)" $(BINARY_PLATFORM) $(CC) $(NM) $(SYSROOT)) + # ---------------------------------------- # Regular install # ---------------------------------------- @@ -97,45 +114,32 @@ INSTALL_FILES = $(DESTDIR)$(bindir)/luarocks \ install: $(INSTALL_FILES) -$(DESTDIR)$(bindir)/luarocks: ./build/luarocks +$(DESTDIR)$(bindir)/luarocks: $(builddir)/luarocks $(INSTALL) -D "$<" "$@" -$(DESTDIR)$(bindir)/luarocks-admin: ./build/luarocks-admin +$(DESTDIR)$(bindir)/luarocks-admin: $(builddir)/luarocks-admin $(INSTALL) -D "$<" "$@" $(DESTDIR)$(luadir)/luarocks/%.lua: src/luarocks/%.lua $(INSTALL_DATA) -D "$<" "$@" -$(DESTDIR)$(luarocksconfdir)/config-$(LUA_VERSION).lua: ./build/config-$(LUA_VERSION).lua +$(DESTDIR)$(luarocksconfdir)/config-$(LUA_VERSION).lua: $(builddir)/config-$(LUA_VERSION).lua $(INSTALL_DATA) -D "$<" "$@" uninstall: rm -rf $(INSTALL_FILES) -# ---------------------------------------- -# Binary build -# ---------------------------------------- - -binary: build-binary/luarocks.exe build-binary/luarocks-admin.exe - -build-binary/luarocks.exe: src/bin/luarocks $(LUAROCKS_FILES) - (unset $(LUA_ENV_VARS); \ - "$(LUA)" binary/all_in_one "$<" "$(LUA_DIR)" "^src/luarocks/admin/" "$(luarocksconfdir)" "$(@D)" $(BINARY_PLATFORM) $(CC) $(NM) $(SYSROOT)) - -build-binary/luarocks-admin.exe: src/bin/luarocks-admin $(LUAROCKS_FILES) - (unset $(LUA_ENV_VARS); \ - "$(LUA)" binary/all_in_one "$<" "$(LUA_DIR)" "^src/luarocks/cmd/" "$(luarocksconfdir)" "$(@D)" $(BINARY_PLATFORM) $(CC) $(NM) $(SYSROOT)) - # ---------------------------------------- # Binary install # ---------------------------------------- LUAROCKS_CORE_FILES = $(wildcard src/luarocks/core/* src/luarocks/loader.lua) -INSTALL_BINARY_FILES = $(patsubst src/%, $(DESTDIR)$(luadir)/%, $(LUAROCKS_CORE_FILES)) +INSTALL_BINARY_FILES = $(patsubst src/%, $(DESTDIR)$(luadir)/%, $(LUAROCKS_CORE_FILES)) \ + $(DESTDIR)$(luarocksconfdir)/config-$(LUA_VERSION).lua -install-binary: $(INSTALL_BINARY_FILES) build-binary/luarocks.exe build-binary/luarocks-admin.exe - $(INSTALL) -D build-binary/luarocks.exe "$(DESTDIR)$(bindir)/luarocks" - $(INSTALL) -D build-binary/luarocks-admin.exe "$(DESTDIR)$(bindir)/luarocks-admin" +install-binary: $(INSTALL_BINARY_FILES) + $(INSTALL) -D "$(buildbinarydir)/luarocks.exe" "$(DESTDIR)$(bindir)/luarocks" + $(INSTALL) -D "$(buildbinarydir)/luarocks-admin.exe" "$(DESTDIR)$(bindir)/luarocks-admin" # ---------------------------------------- # Bootstrap install @@ -162,8 +166,8 @@ clean: windows-clean rm -rf ./config.unix \ ./luarocks \ ./luarocks-admin \ - ./build/ \ - build-binary \ + $(builddir)/ \ + $(buildbinarydir)/ \ ./.luarocks \ ./lua_modules diff --git a/binary/Makefile.windows b/binary/Makefile.windows index e7a5ea3b..e7bcca27 100644 --- a/binary/Makefile.windows +++ b/binary/Makefile.windows @@ -16,7 +16,7 @@ windows-binary: windows-deps/lib/liblua.a windows-deps/lib/libssl.a windows-deps STATIC_GCC_RANLIB=$(MINGW_PREFIX)-ranlib \ STATIC_GCC_CC=$(MINGW_PREFIX)-gcc \ LUAROCKS_CROSS_COMPILING=1 \ - $(MAKE) binary LUA_DIR=$(CURDIR)/windows-deps CC=$(MINGW_PREFIX)-gcc NM=$(MINGW_PREFIX)-nm BINARY_PLATFORM=windows BINARY_TARGET=build-windows-binary BINARY_SYSROOT=$(MINGW_SYSROOT) + $(MAKE) binary LUA_DIR=$(CURDIR)/windows-deps CC=$(MINGW_PREFIX)-gcc NM=$(MINGW_PREFIX)-nm BINARY_PLATFORM=windows buildbinarydir=build-windows-binary BINARY_SYSROOT=$(MINGW_SYSROOT) build-windows-deps/lua-$(LIBLUA_VERSION).tar.gz: mkdir -p $(@D) diff --git a/binary/all_in_one b/binary/all_in_one index f1c2e0a1..d6517d79 100755 --- a/binary/all_in_one +++ b/binary/all_in_one @@ -29,7 +29,7 @@ local MAIN_PROGRAM = arg[1] or "src/bin/luarocks" local LUA_DIR = arg[2] or "/usr" local EXCLUDE = arg[3] or "^src/luarocks/admin/" local SYSCONFDIR = arg[4] or "/etc/luarocks" -local TARGET = arg[5] or "binary-build" +local TARGET = arg[5] or "build-binary" local MY_PLATFORM = arg[6] or "unix" local CC = arg[7] or "gcc" local NM = arg[8] or "nm" -- cgit v1.2.3-55-g6feb