# Makefile
#
# Copyright 1998, 1999 Michael Elizabeth Chastain, <mailto:mec@shout.net>.
# Licensed under the Gnu Public License, version 2.

ifndef BISON
BISON			:= bison
endif

DEBUG			:= -g2
PROFILE			:= -p
OPTIMIZE		:= -O2
CFLAGS			:= -Wall $(DEBUG) $(PROFILE) $(OPTIMIZE)
CFLAGS-mode-menu.o	:= -I /usr/include/ncurses
LFLAGS			:= $(DEBUG) $(PROFILE)
LIBS-mconfig		:= -lncurses
list-exe		:= mconfig test-lexer test-parser

default: $(list-exe)
	@ exit 0

$(list-exe):
	$(strip gcc $(LFLAGS) -o $@ $^ $(LIBS-$@) )

test-lexer:								\
    test-lexer.o lexer.o misc.o

test-parser:								\
    test-parser.o parser.tab.o lexer.o misc.o symbol.o

mconfig:								\
    main.o parser.tab.o lexer.o misc.o semantic.o symbol.o		\
    argument.o output.o							\
    mode-menu.o mode-x-gtk.o mode-line.o mode-old.o			\
    mode-syntax.o mode-random.o mode-mutate.o				\
    mode-minimum.o mode-maximum.o

parser.tab.c parser.tab.h: parser.y
	$(BISON) -b parser -v -d $<

%.o: %.c mconfig.h
	$(strip gcc $(CFLAGS) $(CFLAGS-$@) -c $<)

lexer.o main.o test-lexer.o test-parser.o mode-menu.o: parser.tab.h

.PHONY: clean

clean:
	rm -f $(list-exe) gmon.out *.o *.output *.tab.c *.tab.h autoconf.* config.*
