1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243
|
# ===========================================================================
# CONFIGURATION OPTIONS
# ===========================================================================
# It should be mostly safe to leave these options at the default.
PREFIX ?= $(HOME)
BINDIR ?= $(PREFIX)/bin
SHAREDIR ?= $(PREFIX)/share
DOCDIR ?= $(SHAREDIR)/doc
MANDIR ?= $(SHAREDIR)/man
DESTDIR ?=
# Where do the temporary files go?
OBJDIR = .obj
# The compiler used for the native build (curses, X11)
CC ?= cc
# Which ninja do you want to use?
ifeq ($(strip $(shell type ninja >/dev/null; echo $$?)),0)
NINJA ?= ninja
else
ifeq ($(strip $(shell type ninja-build >/dev/null; echo $$?)),0)
NINJA ?= ninja-build
else
$(error No ninja found)
endif
endif
# Global CFLAGS and LDFLAGS.
CFLAGS ?=
LDFLAGS ?=
# Used for the Windows build (either cross or native)
WINCC ?= i686-w64-mingw32-gcc
WINDRES ?= i686-w64-mingw32-windres
MAKENSIS ?= makensis
ifneq ($(strip $(shell type $(MAKENSIS) >/dev/null 2>&1; echo $$?)),0)
# If makensis isn't on the path, chances are we're on Cygwin doing a
# Windows build --- so look in the default installation directory.
MAKENSIS := /cygdrive/c/Program\ Files\ \(x86\)/NSIS/makensis.exe
endif
# Application version and file format.
VERSION := 0.8
FILEFORMAT := 8
ifdef SOURCE_DATE_EPOCH
DATE := $(shell LC_ALL date --utc --date="@$(SOURCE_DATE_EPOCH)" +'%-d %B %Y')
else
DATE := $(shell date +'%-d %B %Y')
endif
# Which Lua do you want to use?
#
# Use 'builtin' if you want to use the built-in Lua 5.1. If
# you want to dynamically link to your system's Lua, or to Luajit,
# use a pkg-config name instead (e.g. lua-5.1, lua-5.2, luajit).
# WordGrinder works with 5.1, 5.2, 5.3, and LuaJit.
#
# Alternatively, use a flag specifier string like this:
# --cflags={-I/usr/include/thingylua} --libs={-L/usr/lib/thingylua -lthingylua}
LUA_PACKAGE ?= builtin
# Hack to try and detect the presence of the Xft library (it's not in
# pkg-config).
ifneq ($(wildcard /usr/include/X11/Xft/Xft.h),)
XFT_PACKAGE ?= \
--cflags={-I/usr/include/X11} --libs={-lX11 -lXft}
else ifneq ($(wildcard /usr/X11R6/include/X11/Xft/Xft.h),)
XFT_PACKAGE ?= \
--cflags={-I/usr/X11R6/include -I/usr/X11R6/include/X11} \
--libs={-L/usr/X11R6/lib -lX11 -lXft}
else
XFT_PACKAGE ?= none
endif
# Hack to try and detect OSX's non-pkg-config compliant ncurses.
ifneq ($(filter Darwin%,$(shell uname)),)
CURSES_PACKAGE ?= --cflags={-I/usr/include} --libs={-L/usr/lib -lncurses}
else ifneq ($(filter OpenBSD,$(shell uname)),)
CURSES_PACKAGE ?= --cflags={-I/usr/include} --libs={-L/usr/lib -lncurses}
else
CURSES_PACKAGE ?= ncursesw
endif
# By default, WordGrinder uses the builtin versions of these libraries.
# However, they're overridable --- this is mainly of use if you're a
# package maintainer and want to dynamically link to your platform's
# version.
#
# Important note: the pkg-config files for Lua packages are typically
# wrong, as they'll try to link in the wrong Lua library. You'll
# probably have to use a manual flag specifier string. Also, setting
# these only makes sense with 'make all' --- don't use this with
# 'make dev' (but you probably won't be doing this anyway).
LPEG_PACKAGE ?= builtin
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
# ===========================================================================
#
# If you need to edit anything below here, please let me know so I can add
# a proper configuration option.
hide = @
LUA_INTERPRETER = $(OBJDIR)/lua
NINJABUILD = \
$(hide) $(NINJA) -f $(OBJDIR)/build.ninja $(NINJAFLAGS)
# Builds and tests the Unix release versions only.
.PHONY: all
all: $(OBJDIR)/build.ninja
$(NINJABUILD) all
# Builds, tests and installs the Unix release versions only.
.PHONY: install
install: $(OBJDIR)/build.ninja
$(NINJABUILD) install
# Builds and installs the Unix release versions only, without testing.
.PHONY: install-notests
install-notests: $(OBJDIR)/build.ninja
$(NINJABUILD) install-notests
# Builds and tests everything that's buildable on your machine. Don't use this
# unless you know what you're doing (it's pretty brittle given non-standard
# build flags).
.PHONY: dev
dev: $(OBJDIR)/build.ninja
$(NINJABUILD) dev
# Builds Windows, possibly via cross-compilation (but doesn't test it because
# we can only do that on actual Windows).
.PHONY: windows
windows: $(OBJDIR)/build.ninja
$(NINJABUILD) bin/WordGrinder-$(VERSION)-setup.exe
# Run the Windows tests
.PHONY: wintests
wintests: $(OBJDIR)/build.ninja
$(NINJABUILD) wintests
.DELETE_ON_ERROR:
$(OBJDIR)/build.ninja:: $(LUA_INTERPRETER) build.lua Makefile
@mkdir -p $(dir $@)
$(hide) $(LUA_INTERPRETER) build.lua \
BINDIR="$(BINDIR)" \
BUILDFILE="$@.tmp" \
CC="$(CC)" \
CFLAGS="$(CFLAGS)" \
CURSES_PACKAGE="$(CURSES_PACKAGE)" \
DATE="$(DATE)" \
DESTDIR="$(DESTDIR)" \
DOCDIR="$(DOCDIR)" \
FILEFORMAT="$(FILEFORMAT)" \
LDFLAGS="$(LDFLAGS)" \
LUABITOP_PACKAGE="$(LUABITOP_PACKAGE)" \
LPEG_PACKAGE="$(LPEG_PACKAGE)" \
LUA_INTERPRETER="$(LUA_INTERPRETER)" \
LUA_PACKAGE="$(LUA_PACKAGE)" \
MAKENSIS="$(MAKENSIS)" \
MANDIR="$(MANDIR)" \
MINIZIP_PACKAGE="$(MINIZIP_PACKAGE)" \
OBJDIR="$(OBJDIR)" \
SHAREDIR="$(SHAREDIR)" \
UTHASH_PACKAGE="$(UTHASH_PACKAGE)" \
VERSION="$(VERSION)" \
WANT_STRIPPED_BINARIES="$(WANT_STRIPPED_BINARIES)" \
WINCC="$(WINCC)" \
WINDRES="$(WINDRES)" \
XFT_PACKAGE="$(XFT_PACKAGE)"
$(hide) mv $@.tmp $@
clean:
@echo CLEAN
@rm -rf $(OBJDIR) bin
ifeq ($(LUA_INTERPRETER),$(OBJDIR)/lua)
$(LUA_INTERPRETER): src/c/emu/lua-5.1.5/*.[ch]
@echo Bootstrapping build
@mkdir -p $(dir $@)
@$(CC) -o $(LUA_INTERPRETER) -O src/c/emu/lua-5.1.5/*.c src/c/emu/tmpnam.c -lm -DLUA_USE_EMU_TMPNAM
endif
.PHONY: distr
distr: wordgrinder-$(VERSION).tar.xz
.PHONY: debian-distr
debian-distr: wordgrinder-$(VERSION)-minimal-dependencies-for-debian.tar.xz
.PHONY: wordgrinder-$(VERSION).tar.xz
wordgrinder-$(VERSION).tar.xz:
tar cvaf $@ \
--transform "s,^,wordgrinder-$(VERSION)/," \
extras \
licenses \
scripts \
src \
testdocs \
tests \
tools \
build.lua \
Makefile \
README \
README.wg \
README.Windows.txt \
wordgrinder.man \
xwordgrinder.man
.PHONY: wordgrinder-$(VERSION)-minimal-dependencies-for-debian.tar.xz
wordgrinder-$(VERSION)-minimal-dependencies-for-debian.tar.xz:
tar cvaf $@ \
--transform "s,^,wordgrinder-$(VERSION)/," \
--exclude "*.dictionary" \
--exclude "src/c/emu" \
extras \
licenses \
scripts \
src \
testdocs \
tests \
tools \
build.lua \
Makefile \
README \
README.wg \
README.Windows.txt \
wordgrinder.man \
xwordgrinder.man
|