1 #
   2 # Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
   3 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4 #
   5 # This code is free software; you can redistribute it and/or modify it
   6 # under the terms of the GNU General Public License version 2 only, as
   7 # published by the Free Software Foundation.  Oracle designates this
   8 # particular file as subject to the "Classpath" exception as provided
   9 # by Oracle in the LICENSE file that accompanied this code.
  10 #
  11 # This code is distributed in the hope that it will be useful, but WITHOUT
  12 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13 # FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14 # version 2 for more details (a copy is included in the LICENSE file that
  15 # accompanied this code).
  16 #
  17 # You should have received a copy of the GNU General Public License version
  18 # 2 along with this work; if not, write to the Free Software Foundation,
  19 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20 #
  21 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22 # or visit www.oracle.com if you need additional information or have any
  23 # questions.
  24 #
  25 
  26 LIBJSOUND_SRC_DIRS := \
  27     $(JDK_TOPDIR)/src/share/native/com/sun/media/sound \
  28     $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/native/com/sun/media/sound
  29 
  30 LIBJSOUND_SRC_FILES := Utilities.c Platform.c
  31 
  32 LIBJSOUND_LANG := C
  33 LIBJSOUND_CFLAGS := $(foreach dir, $(LIBJSOUND_SRC_DIRS), -I$(dir))
  34 
  35 EXTRA_SOUND_JNI_LIBS :=
  36 
  37 LIBJSOUND_MIDIFILES := \
  38     MidiInDevice.c \
  39     MidiInDeviceProvider.c \
  40     MidiOutDevice.c \
  41     MidiOutDeviceProvider.c \
  42     PlatformMidi.c
  43 
  44 # files needed for ports
  45 LIBJSOUND_PORTFILES := \
  46     PortMixerProvider.c \
  47     PortMixer.c
  48 
  49 # files needed for direct audio
  50 LIBJSOUND_DAUDIOFILES := \
  51     DirectAudioDeviceProvider.c \
  52     DirectAudioDevice.c
  53 
  54 ifeq ($(OPENJDK_TARGET_OS), windows)
  55   EXTRA_SOUND_JNI_LIBS += jsoundds
  56   LIBJSOUND_CFLAGS += -DX_PLATFORM=X_WINDOWS \
  57       -DUSE_PLATFORM_MIDI_OUT=TRUE \
  58       -DUSE_PLATFORM_MIDI_IN=TRUE \
  59       -DUSE_PORTS=TRUE
  60   LIBJSOUND_SRC_FILES += \
  61       PLATFORM_API_WinOS_MidiIn.cpp \
  62       PLATFORM_API_WinOS_MidiOut.c \
  63       PLATFORM_API_WinOS_Util.c \
  64       PLATFORM_API_WinOS_Ports.c
  65   LIBJSOUND_SRC_FILES += $(LIBJSOUND_MIDIFILES)
  66   LIBJSOUND_SRC_FILES += $(LIBJSOUND_PORTFILES)
  67 endif # OPENJDK_TARGET_OS windows
  68 
  69 ifeq ($(OPENJDK_TARGET_OS), linux)
  70   EXTRA_SOUND_JNI_LIBS += jsoundalsa
  71   LIBJSOUND_CFLAGS += -DX_PLATFORM=X_LINUX
  72 endif # OPENJDK_TARGET_OS linux
  73 
  74 ifeq ($(OPENJDK_TARGET_OS), aix)
  75   LIBJSOUND_CFLAGS += -DX_PLATFORM=X_AIX
  76 endif # OPENJDK_TARGET_OS aix
  77 
  78 ifeq ($(OPENJDK_TARGET_OS), macosx)
  79   LIBJSOUND_LANG := C++
  80   LIBJSOUND_CFLAGS += -DX_PLATFORM=X_MACOSX \
  81       -DUSE_PORTS=TRUE \
  82       -DUSE_DAUDIO=TRUE \
  83       -DUSE_PLATFORM_MIDI_OUT=TRUE \
  84       -DUSE_PLATFORM_MIDI_IN=TRUE
  85   LIBJSOUND_SRC_DIRS += $(JDK_TOPDIR)/src/macosx/native/com/sun/media/sound
  86   LIBJSOUND_SRC_FILES += \
  87       PLATFORM_API_MacOSX_Utils.cpp \
  88       PLATFORM_API_MacOSX_PCM.cpp \
  89       PLATFORM_API_MacOSX_Ports.cpp \
  90       PLATFORM_API_MacOSX_MidiIn.c \
  91       PLATFORM_API_MacOSX_MidiOut.c \
  92       PLATFORM_API_MacOSX_MidiUtils.c
  93   LIBJSOUND_SRC_FILES += $(LIBJSOUND_MIDIFILES)
  94   LIBJSOUND_SRC_FILES += $(LIBJSOUND_PORTFILES)
  95   LIBJSOUND_SRC_FILES += $(LIBJSOUND_DAUDIOFILES)
  96 endif # OPENJDK_TARGET_OS macosx
  97 
  98 ifeq ($(OPENJDK_TARGET_OS), solaris)
  99   LIBJSOUND_CFLAGS += -DX_PLATFORM=X_SOLARIS \
 100       -DUSE_PORTS=TRUE \
 101       -DUSE_DAUDIO=TRUE
 102   LIBJSOUND_SRC_FILES += \
 103       PLATFORM_API_SolarisOS_Utils.c \
 104       PLATFORM_API_SolarisOS_Ports.c \
 105       PLATFORM_API_SolarisOS_PCM.c
 106   LIBJSOUND_SRC_FILES += $(LIBJSOUND_MIDIFILES)
 107   LIBJSOUND_SRC_FILES += $(LIBJSOUND_PORTFILES)
 108   LIBJSOUND_SRC_FILES += $(LIBJSOUND_DAUDIOFILES)
 109 endif # OPENJDK_TARGET_OS solaris
 110 
 111 
 112 ifeq ($(JVM_VARIANT_ZERO), true)
 113   LIBJSOUND_CFLAGS += -DX_ARCH=X_ZERO
 114 else
 115   ifeq ($(OPENJDK_TARGET_CPU), x86)
 116     LIBJSOUND_CFLAGS += -DX_ARCH=X_I586
 117   endif
 118 
 119   ifeq ($(OPENJDK_TARGET_CPU), sparc)
 120     LIBJSOUND_CFLAGS += -DX_ARCH=X_SPARC
 121   endif
 122 
 123   ifeq ($(OPENJDK_TARGET_CPU), sparcv9)
 124     LIBJSOUND_CFLAGS += -DX_ARCH=X_SPARCV9
 125   endif
 126 
 127   ifeq ($(OPENJDK_TARGET_CPU), x86_64)
 128     LIBJSOUND_CFLAGS += -DX_ARCH=X_AMD64
 129   endif
 130 
 131   ifeq ($(OPENJDK_TARGET_CPU), arm)
 132     LIBJSOUND_CFLAGS += -DX_ARCH=X_ARM
 133   endif
 134 
 135   ifeq ($(OPENJDK_TARGET_CPU), ppc)
 136     LIBJSOUND_CFLAGS += -DX_ARCH=X_PPC
 137   endif
 138 
 139   ifeq ($(OPENJDK_TARGET_CPU), ppc64)
 140        LIBJSOUND_CFLAGS += -DX_ARCH=X_PPC64
 141   endif
 142 
 143   ifeq ($(OPENJDK_TARGET_CPU), ppc64le)
 144        LIBJSOUND_CFLAGS += -DX_ARCH=X_PPC64LE
 145   endif
 146 endif
 147 
 148 LIBJSOUND_CFLAGS += -DEXTRA_SOUND_JNI_LIBS='"$(EXTRA_SOUND_JNI_LIBS)"'
 149 
 150 $(eval $(call SetupNativeCompilation,BUILD_LIBJSOUND, \
 151     LIBRARY := jsound, \
 152     OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
 153     SRC := $(LIBJSOUND_SRC_DIRS), \
 154     INCLUDE_FILES := $(LIBJSOUND_SRC_FILES), \
 155     LANG := $(LIBJSOUND_LANG), \
 156     OPTIMIZATION := LOW, \
 157     CFLAGS := $(CFLAGS_JDKLIB) \
 158         $(LIBJSOUND_CFLAGS), \
 159     CXXFLAGS := $(CXXFLAGS_JDKLIB) $(LIBJSOUND_CFLAGS), \
 160     MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libjsound/mapfile-vers, \
 161     LDFLAGS := $(LDFLAGS_JDKLIB) \
 162         $(call SET_SHARED_LIBRARY_ORIGIN), \
 163     LDFLAGS_macosx := -framework CoreAudio -framework CoreFoundation \
 164         -framework CoreServices -framework AudioUnit $(LIBCXX) \
 165         -framework CoreMIDI -framework AudioToolbox, \
 166     LDFLAGS_windows := $(WIN_JAVA_LIB) advapi32.lib winmm.lib, \
 167     LDFLAGS_SUFFIX_posix := -ljava -ljvm, \
 168     LDFLAGS_SUFFIX_solaris := -lc, \
 169     VERSIONINFO_RESOURCE := $(JDK_TOPDIR)/src/windows/resource/version.rc, \
 170     RC_FLAGS := $(RC_FLAGS) \
 171         -D "JDK_FNAME=jsound.dll" \
 172         -D "JDK_INTERNAL_NAME=jsound" \
 173         -D "JDK_FTYPE=0x2L", \
 174     OBJECT_DIR := $(JDK_OUTPUTDIR)/objs/libjsound, \
 175     DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES)))
 176 
 177 $(BUILD_LIBJSOUND): $(BUILD_LIBJAVA)
 178 
 179 BUILD_LIBRARIES += $(BUILD_LIBJSOUND)
 180 
 181 ##########################################################################################
 182 
 183 ifneq ($(filter jsoundalsa, $(EXTRA_SOUND_JNI_LIBS)), )
 184 
 185   $(eval $(call SetupNativeCompilation,BUILD_LIBJSOUNDALSA, \
 186       LIBRARY := jsoundalsa, \
 187       OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
 188       SRC := $(LIBJSOUND_SRC_DIRS), \
 189       INCLUDE_FILES := Utilities.c $(LIBJSOUND_MIDIFILES) $(LIBJSOUND_PORTFILES) \
 190           $(LIBJSOUND_DAUDIOFILES) \
 191           PLATFORM_API_LinuxOS_ALSA_CommonUtils.c \
 192           PLATFORM_API_LinuxOS_ALSA_PCM.c \
 193           PLATFORM_API_LinuxOS_ALSA_PCMUtils.c \
 194           PLATFORM_API_LinuxOS_ALSA_MidiIn.c \
 195           PLATFORM_API_LinuxOS_ALSA_MidiOut.c \
 196           PLATFORM_API_LinuxOS_ALSA_MidiUtils.c \
 197           PLATFORM_API_LinuxOS_ALSA_Ports.c, \
 198       LANG := C, \
 199       OPTIMIZATION := LOW, \
 200       CFLAGS := $(CFLAGS_JDKLIB) $(ALSA_CFLAGS) \
 201           $(LIBJSOUND_CFLAGS) \
 202           -DUSE_DAUDIO=TRUE \
 203           -DUSE_PORTS=TRUE \
 204           -DUSE_PLATFORM_MIDI_OUT=TRUE \
 205           -DUSE_PLATFORM_MIDI_IN=TRUE, \
 206       MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libjsoundalsa/mapfile-vers, \
 207       LDFLAGS := $(LDFLAGS_JDKLIB) \
 208           $(call SET_SHARED_LIBRARY_ORIGIN), \
 209       LDFLAGS_SUFFIX := $(ALSA_LIBS) -ljava -ljvm, \
 210       OBJECT_DIR := $(JDK_OUTPUTDIR)/objs/libjsoundalsa, \
 211       DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES)))
 212 
 213   $(BUILD_LIBJSOUNDALSA): $(BUILD_LIBJAVA)
 214 
 215   BUILD_LIBRARIES += $(BUILD_LIBJSOUNDALSA)
 216 
 217 endif
 218 
 219 ##########################################################################################
 220 
 221 ifneq ($(filter jsoundds, $(EXTRA_SOUND_JNI_LIBS)), )
 222 
 223   $(eval $(call SetupNativeCompilation,BUILD_LIBJSOUNDDS, \
 224       LIBRARY := jsoundds, \
 225       OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
 226       SRC := $(LIBJSOUND_SRC_DIRS), \
 227       INCLUDE_FILES := Utilities.c $(LIBJSOUND_DAUDIOFILES) \
 228           PLATFORM_API_WinOS_DirectSound.cpp, \
 229       LANG := C++, \
 230       OPTIMIZATION := LOW, \
 231       CFLAGS := $(CFLAGS_JDKLIB) \
 232           $(LIBJSOUND_CFLAGS) \
 233           -DUSE_DAUDIO=TRUE, \
 234       LDFLAGS := $(LDFLAGS_JDKLIB) $(LDFLAGS_CXX_JDK) \
 235           $(call SET_SHARED_LIBRARY_ORIGIN), \
 236       LDFLAGS_SUFFIX := $(LDFLAGS_JDKLIB_SUFFIX) dsound.lib winmm.lib user32.lib ole32.lib, \
 237       VERSIONINFO_RESOURCE := $(JDK_TOPDIR)/src/windows/resource/version.rc, \
 238       RC_FLAGS := $(RC_FLAGS) \
 239           -D "JDK_FNAME=jsoundds.dll" \
 240           -D "JDK_INTERNAL_NAME=jsoundds" \
 241           -D "JDK_FTYPE=0x2L", \
 242       OBJECT_DIR := $(JDK_OUTPUTDIR)/objs/libjsoundds, \
 243       DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES)))
 244 
 245   $(BUILD_LIBJSOUNDDS): $(BUILD_LIBJAVA)
 246 
 247   BUILD_LIBRARIES += $(BUILD_LIBJSOUNDDS)
 248 
 249 endif