@@ -14,7 +14,7 @@ OBJS_EXTRA :=
1414# command line option
1515OPTS :=
1616
17- LDFLAGS := -lm
17+ LDFLAGS :=
1818
1919# virtio-blk
2020ENABLE_VIRTIOBLK ?= 1
@@ -56,37 +56,61 @@ endif
5656
5757# virtio-snd
5858ENABLE_VIRTIOSND ?= 1
59- ifneq ($(UNAME_S ) ,$(filter $(UNAME_S ) ,Linux) )
59+ ifneq ($(UNAME_S ) ,$(filter $(UNAME_S ) ,Linux Darwin ) )
6060 ENABLE_VIRTIOSND := 0
6161endif
6262
63- # Check ALSA installation
6463ifeq ($(UNAME_S ) ,Linux)
64+ # Check ALSA installation
6565 ifeq (0, $(call check-alsa))
6666 $(warning No libasound installed. Check libasound in advance.)
6767 ENABLE_VIRTIOSND := 0
6868 endif
6969endif
70+ ifeq ($(UNAME_S ) ,Darwin)
71+ ifeq (0, $(call check-coreaudio))
72+ $(warning No CoreAudio installed Check AudioToolbox in advance.)
73+ ENABLE_VIRTIOSND := 0
74+ endif
75+ endif
7076$(call set-feature, VIRTIOSND)
7177ifeq ($(call has, VIRTIOSND) , 1)
7278 OBJS_EXTRA += virtio-snd.o
7379
74- LDFLAGS += -lasound -lpthread
75- CFLAGS += -Icnfa
80+ PORTAUDIOLIB := portaudio/lib/.libs/libportaudio.a
81+ LDFLAGS += $( PORTAUDIOLIB )
7682
77- cnfa/Makefile :
78- git submodule update --init cnfa
79- cnfa/os_generic : cnfa/Makefile
80- $(MAKE ) -C $(dir $< ) os_generic.h
81- CNFA_LIB := cnfa/CNFA_sf.h
82- $(CNFA_LIB ) : cnfa/Makefile cnfa/os_generic
83- $(MAKE ) -C $(dir $< ) CNFA_sf.h
84- main.o : $(CNFA_LIB )
83+ ifeq ($(UNAME_S),Linux)
84+ LDFLAGS += -lasound -lrt
85+ # Check PulseAudio installation
86+ ifeq (0, $(call check-pa))
87+ LDFLAGS += -lpulse
88+ endif
89+ endif
90+ ifeq ($(UNAME_S),Darwin)
91+ LDFLAGS += -framework CoreServices -framework CoreFoundation -framework AudioUnit -framework AudioToolbox -framework CoreAudio
92+ endif
8593
86- # suppress warning when compiling CNFA
87- virtio-snd.o : CFLAGS += -Wno-unused-parameter -Wno-sign-compare
94+ CFLAGS += -Iportaudio/include
95+ # PortAudio requires libm, yet we set -lm in the end of LDFLAGS
96+ # so that the other libraries will be benefited for no need to set
97+ # -lm separately.
98+ LDFLAGS += -lpthread
99+
100+ portaudio/Makefile :
101+ git submodule update --init portaudio
102+ $(PORTAUDIOLIB ) : portaudio/Makefile
103+ cd $(dir $< ) && ./configure
104+ $(MAKE ) -C $(dir $< )
105+ main.o : $(PORTAUDIOLIB )
106+
107+ # suppress warning when compiling PortAudio
108+ virtio-snd.o : CFLAGS += -Wno-unused-parameter
88109endif
89110
111+ # Set libm as the last dependency so that no need to set -lm seperately.
112+ LDFLAGS += -lm
113+
90114# .DEFAULT_GOAL should be set to all since the very first target is not all
91115# after git submodule.
92116.DEFAULT_GOAL := all
0 commit comments