Makefile (1235B)
1 # GNU Makefile for Chess Anki Trainer 2 # 3 # Usage: make [-f path\Makefile] [DEBUG=Y] [NO_UNICODE=Y] target 4 5 NAME = chess 6 CC = gcc 7 8 CFLAGS = -I include 9 LDFLAGS =-lcurl -ljson-c 10 11 SRC = src 12 OBJ = obj 13 BIN = bin 14 15 SRCS=$(wildcard $(SRC)/*.c) 16 OBJS=$(patsubst $(SRC)/%.c, $(OBJ)/%.o, $(SRCS)) 17 TRGT=$(BIN)/$(NAME) 18 19 ifeq ($(DEBUG),Y) 20 LDFLAGS += -lciid -lpaned 21 CFLAGS += -ggdb -Wall -Wextra -Werror -Wpedantic 22 else 23 LDFLAGS += -lcii -lpane 24 endif 25 ifeq ($(NO_UNICODE),Y) 26 CFLAGS += -D NO_UNICODE 27 endif 28 29 LDFLAGS += -lm 30 31 all: $(TRGT) 32 33 $(TRGT): $(OBJS) 34 $(CC) $^ $(CFLAGS) $(LDFLAGS) -o $@ 35 36 $(OBJ)/%.o: $(SRC)/%.c 37 $(CC) -c $< -o $@ $(CFLAGS) $(LDFLAGS) 38 39 clean: 40 -$(RM) $(TRGT) $(OBJS) 41 42 help: 43 @echo "Chess Anki Trainer" 44 @echo 45 @echo "Usage: make [-f path\Makefile] [DEBUG=Y] [NO_UNICODE=Y] target" 46 @echo 47 @echo "Target rules:" 48 @echo " all - Compiles binary file [Default]" 49 @echo " clean - Clean the project by removing binaries" 50 @echo " help - Prints a help message with target rules" 51 @echo 52 @echo "Optional parameters:" 53 @echo " DEBUG - Compile binary file with debug flags enabled" 54 @echo " NO_UNICODE - Compile binary file that does not use Unicode characters" 55 @echo 56 57 .PHONY: all clean help docs