Skip to content

Instantly share code, notes, and snippets.

@Ravenslofty
Created November 27, 2016 18:01
Show Gist options
  • Save Ravenslofty/1d4110cbb77cb40c907cbfb20aa12a3a to your computer and use it in GitHub Desktop.
Save Ravenslofty/1d4110cbb77cb40c907cbfb20aa12a3a to your computer and use it in GitHub Desktop.
WyldChess makefile
VERSION = 1.0
CC = gcc
CFLAGS = -std=c11 -O3 -pthread
SRC = src/*.c
OBJ = $(SOURCES:.c=.o)
NAME = wyldchess
BIN_PATH = binaries/v$(VERSION)
EXEC = $(BIN_PATH)/$(TARGET)/$(EXEC_BASE)$(VERSION)
EXT =
ifeq ($(FAST), 1)
EXT = _fast_tc
CFLAGS += -DTEST
endif
ifeq ($(POPCNT), 1)
EXT = $(EXT)_popcnt
CFLAGS += -mpopcnt
endif
ifeq ($(PERFT),1)
CFLAGS += -fopenmp -DPERFT -DTHREADS=3
endif
ifeq ($(TARGET),"win64")
CC = x86_64-w64-mingw32-gcc
EXT = $(EXT).exe
CFLAGS += -static
endif
ifeq ($(STATS),1)
CFLAGS += -DSTATS
endif
EXEC = $(EXEC)/$(NAME)$(EXT)
all: sane $(SRC) $(EXEC)
sane:
test "$(TARGET)" = "win64" || test "$(TARGET)" = "linux"
$(EXEC): $(OBJ)
-mkdir -p $(BIN_PATH)/$(TARGET)
$(CC) $(CFLAGS) $(OBJ) -o $@
.c.o:
$(CC) $(CFLAGS) $< -o $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment