-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
165 lines (146 loc) · 4.15 KB
/
Makefile
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
.PHONY: all \
raylib swigraylib \
clean cleangen cleanbuild
## Build mode: DEBUG, RELEASE
BUILD_MODE ?= DEBUG
## Output library type
# - STATIC (.a)
# - SHARED (.dll/.so)
SWIGRAYLIB_LIBTYPE ?= SHARED
## Output library file name
SWIGRAYLIB_LIB_NAME ?= swigraylib
ifeq ($(OS),Windows_NT)
SWIGRAYLIB_LIB_NAME_PREFIX ?=
else
SWIGRAYLIB_LIB_NAME_PREFIX ?= lib
endif
SWIGRAYLIB_LIB_NAME_SUFFIX ?=
ifeq ($(SWIGRAYLIB_LIBTYPE),STATIC)
ifeq ($(OS),Windows_NT)
SWIGRAYLIB_LIB_NAME_EXTENSION ?= lib
else
SWIGRAYLIB_LIB_NAME_EXTENSION ?= a
endif
else
ifeq ($(OS),Windows_NT)
SWIGRAYLIB_LIB_NAME_EXTENSION ?= dll
else
SWIGRAYLIB_LIB_NAME_EXTENSION ?= so
endif
endif
SWIGRAYLIB_LIB_NAME_FULL = $(SWIGRAYLIB_RELEASE_PATH)/$(SWIGRAYLIB_LIB_NAME_PREFIX)$(SWIGRAYLIB_LIB_NAME)$(SWIGRAYLIB_LIB_NAME_SUFFIX).$(SWIGRAYLIB_LIB_NAME_EXTENSION)
## Output library location
SWIGRAYLIB_RELEASE_PATH ?= .
## Raylib library info
# Skip compiling raylib if use external raylib
USE_EXTERNAL_RAYLIB ?= FALSE
RAYLIB_LIB_NAME ?= raylib
RAYLIB_LIB_PATH ?= ./raylib
RAYLIB_INCLUDE_PATH ?= ./raylib/src
RAYLIB_BUILD_MODE = $(BUILD_MODE)
RAYLIB_PROJECT_PATH ?= ./raylib
# Raylib sub-make
RAYLIB_EXTRA_OPTIONS ?=
export
unexport CFLAGS
unexport LDFLAGS
unexport LDLIBS
## Swigraylib options
# The target language and the target OS correspond to the binding files provided from `gen/raylib.i/`
SWIGRAYLIB_TARGET_LANG ?= lua
ifeq ($(OS),Windows_NT)
SWIGRAYLIB_TARGET_OS ?= windows
else
UNAMEOS=$(shell uname)
ifeq ($(UNAMEOS),Linux)
SWIGRAYLIB_TARGET_OS ?= linux
endif
ifeq ($(UNAMEOS),FreeBSD)
SWIGRAYLIB_TARGET_OS ?= freebsd
endif
ifeq ($(UNAMEOS),OpenBSD)
SWIGRAYLIB_TARGET_OS ?= openbsd
endif
ifeq ($(UNAMEOS),NetBSD)
SWIGRAYLIB_TARGET_OS ?= netbsd
endif
ifeq ($(UNAMEOS),DragonFly)
SWIGRAYLIB_TARGET_OS ?= dragonfly
endif
ifeq ($(UNAMEOS),Darwin)
SWIGRAYLIB_TARGET_OS ?= macosx
endif
endif
# The generator requires SWIG
SWIGRAYLIB_BINDING_GENERATOR_OPTIONS_USE_DEFAULT ?= TRUE
# The generator requires SWIG
SWIGRAYLIB_BINDING_GENERATOR_OPTIONS ?=
## Lua library info
LUA_LIB_NAME ?= lua5.1
LUA_LIB_PATH ?= /usr/lib/x86_64-linux-gnu
LUA_INCLUDE_PATH ?= /usr/include/lua5.1
########
OBJS = raylib.i.o
RAYLIB_I_C = ./gen/raylib.i/raylib.i.$(SWIGRAYLIB_TARGET_LANG).$(SWIGRAYLIB_TARGET_OS).c
CFLAGS += -std=c99 -Wall -D_DEFAULT_SOURCE -Werror=pointer-arith
LDFLAGS += -L$(RAYLIB_LIB_PATH) -L$(LUA_LIB_PATH)
LDLIBS += -l$(RAYLIB_LIB_NAME) -l$(LUA_LIB_NAME)
INCLUDE_PATHS += -I$(RAYLIB_INCLUDE_PATH) -I$(LUA_INCLUDE_PATH)
ifeq ($(BUILD_MODE),DEBUG)
CFLAGS += -g -DSWIGRUNTIME_DEBUG
else
CFLAGS += -s -O1
endif
ifeq ($(SWIGRAYLIB_LIBTYPE),SHARED)
CFLAGS += -fPIC -DBUILD_LIBTYPE_SHARED
endif
ifeq ($(RAYLIB_MODULE_PHYSAC),TRUE)
CFLAGS += -DPHYSAC_IMPLEMENTATION
endif
all: swigraylib
raylib:
ifeq ($(USE_EXTERNAL_RAYLIB),FALSE)
$(MAKE) -C $(RAYLIB_PROJECT_PATH)/src all $(RAYLIB_EXTRA_OPTIONS)
endif
swigraylib: $(OBJS) raylib
ifeq ($(SWIGRAYLIB_LIBTYPE),STATIC)
$(AR) rcs $(SWIGRAYLIB_LIB_NAME_FULL) $(OBJS)
@echo "swigraylib static library generated $(SWIGRAYLIB_LIB_NAME_FULL)!"
endif
ifeq ($(SWIGRAYLIB_LIBTYPE),SHARED)
# WARNING: you should type "make clean" before doing this target
$(CC) -shared -o $(SWIGRAYLIB_LIB_NAME_FULL) $(OBJS) $(LDFLAGS) $(LDLIBS)
@echo "swigraylib shared library generated $(SWIGRAYLIB_LIB_NAME_FULL)!"
endif
raylib.i.o: raylib.i.c
$(CC) -c $< $(CFLAGS) $(INCLUDE_PATHS) -o $@
$(RAYLIB_I_C):
ifeq ($(SWIGRAYLIB_BINDING_GENERATOR_OPTIONS_USE_DEFAULT),TRUE)
sh ./gen/generate.default.sh
else
lua ./gen/generate.lua $(SWIGRAYLIB_BINDING_GENERATOR_OPTIONS)
endif
raylib.i.c: $(RAYLIB_I_C)
cp --update $< $@
clean: cleangen cleanbuild
cleangen:
ifeq ($(OS),Windows_NT)
del gen/raylib.i/raylib.i.*.c
else
rm -fv gen/raylib.i/raylib.i.*.c
endif
cleanbuild:
ifeq ($(USE_EXTERNAL_RAYLIB),FALSE)
$(MAKE) -C $(RAYLIB_PROJECT_PATH)/src clean $(RAYLIB_EXTRA_OPTIONS)
endif
ifeq ($(OS),Windows_NT)
del *.o /s
del raylib.i.c
del *$(RAYLIB_LIB_NAME)*.lib
del *$(RAYLIB_LIB_NAME)*.dll
else
rm -rfv *.o
rm -fv raylib.i.c
rm -fv *$(RAYLIB_LIB_NAME)*.a
rm -fv *$(RAYLIB_LIB_NAME)*.so
endif