summaryrefslogtreecommitdiff
path: root/config.mk (plain)
blob: 925d25c33ea882b823cab3ee2c5bf58528adaa10
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

# build configuration file

# ?= is used to allow overriding through environment variables or from an
# upper-level Makefile. change ?= to = when modifying values.
# $(shell) should only be used in simply expanded variables (using :=), so
# we can't just use ?=. we check if the variable's empty before setting it.

# RATIONALE

# This package doesn't use autoconf and automake, which are ugly both in
# design and implementation, and although they may support hundreds of Unix
# variants, each of them broken in its own special way, they don't help very
# much on Windows and OS X.
#
# To make porting as simple as possible when autoconf's extensible database
# of kludges and workarounds isn't available, a "worse is better" philosophy
# was adopted: even if the generic config.mk won't work on strange platforms,
# it is so small and simple that the platform's users, who are knowledgeable
# about it and can experiment with it, shouldn't have a problem changing
# options or even replacing the entire build system.
#
# The project's philosophy is that platform-specific tweaks and workarounds
# should be provided, but kept as self-contained as possible. For example,
# config.mk should stay platform-agnostic, and platforms needing specific
# options should have them in separate files.

# PROGRAMS

CC = gcc

INSTALL = install

RM = rm -f

ifeq ($(LUA),)
LUA := $(if $(shell lua5.1 -e 'print(true)' 2>&-),lua5.1,lua)
endif

# INSTALLATION

PREFIX ?= /usr/local
BINDIR ?= $(PREFIX)/bin
DATADIR ?= $(PREFIX)/share/ult

# 'make install' prefixes destinations with $(DESTDIR) when installing. This
# can be used for staged installs and binary package creation.
DESTDIR =

# COMPILATION FLAGS

CFLAGS ?= -O2 -Wall
LDFLAGS ?=

ifeq ($(LUA_CFLAGS),)
LUA_CFLAGS := $(or $(shell pkg-config --silence-errors --cflags lua5.1),$(shell pkg-config --silence-errors --cflags 'lua >= 5.1'))
endif
ifeq ($(LUA_LDFLAGS),)
LUA_LDFLAGS := $(or $(shell pkg-config --silence-errors --libs lua5.1),$(shell pkg-config --silence-errors --libs 'lua >= 5.1'),-llua)
endif

ifeq ($(SDL_CFLAGS),)
SDL_CFLAGS := $(shell sdl-config --cflags)
endif
ifeq ($(SDL_LDFLAGS),)
SDL_LDFLAGS := $(or $(shell sdl-config --libs),-lSDL)
endif

ifeq ($(FREETYPE_CFLAGS),)
FREETYPE_CFLAGS := $(shell freetype-config --cflags)
endif
ifeq ($(FREETYPE_LDFLAGS),)
FREETYPE_LDFLAGS := $(or $(shell freetype-config --libs),-lfreetype)
endif

SDL_IMAGE_CFLAGS ?=
SDL_IMAGE_LDFLAGS ?= -lSDL_image

SDL_MIXER_CFLAGS ?=
SDL_MIXER_LDFLAGS ?= -lSDL_mixer

GL_LDFLAGS ?= -lGL
GLU_LDFLAGS ?= -lGLU

ZLIB_CFLAGS ?=
ZLIB_LDFLAGS ?= -lz

# LUAJIT

# JITLIB is the directory containing opt.lua and other LuaJIT .lua files.
# Don't forget to set LUA_LDFLAGS and LUA_CFLAGS to LuaJIT libs and includes.

ifeq ($(JITLIB),)
JITLIB := $(dir $(wildcard /usr/share/lua/jit/opt.lua))
endif