-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.in
196 lines (158 loc) · 6.29 KB
/
Makefile.in
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
184
185
186
187
188
189
190
191
192
193
194
195
196
# Makefile for the Anna interpreter
#
# Copyright 2011-2014 Axel Liljencrantz
#
# Choose the compiler. Probably has to be a modern GCC version, since
# Anna uses a few GCC extensions.
CC := @CC@
ANNABIND := ANNA_BOOTSTRAP_DIRECTORY=./bootstrap bin/anna util/annabind.anna
ANNADOC := ANNA_BOOTSTRAP_DIRECTORY=./bootstrap bin/anna util/annadoc.anna
INSTALL := @INSTALL@
PACKAGE_TARNAME = @PACKAGE_TARNAME@
#
# Installation directories
#
prefix = $(DESTDIR)@prefix@
exec_prefix = @exec_prefix@
datarootdir = @datarootdir@
datadir = @datadir@
annadatadir = $(datadir)/anna
bootstrapdir = $(annadatadir)/bootstrap
bindir = @bindir@
mandir = @mandir@
docdir = @docdir@
localedir = @localedir@
libdir = ${prefix}/lib/anna
# Uncomment to get output suitable for gcov
COV_FLAGS := #--coverage
# The no-gcse flag removes the global common sub-expression
# optimization. This optimization interacts badly with computed gotos,
# a feature used heavily in the main interpreter loop. Dropping this
# optimization increases overall performance slightly. Unfortunatly,
# with lto, there does not seem to be any way to drop this flag only
# for one function or one compilation unit.
PROF_FLAGS := #-flto -O3 -fuse-linker-plugin -fno-gcse
# CFLAGS_NOWARN consists of all cflags not related to warnings. Used
# for compiling some code that we can't easily fix minor problems in,
# e.g. autogenerated code and code from external sources.
CFLAGS_NOWARN := @CFLAGS@ $(PROF_FLAGS) $(COV_FLAGS) -I include -I . \
-DANNA_BOOTSTRAP_DIRECTORY=L\"$(bootstrapdir)\" -DANNA_LIB_DIR=L\"$(libdir)\"
# Full cflags, including warnings
CFLAGS := $(CFLAGS_NOWARN) @CFLAGS_WARN@
ANNA_LIB_OBJS := src/lib/lang/lang.o src/lib/reflection/reflection.o \
src/lib/parser/parser.o src/lib/ctime.o src/lib/debug/debug.o src/lib/mp/mp.o
# All object files used by the main anna binary
ANNA_OBJS := $(ANNA_LIB_OBJS) src/dtoa.o src/node/node.o src/macro.o \
src/stack.o autogen/lex.o autogen/yacc.o src/type.o src/function.o \
src/util/util.o src/module.o src/vm.o src/alloc/alloc.o src/compile.o \
src/wutil.o src/common.o src/anna.o src/attribute.o src/object.o \
src/error.o src/parse.o src/invoke.o src/fallback.o
LDFLAGS := @LIBS@ @LDFLAGS@ -rdynamic $(PROF_FLAGS) $(COV_FLAGS)
PROGRAMS := bin/anna
ANNA_INTERNAL_BINDINGS := lib/unix.so lib/getText.so lib/readLine.so
ANNA_EXTERNAL_BINDINGS := lib/curses.so lib/math.so lib/cmath.so
all: $(PROGRAMS) bindings documentation
.PHONY: all
bindings: $(ANNA_EXTERNAL_BINDINGS)
.PHONY: bindings
internal_bindings:
for i in internalBindings/*.bind; do $(ANNABIND) $$i > lib/$$(basename $$i .bind).c; done
.PHONY: internal_bindings
lib/%.c: bindings/%.bind bin/anna
$(ANNABIND) bindings/$*.bind > $@ || rm $@
#########################################################
# BEGIN DEPENDENCY TRACKING #
# See "Recursive make considered harmful" for an #
# explanation of how this code works. #
#########################################################
%.d: %.c
@printf "%s" $@ " " >$@; $(CC) -I include -I . -MT $(@:.d=.o) -MM -MG $*.c >> $@ || rm $@
ifneq "$(MAKECMDGOALS)" "clean"
-include $(ANNA_OBJS:.o=.d)
endif
#########################################################
# END DEPENDENCY TRACKING #
#########################################################
install: all
$(INSTALL) -m 755 -d $(bindir)
for i in $(PROGRAMS); do\
$(INSTALL) -m 755 $$i $(bindir) ; \
done;
$(INSTALL) -m 755 util/annabind.anna $(bindir)/annabind
$(INSTALL) -m 755 -d $(libdir)
$(INSTALL) -m 755 -d $(bootstrapdir)
$(INSTALL) -m 644 lib/*.anna lib/*.so $(libdir)
$(INSTALL) -m 644 bootstrap/*.anna $(bootstrapdir)
for i in `find include -type d`; do\
$(INSTALL) -m 755 -d $(prefix)/$$i; \
done;
for i in `find include -name '[^.#]*.h'`; do\
$(INSTALL) -m 644 $$i $(prefix)/$$i; \
done;
for i in `cd documentation; find . -name '[^.#]*.html' -o -name '[^.#]*.js' -o -name '[^.#]*.css'`; do\
if test -f "documentation/$$i"; then $(INSTALL) -D -m 644 "documentation/$$i" $(docdir)/$$i; fi; \
done;
.PHONY: install
# make uninstall removes any anna-related directories. It doesn't try to not
# uninstall any Anna libraries that have been installed by third parties.
# If you want proper uninstall support, better use a real package manager.
uninstall:
-for i in $(PROGRAMS); do \
rm -f $(prefix)/$$i; \
done;
-rm $(bindir)/annabind
-rm $(libdir)/*
-rmdir $(libdir)
-rm $(bootstrapdir)/*
-rmdir $(bootstrapdir)
-rmdir $(annadatadir)
-rmdir $(bindir)
-rm -rf $(prefix)/include/anna/
-rm -rf $(docdir)/
.PHONY: uninstall
lib/%.o: lib/%.c
$(CC) -fPIC -c lib/$*.c -o lib/$*.o $(CFLAGS_NOWARN)
%.so: %.o
$(CC) -shared $*.o -o $@ $(LDFLAGS)
bin/anna: $(ANNA_OBJS)
$(CC) $(ANNA_OBJS) -o $@ $(LDFLAGS)
autogen/lex.c: src/lex.y
flex -CFe -8 -oautogen/lex.c -Panna_lex_ src/lex.y
autogen/lex.h: autogen/lex.c
autogen/yacc.c: src/yacc.y
bison -d src/yacc.y -o autogen/yacc.c -v -p anna_yacc_
autogen/yacc.h: autogen/yacc.c
autogen/%.c: bin/make_%.sh
./bin/make_$*.sh >autogen/$*.c
# These files consist of either external or autogenerated code, not
# much to do about the warnings, so we silence them...
src/dtoa.o: src/dtoa.c
$(CC) $(CFLAGS_NOWARN) -c src/dtoa.c -o src/dtoa.o -DIEEE_8087 -DLong=int
autogen/lex.o: autogen/lex.c
$(CC) $(CFLAGS_NOWARN) -c autogen/lex.c -o autogen/lex.o
check: test
.PHONY: check
documentation: documentation/api
documentation/api: bin/anna lib/*.anna bindings util/documentation/*.html bootstrap/*.anna util/annadoc.anna
$(ANNADOC) && touch documentation/api
test: bin/anna
time ./bin/anna_tests.sh
.PHONY: test
clean:
rm -f src/*.o src/*.d src/*/*.o src/*/*/*.d src/*/*/*.o src/*/*.d autogen/*.o autogen/*.c autogen/*.h autogen/*.d autogen/*.output *.gcov *.gcda *.gcno bin/anna gmon.out lib/*.so lib/*.o lib/*.d lib/*.o documentation/index.html $(ANNA_EXTERNAL_BINDINGS:.so=.c)
-rm -r documentation/api
.PHONY: clean
# Syntax check support for flymake
check-syntax:
for src in ${CHK_SOURCES}; do \
root=$$(head $$src|sed -n -e "s|.*// *ROOT: *\([^ ]*\).*|\1|p"); \
if test "$$root"; then \
$(CC) -o /dev/null -S $$root $(CFLAGS); \
else \
$(CC) -o /dev/null -S $$src $(CFLAGS); \
fi; \
done; true;
.PHONY: check-syntax
distclean: clean
rm -f config.status config.log include/anna/config.h Makefile
.PHONY: distclean