-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
66 lines (55 loc) · 1.67 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
UNAME_S := $(shell uname -s)
CC := gcc
# Model compiler
MC := ./tetgen
MCFLAGS := -pYBNI
CFLAGS := -Iinclude -c -g -DGLFW_INCLUDE_NONE -Wall -Wextra -Werror -Wno-int-in-bool-context -Wno-misleading-indentation -Wno-shift-negative-value
CPPFLAGS := -std=c++11 -Wno-class-memaccess
ifeq ($(UNAME_S), Linux)
LDFLAGS := -lstdc++ -lm -lglfw
endif
ifeq ($(findstring MSYS, $(UNAME_S)), MSYS)
LDFLAGS := -Llib -lglfw3dll -lgdi32 -lstdc++
endif
DEPFLAGS = -MT $@ -MMD -MP -MF $(DEPDIR)/$*.d
OUTDIR := bin
DLLDIR := deploy
EXEC_NAME := $(OUTDIR)/PRIM
RESDIR := res
SRCDIR := src
DEPDIR := deps
OBJDIR := obj
SOURCES := $(wildcard $(SRCDIR)/*.c*)
MODELS := $(wildcard $(RESDIR)/models/*.off)
OBJS := $(patsubst $(SRCDIR)/%.c,$(OBJDIR)/%.o, $(SOURCES))
OBJS := $(patsubst $(SRCDIR)/%.cpp,$(OBJDIR)/%.o, $(OBJS))
TETRAS := $(patsubst %.off,%.ele, $(MODELS))
.PHONY: all clean run $(RESDIR)
all: $(DEPDIR) $(OBJDIR) $(OUTDIR) $(EXEC_NAME) $(TETRAS)
@cp -r $(DLLDIR)/* $(OUTDIR)
@[ "$(shell ls -A $(RESDIR))" ] && cp -r $(RESDIR)/* $(OUTDIR) || :
clean:
rm -f $(EXEC_NAME)
rm -rf $(OUTDIR)
rm -rf $(OBJDIR)
rm -rf $(DEPDIR)
rm -f $(TETRAS) $(patsubst %.off,%.face, $(MODELS))
run: all
@echo ">>> Running $(EXEC_NAME) ..."
@$(EXEC_NAME)
$(DEPDIR):
@mkdir $(DEPDIR)
$(OUTDIR):
@mkdir $(OUTDIR)
$(OBJDIR):
@mkdir $(OBJDIR)
$(EXEC_NAME): $(OBJS)
$(CC) $^ $(LDFLAGS) -o $@
-include $(patsubst $(OBJDIR)/%.o,$(DEPDIR)/%.d,$(OBJS))
%.ele: %.off
$(MC) $(MCFLAGS) $<
@rm -f $*.smesh $*.edge
$(OBJDIR)/%.o: $(SRCDIR)/%.c
$(CC) $(CFLAGS) $(DEPFLAGS) $< -o $@
$(OBJDIR)/%.o: $(SRCDIR)/%.cpp
$(CC) $(CFLAGS) $(CPPFLAGS) $(DEPFLAGS) $< -o $@