summaryrefslogtreecommitdiff
path: root/Makefile
blob: 60c9ecc097a3dee2661538d411ea825c30300bae (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
OPTFLAGS = -Os -Wall
CFLAGS   = -std=c11 -D_POSIX_C_SOURCE=200809L $(OPTFLAGS)

GENSRCS  = lexer.c parser.c
GENHDRS  = lexer.h parser.h
SRCS     = $(sort $(wildcard *.c) $(GENSRCS))
OBJS     = $(SRCS:.c=.o)
TARGET   = nqasm nqdasm

all: $(TARGET)

clean:
	rm -f $(GENSRCS) $(GENHDRS) $(OBJS) $(TARGET)

lexer.c lexer.h: lexer.l
	flex $<

parser.c parser.h: parser.y
	bison $<

lexer.o: parser.h
parser.o: lexer.h

%.o: %.c
	$(CC) $(CFLAGS) -c $< -o $@

nqasm:  $(filter-out nqdasm.o,$(OBJS))
nqdasm: mnemonics.o nqdasm.o

$(TARGET):
	$(CC) $(CFLAGS) $^ -o $@

.PHONY: all clean