-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsys.mk
More file actions
87 lines (67 loc) · 2.52 KB
/
sys.mk
File metadata and controls
87 lines (67 loc) · 2.52 KB
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
# Extract the top directory
TOP_DIR_SHORT:=$(dir $(lastword $(MAKEFILE_LIST)))
TOP_DIR:=$(abspath $(TOP_DIR_SHORT))
# Allow the flags to be overwritten by config.mk
CFLAGS:=
CXXFLAGS:=
LDFLAGS:=
DEPS:=
# This is not defined
STRIP:=strip
EXTERN_DIR:=$(TOP_DIR)/extern
EXTERN_DIR_SHORT:=$(TOP_DIR_SHORT)/extern
PKG_DIR:=$(EXTERN_DIR)/pkg
include $(TOP_DIR)/config.mk
# Get the OS version
UNAME:=$(shell uname -s)
ifneq ($(findstring CYGWIN, $(UNAME)),)
SYS_CFLAGS := -DSYS_WINDOWS -DOS_CYGWIN
USE_MANIFEST := true
WINDRES := windres
XBUILD_TARGET ?= i686-w64-mingw32
XBUILD_ERROR := Unable to find the 32-bit MinGW compiler. Please install the mingw64-i686-gcc-core package
endif
ifneq ($(findstring MINGW, $(UNAME)),)
# MinGW doesn't have a default compiler so we have to force it to GCC
SYS_CFLAGS := -DSYS_WINDOWS -DOS_MINGW
CC := gcc
CXX := g++
LD := gcc
endif
ifneq ($(findstring DragonFly, $(UNAME)),)
SYS_CFLAGS := -DSYS_UNIX -DOS_DRAGONFLY
XBUILD_TARGET ?= i686-w64-mingw32
XBUILD_ERROR := Unable to find the 32-bit MinGW compiler.
endif
ifneq ($(findstring Linux, $(UNAME)),)
SYS_CFLAGS := -DSYS_UNIX -DOS_LINUX
# Linux actually has these available
XBUILD_TARGET ?= i686-w64-mingw32
XBUILD_ERROR := Unable to find the 32-bit MinGW compiler. Please install the gcc-mingw-w64 package
endif
# Check if we should do a MinGW cross compile
ifndef NATIVE_BUILD
# Override the system CFLAGS
SYS_CFLAGS := -DSYS_WINDOWS -DOS_MINGW
USE_MANIFEST := true
XBUILD_CC := $(XBUILD_TARGET)-gcc
XBUILD_CXX := $(XBUILD_TARGET)-g++
XBUILD_LD := $(XBUILD_TARGET)-gcc
XBUILD_AR := $(XBUILD_TARGET)-ar
XBUILD_STRIP := $(XBUILD_TARGET)-strip
XBUILD_WINDRES := $(XBUILD_TARGET)-windres
# This will be used for the --build flag to configure; auto-guess it using the -dumpmachine option of GCC
XBUILD_MACH ?= $(shell gcc -dumpmachine)
ifneq ($(findstring GCC,$(shell $(XBUILD_CC) --version)),GCC)
$(error $(XBUILD_ERROR))
endif
CC := $(XBUILD_CC)
CXX := $(XBUILD_CXX)
LD := $(XBUILD_LD)
AR := $(XBUILD_AR)
STRIP := $(XBUILD_STRIP)
WINDRES := $(XBUILD_WINDRES)
EXE := .exe
endif
CFLAGS += $(SYS_CFLAGS)
CXXFLAGS += $(SYS_CFLAGS)