-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
44 lines (33 loc) · 889 Bytes
/
Makefile
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
PREFIX=/usr/local
BINDIR=$(PREFIX)/bin
LIBDIR=$(PREFIX)
OUTDIR=out
EXT=stack
EXAMPLES_DIR=examples
CC=$(OUTDIR)/slc
EXAMPLE_FILES := $(wildcard $(EXAMPLES_DIR)/*.$(EXT))
EXAMPLE_OUT_FILES := $(patsubst $(EXAMPLES_DIR)/%.$(EXT), $(OUTDIR)/%, $(EXAMPLE_FILES))
all: build
$(OUTDIR):
mkdir -p $(OUTDIR)
$(CC): $(OUTDIR)
fasm bootstrap/stack.asm $(OUTDIR)/stack.o
ld $(OUTDIR)/stack.o -o $(CC)
bootstrap: $(CC)
build: $(CC)
$(CC) stack.$(EXT) -a > bootstrap/stack.asm
fasm bootstrap/stack.asm $(OUTDIR)/stack.o
ld $(OUTDIR)/stack.o -o $(CC)
$(OUTDIR)/%: $(EXAMPLES_DIR)/%.$(EXT) build
$(CC) $< > $(OUTDIR)/$*.asm
fasm $(OUTDIR)/$*.asm $(OUTDIR)/$*.o
ld $(OUTDIR)/$*.o -o $@
examples: $(EXAMPLE_OUT_FILES)
.PHONY: clean install bootstrap examples
install:
mkdir -p $(BINDIR)
mkdir -p $(LIBDIR)
cp $(OUTDIR)/slc $(BINDIR)/slc
cp -r lib $(LIBDIR)
clean:
rm -rf $(OUTDIR)