summaryrefslogtreecommitdiff
path: root/05/Makefile
blob: 01194ff96908ecdce505fe9deb4b58d3ab4502e1 (plain)
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
TCCDIR=tcc-0.9.27
TCC=$(TCCDIR)/tcc
TCC0=$(TCC)0
TCCINST=tcc-bootstrap
all: out04 a.out $(TCCDIR)/lib/libtcc1.a
in04: *.b ../04a/out04
	../04a/out04 main.b in04
out04: in04 ../04/out03
	../04/out03 in04 out04
%.html: %.md ../markdown
	../markdown $<
%.out: %.c *.h out04
	./out04 $< $@
a.out: main.c *.h out04
	./out04
test.out: test.s.o test.c.o
	$(TCC0) -static -nostdlib test.s.o test.c.o -o test.out
test.s.o: $(TCC0) test.s
	$(TCC0) -static -nostdlib -c test.s -o test.s.o
test.c.o: $(TCC0) test.c
	$(TCC0) -static -nostdlib -c test.c -o test.c.o
$(TCC0): $(TCCDIR)/*.c $(TCCDIR)/*.h out04
	cd $(TCCDIR) && ../out04 tcc.c tcc0
$(TCCDIR)/lib/libtcc1.a: $(TCC0) $(TCCDIR)/lib/*.[cS]
	$(TCC0) -c $(TCCDIR)/lib/alloca86_64-bt.S -o $(TCCDIR)/lib/alloca86_64-bt.o
	$(TCC0) -c $(TCCDIR)/lib/alloca86_64.S -o $(TCCDIR)/lib/alloca86_64.o
	$(TCC0) -c $(TCCDIR)/lib/va_list.c -o $(TCCDIR)/lib/va_list.o
	$(TCC0) -c $(TCCDIR)/lib/libtcc1.c -o $(TCCDIR)/lib/libtcc1.o
	$(TCC0) -ar $(TCCDIR)/lib/libtcc1.a $(TCCDIR)/lib/*.o
install: $(TCCDIR)/lib/libtcc1.a $(TCCDIR)/include/*.h
	mkdir -p $(TCCINST)/include
	cp -r $(TCCDIR)/include/*.h $(TCCINST)/include/
	cp -r $(TCCDIR)/lib/libtcc1.a $(TCCINST)/
	$(MAKE) -C musl-0.6.0
	$(MAKE) -C musl-0.6.0 install
$(TCC)1: $(TCC0) $(TCCINST)/libtcc1.a
	cd $(TCCDIR) && ./tcc0 -nostdinc -nostdlib -B ../tcc-boostrap -L../musl-bootstrap/lib -lc -I ../musl-bootstrap/include tcc.c -o tcc1
tcc: $(TCC)1

$(TCC)2: $(TCC)1
	cd $(TCCDIR) && ./tcc1 tcc.c -o tcc2
$(TCC)0a: $(TCCDIR)/*.c $(TCCDIR)/*.h
	cd $(TCCDIR) && gcc tcc.c -o tcc0a
$(TCC)1a: $(TCCDIR)/*.c $(TCCDIR)/*.h
	cd $(TCCDIR) && ./tcc0a tcc.c -o tcc1a
clean:
	rm -rf musl-bootstrap
	rm -rf tcc-bootstrap
	rm -f out* README.html *.out *.o $(TCCDIR)/tcc[0123456] $(TCCDIR)/tcc[0123456]a $(TCCDIR)/lib/*.[oa]