forked from briling/v
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
89 lines (72 loc) · 1.99 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
CC=gcc
OPT=-O2
GPROF=#-pg
GDB=#-g
ASM=#-g -Wa,[email protected]
W= \
-Warray-bounds\
-Wfloat-equal\
-Wimplicit\
-Wmaybe-uninitialized\
-Wmissing-braces\
-Wparentheses\
-Wsequence-point\
-Wtype-limits\
-Wundef\
-Wuninitialized\
-Wmisleading-indentation\
-Wempty-body\
-Wmemset-elt-size\
-Wduplicated-branches\
-Wswitch-unreachable\
-Wunused\
-Wunused-but-set-variable\
-Wunused-parameter\
#-Winline\
#-Wunsafe-loop-optimizations\
#-W -Wall\
-Wswitch\
-Wno-format\
-Wconversion\
-Wsign-compare\
-Wjump-misses-init\
#-Werror\
GIT_HASH=`git rev-parse HEAD 2> /dev/null || echo --`
GIT_BRANCH=`git rev-parse --abbrev-ref HEAD 2> /dev/null || echo --`
export VERSION_FLAGS=-DGIT_HASH="\"$(GIT_HASH)\""\
-DGIT_BRANCH="\"$(GIT_BRANCH)\""\
-DBUILD_USER="\"$(USER)@$(shell hostname)\""\
-DBUILD_DIRECTORY="\"$(PWD)\""
CFLAGS= -c -std=gnu11 -MMD $(OPT) $(GPROF) $(W) $(GDB) $(ASM)
OFLAGS= -lm $(GPROF)
INCL=\
-I$(SRCDIR)/mol -I$(SRCDIR)/math \
-I$(SRCDIR)/v -I$(SRCDIR)/sym
OBJDIR=./obj
SRCDIR=./src
molsrc=$(wildcard $(SRCDIR)/mol/*.c)
molobj=$(molsrc:$(SRCDIR)/%.c=$(OBJDIR)/%.o)
mathsrc=$(wildcard $(SRCDIR)/math/*.c)
mathobj=$(mathsrc:$(SRCDIR)/%.c=$(OBJDIR)/%.o)
vsrc=$(wildcard $(SRCDIR)/v/*.c)
vobj=$(vsrc:$(SRCDIR)/%.c=$(OBJDIR)/%.o)
symsrc=$(wildcard $(SRCDIR)/sym/*.c)
symobj=$(symsrc:$(SRCDIR)/%.c=$(OBJDIR)/%.o)
default : v
all : v
v : $(vobj) $(molobj) $(mathobj) $(symobj) $(OBJDIR)/v.o
$(CC) $^ -o $@ $(OFLAGS) -lX11 -lXpm
$(OBJDIR)/%.o : $(SRCDIR)/%.c
$(CC) $(CFLAGS) $< -o $@ $(INCL)
$(OBJDIR)/v.o : $(SRCDIR)/v.c
$(CC) $(CFLAGS) $< -o $@ $(INCL) -I$(SRCDIR)/v $(VERSION_FLAGS)
clean:
rm -f $(OBJDIR)/*/*/*.o $(OBJDIR)/*/*.o $(OBJDIR)/*.o v
cleand:
rm -f $(OBJDIR)/*/*/*.d $(OBJDIR)/*/*.d $(OBJDIR)/*.d
cleantags:
rm -f ./.tags ./.types.vim
cleanasm:
rm -f $(OBJDIR)/*/*/*.s $(OBJDIR)/*/*.s $(OBJDIR)/*.s
cleanall: clean cleand cleantags cleanasm
include $(wildcard $(OBJDIR)/*/*.d $(OBJDIR)/*.d)