Skip to content
Snippets Groups Projects
Makefile 647 B
CC=gcc
RM=rm -Rfv

LFLAGS= -lm
CFLAGS = -std=c99 -pedantic -Wall -Wextra -D_POSIX_SOURCE -D_GNU_SOURCE

ifdef DEBUG
	CFLAGS += -ggdb -DDEBUG
else
	CFLAGS += -g -O2
endif

all: shell

clean:
	$(RM) shell *.o input.lex.* input.yacc.*

shell: input.yacc.o input.lex.o shell.o
	$(CC) $(CFLAGS) $(LFLAGS) -o $@ $^

input.yacc.c: input.y
	bison --debug --verbose -d -o $@ $<

input.yacc.h: input.yacc.c

input.lex.c: input.l
	`which flex35 2>/dev/null || which flex 2>/dev/null` \
		-C --header-file=input.lex.h -o $@ -d $<

input.lex.h: input.lex.c

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

input.lex.o:  input.yacc.h input.l.h
input.yacc.o: input.lex.h