summaryrefslogtreecommitdiff
path: root/Makefile
blob: 4ab9ab634fe0f7abaa0a2368ca64651f464b6cb5 (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
50
51
52
53
54
55
56

#all: lrlc.fromscratch
all: lrlc.bootstrap

# for debugging
CC ?= clang
CFLAGS ?= -fsanitize=undefined -g


LRLC ?= lrlc
CFLAGS += -Wall -Wextra -pedantic -Wno-shift-overflow -std=c89

HOSTCC ?= $(CC)
HOSTCFLAGS ?= $(CFLAGS)

PREFIX ?= /usr/local
EPREFIX ?= $(PREFIX)

LRLC_OBJECTS = compiler/ident.o compiler/parser.o compiler/main.o
BOOTSTRAP_OBJECTS = bootstrap/arena.o bootstrap/ctrans.o bootstrap/ident.o bootstrap/parse.o bootstrap/main.o bootstrap/types.o

INSTALL ?= install
INSTALL_D ?= install -D
RM ?= rm
RM_F ?= rm -f

.lc.o:
	$(LRLC) -c $< -o $@

# TODO should LRL use headers?
#compiler/parser.o: compiler/parser.lh

#lrlc.fromscratch: lrlc.bootstrap $(LRLC_OBJECTS)
#	./lrlc.bootstrap $(BOOTSTRAP_LRLCFLAGS) $< -o $@

#lrlc.fromhost: $(LRLC_OBJECTS)
#	$(LRLC) $(LRLCFLAGS) $< -o $@

bootstrap/arena.o: bootstrap/bootstrap.h
bootstrap/ctrans.o: bootstrap/bootstrap.h
bootstrap/parse.o: bootstrap/bootstrap.h bootstrap/hash.h
bootstrap/main.o: bootstrap/bootstrap.h
bootstrap/types.o: bootstrap/bootstrap.h bootstrap/hash.h

lrlc.bootstrap: $(BOOTSTRAP_OBJECTS)
	$(HOSTCC) $(HOSTCFLAGS) $(BOOTSTRAP_OBJECTS) -o $@

.PHONY: all check clean distclean install uninstall
.SUFFIXES: .c .lc
clean:
	$(RM_F) $(BOOTSTRAP_OBJECTS) $(LRLC_OBJECTS) lrlc.bootstrap lrlc.fromscratch lrlc.fromhost
distclean: clean
#install:
#	#$(INSTALL_P) -d -m 755 $(DESTDIR)$(EPREFIX)
#	$(INSTALL_D) -m 755 lrlc.fromscratch $(DESTDIR)$(EPREFIX)/lrlc
#uninstall:
#	$(RM) $(DESTDIR)$(EPREFIX)/lrlc