-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathConfig.mk
More file actions
77 lines (61 loc) · 2.32 KB
/
Copy pathConfig.mk
File metadata and controls
77 lines (61 loc) · 2.32 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
# Copyright (c) 2006-2010, Intel Corporation
# All rights reserved.
# -*- mode: Makefile; -*-
# debug build
debug ?= n
# cc-option: Check if compiler supports first option, else fall back to second.
# Usage: cflags-y += $(call cc-option,$(CC),-march=winchip-c6,-march=i586)
cc-option = $(shell if test -z "`$(1) $(2) -S -o /dev/null -xc \
/dev/null 2>&1`"; then echo "$(2)"; else echo "$(3)"; fi ;)
CFLAGS_WARN = -Wall -Wformat-security -Werror -Wstrict-prototypes \
-Wextra -Winit-self -Wswitch-default -Wunused-parameter \
-Wwrite-strings \
$(call cc-option,$(CC),-Wlogical-op,) \
-Wno-missing-field-initializers
AS = as
LD = ld
CC = gcc
CPP = cpp
AR = ar
RANLIB = ranlib
NM = nm
STRIP = strip
OBJCOPY = objcopy
OBJDUMP = objdump
CFLAGS += $(CFLAGS_WARN) -fno-strict-aliasing -std=gnu99
# due to bug in gcc v4.2,3,?
CFLAGS += $(call cc-option,$(CC),-Wno-array-bounds,)
ifeq ($(debug),y)
CFLAGS += -g -DDEBUG
else
CFLAGS += -O2 -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2
endif
#
# slboot-specific build settings
#
RELEASEVER := "1.0.0"
RELEASETIME := "2021-08-01 15:00 +0800"
# if target arch is 64b, then convert -m64 to -m32 (slexec is always 32b)
CFLAGS += -m32
CFLAGS += -march=i686
CFLAGS += -nostdinc
CFLAGS += -fno-builtin -fno-common -fno-strict-aliasing
CFLAGS += -fomit-frame-pointer
CFLAGS += -pipe
CFLAGS += -iwithprefix include
CFLAGS += -I$(CURDIR)/include
# ensure no floating-point variables
CFLAGS += -msoft-float
# Disable PIE/SSP if GCC supports them. They can break us.
CFLAGS += $(call cc-option,$(CC),-nopie,)
CFLAGS += $(call cc-option,$(CC),-fno-stack-protector,)
CFLAGS += $(call cc-option,$(CC),-fno-stack-protector-all,)
CFLAGS += $(call cc-option,$(CC),-fno-stack-check,)
# changeset variable for banner
CFLAGS += -DSLEXEC_CHANGESET=\""$(shell ((hg parents --template "{isodate|isodate} {rev}:{node|short}" >/dev/null && hg parents --template "{isodate|isodate} {rev}:{node|short}") || echo "$(RELEASETIME) $(RELEASEVER)") 2>/dev/null)"\"
AFLAGS += -D__ASSEMBLY__
# Most CFLAGS are safe for assembly files:
# -std=gnu{89,99} gets confused by #-prefixed end-of-line comments
AFLAGS += $(patsubst -std=gnu%,,$(CFLAGS))
# LDFLAGS are only passed directly to $(LD)
LDFLAGS = -melf_i386