Skip to content

Commit

Permalink
Fix most targets in the Makefile, using stage-1 when needed.
Browse files Browse the repository at this point in the history
  • Loading branch information
attila-lendvai committed Jan 29, 2014
1 parent 42cbcf9 commit 866be90
Show file tree
Hide file tree
Showing 4 changed files with 120 additions and 89 deletions.
203 changes: 117 additions & 86 deletions Makefile
Expand Up @@ -21,7 +21,8 @@ SO = so
SOCFLAGS = -shared -msse -msse2
endif

.SUFFIXES :
.SUFFIXES:
.SECONDARY:

all : eval

Expand All @@ -34,47 +35,64 @@ status : .force
eval :
cd bootstrap/c ; make

stage-% : build/stage-%/eval
@true >/dev/null

build/stage-%/eval :
echo Building stage-$*
rm -rf ./build/stage-$*
mkdir -p build
git clone --branch stage-$* . ./build/stage-$*
cd ./build/stage-$* ; make

check-maru : eval
# FIXME: maru-nfibs.k is not checked in the repo?
# FIXME: maru-nfibs.k is not checked into the repo?
# ./eval ir-gen-c.k maru.k maru-nfibs.k
./eval ir-gen-c.k maru.k maru-gc.k
./eval ir-gen-c.k maru.k maru-test.k

check-marux : eval
# FIXME: maru-nfibs.k is not checked in the repo?
# FIXME: maru-nfibs.k is not checked into the repo?
# ./eval ir-gen-x86.k maru.k maru-nfibs.k
./eval ir-gen-x86.k maru.k maru-gc.k
./eval ir-gen-x86.k maru.k maru-test.k

test-maru : eval
./eval ir-gen-c.k maru.k maru-test.k > test.c && cc -fno-builtin -g -o test test.c -ldl && ./test 32
# FIXME: maru-nfibs.k is not checked in the repo?
# ./eval ir-gen-c.k maru.k maru-nfibs.k > test.c && cc -fno-builtin -g -o test test.c -ldl && ./test 32
./eval ir-gen-c.k maru.k maru-gc.k > test.c && cc -fno-builtin -g -o test test.c -ldl && ./test 32
mkdir -p build
./eval ir-gen-c.k maru.k maru-test.k > ./build/test.c && cc -fno-builtin -g -o ./build/test ./build/test.c -ldl && ./build/test 32
# FIXME: maru-nfibs.k is not checkedto in the repo?
# ./eval ir-gen-c.k maru.k maru-nfibs.k > ./build/test.c && cc -fno-builtin -g -o ./build/test ./build/test.c -ldl && ./build/test 32
./eval ir-gen-c.k maru.k maru-gc.k > ./build/test.c && cc -fno-builtin -g -o ./build/test ./build/test.c -ldl && ./build/test 32

# FIXME test2.c and maru-test2.k are not checked into the repo?
#test-maru : eval
# ./eval2 ir-gen-x86.k maru.k maru-test2.k > test.s && cc -fno-builtin -g -o test2 test2.c test.s && ./test2 15
test2-maru : stage-1
cd ./build/stage-1/ ; ./eval2 ../../ir-gen-x86.k ../../maru.k ../../maru-test2.k > ../../build/test.s
cc -fno-builtin -g -o ../../build/test2 ../../build/test2.c ../../build/test.s
./build/test2 15

# FIXME test2.c and maru-test3.k are not checked into the repo?
test3-maru : eval2
./eval2 ir-gen-x86.k maru.k maru-test3.k > test.s && cc -m32 -fno-builtin -g -o test3 test.s && ./test3

maru-check : eval .force
./eval -g ir-gen-x86.k maru.k maru-check.k > maru-check.s
cc -m32 -o maru-check maru-check.s
./maru-check
./eval -g ir-gen-x86.k maru.k maru-check.k > ./build/maru-check.s
cc -m32 -o ./build/maru-check ./build/maru-check.s
./build/maru-check

maru-check-c : eval .force
./eval ir-gen-c.k maru.k maru-check.k > maru-check.c
cc -o maru-check maru-check.c -ldl
./maru-check
./eval ir-gen-c.k maru.k maru-check.k > ./build/maru-check.c
cc -o ./build/maru-check ./build/maru-check.c -ldl
./build/maru-check

