Makefile (1633B)
1 # GNU Makefile for Game of Life simulation 2 # 3 # Usage: make [-f path\Makefile] [DEBUG=Y] [NO_UNICODE=Y] [NO_MOUSE=Y] target 4 5 NAME = gol 6 CC = gcc 7 8 CFLAGS = -I include 9 10 SRC = src 11 OBJ = obj 12 BINDIR = bin 13 LATEX = docs/latex 14 15 BIN = bin/$(NAME) 16 SRCS=$(wildcard $(SRC)/*.c) 17 OBJS=$(patsubst $(SRC)/%.c, $(OBJ)/%.o, $(SRCS)) 18 19 ifeq ($(OS),Windows_NT) 20 LDFLAGS = -lpdcurses 21 RM = del 22 NAME := $(NAME).exe 23 DEL_CLEAN = $(subst /,\,$(BIN)) $(subst /,\,$(OBJS)) 24 else 25 LDFLAGS = -lncurses 26 RM = rm -f 27 DEL_CLEAN = $(BIN) $(OBJS) 28 endif 29 30 ifeq ($(DEBUG),Y) 31 CFLAGS += -ggdb -Wall 32 endif 33 34 ifeq ($(NO_UNICODE),Y) 35 CFLAGS += -D NO_UNICODE 36 endif 37 38 ifeq ($(NO_MOUSE),Y) 39 CFLAGS += -D NO_MOUSE 40 endif 41 42 all: $(BIN) 43 44 $(BIN): $(OBJS) 45 $(CC) $^ $(CFLAGS) $(LDFLAGS) -o $@ 46 47 $(OBJ)/%.o: $(SRC)/%.c 48 $(CC) -c $< -o $@ $(CFLAGS) $(LDFLAGS) 49 50 clean: 51 -$(RM) $(DEL_CLEAN) 52 53 docs: 54 doxygen 55 make -C $(LATEX) 56 57 help: 58 @echo "Game of Life Simulation" 59 @echo 60 @echo "Usage: make [-f path\Makefile] [DEBUG=Y] [NO_UNICODE=Y] target" 61 @echo 62 @echo "Target rules:" 63 @echo " all - Compiles binary file [Default]" 64 @echo " clean - Clean the project by removing binaries" 65 @echo " help - Prints a help message with target rules" 66 @echo " docs - Compile html and pdf documentation using doxygen and pdflatex" 67 @echo 68 @echo "Optional parameters:" 69 @echo " DEBUG - Compile binary file with debug flags enabled" 70 @echo " NO_UNICODE - Compile binary file that does not use Unicode characters" 71 @echo " NO_MOUSE - Compile binary file that does not have mouse support even if terminal supports it" 72 @echo 73 74 .PHONY: all clean help docs