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