From adb12983d77374737e543072adb8e938b417e244 Mon Sep 17 00:00:00 2001 From: David Given Date: Sat, 4 Nov 2017 11:11:25 +0100 Subject: [PATCH] Add a WANT_STRIPPED_BINARIES makefile flag which controls whether binaries are stripped before installation or not (as Fedora wants unstripped binaries). Closes: #46 --- Makefile | 7 ++++++- build.lua | 35 ++++++++++++++++++++++++----------- 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 3c013af..9766123 100644 --- a/Makefile +++ b/Makefile @@ -77,6 +77,10 @@ LUABITOP_PACKAGE ?= builtin MINIZIP_PACKAGE ?= builtin UTHASH_PACKAGE ?= builtin +# Do you want your binaries stripped on installation? + +WANT_STRIPPED_BINARIES ?= yes + # =========================================================================== # END OF CONFIGURATION OPTIONS # =========================================================================== @@ -134,13 +138,14 @@ $(OBJDIR)/build.ninja:: $(LUA_INTERPRETER) build.lua Makefile OBJDIR="$(OBJDIR)" \ UTHASH_PACKAGE="$(UTHASH_PACKAGE)" \ VERSION="$(VERSION)" \ + WANT_STRIPPED_BINARIES="$(WANT_STRIPPED_BINARIES)" \ WINCC="$(WINCC)" \ WINDRES="$(WINDRES)" \ XFT_PACKAGE="$(XFT_PACKAGE)" \ clean: @echo CLEAN - @rm -rf $(OBJDIR) + @rm -rf $(OBJDIR) bin ifeq ($(LUA_INTERPRETER),$(OBJDIR)/lua) $(LUA_INTERPRETER): src/c/emu/lua-5.1.5/*.[ch] diff --git a/build.lua b/build.lua index fed80c4..1efa772 100644 --- a/build.lua +++ b/build.lua @@ -351,6 +351,12 @@ function install_file(mode, src, dest) installables[#installables+1] = dest end +-- Sanity check + +if (not WANT_STRIPPED_BINARIES) or (WANT_STRIPPED_BINARIES == "") then + WANT_STRIPPED_BINARIES = "yes" +end + -- Detect what tools we have available. io.write("Windows toolchain: ") @@ -504,28 +510,35 @@ if want_frontend("x11") or want_frontend("curses") then end print("The preferred Lua package is: '"..LUA_PACKAGE.."'") + local function strip_binary(binary) + if WANT_STRIPPED_BINARIES == "yes" then + local stripped = binary.."-stripped" + emit("build ", stripped, ": strip ", binary) + allbinaries[#allbinaries+1] = stripped + binary = stripped + end + + return binary + end + local preferred_test local preferred_curses local preferred_x11 - local stripped_curses - local stripped_x11 if want_frontend("curses") then preferred_curses = "bin/wordgrinder-"..package_name(LUA_PACKAGE).."-curses-release" preferred_test = "test-"..package_name(LUA_PACKAGE).."-curses-debug" - stripped_curses = preferred_curses.."-stripped" - emit("build ", stripped_curses, ": strip ", preferred_curses) - allbinaries[#allbinaries+1] = stripped_curses - install_file("755", stripped_curses, DESTDIR..BINDIR.."/wordgrinder") + + preferred_curses = strip_binary(preferred_curses) + install_file("755", preferred_curses, DESTDIR..BINDIR.."/wordgrinder") end if want_frontend("x11") then preferred_x11 = "bin/xwordgrinder-"..package_name(LUA_PACKAGE).."-x11-release" if not preferred_test then preferred_test = "test-"..package_name(LUA_PACKAGE).."-x11-debug" end - stripped_x11 = preferred_x11.."-stripped" - emit("build ", stripped_x11, ": strip ", preferred_x11) - allbinaries[#allbinaries+1] = stripped_x11 - install_file("755", stripped_x11, DESTDIR..BINDIR.."/xwordgrinder") + + preferred_x11 = strip_binary(preferred_x11) + install_file("755", preferred_x11, DESTDIR..BINDIR.."/xwordgrinder") end install_file("644", "bin/wordgrinder.1", DESTDIR..MANDIR.."/man1/wordgrinder.1") install_file("644", "README.wg", DESTDIR..DOCDIR.."/wordgrinder/README.wg") @@ -534,7 +547,7 @@ if want_frontend("x11") or want_frontend("curses") then emit(" date = ", DATE) emit(" version = ", VERSION) - emit("build all: phony bin/wordgrinder.1 ", stripped_curses or "", " ", stripped_x11 or "", " ", preferred_test) + emit("build all: phony bin/wordgrinder.1 ", preferred_curses or "", " ", preferred_x11 or "", " ", preferred_test) emit("build install: phony all ", table.concat(installables, " ")) end