maru-label : eval .force
./eval ir-gen-x86.k maru.k maru-label.k > maru-label.s
cc -m32 -o maru-label maru-label.s
./maru-label
./eval ir-gen-x86.k maru.k maru-label.k > ./build/maru-label.s
cc -m32 -o ./build/maru-label ./build/maru-label.s
./build/maru-label

maru-label-c : eval .force
./eval ir-gen-c.k maru.k maru-label.k > maru-label.c
cc -o maru-label maru-label.c -ldl
./maru-label
./eval ir-gen-c.k maru.k maru-label.k > ./build/maru-label.c
cc -o ./build/maru-label ./build/maru-label.c -ldl
./build/maru-label

NFIBS=40

Expand Down Expand Up @@ -107,106 +125,122 @@ cg : eval .force
ld --build-id --eh-frame-hdr -m elf_i386 --hash-style=both -dynamic-linker /lib/ld-linux.so.2 -o test /usr/lib/gcc/i486-linux-gnu/4.4.5/../../../../lib/crt1.o /usr/lib/gcc/i486-linux-gnu/4.4.5/../../../../lib/crti.o /usr/lib/gcc/i486-linux-gnu/4.4.5/crtbegin.o -L/usr/lib/gcc/i486-linux-gnu/4.4.5 -L/usr/lib/gcc/i486-linux-gnu/4.4.5 -L/usr/lib/gcc/i486-linux-gnu/4.4.5/../../../../lib -L/lib/../lib -L/usr/lib/../lib -L/usr/lib/gcc/i486-linux-gnu/4.4.5/../../.. a.out -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/gcc/i486-linux-gnu/4.4.5/crtend.o /usr/lib/gcc/i486-linux-gnu/4.4.5/../../../../lib/crtn.o
./test

test : emit.l eval.l eval1
$(TIME) ./eval1 -O emit.l eval.l > test.s && $(CC32) -c -o test.o test.s && size test.o && $(CC32) -o test test.o
bootstrapped-eval : build/bootstrapped-eval
@true >/dev/null

build/bootstrapped-eval : emit.l eval.l stage-1
# we could do it this way also, but in the current setup (require "osdefs.k") would not find the stage-1 osdefs.k, so we need to cd there instead
# $(TIME) ./build/stage-1/eval1 -b ./build/stage-1/boot.l -O emit.l eval.l > ./build/test.s
cd ./build/stage-1/ ; $(TIME) ./eval1 -O ../../emit.l ../../eval.l > ../bootstrapped-eval.s
$(CC32) -c -o ./build/bootstrapped-eval.o ./build/bootstrapped-eval.s
size ./build/bootstrapped-eval.o
$(CC32) -o ./build/bootstrapped-eval ./build/bootstrapped-eval.o

time : .force
$(TIME) ./eval1 -O emit.l eval.l eval.l eval.l eval.l eval.l > /dev/null
time : .force stage-1
cd ./build/stage-1/ ; $(TIME) ./eval1 -O ../../emit.l ../../eval.l ../../eval.l ../../eval.l ../../eval.l ../../eval.l > /dev/null

test2 : test .force
$(TIME) ./test -O boot.l emit.l eval.l > test2.s
diff test.s test2.s
test2 : stage-1 bootstrapped-eval .force
cd ./build/stage-1/ ; $(TIME) ../../build/bootstrapped-eval -O boot.l ../../emit.l ../../eval.l > ../../build/re-bootstrapped-eval.s
diff ./build/bootstrapped-eval.s ./build/re-bootstrapped-eval.s

time2 : .force
$(TIME) ./test boot.l emit.l eval.l eval.l eval.l eval.l eval.l > /dev/null
time2 : .force stage-1
ln -sf ./stage-1/osdefs.k ./build/osdefs.k
cd ./build/ ; $(TIME) ./bootstrapped-eval ./stage-1/boot.l ../emit.l ../eval.l ../eval.l ../eval.l ../eval.l ../eval.l > /dev/null

test-eval : test .force
$(TIME) ./test test-eval.l
# FIXME: test-eval.l is not checked into the repo?
test-eval : bootstrapped-eval .force
$(TIME) ./build/bootstrapped-eval test-eval.l

test-boot : test .force
$(TIME) ./test boot-emit.l
# FIXME: boot-emit.l is not checked into the repo?
test-boot : bootstrapped-eval .force
$(TIME) ./build/bootstrapped-eval boot-emit.l

