@@ -14,7 +14,7 @@ OBJS_EXTRA :=
14
14
# command line option
15
15
OPTS :=
16
16
17
- LDFLAGS := -lm
17
+ LDFLAGS :=
18
18
19
19
# virtio-blk
20
20
ENABLE_VIRTIOBLK ?= 1
@@ -55,37 +55,67 @@ endif
55
55
56
56
# virtio-snd
57
57
ENABLE_VIRTIOSND ?= 1
58
- ifneq ($(UNAME_S ) ,$(filter $(UNAME_S ) ,Linux) )
58
+ ifneq ($(UNAME_S ) ,$(filter $(UNAME_S ) ,Linux Darwin ) )
59
59
ENABLE_VIRTIOSND := 0
60
60
endif
61
61
62
- # Check ALSA installation
62
+ ENABLE_PULSEAUDIO ?= 1
63
63
ifeq ($(UNAME_S ) ,Linux)
64
+ # Check ALSA installation
64
65
ifeq (0, $(call check-alsa))
65
66
$(warning No libasound installed. Check libasound in advance.)
66
67
ENABLE_VIRTIOSND := 0
67
68
endif
69
+
70
+ # Check PulseAudio installation
71
+ ifeq (0, $(call check-pa))
72
+ $(warning No PulseAudio installed.)
73
+ ENABLE_PULSEAUDIO := 0
74
+ endif
75
+ endif
76
+ ifeq ($(UNAME_S ) ,Darwin)
77
+ ifeq (0, $(call check-ca))
78
+ $(warning No CoreAudio installed Check AudioToolbox in advance.)
79
+ ENABLE_VIRTIOSND := 0
80
+ endif
68
81
endif
69
82
$(call set-feature, VIRTIOSND)
70
83
ifeq ($(call has, VIRTIOSND) , 1)
71
84
OBJS_EXTRA += virtio-snd.o
72
85
73
- LDFLAGS += -lasound -lpthread
74
- CFLAGS += -Icnfa
75
-
76
- cnfa/Makefile :
77
- git submodule update --init cnfa
78
- cnfa/os_generic : cnfa/Makefile
79
- $(MAKE ) -C $(dir $< ) os_generic.h
80
- CNFA_LIB := cnfa/CNFA_sf.h
81
- $(CNFA_LIB ) : cnfa/Makefile cnfa/os_generic
82
- $(MAKE ) -C $(dir $< ) CNFA_sf.h
83
- main.o : $(CNFA_LIB )
86
+ PORTAUDIOLIB := portaudio/lib/.libs/libportaudio.a
87
+ LDFLAGS += $(PORTAUDIOLIB )
84
88
85
- # suppress warning when compiling CNFA
86
- virtio-snd.o : CFLAGS += -Wno-unused-parameter -Wno-sign-compare
89
+ ifeq ($(UNAME_S),Linux)
90
+ LDFLAGS += -lasound -lrt
91
+ ifeq (1, $(ENABLE_PULSEAUDIO))
92
+ LDFLAGS += -lpulse
93
+ endif
94
+ endif
95
+ ifeq ($(UNAME_S),Darwin)
96
+ LDFLAGS += -framework CoreServices -framework CoreFoundation -framework AudioUnit -framework AudioToolbox -framework CoreAudio
97
+ endif
98
+
99
+ CFLAGS += -Iportaudio/include
100
+ # PortAudio requires libm, yet we set -lm in the end of LDFLAGS
101
+ # so that the other libraries will be benefited for no need to set
102
+ # -lm separately.
103
+ LDFLAGS += -lpthread
104
+
105
+ portaudio/Makefile :
106
+ git submodule update --init portaudio
107
+ $(PORTAUDIOLIB ) : portaudio/Makefile
108
+ @cd $(dir $< ) && ./configure
109
+ @cd $(dir $< ) && $(MAKE )
110
+ $(OBJS ) : $(PORTAUDIOLIB )
111
+
112
+ # suppress warning when compiling PortAudio
113
+ virtio-snd.o : CFLAGS += -Wno-unused-parameter
87
114
endif
88
115
116
+ # Set libm as the last dependency so that no need to set -lm seperately.
117
+ LDFLAGS += -lm
118
+
89
119
# .DEFAULT_GOAL should be set to all since the very first target is not all
90
120
# after git submodule.
91
121
.DEFAULT_GOAL := all
0 commit comments