-
Notifications
You must be signed in to change notification settings - Fork 25
/
Makefile
49 lines (31 loc) · 910 Bytes
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
EXE?=2048-in-terminal
TARGET=$(BUILDDIR)/$(EXE)
SRCDIR=src
BUILDDIR=_build
$(shell mkdir -p $(BUILDDIR))
SRC=$(wildcard $(SRCDIR)/*.c)
OBJ=$(SRC:$(SRCDIR)/%.c=$(BUILDDIR)/%.o)
DEP=$(SRC:$(SRCDIR)/%.c=$(BUILDDIR)/%.d)
NCURSES_LIB?=ncurses
NCURSES_CFLAGS?=`pkg-config --cflags $(NCURSES_LIB)`
NCURSES_LDLIBS?=`pkg-config --libs $(NCURSES_LIB)`
CFLAGS?=-Wall -Wextra -pedantic -std=c11 -O2 -march=native -D_GNU_SOURCE $(NCURSES_CFLAGS)
LDLIBS?=$(NCURSES_LDLIBS)
PREFIX?=/usr/local
BINDIR?=$(PREFIX)/bin
.PHONY: all clean install uninstall
all: $(TARGET)
$(TARGET): $(OBJ)
$(CC) $(CFLAGS) $^ -o $(TARGET) $(LDLIBS)
%.o : %.c
$(BUILDDIR)/%.o: $(SRCDIR)/%.c $(BUILDDIR)/%.d
$(CC) -MM $< -MQ $(BUILDDIR)/$*.o -MF $(BUILDDIR)/$*.d
$(CC) -c $(CFLAGS) $< -o $@
%.d: ;
-include $(DEP)
clean:
@-rm -r $(BUILDDIR)
install: $(TARGET)
install -m 755 $(TARGET) $(BINDIR)
uninstall:
rm $(BINDIR)/$(EXE)