NAME	:= MarhaEngine

OBJ		:= $(SRC:source/%.c=obj/%.o)
SRC		:= source/client.c
#$(wildcard source/*.c)

CC		:= gcc
CFLAG	:= -ggdb -Wall -Wextra -Werror -Wpedantic -I include -O0 -std=c99

ifeq ($(OS), Windows_NT)
CFLAG	+= -I C:\raylibs\include
LFLAG	:= -lraylib -lopengl32 -lgdi32 -lwinmm -lpthread
endif
ifeq ($(shell uname -s), Linux)
LFLAG	:= -lraylib -lGL -lm -lpthread -ldl -lrt -lX11
endif

all:	$(NAME)

obj/%.o : source/%.c | makedir
	$(CC) $(CFLAG) -c $< -o $@

$(NAME): $(OBJ)
	$(CC) $(OBJ) $(LFLAG) -o build/$(NAME)

makedir:
	mkdir -p obj
	mkdir -p build

clean:
	rm -rf obj/

fclean: clean
	rm -rf build/

re: fclean all

.PHONY: all $(NAME) clean fclean makedir
