C_FILES=math/math.c parser/parser.c

H_FILES=math/math.h parser/parser.h

MAIN_C=main.c



PROGRAM=calculator


OBJS=$(C_FILES:.c=.o)
AUTOSAVES=$(C_FILES:.c=.c~) $(H_FILES:.h=.h~) $(MAIN_C:.c=.c~)


CFLAGS=-Wall -Werror -pedantic




# calculator.out : $(C_FILES) $(H_FILES)
# 	gcc -Wall -Werror -pedantic $(C_FILES) -o $@


all: $(PROGRAM)

check:
	@echo "OBJS:    $(OBJS)"
	@echo "C_FILES: $(C_FILES)"
	@echo "H_FILES: $(H_FILES)"

$(OBJS): $(H_FILES) Makefile

%.c:Makefile $(C_FILES)

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

%.E::%.c
	gcc -E $< -o $@

check: all

clean:
	-rm -f $(OBJS) calculator calculator.out a.out *~ *.o
	-rm -f $(AUTOSAVES)

$(PROGRAM): $(OBJS) $(MAIN_C)
	gcc $(CFLAGS) $(MAIN_C) $(OBJS) -o $@


indent:
	indent -gnu $(C_FILES) $(MAIN_C) $(H_FILES)


run:
	./$(PROGRAM)
