-
Notifications
You must be signed in to change notification settings - Fork 13
/
Makefile
50 lines (37 loc) · 982 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
50
CC = g++
LD = g++
BUILD_DIR = build
SRC = src
SRCS = $(wildcard ./src/*.cc)
OBJS = $(addprefix $(BUILD_DIR)/, $(patsubst %cc, %o, $(notdir $(SRCS))))
TARGET = keysound
INCLUDE = -I./include
LIB = -lpthread
CFLAGS = -O3
MARCO =
ifeq ($(CFLAG), )
MARCO+=-D USE_PULSE
LIB+=-lpulse-simple
LIB+=-lpulse
else ifeq ($(CFLAG), pulse)
MARCO+=-D USE_PULSE
LIB+=-lpulse-simple
else ifeq ($(CFLAG), alsa)
MARCO+=-D USE_ALSA
LIB+=-lasound
else ifeq ($(CFLAG), sdl)
MARCO+=-D USE_SDL
LIB+=-lSDL2
endif
.PHONY: all clean
all: $(TARGET)
$(TARGET): $(OBJS)
$(LD) -o $@ $^ $(CFLAGS) $(LIB)
# 由cc生成oo,编译的时候只需要头文件和源文件,不需要-l的,但是需要-D
# Generate oo from cc files, but only using the header and source files
# for compiling. Don't use -I, instead use -D
$(BUILD_DIR)/%.o:$(SRC)/%.cc
@ if [ ! -d $(BUILD_DIR) ]; then mkdir -p $(BUILD_DIR); fi;
$(CC) -c $(INCLUDE) $(CFLAGS) $(MARCO) -o $@ $<
clean:
rm -f $(OBJS) $(TARGET)