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


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 calculator-debug a.out *~ *.o
	-rm -f $(AUTOSAVES)

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


debug: $(OBJS) $(MAIN_C)
	gcc -g $(CFLAGS) $(MAIN_C) $(OBJS) -o calculator-debug
 #Helt enkelt kompilerar programmet med -g flaggan så att den kan debuggas. 


black-box: 
	./test.sh 





















# #missing args
# 	@echo Calling calculator with arguments 
# 	@echo Expecting MISSING ARGUMENTS
# 	./$(PROGRAM) 1 + 1

# 	@echo Calling calculator with arguments 1
# 	@echo Expecting MISSING ARGUMENTS
# 	./$(PROGRAM) 1
# 	@echo Calling calculator with arguments 1 +
# 	@echo Expecting MISSING ARGUMENTS
# 	./$(PROGRAM) 1 +
# 	@echo Calling calculator with arguments + 1
# 	@echo Expecting MISSING ARGUMENTS
# 	./$(PROGRAM) + 1
# 	#invalid inputs
# 	@echo Calling calculator with arguments a + 1 
# 	@echo Expecting SYNTAX ERROR
# 	./$(PROGRAM) a + 1
# 	@echo Calling calculator with arguments 1 + a
# 	@echo Expecting SYNTAX ERROR
# 	./$(PROGRAM) 1 + a
# 	@echo Calling calculator with arguments 1 + 1a
# 	@echo Expecting SYNTAX ERROR
# 	./$(PROGRAM) 1 + 1a
# 	@echo Calling calculator with arguments 1a + 1
# 	@echo Expecting SYNTAX ERROR
# 	./$(PROGRAM) 1a + 1
# 	@echo Calling calculator with arguments a + a
# 	@echo Expecting SYNTAX ERROR
# 	./$(PROGRAM) a + a
# 	@echo Calling calculator with arguments a a a
# 	@echo Expecting SYNTAX ERROR
# 	./$(PROGRAM) a a a
# 	@echo Calling calculator with arguments -1a + 1
# 	@echo Expecting SYNTAX ERROR
# 	./$(PROGRAM) -1a + 1
# 	@echo Calling calculator with arguments 1 + -1a
# 	@echo Expecting SYNTAX ERROR
# 	./$(PROGRAM) 1 + -1a
# 	#invalid operator
# 	@echo Calling calculator with arguments 1 ++ 1
# 	@echo Expecting SYNTAX ERROR
# 	./$(PROGRAM) 1 ++ 1
# 	@echo Calling calculator with arguments 1 -/ 1
# 	@echo Expecting SYNTAX ERROR
# 	./$(PROGRAM) 1 -/ 1
# 	@echo Calling calculator with arguments 1 1 1
# 	@echo Expecting SYNTAX ERROR
# 	./$(PROGRAM) 1 1 1
# 	@echo Calling calculator with arguments 1.1.1 + 1
# 	@echo Expecting SYNTAX ERROR
# 	./$(PROGRAM) 1.1.1 + 1
# 	@echo Calling calculator with arguments ..1 + 1
# 	@echo Expecting SYNTAX ERROR
# 	./$(PROGRAM) ..1 + 1
# 	#Math errors
# 	@echo Calling calculator with arguments 1  / 0
# 	@echo Expecting MATH ERROR
# 	./$(PROGRAM) 1  / 0
# 	@echo Calling calculator with arguments 1 % 0
# 	@echo Expecting MATH ERROR
# 	./$(PROGRAM) 1 % 0
# 	@echo Calling calculator with arguments 1 % 0.5
# 	@echo Expecting MATH ERROR
# 	./$(PROGRAM) 1 % 0.5
# 	#Successaful integer output
# 	@echo Calling calculator with arguments 1 + 1
# 	@echo Expecting 2
# 	./$(PROGRAM) 1 + 1
# 	@echo Calling calculator with arguments 1 + 0
# 	@echo Expecting 1
# 	./$(PROGRAM) 1 + 0
# 	@echo Calling calculator with arguments 2 - 1
# 	@echo Expecting 1
# 	./$(PROGRAM) 2 - 1
# 	@echo Calling calculator with arguments -1 - -1
# 	@echo Expecting 0 
# 	./$(PROGRAM) -1 - -1
# 	@echo Calling calculator with arguments 1 + -1
# 	@echo Expecting 0 
# 	./$(PROGRAM) 1 + -1
# 	@echo Calling calculator with arguments 2 x 2
# 	@echo Expecting 4
# 	./$(PROGRAM) 2 x 2
# 	@echo Calling calculator with arguments 2 x 0
# 	@echo Expecting 0 
# 	./$(PROGRAM) 2 x 0
# 	@echo Calling calculator with arguments 10 / 5
# 	@echo Expecting 2
# 	./$(PROGRAM) 10 / 5
# 	@echo Calling calculator with arguments 10 % 3
# 	@echo Expecting 1
# 	./$(PROGRAM) 10 % 3
# 	@echo Calling calculator with arguments 5 / 10
# 	@echo Expecting 0.5
# 	./$(PROGRAM) 5 / 10
# 	@echo Calling calculator with arguments 5 % 10
# 	@echo Expecting 5
# 	./$(PROGRAM) 5 % 10
# 	#Successful float operations  
# 	@echo Calling calculator with arguments 1 + 0.5
# 	@echo Expecting  1.5
# 	./$(PROGRAM) 1 + 0.5
# 	@echo Calling calculator with arguments 0.5 - 1
# 	@echo Expecting  -0.5
# 	./$(PROGRAM) 0.5 - 1
# 	@echo Calling calculator with arguments 1 x 0.5
# 	@echo Expecting 0.5 
# 	./$(PROGRAM) 1 x 0.5
# 	@echo Calling calculator with arguments 1 / 0.5
# 	@echo Expecting 2 
# 	./$(PROGRAM) 1 / 0.5
# 	@echo Calling calculator with arguments 10 % 6.5
# 	@echo Expecting  4
# 	./$(PROGRAM) 10 % 6.5
# 	@echo Calling calculator with arguments 1 + .5
# 	@echo Expecting  1.5
# 	./$(PROGRAM) 1 + .5
# 	@echo Calling calculator with arguments .5 + .5
# 	@echo Expecting 1 
# 	./$(PROGRAM) .5 + .5
