-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
171 lines (147 loc) · 2.84 KB
/
Makefile
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
#
# Makefile for libscheme
#
#
# This must be an ANSI C compiler.
#
CC?=cc
#
# Determine compiler include paths.
#
CCINCLUDE:=$(shell ./conf-includes $(CC))
CCINCLUDEFLAGS:=$(CCINCLUDE:%=-I%)
#
# We are compiling library code.
#
CFLAGS+=-DIN_LIBSCHEME
#
# Use local includes.
#
CFLAGS+=-I. -Ibindings
#
# Optimization and debugging flags go here.
#
CFLAGS+=-Os -g
#
# We want lots of warnings.
#
CFLAGS+=-Wall -Wextra -Wno-unused-function -Wno-unused-parameter
#
# GCC can suggest pure, const and noreturn candidate functions.
#
#CFLAGS+= \
# -Wsuggest-attribute=const \
# -Wsuggest-attribute=format \
# -Wsuggest-attribute=malloc \
# -Wsuggest-attribute=noreturn \
# -Wsuggest-attribute=pure
#
# The math library is needed for the numeric functions
# in scheme_number.c.
#
LIBS+=-lm
#
# We also use the boehm-weiser garbage collector
#
LIBS+=-lgc
#
# Dynamic linker library
#
LIBS+=-ldl
#
# Foreign function interface library
#
LIBS+=-lffi
#
# If your system needs ranlib, put it here. Otherwise,
# use a colon.
#
RANLIB=:
#
# The size program for some stats
#
SIZE=size
#
# We currently use good old makedepend.
#
MAKEDEPEND=makedepend
#
# Source files
#
SCHEME_SRCS = \
scheme_alloc.c \
scheme_bool.c \
scheme_char.c \
scheme_env.c \
scheme_error.c \
scheme_eval.c \
scheme_fun.c \
scheme_hash.c \
scheme_list.c \
scheme_number.c \
scheme_pointer.c \
scheme_port.c \
scheme_print.c \
scheme_promise.c \
scheme_read.c \
scheme_string.c \
scheme_struct.c \
scheme_symbol.c \
scheme_syntax.c \
scheme_type.c \
scheme_vector.c
POSIX_SRCS = \
bindings/posix_file.c \
bindings/posix_proc.c
LIBDL_SRCS = \
bindings/libdl.c
LIBFFI_SRCS = \
bindings/libffi.c
#
# Object files
#
SCHEME_OBJS = $(patsubst %.c,%.o,$(SCHEME_SRCS))
POSIX_OBJS = $(patsubst %.c,%.o,$(POSIX_SRCS))
LIBDL_OBJS = $(patsubst %.c,%.o,$(LIBDL_SRCS))
LIBFFI_OBJS = $(patsubst %.c,%.o,$(LIBFFI_SRCS))
#
# Derived variables
#
SRCS = $(SCHEME_SRCS) $(POSIX_SRCS) $(LIBDL_SRCS) $(LIBFFI_SRCS)
OBJS = $(SCHEME_OBJS) $(POSIX_OBJS) $(LIBDL_OBJS) $(LIBFFI_OBJS)
# Build main executable
scheme: libscheme.a main.o
$(CC) $(CFLAGS) -o scheme main.o libscheme.a $(LIBS)
$(SIZE) scheme
# Build static library
libscheme.a: $(OBJS)
$(AR) rv libscheme.a $(OBJS)
$(RANLIB) libscheme.a
$(SIZE) libscheme.a
# Run benchmark
bench: scheme
time -v ./scheme bench.scm
.PHONY: bench
# Run tests
test: scheme
time -v ./scheme run-tests.scm
rm -f tmp1 tmp2 tmp3
.PHONY: test
# Generate index
cscope: $(SRCS)
cscope -b $(CCINCLUDEFLAGS) $(^)
.PHONY: cscope
# Update dependencies
-include Makedepends
depend: $(SRCS)
touch Makedepends
$(MAKEDEPEND) -f Makedepends $(CCINCLUDEFLAGS) -- $(CFLAGS) -- $(^)
rm Makedepends.bak
.PHONY: depend
# Clean build
clean:
$(RM) -f \
Makedepends $(OBJS) scheme main.o \
libscheme.a libscheme.aux libscheme.dvi libscheme.log \
tmp1 tmp2 tmp3 cscope.out
.PHONY: clean