1# === Luakit Makefile Configuration ========================================== 2 3# Compile/link options. 4CC ?= gcc 5CFLAGS += -std=c11 -D_XOPEN_SOURCE=600 -W -Wall -Wextra -Werror=unused-result 6LDFLAGS += 7CPPFLAGS += 8PKG_CONFIG ?= pkg-config 9 10# Get current luakit version. 11VERSION ?= $(shell ./build-utils/getversion.sh) 12CPPFLAGS += -DVERSION=\"$(VERSION)\" 13 14# === Default build options ================================================== 15 16DEVELOPMENT_PATHS ?= 0 17USE_LUAJIT ?= 1 18 19# === Paths ================================================================== 20 21PREFIX ?= /usr/local 22MANPREFIX = $(PREFIX)/man 23DOCDIR ?= $(PREFIX)/share/doc/luakit 24XDGPREFIX ?= /usr/local/etc/xdg 25PIXMAPDIR ?= $(PREFIX)/share/pixmaps 26APPDIR ?= $(PREFIX)/share/applications 27LIBDIR ?= $(PREFIX)/lib/luakit 28 29# Should luakit be built to load relative config paths (./lib ./config) ? 30# (Useful when running luakit from it's source directory, disable otherwise). 31ifneq ($(DEVELOPMENT_PATHS),0) 32 CPPFLAGS += -DDEVELOPMENT_PATHS 33 CFLAGS += 34endif 35 36# === Platform specific ====================================================== 37 38uname_s := $(shell uname -s) 39 40# Mac OSX 41ifeq ($(uname_s),Darwin) 42 LINKER_EXPORT_DYNAMIC = 0 43endif 44 45# Some systems need the --export-dynamic linker option to load other 46# dynamically linked C Lua modules (for example lua-filesystem). 47ifneq ($(LINKER_EXPORT_DYNAMIC),0) 48 LDFLAGS += -Wl,--export-dynamic 49endif 50 51# === Lua package name detection ============================================= 52 53LUA_PKG_NAMES += lua-5.1 lua5.1 lua51 54 55# Force linking against Lua's Just-In-Time compiler. 56# See http://luajit.org/ for more information. 57ifeq ($(USE_LUAJIT),1) 58 LUA_PKG_NAME := luajit 59else 60# User hasn't specificed, use LuaJIT if we can find it. 61ifneq ($(USE_LUAJIT),0) 62 LUA_PKG_NAMES := luajit $(LUA_PKG_NAMES) 63endif 64endif 65 66# Search for Lua package name if not forced by user. 67ifeq ($(LUA_PKG_NAME),) 68LUA_PKG_NAME = $(shell sh -c '(for name in $(LUA_PKG_NAMES); do \ 69 $(PKG_CONFIG) --exists $$name && echo $$name; done) | head -n 1') 70endif 71 72# === Lua binary name detection ============================================= 73 74LUA_BIN_NAMES += lua-5.1 lua5.1 lua51 75ifneq ($(USE_LUAJIT),0) 76 LUA_BIN_NAMES := luajit luajit51 $(LUA_BIN_NAMES) 77endif 78 79# Search for Lua binary name if not forced by user. 80ifeq ($(LUA_BIN_NAME),) 81 LUA_BIN_NAME := $(shell sh -c '(for name in $(LUA_BIN_NAMES); do \ 82 hash $$name 2>/dev/null && ($$name -v 2>&1 | grep -Eq "^Lua 5\.1|^LuaJIT") && echo $$name; done) | head -n 1') 83endif 84 85ifeq ($(LUA_BIN_NAME),) 86 $(error Cannot find the Lua binary name. \ 87 Tried the following: $(LUA_BIN_NAMES). \ 88 Manually override by setting LUA_BIN_NAME) 89endif 90 91# === Required build packages ================================================ 92 93# Packages required to build luakit. 94PKGS += gtk+-3.0 95PKGS += gthread-2.0 96PKGS += webkit2gtk-4.0 97PKGS += sqlite3 98PKGS += $(LUA_PKG_NAME) 99PKGS += javascriptcoregtk-4.0 100 101# Check user has correct packages installed (and found by pkg-config). 102PKGS_OK := $(shell $(PKG_CONFIG) --print-errors --exists $(PKGS) && echo 1) 103ifneq ($(PKGS_OK),1) 104 $(error Cannot find required package(s\) to build luakit. Please \ 105 check you have the above packages installed and try again) 106endif 107 108# Add pkg-config options to compile flags. 109CFLAGS += $(shell $(PKG_CONFIG) --cflags $(PKGS)) 110CFLAGS += -I./ 111 112# Add pkg-config options to linker flags. 113LDFLAGS += $(shell $(PKG_CONFIG) --libs $(PKGS)) 114