Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Automatically track dependencies in Makefile.

  • Loading branch information...
commit 51001f94b087a9ca3522f8e417072c1ec8a0ce38 1 parent 79786f1
@nominolo nominolo authored
Showing with 42 additions and 64 deletions.
  1. +1 −0  .gitignore
  2. +39 −62 Makefile
  3. +2 −2 rts/InterpThreaded.c
View
1  .gitignore
@@ -2,6 +2,7 @@
asm_offsets.incl
gen_offs
*.hi
+.deps
*~
# Util executables
utils/genopcodes
View
101 Makefile
@@ -1,83 +1,60 @@
-all: testloader
+.SUFFIXES: # delete default rules
-INCLUDES = -Iincludes -Irts
-CFLAGS = $(INCLUDES) -O3 -g
+.PHONY: all
+all: interp
-DIST = $(HOME)/tmp/dist-devel/lambdachine
+DEPDIR = .deps
+DEPDIRS = $(DEPDIR) $(DEPDIR)/rts
-utils/print_config: utils/print_config.o
- @echo "LINK $^ => $@"
- @$(CC) -o $@ $^
+INCLUDES = -Iincludes -Irts
+CFLAGS = -g
-interp: rts/InterpThreaded.o rts/ClosureFlags.o rts/MiscClosures.o rts/Capability.o rts/Thread.o rts/PrintClosure.o
- @echo "LINK $^ => $@"
- @$(CC) -o $@ $^
+df = $(DEPDIR)/$(*D)/$(*F)
-testloader: rts/Loader.o rts/HashTable.o rts/FileUtils.o rts/PrintClosure.o rts/Bytecode.o
- @echo "LINK $^ => $@"
- @$(CC) -o $@ $^
+#SRCS := $(wildcard rts/*.c)
+SRCS = rts/Bytecode.c rts/Capability.c rts/ClosureFlags.c \
+ rts/FileUtils.c rts/HashTable.c rts/InterpThreaded.c \
+ rts/Loader.c rts/MiscClosures.c rts/PrintClosure.c \
+ rts/Thread.c
-utils/genopcodes.o: includes/Bytecode.h
-utils/genopcodes: utils/genopcodes.o
+echo:
+ @echo "SRCS = $(SRCS)"
+#SRCS = rts/Loader.c rts/HashTable.c
+
+interp: $(SRCS:.c=.o)
@echo "LINK $^ => $@"
@$(CC) -o $@ $^
-compiler/Opcodes.h: utils/genopcodes
- ./$< > $@
-
-rts/Bytecode.o: includes/Bytecode.h
-# def.h: arch.h
-# vm.h: def.h bc.h
-gen_offs.o: vm.h
-# dispatch.o: asm_offsets.incl
-bci.o: opcodes.h asm_offsets.incl
-vm.o: vm.h bc.h def.h
-print_config.o: includes/Arch.h includes/Common.h
-rts/InterpThreaded.o: includes/Arch.h includes/Common.h includes/Bytecode.h includes/Opcodes.h \
- includes/Capability.h
-rts/Thread.o: includes/Thread.h includes/Bytecode.h includes/Common.h
-rts/MiscClosures.o: includes/InfoTables.h includes/Common.h includes/Bytecode.h includes/MiscClosures.h
-rts/Loader.o: includes/Loader.h rts/HashTable.h includes/InfoTables.h includes/FileUtils.h
+$(DEPDIR):
+ mkdir $@
+$(DEPDIR)/rts:
+ mkdir $@
-rts/FileUtils.o: includes/FileUtils.h
-
-# %.o: %.c
-# @echo "CC $< => $@"
-# @$(CC) -m32 -Wall -c $< -o $@
-
-# %.o: %.s
-# @echo "ASM $< => $@"
-# @$(CC) -m32 -c $< -o $@
-
-# bci.o: bci.S
-# @echo "ASM $< => $@"
-# @$(CC) -m64 -c $< -o $@
+# Building a C file automatically generates dependencies as a side effect
+# The dependency file for `rts/Foo.c' lives at `.deps/rts/Foo.c'.
+%.o: %.c
+ @echo "CC $(CFLAGS) $< => $@"
+ @gcc -c $(INCLUDES) -MD -MF $(patsubst %.c,$(DEPDIR)/%.d,$<) $(CFLAGS) -o $@ $<
+ @cp $(df).d $(df).P; \
+ sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
+ -e '/^$$/ d' -e 's/$$/ :/' < $(df).d >> $(df).P; \
+ rm -f $(df).d
-# test: main.o dispatch.o
-# @echo "LINK $^ => $@"
-# @$(CC) -m32 -o $@ $^
-gen_offs: gen_offs.o
+utils/genopcodes: utils/genopcodes.o
@echo "LINK $^ => $@"
@$(CC) -o $@ $^
-asm_offsets.incl: gen_offs
- @echo "GEN $@"
- @./gen_offs
-
-%.o: %.S
- @echo "ASM $< => $@"
- @$(CC) $(CFLAGS) -c $< -o $@
-
-%.o: %.c
- @echo "CC $< => $@"
- @$(CC) $(CFLAGS) -Wall -c $< -o $@
-
-test: vm.o bci.o bc.o
+utils/print_config: utils/print_config.o
@echo "LINK $^ => $@"
@$(CC) -o $@ $^
+compiler/Opcodes.h: utils/genopcodes
+ ./$< > $@
+
.PHONY: clean
clean:
- rm -f *.o rts/*.o test gen_offs asm_offsets.incl
+ rm -f $(SRCS:%.c=%.o) utils/*.o
+
+-include $(SRCS:%.c=$(DEPDIR)/%.P)
View
4 rts/InterpThreaded.c
@@ -599,7 +599,7 @@ static ThunkInfoTable silly1_info = {
static Closure silly1 =
DEF_CLOSURE(&silly1_info, { 0 });
-
+/*
int main(int argc, char* argv[])
{
initVM();
@@ -614,7 +614,7 @@ int main(int argc, char* argv[])
//printf("%0" FMT_WordLen FMT_WordX "\n", T0->stack[1]);
return 0;
}
-
+*/
int
stackOverflow(Thread* thread, Word* top, u4 increment)
{
Please sign in to comment.
Something went wrong with that request. Please try again.