-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile.inc
92 lines (79 loc) · 1.56 KB
/
Makefile.inc
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
#
# Makefile.inc
#
# if needed, adjust the correct prefix for your specific toolchain, e.g.
#TOOLCHAIN := i686-w64-mingw32-
CC := $(TOOLCHAIN)gcc
AR := $(TOOLCHAIN)ar
OCPY := $(TOOLCHAIN)objcopy
# name prefixes
PREFIX_LONG = lucciefr
PREFIX_SHORT = lcfr
LDFLAGS += -static-libgcc
# "global" libs for linking: math
LD_LIBS := -lm
# platform specific rules:
ARCH := $(shell uname -s)
ifeq ($(ARCH),Linux)
LINUX := 1
TARGET := lin
CFLAGS += -fPIC
DLL := .so
# dynamic loading
LD_LIBS += -ldl
# POSIX threads
LD_LIBS += -lpthread
else
ifeq ($(ARCH),Darwin) # MacOSX
DARWIN := 1
TARGET := osx
DLL := .so
# dynamic loading
LD_LIBS += -ldl
# POSIX threads
LD_LIBS += -lpthread
else # Windows, MinGW
WINDOWS := 1
TARGET := win
EXE := .exe
DLL := .dll
# PE format
BINFMT_32 := pei-i386
BINFMT_64 := pei-x86-64
# objcopy needs to add a '_' prefix
OFLAGS := --change-leading-char
# process API
LD_LIBS += -lpsapi
endif
endif
# default values for (unset) build vars
BITS ?= 32
DEBUG ?= 0
LINUX ?= 0
DARWIN ?= 0
WINDOWS ?= 0
BINFMT_32 ?= elf32-i386
BINFMT_64 ?= elf64-x86-64
BUILDVARS := -D_GNU_SOURCE
BUILDVARS += -DBITS=$(BITS)
BUILDVARS += -DDEBUG=$(DEBUG)
BUILDVARS += -D_LINUX=$(LINUX)
BUILDVARS += -D_DARWIN=$(DARWIN)
BUILDVARS += -D_WINDOWS=$(WINDOWS)
ifeq ($(DEBUG),1)
CFLAGS += -g
else
# strip executables
LDFLAGS += -s
endif
CFLAGS += -m$(BITS) $(BUILDVARS)
# objcopy flags
OFLAGS += -I binary -B i386
ifeq ($(BITS), 32)
OFLAGS += -O $(BINFMT_32)
else
OFLAGS += -O $(BINFMT_64)
endif
ifeq ($(QUIET),1)
TO_NULL = >/dev/null
endif