-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
50 lines (35 loc) · 887 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
42
43
44
45
46
47
48
49
CC := g++
CFLAGS := -g -Wall -std=c++11
LIBS := -lsoundio -lsndfile
ifdef DEBUG
CFLAGS += -O0
else
CFLAGS += -O3
endif
MAIN_SRCS = src/wavplayer.cc
HEADERS = $(wildcard src/*.h)
OBJECTS_SRC = $(wildcard src/*.cc)
OBJECTS_SRC_FILTERED = $(filter-out $(MAIN_SRCS), $(OBJECTS_SRC))
OBJDIR := obj
OBJECTS := $(addprefix $(OBJDIR)/,$(OBJECTS))
TARGETOBJ := $(OBJDIR)/src
TARGETDIR := bin
TRG_wavplayer = $(TARGETDIR)/wavplayer
.PHONY: default all clean
.PRECIOUS: $(OBJECTS)
.PHONY: wavplayer
wavplayer: $(TRG_wavplayer)
default: all
all: wavplayer
%.o: %.cc $(HEADERS)
@mkdir -p $(@D)
$(CC) $(CFLAGS) -c $< -o $@
$(OBJDIR)/%.o: %.cc $(HEADERS)
@mkdir -p $(@D)
$(CC) $(CFLAGS) -c $< -o $@
$(TRG_wavplayer): $(OBJECTS) $(TARGETOBJ)/wavplayer.o
@mkdir -p $(@D)
$(CC) $(OBJECTS) $(TARGETOBJ)/wavplayer.o $(LIBS) -o $@
clean:
rm -rf $(OBJDIR)
rm -rf $(TRG_wavplayer)