Compare commits
1 Commits
1dfec8af24
...
85692497a6
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
85692497a6 |
82
Makefile
82
Makefile
@ -1,70 +1,36 @@
|
|||||||
.SUFFIXES:
|
TEE :=
|
||||||
|
|
||||||
GCC_FLAGS := -g -O0 -Wall
|
GCC_FLAGS := -g -O0 -Wall
|
||||||
|
|
||||||
|
run: it1 it2
|
||||||
|
|
||||||
|
it0:
|
||||||
|
echo "Hand made"
|
||||||
|
|
||||||
all: it2-out
|
it1:
|
||||||
|
cat it1-in.lang0 | python3 it0-out.py $(if $(TEE),| tee,> ) it1-out0.py
|
||||||
|
|
||||||
|
cat it1-in.lang0 | python3 it1-out0.py $(if $(TEE),| tee,> ) it1-out1.py
|
||||||
|
diff it1-out0.py it1-out1.py > it1-out1.diff
|
||||||
|
cat it1-in.lang0 | python3 it1-out1.py $(if $(TEE),| tee,> ) it1-out2.py
|
||||||
|
diff it1-out1.py it1-out2.py > it1-out2.diff
|
||||||
|
cat it1-in.lang0 | python3 it1-out2.py $(if $(TEE),| tee,> ) it1-out.py
|
||||||
|
diff it1-out2.py it1-out.py > it1-out.diff
|
||||||
|
|
||||||
|
# See how much our hand written code differs from resulting code
|
||||||
|
-diff it0-out.py it1-out0.py > it0-out0.diff
|
||||||
|
|
||||||
# it0-out.py => Hand made
|
it2: it1
|
||||||
|
cat it2-in.lang0 | python3 it1-out.py $(if $(TEE),| tee,> ) it2-out0.py
|
||||||
|
|
||||||
|
|
||||||
it1-out0.py: it0-out.py it1-in.lang0
|
|
||||||
cat it1-in.lang0 | python3 it0-out.py > it1-out0.py
|
|
||||||
|
|
||||||
it1-out1.py: it1-out0.py it1-in.lang0
|
|
||||||
cat it1-in.lang0 | python3 it1-out0.py > it1-out1.py
|
|
||||||
# We can diff here since the target hasn't changed
|
|
||||||
# The target for it0 is the same as for it1
|
|
||||||
diff it1-out0.py it1-out1.py
|
|
||||||
|
|
||||||
it1-out2.py: it1-out1.py it1-in.lang0
|
|
||||||
cat it1-in.lang0 | python3 it1-out1.py > it1-out2.py
|
|
||||||
diff it1-out1.py it1-out2.py
|
|
||||||
|
|
||||||
it1-out3.py: it1-out2.py it1-in.lang0
|
|
||||||
cat it1-in.lang0 | python3 it1-out2.py > it1-out3.py
|
|
||||||
diff it1-out2.py it1-out3.py
|
|
||||||
|
|
||||||
it1-out.py: it1-out3.py
|
|
||||||
cp it1-out3.py it1-out.py
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
it2-out0.py: it1-out.py it2-in.lang0
|
|
||||||
cat it2-in.lang0 | python3 it1-out.py > it2-out0.py
|
|
||||||
|
|
||||||
# No gcc step since the target is still python here
|
|
||||||
|
|
||||||
it2-out1.c: it2-out0.py it2-in.lang0
|
|
||||||
cat it2-in.lang0 | python3 it2-out0.py > it2-out1.c
|
|
||||||
# diff it2-out0.py it2-out1.py Do not diff - the target changed so the output will be different
|
|
||||||
|
|
||||||
it2-out1: it2-out1.c
|
|
||||||
gcc it2-out1.c -o it2-out1 $(GCC_FLAGS)
|
|
||||||
|
|
||||||
it2-out2.c: it2-out1 it2-in.lang0
|
|
||||||
cat it2-in.lang0 | ./it2-out1 > it2-out2.c
|
|
||||||
diff it2-out1.c it2-out2.c
|
|
||||||
|
|
||||||
it2-out2: it2-out2.c
|
|
||||||
gcc it2-out2.c -o it2-out2 $(GCC_FLAGS)
|
|
||||||
|
|
||||||
it2-out3.c: it2-out2 it2-in.lang0
|
|
||||||
cat it2-in.lang0 | ./it2-out2 > it2-out3.c
|
|
||||||
diff it2-out2.c it2-out3.c
|
|
||||||
|
|
||||||
it2-out3: it2-out3.c
|
|
||||||
gcc it2-out3.c -o it2-out3 $(GCC_FLAGS)
|
|
||||||
|
|
||||||
it2-out: it2-out3
|
|
||||||
cp it2-out3 it2-out
|
|
||||||
|
|
||||||
|
|
||||||
|
cat it2-in.lang0 | python3 it2-out0.py $(if $(TEE),| tee,> ) it2-out1.c && gcc it2-out1.c -o it2-out1 $(GCC_FLAGS)
|
||||||
|
# diff it2-out0.c it2-out1.c > it2-out1.diff
|
||||||
|
cat it2-in.lang0 | ./it2-out1 $(if $(TEE),| tee,> ) it2-out2.c && gcc it2-out2.c -o it2-out2 $(GCC_FLAGS)
|
||||||
|
diff it2-out1.c it2-out2.c > it2-out2.diff
|
||||||
|
cat it2-in.lang0 | ./it2-out2 $(if $(TEE),| tee,> ) it2-out.c && gcc it2-out.c -o it2-out $(GCC_FLAGS)
|
||||||
|
diff it2-out2.c it2-out.c > it2-out.diff
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
-rm it1-out* it2-out*
|
|
||||||
-rm it1-out* it2-out* it3-out*
|
-rm it1-out* it2-out* it3-out*
|
||||||
|
|
||||||
|
.PHONY: it2
|
||||||
|
|||||||
@ -154,12 +154,10 @@ How to run
|
|||||||
Install python3 and make
|
Install python3 and make
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
make clean all
|
make clean run
|
||||||
```
|
```
|
||||||
|
|
||||||
Get more info
|
Get more info
|
||||||
```
|
```
|
||||||
make TRACE=1 clean all
|
make TRACE=1 clean run
|
||||||
```
|
```
|
||||||
|
|
||||||
You will now have a lang0 compiler in python for python in `./it1-out.py`, and one written in C for C in `./it2-out`.
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user