1 #
   2 # Copyright (c) 2011, 2014, 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/java.desktop/share/native/libjsound \
  28     $(JDK_TOPDIR)/src/java.desktop/$(OPENJDK_TARGET_OS_TYPE)/native/libjsound \
  29     #
  30 LIBJSOUND_CFLAGS := \
  31     -I$(SUPPORT_OUTPUTDIR)/headers/java.desktop \
  32     $(LIBJAVA_HEADER_FLAGS) \
  33     $(foreach dir, $(LIBJSOUND_SRC_DIRS), -I$(dir)) \
  34     #
  35 
  36 LIBJSOUND_SRC_FILES := Utilities.c Platform.c
  37 
  38 LIBJSOUND_LANG := C
  39 
  40 EXTRA_SOUND_JNI_LIBS :=
  41 
  42 LIBJSOUND_MIDIFILES := \
  43     MidiInDevice.c \
  44     MidiInDeviceProvider.c \
  45     MidiOutDevice.c \
  46     MidiOutDeviceProvider.c \
  47     PlatformMidi.c
  48 
  49 # files needed for ports
  50 LIBJSOUND_PORTFILES := \
  51     PortMixerProvider.c \
  52     PortMixer.c
  53 
  54 # files needed for direct audio
  55 LIBJSOUND_DAUDIOFILES := \
  56     DirectAudioDeviceProvider.c \
  57     DirectAudioDevice.c
  58 
  59 ifeq ($(OPENJDK_TARGET_OS), windows)
  60   EXTRA_SOUND_JNI_LIBS += jsoundds
  61   LIBJSOUND_CFLAGS += -DX_PLATFORM=X_WINDOWS \
  62       -DUSE_PLATFORM_MIDI_OUT=TRUE \
  63       -DUSE_PLATFORM_MIDI_IN=TRUE \
  64       -DUSE_PORTS=TRUE
  65   LIBJSOUND_SRC_FILES += \
  66       PLATFORM_API_WinOS_MidiIn.cpp \
  67       PLATFORM_API_WinOS_MidiOut.c \
  68       PLATFORM_API_WinOS_Util.c \
  69       PLATFORM_API_WinOS_Ports.c
  70   LIBJSOUND_SRC_FILES += $(LIBJSOUND_MIDIFILES)
  71   LIBJSOUND_SRC_FILES += $(LIBJSOUND_PORTFILES)
  72 endif # OPENJDK_TARGET_OS windows
  73 
  74 ifeq ($(OPENJDK_TARGET_OS), linux)
  75   EXTRA_SOUND_JNI_LIBS += jsoundalsa
  76   LIBJSOUND_CFLAGS += -DX_PLATFORM=X_LINUX
  77 endif # OPENJDK_TARGET_OS linux
  78 
  79 ifeq ($(OPENJDK_TARGET_OS), aix)
  80   LIBJSOUND_CFLAGS += -DX_PLATFORM=X_AIX
  81 endif # OPENJDK_TARGET_OS aix
  82 
  83 ifeq ($(OPENJDK_TARGET_OS), macosx)
  84   LIBJSOUND_LANG := C++
  85   LIBJSOUND_CFLAGS += -DX_PLATFORM=X_MACOSX \
  86       -DUSE_PORTS=TRUE \
  87       -DUSE_DAUDIO=TRUE \
  88       -DUSE_PLATFORM_MIDI_OUT=TRUE \
  89       -DUSE_PLATFORM_MIDI_IN=TRUE
  90   LIBJSOUND_SRC_DIRS += $(JDK_TOPDIR)/src/java.desktop/macosx/native/libjsound
  91   LIBJSOUND_SRC_FILES += \
  92       PLATFORM_API_MacOSX_Utils.cpp \
  93       PLATFORM_API_MacOSX_PCM.cpp \
  94       PLATFORM_API_MacOSX_Ports.cpp \
  95       PLATFORM_API_MacOSX_MidiIn.c \
  96       PLATFORM_API_MacOSX_MidiOut.c \
  97       PLATFORM_API_MacOSX_MidiUtils.c
  98   LIBJSOUND_SRC_FILES += $(LIBJSOUND_MIDIFILES)
  99   LIBJSOUND_SRC_FILES += $(LIBJSOUND_PORTFILES)
 100   LIBJSOUND_SRC_FILES += $(LIBJSOUND_DAUDIOFILES)
 101 endif # OPENJDK_TARGET_OS macosx
 102 
 103 ifeq ($(OPENJDK_TARGET_OS), solaris)
 104   LIBJSOUND_CFLAGS += -DX_PLATFORM=X_SOLARIS \
 105       -DUSE_PORTS=TRUE \
 106       -DUSE_DAUDIO=TRUE
 107   LIBJSOUND_SRC_FILES += \
 108       PLATFORM_API_SolarisOS_Utils.c \
 109       PLATFORM_API_SolarisOS_Ports.c \
 110       PLATFORM_API_SolarisOS_PCM.c
 111   LIBJSOUND_SRC_FILES += $(LIBJSOUND_MIDIFILES)
 112   LIBJSOUND_SRC_FILES += $(LIBJSOUND_PORTFILES)
 113   LIBJSOUND_SRC_FILES += $(LIBJSOUND_DAUDIOFILES)
 114 endif # OPENJDK_TARGET_OS solaris
 115 
 116 
 117 ifeq ($(JVM_VARIANT_ZERO), true)
 118   LIBJSOUND_CFLAGS += -DX_ARCH=X_ZERO
 119 else
 120   ifeq ($(OPENJDK_TARGET_CPU), x86)
 121     LIBJSOUND_CFLAGS += -DX_ARCH=X_I586
 122   endif
 123 
 124   ifeq ($(OPENJDK_TARGET_CPU), sparc)
 125     LIBJSOUND_CFLAGS += -DX_ARCH=X_SPARC
 126   endif
 127 
 128   ifeq ($(OPENJDK_TARGET_CPU), sparcv9)
 129     LIBJSOUND_CFLAGS += -DX_ARCH=X_SPARCV9
 130   endif
 131 
 132   ifeq ($(OPENJDK_TARGET_CPU), x86_64)
 133     LIBJSOUND_CFLAGS += -DX_ARCH=X_AMD64
 134   endif
 135 
 136   ifeq ($(OPENJDK_TARGET_CPU), arm)
 137     LIBJSOUND_CFLAGS += -DX_ARCH=X_ARM
 138   endif
 139 
 140   ifeq ($(OPENJDK_TARGET_CPU), ppc)
 141     LIBJSOUND_CFLAGS += -DX_ARCH=X_PPC
 142   endif
 143 
 144   ifeq ($(OPENJDK_TARGET_CPU), ppc64)
 145        LIBJSOUND_CFLAGS += -DX_ARCH=X_PPC64
 146   endif
 147 endif
 148 
 149 LIBJSOUND_CFLAGS += -DEXTRA_SOUND_JNI_LIBS='"$(EXTRA_SOUND_JNI_LIBS)"'
 150 
 151 $(eval $(call SetupNativeCompilation,BUILD_LIBJSOUND, \
 152     LIBRARY := jsound, \
 153     OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
 154     SRC := $(LIBJSOUND_SRC_DIRS), \
 155     INCLUDE_FILES := $(LIBJSOUND_SRC_FILES), \
 156     LANG := $(LIBJSOUND_LANG), \
 157     OPTIMIZATION := LOW, \
 158     CFLAGS := $(CFLAGS_JDKLIB) \
 159         $(LIBJSOUND_CFLAGS), \
 160     CXXFLAGS := $(CXXFLAGS_JDKLIB) $(LIBJSOUND_CFLAGS), \
 161     MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libjsound/mapfile-vers, \
 162     LDFLAGS := $(LDFLAGS_JDKLIB) \
 163         $(call SET_SHARED_LIBRARY_ORIGIN), \
 164     LDFLAGS_macosx := -framework CoreAudio -framework CoreFoundation \
 165         -framework CoreServices -framework AudioUnit $(LIBCXX) \
 166         -framework CoreMIDI -framework AudioToolbox, \
 167     LDFLAGS_windows := $(WIN_JAVA_LIB) advapi32.lib winmm.lib, \
 168     LDFLAGS_SUFFIX_unix := -ljava -ljvm, \
 169     LDFLAGS_SUFFIX_solaris := -lc, \
 170     VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \
 171     RC_FLAGS := $(RC_FLAGS) \
 172         -D "JDK_FNAME=jsound.dll" \
 173         -D "JDK_INTERNAL_NAME=jsound" \
 174         -D "JDK_FTYPE=0x2L", \
 175     OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjsound, \
 176     DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES)))
 177 
 178 $(BUILD_LIBJSOUND): $(BUILD_LIBJAVA)
 179 
 180 TARGETS += $(BUILD_LIBJSOUND)
 181 
 182 ##########################################################################################
 183 
 184 ifneq ($(filter jsoundalsa, $(EXTRA_SOUND_JNI_LIBS)), )
 185 
 186   $(eval $(call SetupNativeCompilation,BUILD_LIBJSOUNDALSA, \
 187       LIBRARY := jsoundalsa, \
 188       OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
 189       SRC := $(LIBJSOUND_SRC_DIRS), \
 190       INCLUDE_FILES := Utilities.c $(LIBJSOUND_MIDIFILES) $(LIBJSOUND_PORTFILES) \
 191           $(LIBJSOUND_DAUDIOFILES) \
 192           PLATFORM_API_LinuxOS_ALSA_CommonUtils.c \
 193           PLATFORM_API_LinuxOS_ALSA_PCM.c \
 194           PLATFORM_API_LinuxOS_ALSA_PCMUtils.c \
 195           PLATFORM_API_LinuxOS_ALSA_MidiIn.c \
 196           PLATFORM_API_LinuxOS_ALSA_MidiOut.c \
 197           PLATFORM_API_LinuxOS_ALSA_MidiUtils.c \
 198           PLATFORM_API_LinuxOS_ALSA_Ports.c, \
 199       LANG := C, \
 200       OPTIMIZATION := LOW, \
 201       CFLAGS := $(CFLAGS_JDKLIB) $(ALSA_CFLAGS) \
 202           $(LIBJSOUND_CFLAGS) \
 203           -DUSE_DAUDIO=TRUE \
 204           -DUSE_PORTS=TRUE \
 205           -DUSE_PLATFORM_MIDI_OUT=TRUE \
 206           -DUSE_PLATFORM_MIDI_IN=TRUE, \
 207       MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libjsoundalsa/mapfile-vers, \
 208       LDFLAGS := $(LDFLAGS_JDKLIB) \
 209           $(call SET_SHARED_LIBRARY_ORIGIN), \
 210       LDFLAGS_SUFFIX := $(ALSA_LIBS) -ljava -ljvm, \
 211       OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjsoundalsa, \
 212       DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES)))
 213 
 214   $(BUILD_LIBJSOUNDALSA): $(BUILD_LIBJAVA)
 215 
 216   TARGETS += $(BUILD_LIBJSOUNDALSA)
 217 
 218 endif
 219 
 220 ##########################################################################################
 221 
 222 ifneq ($(filter jsoundds, $(EXTRA_SOUND_JNI_LIBS)), )
 223 
 224   $(eval $(call SetupNativeCompilation,BUILD_LIBJSOUNDDS, \
 225       LIBRARY := jsoundds, \
 226       OUTPUT_DIR := $(INSTALL_LIBRARIES_HERE), \
 227       SRC := $(LIBJSOUND_SRC_DIRS), \
 228       INCLUDE_FILES := Utilities.c $(LIBJSOUND_DAUDIOFILES) \
 229           PLATFORM_API_WinOS_DirectSound.cpp, \
 230       LANG := C++, \
 231       OPTIMIZATION := LOW, \
 232       CFLAGS := $(CFLAGS_JDKLIB) \
 233           $(LIBJSOUND_CFLAGS) \
 234           -DUSE_DAUDIO=TRUE, \
 235       LDFLAGS := $(LDFLAGS_JDKLIB) $(LDFLAGS_CXX_JDK) \
 236           $(call SET_SHARED_LIBRARY_ORIGIN), \
 237       LDFLAGS_SUFFIX := $(LDFLAGS_JDKLIB_SUFFIX) dsound.lib winmm.lib user32.lib ole32.lib, \
 238       VERSIONINFO_RESOURCE := $(GLOBAL_VERSION_INFO_RESOURCE), \
 239       RC_FLAGS := $(RC_FLAGS) \
 240           -D "JDK_FNAME=jsoundds.dll" \
 241           -D "JDK_INTERNAL_NAME=jsoundds" \
 242           -D "JDK_FTYPE=0x2L", \
 243       OBJECT_DIR := $(SUPPORT_OUTPUTDIR)/native/$(MODULE)/libjsoundds, \
 244       DEBUG_SYMBOLS := $(DEBUG_ALL_BINARIES)))
 245 
 246   $(BUILD_LIBJSOUNDDS): $(BUILD_LIBJAVA)
 247 
 248   TARGETS += $(BUILD_LIBJSOUNDDS)
 249 
 250 endif