-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
41 lines (32 loc) · 878 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
CC:=gcc
CCFLAGS:=-Wall -Wextra -Wnonnull
CCLIBS:=-lm -lncursesw -ltinfo
CCEXTRAS:=-fPIC -O2 -g
SRC:=src
INCLUDES:=src
TARGET:=out
OBJ:=obj
BIN:=bin
SOURCES:=$(shell find $(SRC) -name '*.c')
OBJECTS:=$(SOURCES:$(SRC)/%.c=$(OBJ)/%.o)
L_TARGET:=$(TARGET)/linux
L_BIN:=$(L_TARGET)/$(BIN)
L_OBJECTS:=$(addprefix $(L_TARGET)/, $(OBJECTS))
MAKELISTS:=$(patsubst %.c,%,$(subst $(PWD)/$(SRC)/,,$(SOURCES)))
default: clean compile
clean:
rm -rf $(L_BIN)/*
rm -rf $(L_OBJECTS)/*
compile: $(L_OBJECTS)
mkdir -p $(L_BIN)
$(CC) -I$(INCLUDES) $(CCFLAGS) $^ -o $(L_BIN)/2048 $(CCLIBS) $(CCEXTRAS)
$(TARGET)/linux/$(OBJ)/%.o: $(SRC)/%.c
mkdir -p $$(dirname $@)
$(CC) -I$(INCLUDES) $(CCFLAGS) -c $< -o $@ $(CCLIBS) $(CCEXTRAS)
install: compile
mkdir -p /opt/2048
cp -uf $(L_BIN)/2048 /opt/2048/
ln -sf /opt/2048/2048 /usr/bin/
uninstall:
rm -rf /opt/2048
rm -f /usr/bin/2048