-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathMakefile
43 lines (31 loc) · 1.04 KB
/
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
# Makefile for L
CC:=cc
OBJDIR:=build
SRCDIR:=src
CFLAGS:=-c -I$(OBJDIR) -I$(SRCDIR) -Wall
LD:=$(CC) # Use $(CC) as linker so that I don't have to explicitly link to required
# libraries
LDFLAGS:=
LEX:=flex
YACC:=bison
VPATH:=src
OBJECTS:=l-mempool.o l-structures.o main.o lexer.o lexer.c parser.o parser.c l-parser-tokens.h l-token-hashtable.o l-lambda.o l-pretty-printer.o l-repl.o
FULL_OBJS:=$(addprefix $(OBJDIR)/, $(OBJECTS))
all: $(OBJDIR)/l
$(OBJDIR)/l: $(FULL_OBJS)
$(LD) $(LDFLAGS) $(filter-out %.h, $(filter-out %.c, $(FULL_OBJS))) -o $(OBJDIR)/l
$(OBJDIR)/lexer.c: l.lex
$(LEX) -o $@ $<
$(OBJDIR)/parser.c: l.y
$(YACC) -o $@ $<
$(OBJDIR)/l-parser-tokens.h: l.y
$(YACC) $< -o /dev/null --defines=$@
$(OBJDIR)/%.o: %.c
$(CC) $(CFLAGS) $< -o$@
$(filter-out $(OBJDIR)/l-parser-tokens.h, $(FULL_OBJS)): $(OBJDIR)/l-parser-tokens.h $(wildcard $(OBJDIR)/*.h) $(wildcard $(SRCDIR)/*.inc) $(wildcard $(SRCDIR)/*h) | $(OBJDIR)
$(OBJDIR)/l-parser-tokens.h: | $(OBJDIR)
$(OBJDIR):
mkdir $(OBJDIR)
clean:
rm -f $(OBJDIR)/*
rmdir $(OBJDIR)