-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.mk
93 lines (77 loc) · 3 KB
/
config.mk
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
# Get the current version which is either a nearby git tag or a short-hash
# of the current commit.
VERSION ?= $(shell ./build-utils/getversion.sh)
PREFIX ?= /usr/local
INSTALLDIR := $(DESTDIR)$(PREFIX)
MANPREFIX ?= $(PREFIX)/share/man
MANPREFIX := $(DESTDIR)$(MANPREFIX)
DOCDIR ?= $(PREFIX)/share/luapdf/docs
DOCDIR := $(DESTDIR)$(DOCDIR)
# Use the Just-In-Time compiler for lua (for faster lua code execution)
# See http://luajit.org/ & http://luajit.org/performance.html for more
# information.
ifeq ($(USE_LUAJIT),1)
LUA_PKG_NAME = $(shell pkg-config --exists luajit && echo luajit)
ifeq ($(LUA_PKG_NAME),)
$(error Unable to determine luajit pkg-config name, specify manually with \
`LUA_PKG_NAME=<name> make`, use `pkg-config --list-all | grep luajit` to \
find the correct package name for your system. Please also check that you \
have luajit installed)
endif
endif
# The lua pkg-config name changes from system to system, try autodetect it.
ifeq ($(LUA_PKG_NAME),)
LUA_PKG_NAME = $(shell pkg-config --exists lua && echo lua)
endif
ifeq ($(LUA_PKG_NAME),)
LUA_PKG_NAME = $(shell pkg-config --exists lua-5.1 && echo lua-5.1)
endif
ifeq ($(LUA_PKG_NAME),)
LUA_PKG_NAME = $(shell pkg-config --exists lua5.1 && echo lua5.1)
endif
ifeq ($(LUA_PKG_NAME),)
LUA_PKG_NAME = $(shell pkg-config --exists lua51 && echo lua51)
endif
ifeq ($(LUA_PKG_NAME),)
$(error Unable to determine lua pkg-config name, specify manually with \
`LUA_PKG_NAME=<name> make`, use `pkg-config --list-all | grep lua` to \
find the correct package name for your system. Please also check that you \
have lua >= 5.1 installed)
endif
# Packages required to build luapdf
PKGS := gtk+-2.0 gthread-2.0 poppler-glib cairo-gobject $(LUA_PKG_NAME)
# Build luapdf with libunqiue bindings (for writing simple single-
# instance applications using dbus).
# To disable use `make USE_UNIQUE=0`.
ifneq ($(USE_UNIQUE),0)
CPPFLAGS += -DWITH_UNIQUE
PKGS += unique-1.0
endif
# Should we load relative config paths first?
ifneq ($(DEVELOPMENT_PATHS),0)
CPPFLAGS += -DDEVELOPMENT_PATHS
endif
# Check user has the required libs installed.
ifneq ($(shell pkg-config --print-errors --exists $(PKGS) && echo 1),1)
$(error Cannot find required libraries to build luapdf. Please check you \
have the above packages installed and try again.)
endif
# Add pre-processor flags
CPPFLAGS := -DVERSION=\"$(VERSION)\" $(CPPFLAGS)
# Generate compiler options
INCS := $(shell pkg-config --cflags $(PKGS)) -I./
CFLAGS := -std=gnu99 -ggdb -W -Wall -Wextra $(INCS) $(CFLAGS)
# Generate linker options
LIBS := $(shell pkg-config --libs $(PKGS))
LDFLAGS := $(LIBS) $(LDFLAGS) -Wl,--export-dynamic
# Building on OSX
# TODO: These lines have never been tested
#CFLAGS += -lgthread-2.0
#LDFLAGS += -pthread
# Building on FreeBSD (or just use gmake)
# TODO: These lines have never been tested
#VERSION != echo `./build-utils/getversion.sh`
#INCS != echo -I. -I/usr/include `pkg-config --cflags $(PKGS)`
#LIBS != echo -L/usr/lib `pkg-config --libs $(PKGS)`
# Custom compiler / linker
#CC = clang