-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathMakefile
46 lines (40 loc) · 1.05 KB
/
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
###############################################
# Definitions
###############################################
CC = gcc
EXEC = cube
SRC_DIR = src
INC_DIR = include
# where to store the mesh (text) files -
# set it from the command line if you want another location
PREFIX = /usr
CFG_DIR = $(PREFIX)/share/retrocube
CFLAGS = -Wall -Wno-stringop-truncation -Wno-maybe-uninitialized -I$(INC_DIR)\
-std=gnu99 -O3 -DCFG_DIR=$(CFG_DIR)
LDFLAGS = -lm
SOURCES = $(wildcard $(SRC_DIR)/*.c) \
main.c
OBJECTS = $(SOURCES:%.c=%.o)
MKDIR = mkdir -p
CP = cp -r
RM = rm -rf
###############################################
# Compilation
###############################################
all: $(EXEC)
$(EXEC): $(OBJECTS) cfg
$(CC) $(OBJECTS) -o $(EXEC) $(LDFLAGS)
%.o: %.c
$(CC) $(CFLAGS) -c $^ -o $@
###############################################
# Commands (phony targets)
###############################################
.PHONY: cfg
cfg:
# copy config files into CFG_DIR
$(MKDIR) $(CFG_DIR)
$(CP) mesh_files/*.scl $(CFG_DIR)
.PHONY: clean
clean:
$(RM) $(OBJECTS)
$(RM) $(EXEC)