# FIXME: ./emit.l ?!
test-emit : eval .force
./emit.l test-emit.l | tee test.s && $(CC32) -c -o test.o test.s && size test.o && $(CC32) -o test test.o && ./test

peg.l : eval parser.l peg-compile.l peg-boot.l peg.g
-rm peg.l.new
./eval parser.l peg-compile.l peg-boot.l > peg.l.new
-mv peg.l peg.l.$(shell date '+%Y%m%d.%H%M%S')
mv peg.l.new peg.l
build/peg.l : eval parser.l peg-compile.l peg-boot.l peg.g
./eval parser.l peg-compile.l peg-boot.l > ./build/peg.l

test-repl : eval peg.l .force
test-repl : eval build/peg.l .force
./eval repl.l test-repl.l

test-peg : eval peg.l .force
$(TIME) ./eval parser.l peg.l test-peg.l > peg.n
$(TIME) ./eval parser.l peg.n test-peg.l > peg.m
diff peg.n peg.m
# FIXME this seems to get into an endless loop, or just runs longer than half an hour?
test-peg : eval build/peg.l .force
$(TIME) ./eval parser.l ./build/peg.l test-peg.l > ./build/peg.n
$(TIME) ./eval parser.l ./build/peg.n test-peg.l > ./build/peg.m
diff ./build/peg.n ./build/peg.m

test-compile-grammar :
./eval compile-grammar.l test-dc.g > test-dc.g.l
./eval compile-grammar.l test-dc.g > ./build/test-dc.g.l
./eval compile-dc.l test.dc

test-compile-irgol : eval32 irgol.g.l .force
./eval compile-irgol.l test.irgol > test.c
$(CC32) -fno-builtin -g -o test test.c
# FIXME this dies both all three eval.c versions
test-compile-irgol : eval build/irgol.g.l .force
# cd ./build/stage-1/ ; ln -sf ../../build/irgol.g.l . ; ./eval1 ../../compile-irgol.l ../../test.irgol > ../../build/test.c
./eval compile-irgol.l test.irgol > ./build/test.c
$(CC32) -fno-builtin -g -o ./build/test ./build/test.c
@echo
./test
./build/test

irgol.g.l : tpeg.l irgol.g
./eval compile-tpeg.l irgol.g > irgol.g.l
build/irgol.g.l : eval compile-tpeg.l build/tpeg.l irgol.g
./eval compile-tpeg.l irgol.g > ./build/irgol.g.l

# FIXME: irgol.k is not checked into the repo?
test-irgol : eval .force
./eval irgol.k |tee test.c
$(CC32) -fno-builtin -g -o test test.c
./eval irgol.k | tee ./build/test.c
$(CC32) -fno-builtin -g -o ./build/test ./build/test.c
@echo
./test
./build/test

test-compile-irl : eval32 irl.g.l .force
./eval compile-irl.l test.irl > test.c
$(CC32) -fno-builtin -g -o test test.c
test-compile-irl : stage-1 build/irl.g.l .force
cd ./build/stage-1/ ; ln -sf ../../build/irl.g.l . ; ./eval1 ../../compile-irl.l ../../test.irl > ../../build/test.c
# ./eval compile-irl.l test.irl > ./build/test.c
$(CC) -fno-builtin -g -o ./build/test ./build/test.c
@echo
./test
./build/test

irl.g.l : tpeg.l irl.g
./eval compile-tpeg.l irl.g > irl.g.l
build/irl.g.l : eval compile-tpeg.l build/tpeg.l irl.g
./eval compile-tpeg.l irl.g > ./build/irl.g.l

# FIXME this fails with: string-length: non-String argument: ()
test-ir : eval .force
./eval test-ir.k > test.c
$(CC32) -fno-builtin -g -o test test.c
@echo
./test

tpeg.l : tpeg.g compile-peg.l compile-tpeg.l
$(TIME) ./eval compile-peg.l tpeg.g > tpeg.l.new
-test -f tpeg.l && cp tpeg.l tpeg.l.$(NOW)
mv tpeg.l.new tpeg.l
$(TIME) ./eval compile-tpeg.l tpeg.g > tpeg.ll
sort tpeg.l > tpeg.ls
sort tpeg.ll > tpeg.lls
diff tpeg.ls tpeg.lls
rm tpeg.ls tpeg.ll tpeg.lls

