@@ -14,7 +14,7 @@ OBJS_EXTRA :=
1414# command line option
1515OPTS :=
1616
17- LDFLAGS := -lm
17+ LDFLAGS :=
1818
1919# virtio-blk
2020ENABLE_VIRTIOBLK ?= 1
@@ -55,37 +55,61 @@ endif
5555
5656# virtio-snd
5757ENABLE_VIRTIOSND ?= 1
58- ifneq ($(UNAME_S ) ,$(filter $(UNAME_S ) ,Linux) )
58+ ifneq ($(UNAME_S ) ,$(filter $(UNAME_S ) ,Linux Darwin ) )
5959 ENABLE_VIRTIOSND := 0
6060endif
6161
62- # Check ALSA installation
6362ifeq ($(UNAME_S ) ,Linux)
63+ # Check ALSA installation
6464 ifeq (0, $(call check-alsa))
6565 $(warning No libasound installed. Check libasound in advance.)
6666 ENABLE_VIRTIOSND := 0
6767 endif
6868endif
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
6975$(call set-feature, VIRTIOSND)
7076ifeq ($(call has, VIRTIOSND) , 1)
7177 OBJS_EXTRA += virtio-snd.o
7278
73- LDFLAGS += -lasound -lpthread
74- CFLAGS += -Icnfa
79+ PORTAUDIOLIB := portaudio/lib/.libs/libportaudio.a
80+ LDFLAGS += $( PORTAUDIOLIB )
7581
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
8492
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+ $(MAKE ) -C $(dir $< )
104+ main.o : $(PORTAUDIOLIB )
105+
106+ # suppress warning when compiling PortAudio
107+ virtio-snd.o : CFLAGS += -Wno-unused-parameter
87108endif
88109
110+ # Set libm as the last dependency so that no need to set -lm seperately.
111+ LDFLAGS += -lm
112+
89113# .DEFAULT_GOAL should be set to all since the very first target is not all
90114# after git submodule.
91115.DEFAULT_GOAL := all
0 commit comments