-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
46 lines (31 loc) · 901 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
45
46
CC = gcc
LD = gcc
CFLAGS = -std=c89 -pedantic-errors -Wall -Werror -g -O0 # -O2
LDFLAGS = -ldl -rdynamic
BUILDPATH = build
SOURCES = main.c ast.c value.c parser.c lexer.c interpreter.c image.c util.c stdlib.c bmp.c
HEADERS = ast.h value.h parser.h interpreter.h image.h util.h bmp.h
TARGET = image-transformer
OBJECTS = $(SOURCES:%.c=$(BUILDPATH)/%.o)
.PHONY: all build clean modules
.SUFFIXES:
all: build modules
clean:
@+cd modules; make clean
@rm -vrf $(BUILDPATH) 2> /dev/null; true
@rm -v parser.h parser.c lexer.c $(TARGET) 2> /dev/null; true
build: $(TARGET)
modules:
@+cd modules; make
%.lex:
%.y:
parser.h parser.c: parser.y
bison --defines=parser.h -o parser.c parser.y
lexer.c: lexer.lex parser.h
flex -o lexer.c lexer.lex
%.c:
$(OBJECTS): $(BUILDPATH)/%.o : %.c $(HEADERS)
@mkdir -p $(@D)
$(CC) -c -o $@ $< $(CFLAGS)
$(TARGET): $(OBJECTS)
$(LD) -o $@ $^ $(LDFLAGS)