test-mach-o : eval32 .force
build/tpeg.l : eval tpeg.g compile-peg.l
$(TIME) ./eval compile-peg.l tpeg.g > ./build/tpeg.l

test-tpeg.l : build/tpeg.l stage-1 compile-tpeg.l
# -test -f tpeg.l && cp tpeg.l tpeg.l.$(NOW)
# mv tpeg.l.new tpeg.l
$(TIME) ./eval compile-tpeg.l tpeg.g > ./build/tpeg.ll
sort ./build/tpeg.l > ./build/tpeg.l.sorted
sort ./build/tpeg.ll > ./build/tpeg.ll.sorted
diff ./build/tpeg.l.sorted ./build/tpeg.ll.sorted

test-mach-o : eval .force
./eval32 test-mach-o.l
@echo
size a.out
chmod +x a.out
@echo
./a.out

test-elf : eval32 .force
test-elf : eval .force
./eval32 test-elf.l
@echo
size a.out
chmod +x a.out
@echo
./a.out

test-assembler : eval32 .force
test-assembler : eval .force
./eval32 assembler.k

test-recursion2 :
test-recursion2 : eval
./eval compile-grammar.l test-recursion2.g > test-recursion2.g.l
./eval compile-recursion2.l test-recursion2.txt

Expand All @@ -220,18 +254,16 @@ test-main2 : eval32 .force
chmod +x test-pegen
$(TIME) ./test-pegen

cpp.g.l : cpp.g tpeg.l
./eval compile-tpeg.l $< > $@.new
mv $@.new $@
build/cpp.g.l : cpp.g tpeg.l
./eval compile-tpeg.l $< > $@

test-cpp : eval cpp.g.l .force
test-cpp : eval build/cpp.g.l .force
./eval compile-cpp.l cpp-small-test.c

osdefs.g.l : osdefs.g tpeg.l
./eval compile-tpeg.l $< > $@.new
mv $@.new $@
build/osdefs.g.l : osdefs.g build/tpeg.l
./eval compile-tpeg.l $< > $@

%.osdefs.k : %.osdefs osdefs.g.l
%.osdefs.k : %.osdefs build/osdefs.g.l
./eval compile-osdefs.l $< > $<.c
cc -o $<.exe $<.c
./$<.exe > $@.new
Expand All @@ -241,7 +273,7 @@ osdefs.g.l : osdefs.g tpeg.l
OSDEFS = $(wildcard *.osdefs) $(wildcard net/*.osdefs)
OSKEFS = $(OSDEFS:.osdefs=.osdefs.k)

osdefs : osdefs.g.l $(OSKEFS) .force
osdefs : build/osdefs.g.l $(OSKEFS) .force

profile-peg : .force
$(MAKE) clean eval CFLAGS="-O3 -fno-inline-functions -g -DNDEBUG"
Expand All @@ -265,11 +297,10 @@ stats : .force

clean : .force
cd bootstrap/c ; make clean
rm -f irl.g.l irgol.g.l osdefs.k test.c tpeg.l a.out
rm -f *~ *.o main eval eval32 gceval test *.s mkosdefs *.exe *.$(SO)
rm -rf build
rm -f *~ *.o main eval eval32 gceval *.s mkosdefs *.exe *.$(SO)
rm -f test-main test-pegen
rm -rf *.dSYM *.mshark
rm -rf osdefs.g.l *.osdefs.k

#----------------------------------------------------------------

Expand Down
2 changes: 1 addition & 1 deletion bootstrap/c/Makefile
Expand Up @@ -24,7 +24,7 @@ SO = so
SOCFLAGS = -shared -msse -msse2
endif

all : eval
all : eval eval32

prepare :
mkdir -p build
Expand Down
2 changes: 1 addition & 1 deletion compile-dc.l
Expand Up @@ -3,7 +3,7 @@
;;; ./eval compile-dc.l <filename>.dc

(require "parser.l")
(require "test-dc.g.l")
(require "build/test-dc.g.l")

(while *arguments*
(let* ((arg (next-argument))
Expand Down
2 changes: 1 addition & 1 deletion compile-tpeg.l
Expand Up @@ -2,7 +2,7 @@
;;;
;;; ./eval compile-with-tpeg.l <filename>.g ... > tee <filename>.l

(require "tpeg.l")
(require "build/tpeg.l")
(require "record-case.l")
(require "text-parser.l")

Expand Down

0 comments on commit 866be90

Please sign in to comment.