engine

Chess engine written in C
Log | Files | Refs

Makefile (591B)


      1 NAME = engine
      2 CC = gcc
      3 
      4 CFLAGS = -I include
      5 LDFLAGS = -lm
      6 
      7 SRC = src
      8 OBJ = obj
      9 BINDIR = bin
     10 
     11 SRCS := $(wildcard $(SRC)/*.c)
     12 OBJS=$(patsubst $(SRC)/%.c, $(OBJ)/%.o, $(SRCS))
     13 TRGT=$(BINDIR)/$(NAME)
     14 	
     15 ifeq ($(DEBUG),Y)
     16 	LDFLAGS += -lciid
     17 	CFLAGS += -Wall -Wextra -Werror -Wpedantic -fsanitize=address -ggdb
     18 else
     19 	LDFLAGS += -lcii
     20 	CFLAGS += -Ofast -flto
     21 endif
     22 
     23 
     24 all: pre $(TRGT)
     25 
     26 pre:
     27 	@mkdir -p $(BINDIR)
     28 	@mkdir -p $(OBJ)
     29 
     30 $(TRGT): $(OBJS)
     31 	$(CC) $^ $(CFLAGS) $(LDFLAGS) -o $@
     32 
     33 $(OBJ)/%.o: $(SRC)/%.c
     34 	$(CC) -c $< -o $@ $(CFLAGS) $(LDFLAGS)
     35 
     36 clean:
     37 	rm $(TRGT) $(OBJS)
     38 
     39 .PHONY: all clean pre