-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
68 lines (54 loc) · 1.6 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
CPPSRCS= main.cc marker.cc
CSRCS= # admutils.c mcio.c # files for Nick's I/O
OBJS= $(patsubst %.cc,%.o,$(CPPSRCS)) $(patsubst %.c,%.o,$(CSRCS))
EXEC= mixer
GPP = g++
GCC = gcc
DEFINES=
CFLAGS = -Wall $(DEFINES)
ifdef DEBUG # to use run `make DEBUG=1`
CFLAGS += -g
else
CFLAGS += -O2
endif
# profiling: run program normally then do:
# (note: I haven't read about the options below, I just found them in a
# Dr. Dobb's article.)
# `gprof -b -z hapi gmon.out`
ifdef PROFILE # to use run `make PROFILE=1
CFLAGS += -pg
endif
LIBS =
# dependency variables / commands
DEPDIR = .deps
df = $(DEPDIR)/$(*F)
all: $(EXEC)
$(EXEC): $(OBJS) $(HEADERS)
$(GPP) -o $(EXEC) $(OBJS) $(CFLAGS) $(LIBS)
# This way of building dependencies (per-file) described at
# http://make.paulandlesley.org/autodep.html
.c.o:
@mkdir -p $(DEPDIR)
$(GCC) -MMD $(CFLAGS) -o $@ -c $<
@cp $*.d $(df).P; \
sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
-e '/^$$/ d' -e 's/$$/ :/' < $*.d >> $(df).P; \
rm -f $*.d
.cc.o:
@mkdir -p $(DEPDIR)
$(GPP) -MMD $(CFLAGS) -o $@ -c $<
@cp $*.d $(df).P; \
sed -e 's/#.*//' -e 's/^[^:]*: *//' -e 's/ *\\$$//' \
-e '/^$$/ d' -e 's/$$/ :/' < $*.d >> $(df).P; \
rm -f $*.d
# include the .P dependency files, but don't warn if they don't exist (the -)
-include $(CPPSRCS:%.cc=$(DEPDIR)/%.P)
-include $(CSRCS:%.c=$(DEPDIR)/%.P)
# The following applies if we don't use a dependency directory:
#-include $(SRCS:.cc=.P)
tags: $(SRCS) *.h
ctags --language-force=c++ --extra=+q --fields=+i --excmd=n *.c *.cc *.h
clean:
rm -f $(EXEC) $(OBJS)
clean-deps:
rm -f $(DEPDIR)/*.P