forked from ers35/colorforth
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile.unix
109 lines (78 loc) · 2.48 KB
/
Makefile.unix
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
#-*- Makefile -*-
# Use EXTRA_CF to embed additional colorForth source in the full build,
# EXTRA_CFLAGS=-DUNSAFE_MODE to unsafe colorForth
#
# Example:
# make EXTRA_CF=my-def.cf full
# make EXTRA_CFLAGS=-DUNSAFE_MODE
default: colorforth
all: colorforth
.PHONY: optim_cpl full
CC=gcc
SRC=src/cf.c \
src/cf-stdio.c \
src/color.c \
src/utils.c
INCLUDED_SRC=src/core.c \
src/lib.c \
ext/ext.c \
ext/parser.c \
ext/io.c \
ext/time.c \
ext/math.c \
ext/math-float.c \
ext/dict.c \
ext/os.c \
ext/threads.c \
ext/mp-math.c \
ext/network.c \
ext/sdl.c
SRC_H=src/cf.h \
conf.h \
src/cf-stdio.h \
src/color.h \
src/utils.h
SRC_CF= src-cf/lib.cf \
src-cf/string.cf \
src-cf/utils.cf \
src-cf/quotation.cf
FLAGS=-fPIE -std=gnu99 -O3 -Wall -Werror -Wextra -pedantic \
-s -Wno-missing-braces -Wno-missing-field-initializers -Wno-unused-parameter \
-I. -Isrc -Iext
EXTRA_CLIBS=-lgmp -lpthread
# uncomment the line below if you want to include SDL words
#SDL_FLAGS=`sdl2-config --cflags --libs` -I. -lSDL2_image -lSDL2_ttf -lSDL2_mixer -fPIC
BUILD_ARGS=$(FLAGS) $(EXTRA_CFLAGS) src/main.c $(SRC) $(EXTRA_CLIBS) $(SDL_FLAGS)
optim_cpl:
$(eval EXTRA_CFLAGS := -Wl,--build-id=none -Wl,--gc-sections -Wl,-zcommon-page-size=64 -zmax-page-size=4096)
conf.h: src/conf.tmpl.h
cp src/conf.tmpl.h conf.h
ext/ext.c: ext/0_tmpl.c
cp ext/0_tmpl.c ext/ext.c
colorforth-base: Makefile conf.h src/main.c $(SRC) $(INCLUDED_SRC) $(SRC_H)
$(CC) $(BUILD_ARGS) -o colorforth-base
src-cf/lib-full.cf: $(SRC_CF) $(EXTRA_CF) src-cf/dump-state.cf
cat $(SRC_CF) $(EXTRA_CF) src-cf/dump-state.cf > src-cf/lib-full.cf
src/saved-state.c: colorforth-base src-cf/lib-full.cf
./colorforth-base src-cf/lib-full.cf > src/saved-state.c
colorforth: src/saved-state.c
$(CC) $(BUILD_ARGS) -D__FROM_STATE_FILE -D__ECHO_COLOR -o colorforth
optimize:
@#readelf -l colorforth
@# required: .gnu.version .gnu.version_r
strip --strip-all colorforth
strip -R.comment -R.note -R.eh_frame_hdr -R.eh_frame -R.note.ABI-tag -R.jcr colorforth
objcopy -I elf64-x86-64 -O elf64-x86-64 --section-alignment 512 colorforth colorforth
@#xcc -std=c99 -Os -Wno-missing-braces -target=XS1-L16A-128-QF124-C10 colorforth.c -o colorforth.xe
dump: colorforth
objdump -d -M intel colorforth | less
dumpelf: colorforth
readelf -a colorforth | less
cleanelf: colorforth
termux-elf-cleaner colorforth
clean:
rm -f colorforth-base colorforth
clean-state:
rm -f src/saved-state.c src-cf/lib-full.cf
mrproper: clean clean-state
rm -f conf.h