-
Notifications
You must be signed in to change notification settings - Fork 30
/
Copy pathsnek.defs
183 lines (141 loc) · 3.65 KB
/
snek.defs
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
SNEK_LOCAL_VPATH ?= .
vpath %.c $(SNEK_LOCAL_VPATH):$(SNEK_ROOT)
vpath %.S $(SNEK_LOCAL_VPATH):$(SNEK_ROOT)
vpath %.h $(SNEK_LOCAL_VPATH):$(SNEK_ROOT)
vpath %.ll $(SNEK_LOCAL_VPATH):$(SNEK_ROOT)
vpath %.py $(SNEK_LOCAL_VPATH):$(SNEK_ROOT)
vpath %.builtin $(SNEK_LOCAL_VPATH):$(SNEK_ROOT)
SNEK_VERSION = 1.10
SNEK_DATE = 2024-11-28
SNEK_VERSION_DASH = $(shell echo $(SNEK_VERSION) | sed 's/\./-/g')
SNEK_CLANG = $(shell if $(CC) --version | grep -q -i 'llvm\|clang'; then echo yes; else echo no; fi)
SNEK_PORTS = $(SNEK_ROOT)/ports
SNEK_HOSTS = $(SNEK_ROOT)/hosts
SNEK_DOC = $(SNEK_ROOT)/doc
SNEK_LESSONS = $(SNEK_DOC)/lessons
SNEK_DOC_UTIL = $(SNEK_DOC)/util
SNEK_SRC = \
snek-builtin.c \
snek-code.c \
snek-exec.c \
snek-error.c \
snek-frame.c \
snek-func.c \
snek-lex.c \
snek-list.c \
snek-memory.c \
snek-name.c \
snek-parse.c \
snek-poly.c \
snek-print.c \
snek-string.c \
$(SNEK_LOCAL_SRC)
SNEK_EXT_SRC = \
snek-io.c \
snek-math.c \
snek-input.c \
snek-temperature.c
SNEK_SRC_S = \
$(SNEK_LOCAL_SRC_S)
SNEK_OBJ=$(notdir $(SNEK_SRC:.c=.o)) $(notdir $(SNEK_SRC_S:.S=.o))
SNEK_RAW_INC = \
$(SNEK_ROOT)/snek.h
SNEK_BUILT_INC = \
snek-gram.h \
snek-builtin.h
SNEK_INC = \
$(SNEK_RAW_INC) \
$(SNEK_BUILT_INC) \
$(SNEK_LOCAL_INC)
SNEK_EXT_INC = \
$(SNEK_ROOT)/snek-io.h
SNEK_BUILTINS = \
$(SNEK_ROOT)/snek-keyword.builtin \
$(SNEK_ROOT)/snek-base.builtin \
$(SNEK_LOCAL_BUILTINS)
SNEK_EXT_BUILTINS = \
$(SNEK_ROOT)/snek-math.builtin \
$(SNEK_ROOT)/snek-temperature.builtin
SNEK_MOST_WARNINGS = \
-Wall \
-Wcast-align \
-Wextra \
-Wpointer-arith \
-Wstrict-prototypes \
-Wmissing-prototypes \
-Wmissing-declarations \
-Wnested-externs \
-fstrict-flex-arrays=0 \
--strict-flex-arrays=3 \
-Wshadow
ifeq ($(SNEK_CLANG),yes)
SNEK_MOST_WARNINGS += -Warray-bounds
else
SNEK_MOST_WARNINGS += -Warray-bounds=2
endif
SNEK_WARNINGS = \
$(SNEK_MOST_WARNINGS) \
-Wimplicit-fallthrough
SNEK_BASE_CFLAGS = \
-D_DEFAULT_SOURCE \
$(SNEK_PACKAGE_CFLAGS) \
-I$(SNEK_ROOT) $(SNEK_LOCAL_CFLAGS) \
-DSNEK_VERSION='"$(SNEK_VERSION)"'
LOLA_FLAGS ?=
SNEK_GLOBAL_ALIAS ?= y
SNEK_GLOBAL_NAMES ?= math random time
SNEK_BUILTIN_FLAGS += $^ $(foreach GL,$(SNEK_GLOBAL_NAMES),--global $(GL))
ifeq ($(SNEK_GLOBAL_ALIAS),y)
SNEK_BUILTIN_FLAGS += --alias
endif
ifdef SNEK_NO_SLICE
SNEK_BASE_CFLAGS += -DSNEK_NO_SLICE
SNEK_LOLA_FLAGS += -DSNEK_NO_SLICE
else
SNEK_LOLA_FLAGS += -DSNEK_SLICE
endif
ifdef SNEK_NO_DICT
SNEK_BASE_CFLAGS += -DSNEK_NO_DICT
SNEK_LOLA_FLAGS += -DSNEK_NO_DICT
else
SNEK_LOLA_FLAGS += -DSNEK_DICT
endif
ifdef SNEK_NO_FILE
SNEK_BASE_CFLAGS += -DSNEK_NO_FILE
endif
# We need a special version until debian's avr-libc package is updated
ATMEGA4809_LIBC?=/opt/avr-libc
SNEK_LDFLAGS = -Wl,--gc-sections
SNEK_CFLAGS ?= $(SNEK_WARNINGS) $(SNEK_BASE_CFLAGS)
SNEK_SED = sed \
-e 's;@ICONDIR@;$(ICONDIR);g' \
-e 's;@BINDIR@;$(BINDIR);g' \
-e 's;@SNEKLIB@;$(SNEKLIB);' \
-e 's;@SHAREDIR@;$(SHAREDIR);' \
-e 's/@SNEK_VERSION@/$(SNEK_VERSION)/' \
-e 's/@SNEK_VERSION_DASH@/$(SNEK_VERSION_DASH)/' \
-e 's;@SNEK_ROOT@;$(SNEK_ROOT);' \
-e 's/@SNEK_DATE@/$(SNEK_DATE)/'
.DEFAULT_GOAL = all
ifndef SNEK_NO_BUILD_TARGETS
snek-gram.h: $(SNEK_ROOT)/snek-gram.ll
lola $(SNEK_LOLA_FLAGS) -o $@ $^
snek-builtin.h: $(SNEK_ROOT)/snek-builtin.py $(SNEK_BUILTINS)
python3 $(SNEK_BUILTIN_FLAGS) -o $@
clean::
rm -f snek-gram.h snek-builtin.h $(SNEK_OBJ)
$(SNEK_OBJ): $(SNEK_INC)
ifndef quiet
V?=0
# The user has explicitly enabled quiet compilation.
ifeq ($(V),0)
quiet = @printf " $1 $2 $@\n"; $($1)
endif
# Otherwise, print the full command line.
quiet ?= $($1)
.c.o:
$(call quiet,CC) -c $(CFLAGS) -o $@ $<
.S.o:
$(call quiet,CC) -c $(CFLAGS) -o $@ $<
endif
endif