-
Notifications
You must be signed in to change notification settings - Fork 29
/
Makefile.shared
128 lines (115 loc) · 3.08 KB
/
Makefile.shared
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
# Shared make information between Build engine and games
ENGINELIB=libengine.a
EDITORLIB=libbuild.a
SDL2CONFIG?=$(shell which sdl2-config || which false)
PKGCONFIG?=$(shell which pkg-config || which false)
export SDL2CONFIG PKGCONFIG
BUILDCFLAGS=
BUILDCXXFLAGS=
BUILDCPPFLAGS=
BUILDLDFLAGS=-lm
# Detect the platform by interrogating the C compiler. This allows
# cross-compilation by overriding CC etc.
# For reference:
# Archlinux: x86_64-pc-linux-gnu
# Debian: x86_64-linux-gnu i386-linux-gnu aarch64-linux-gnu arm-linux-gnueabihf
# macOS: x86_64-apple-darwin18.2.0
# mingw32: x86_64-w64-mingw32 i686-w64-mingw32
# FreeBSD: x86_64-unknown-freebsd10.4
TARGETMACHINE?=$(strip $(shell $(CC) -dumpmachine))
export TARGETMACHINE
ifndef PLATFORM
PLATFORM=UNKNOWN
ifneq (,$(findstring -linux,$(TARGETMACHINE)))
PLATFORM=LINUX
endif
ifneq (,$(findstring -freebsd,$(TARGETMACHINE)))
PLATFORM=BSD
endif
ifneq (,$(findstring -mingw32,$(TARGETMACHINE)))
PLATFORM=WINDOWS
endif
ifneq (,$(findstring -darwin,$(TARGETMACHINE)))
PLATFORM=DARWIN
endif
ifneq (,$(findstring -haiku,$(TARGETMACHINE)))
PLATFORM=HAIKU
endif
endif
ifndef ARCHITECTURE
ARCHITECTURE=UNKNOWN
ifneq (,$(findstring aarch64-,$(TARGETMACHINE)))
ARCHITECTURE=ARM_64
endif
ifneq (,$(findstring arm-,$(TARGETMACHINE)))
ARCHITECTURE=ARM
endif
ifneq (,$(findstring x86_64-,$(TARGETMACHINE)))
ARCHITECTURE=X86_64
endif
ifneq (,$(findstring i386-,$(TARGETMACHINE)))
ARCHITECTURE=X86
endif
ifneq (,$(findstring i486-,$(TARGETMACHINE)))
ARCHITECTURE=X86
endif
ifneq (,$(findstring i586-,$(TARGETMACHINE)))
ARCHITECTURE=X86
endif
ifneq (,$(findstring i686-,$(TARGETMACHINE)))
ARCHITECTURE=X86
endif
endif
ifeq ($(PLATFORM),WINDOWS)
RENDERTYPE ?= WIN
EXESUFFIX=.exe
BUILDLDFLAGS+= -lmingwex -lwinmm -lws2_32 -lcomctl32 -lcomdlg32 -luxtheme -lxinput9_1_0
else
RENDERTYPE=SDL
EXESUFFIX=
ifeq ($(PLATFORM),DARWIN)
BUILDLDFLAGS+= -Wl,-dead_strip -Wl,-dead_strip_dylibs
endif
ifeq ($(PLATFORM),HAIKU)
BUILDLDFLAGS+= -lnetwork
endif
endif
ifeq ($(RENDERTYPE),SDL)
ifneq ($(SDL2CONFIG),)
SDLCONFIG_CFLAGS=$(shell $(SDL2CONFIG) --cflags)
SDLCONFIG_LIBS=$(shell $(SDL2CONFIG) --libs)
else
$(error No $(SDL2CONFIG) could be found)
endif
ifeq (1,$(WITHOUT_GTK))
HAVE_GTK=0
else
ifneq (,$(shell $(PKGCONFIG) --atleast-version=3.4 gtk+-3.0 && echo yes))
HAVE_GTK=1
GTKCONFIG_CFLAGS=-DHAVE_GTK $(shell $(PKGCONFIG) --cflags gtk+-3.0)
GTKCONFIG_LIBS=$(shell $(PKGCONFIG) --libs gtk+-3.0) -ldl
else
HAVE_GTK=0
endif
endif
endif
ifeq ($(RENDERTYPE),WIN)
BUILDLDFLAGS+= -mwindows -ldxguid
#BUILDLDFLAGS+= -static
#BUILDLDFLAGS+= -static-libgcc -static-libstdc++
endif
# Until I work out how to deal with PIE and PIC, the x86 inline
# assembly is hopelessly broken, so it's forced off for all.
#ifneq ($(ARCHITECTURE),X86)
USE_ASM=0
#endif
BUILDCPPFLAGS+= -DRENDERTYPE$(RENDERTYPE)=1
ifneq (0,$(USE_POLYMOST))
BUILDCPPFLAGS+= -DUSE_POLYMOST=$(USE_POLYMOST)
endif
ifneq (0,$(USE_OPENGL))
BUILDCPPFLAGS+= -DUSE_OPENGL=$(USE_OPENGL)
endif
ifneq (0,$(USE_ASM))
BUILDCPPFLAGS+= -DUSE_ASM=$(USE_ASM)
endif