1 #
   2 # Mac OS X jfxmedia makefile
   3 #
   4 
   5 # OUTPUT_DIR, BUILD_TYPE and BASE_NAME are passed on the command line or from the 
   6 # parent make process
   7 BUILD_DIR = $(OUTPUT_DIR)/$(BUILD_TYPE)
   8 SRCBASE_DIR = ../..
   9 OBJBASE_DIR = $(BUILD_DIR)/obj/jfxmedia
  10 
  11 BASE_DIR = ../../..
  12 GSTREAMER_LITE_DIR = $(BASE_DIR)/gstreamer/gstreamer-lite
  13 GLIB_LITE_DIR = $(BASE_DIR)/gstreamer/3rd_party/glib/glib-2.28.8
  14 
  15 OSX_PLATFORM_BASE = $(SRCBASE_DIR)/platform/osx
  16 
  17 TARGET_NAME = lib$(BASE_NAME).dylib
  18 TARGET = $(BUILD_DIR)/$(TARGET_NAME)
  19 
  20 # separate library for QTKit based platform
  21 QTK_NAME = lib$(BASE_NAME)_qtkit.dylib
  22 QTK_LIB = $(BUILD_DIR)/$(QTK_NAME)
  23 
  24 AVF_NAME = lib$(BASE_NAME)_avf.dylib
  25 AVF_LIB = $(BUILD_DIR)/$(AVF_NAME)
  26 
  27 # Set up base search path for source and headers
  28 VPATH = $(SRCBASE_DIR):$(GENERATED_HEADERS_DIR):$(JAVA_HOME)/include:$(JAVA_HOME)/include/darwin
  29 
  30 # ------------------------------------------------------------------
  31 # Base compile/link flags
  32 
  33 CFLAGS = -arch x86_64 \
  34          -pipe \
  35          -fPIC                     \
  36          -Werror=implicit-function-declaration \
  37          -DTARGET_OS_MAC=1         \
  38          -D_GNU_SOURCE             \
  39          -msse2                    \
  40          -mmacosx-version-min=10.7
  41 
  42 ifeq ($(BUILD_TYPE), Release)
  43     CFLAGS += -Os
  44 else
  45     CFLAGS += -O0 -g -Wall
  46 endif
  47 
  48 
  49 INCLUDES = -I$(JAVA_HOME)/include \
  50            -I$(JAVA_HOME)/include/darwin \
  51            -I$(SRCBASE_DIR) \
  52            -I$(SRCBASE_DIR)/jni \
  53            -I$(GENERATED_HEADERS_DIR)
  54 
  55 
  56 LDFLAGS = -mmacosx-version-min=10.7 \
  57           -arch x86_64 \
  58           -L$(BUILD_DIR) \
  59           -lobjc \
  60           -framework Cocoa \
  61           -framework CoreVideo
  62 
  63 # ------------------------------------------------------------------
  64 # jfxmedia compile/link flags
  65 
  66 JFXMEDIA_CFLAGS = $(CFLAGS) \
  67          -DGST_REMOVE_DEPRECATED   \
  68          -DGST_DISABLE_GST_DEBUG   \
  69          -DGST_DISABLE_LOADSAVE    \
  70          -DGST_DISABLE_XML         \
  71          -DGSTREAMER_LITE          \
  72          -DJFXMEDIA_JNI_EXPORTS    \
  73          -DHAVE_CONFIG_H           \
  74 
  75 JFXMEDIA_INCLUDES = $(INCLUDES) \
  76            -I$(GLIB_LITE_DIR)/ \
  77            -I$(GLIB_LITE_DIR)/glib \
  78            -I$(GLIB_LITE_DIR)/gmodule \
  79            -I$(GLIB_LITE_DIR)/build/osx \
  80            -I$(GSTREAMER_LITE_DIR)/gstreamer \
  81            -I$(GSTREAMER_LITE_DIR)/gst-plugins-base/gst-libs \
  82            -I$(GSTREAMER_LITE_DIR)/gstreamer/libs
  83 
  84 JFXMEDIA_LDFLAGS = $(LDFLAGS) \
  85           -Wl,-install_name,@rpath/$(TARGET_NAME) \
  86           -lgstreamer-lite \
  87           -lglib-lite
  88 
  89 # ------------------------------------------------------------------
  90 # jfxmedia sources/objects
  91 
  92 JFXMEDIA_SOURCES =                                             \
  93               MediaManagement/Media.cpp                        \
  94               MediaManagement/MediaManager.cpp                 \
  95               Locator/Locator.cpp                              \
  96               Locator/LocatorStream.cpp                        \
  97               PipelineManagement/Pipeline.cpp                  \
  98               PipelineManagement/PipelineFactory.cpp           \
  99               PipelineManagement/VideoFrame.cpp                \
 100               PipelineManagement/Track.cpp                     \
 101               PipelineManagement/AudioTrack.cpp                \
 102               PipelineManagement/VideoTrack.cpp                \
 103               PipelineManagement/SubtitleTrack.cpp             \
 104               jni/JavaPlayerEventDispatcher.cpp                \
 105               jni/JniUtils.cpp                                 \
 106               jni/com_sun_media_jfxmedia_logging_Logger.cpp    \
 107               jni/Logger.cpp                                   \
 108               jni/JavaMediaWarningListener.cpp                 \
 109               jni/JavaInputStreamCallbacks.cpp                 \
 110               jni/JavaBandsHolder.cpp                          \
 111               jni/NativeVideoBuffer.cpp                        \
 112               jni/NativeAudioEqualizer.cpp                     \
 113               jni/NativeAudioSpectrum.cpp                      \
 114               jni/NativeEqualizerBand.cpp                      \
 115               Utils/MediaWarningDispatcher.cpp                 \
 116               Utils/LowLevelPerf.cpp                           \
 117               Utils/posix/posix_critical_section.cpp           \
 118               platform/gstreamer/GstAudioEqualizer.cpp         \
 119               platform/gstreamer/GstAudioPlaybackPipeline.cpp  \
 120               platform/gstreamer/GstAudioSpectrum.cpp          \
 121               platform/gstreamer/GstAVPlaybackPipeline.cpp     \
 122               platform/gstreamer/GstElementContainer.cpp       \
 123               platform/gstreamer/GstJniUtils.cpp               \
 124               platform/gstreamer/GstMediaManager.cpp           \
 125               platform/gstreamer/GstPipelineFactory.cpp        \
 126               platform/gstreamer/GstVideoFrame.cpp             \
 127               platform/gstreamer/GstPlatform.cpp               \
 128               platform/gstreamer/GstMedia.cpp                  \
 129               platform/gstreamer/GstMediaPlayer.cpp            \
 130               Utils/ColorConverter.c                           \
 131               Utils/JObjectPeers.m                             \
 132               Utils/JavaUtils.m                                \
 133               Utils/MTObjectProxy.m                            \
 134               platform/osx/OSXPlatform.mm                      \
 135               platform/osx/OSXMediaPlayer.mm                   \
 136               platform/osx/CVVideoFrame.mm
 137 
 138 JFXMEDIA_OBJECTS = \
 139     $(patsubst %.c, $(OBJBASE_DIR)/%.o, $(filter %.c, $(JFXMEDIA_SOURCES))) \
 140     $(patsubst %.m, $(OBJBASE_DIR)/%.o, $(filter %.m, $(JFXMEDIA_SOURCES))) \
 141     $(patsubst %.cpp, $(OBJBASE_DIR)/%.o, $(filter %.cpp, $(JFXMEDIA_SOURCES))) \
 142     $(patsubst %.mm, $(OBJBASE_DIR)/%.o, $(filter %.mm, $(JFXMEDIA_SOURCES)))
 143 
 144 # ------------------------------------------------------------------
 145 # Rules
 146 
 147 .PHONY: default, checklibs
 148 
 149 default: $(TARGET) $(QTK_LIB) $(AVF_LIB)
 150         @echo "Ensuring $(TARGET_NAME) does not link against QuickTime..."
 151         ! nm -m "$(TARGET)" | grep -E "(QTKit|QuickTime)"
 152         @echo "Ensuring $(AVF_NAME) does not link against QuickTime..."
 153         ! nm -m "$(AVF_LIB)" | grep -E "(QTKit|QuickTime)"
 154 
 155 
 156 # ------------------------------------------------------------------
 157 # jfxmedia rules
 158 
 159 # auto-dependencies
 160 -include $(JFXMEDIA_OBJECTS:.o=.d)
 161 
 162 $(OBJBASE_DIR)/%.o: %.cpp
 163         @mkdir -p $(dir $@)
 164         $(CC) $(JFXMEDIA_CFLAGS) $(JFXMEDIA_INCLUDES) -MD -MF $(OBJBASE_DIR)/$*.d -x c++ -c $< -o $@
 165 
 166 $(OBJBASE_DIR)/%.o: %.c
 167         @mkdir -p $(dir $@)
 168         $(CC) $(JFXMEDIA_CFLAGS) $(JFXMEDIA_INCLUDES) -MD -MF $(OBJBASE_DIR)/$*.d -x c -c $< -o $@
 169 
 170 $(OBJBASE_DIR)/%.o: %.mm
 171         @mkdir -p $(dir $@)
 172         $(CC) $(JFXMEDIA_CFLAGS) $(JFXMEDIA_INCLUDES) -MD -MF $(OBJBASE_DIR)/$*.d -x objective-c++ -c $< -o $@
 173 
 174 $(OBJBASE_DIR)/%.o: %.m
 175         @mkdir -p $(dir $@)
 176         $(CC) $(JFXMEDIA_CFLAGS) $(JFXMEDIA_INCLUDES) -MD -MF $(OBJBASE_DIR)/$*.d -x objective-c -c $< -o $@
 177 
 178 $(TARGET): $(JFXMEDIA_OBJECTS)
 179         @mkdir -p $(dir $@)
 180         $(LINK) -dynamiclib $(JFXMEDIA_LDFLAGS) $(JFXMEDIA_OBJECTS) -o $@
 181 
 182 
 183 # ------------------------------------------------------------------
 184 # AVFoundation platform lib rules
 185 
 186 ifeq ($(BUILD_TYPE), Release)
 187     AVF_XCRUN_FLAGS =
 188 else
 189     # add a -v flag to show the build environment when xcrun is invoked
 190     AVF_XCRUN_FLAGS = -v
 191 endif
 192 
 193 # The AVFoundation code uses ARC which is only supported by the clang compiler, so we'll
 194 # force the use of clang for this module.
 195 ifeq ($(COMPILE_PARFAIT), true)
 196   # call xcrun so we wrap the correct clang++ executable
 197   CLANG_PATH = $(shell xcrun -find clang++)
 198   AVF_CPP = parfait-clang++ --nativecxx "$(CLANG_PATH)"
 199 else
 200   # add -l to show the full command line used to invoke clang++ (for debugging purposes)
 201   AVF_CPP = xcrun -l $(AVF_XCRUN_FLAGS) clang++
 202 endif
 203 
 204 AVF_OBJBASE = $(OBJBASE_DIR)/avf
 205 
 206 # We need a full path to the right SDK
 207 # We use --sdk macosx to force it to use the latest macosx SDK, which should be 10.8 or later
 208 AVF_SYSROOT = $(shell xcodebuild -sdk macosx -version | grep '^Path: ' | sed 's/Path: //')
 209 
 210 # we have to remove -mmacosx-version-min=% from CFLAGS and LDFLAGS and set it to
 211 # 10.8 since this module requires features only in 10.8 and later
 212 AVF_LDFLAGS = $(filter-out -mmacosx-version-min=%, $(LDFLAGS)) \
 213               -isysroot "$(AVF_SYSROOT)" \
 214               -iframework"$(AVF_SYSROOT)/System/Library/Frameworks" \
 215               -mmacosx-version-min=10.8 \
 216               -Wl,-install_name,@rpath/$(AVF_NAME) \
 217               -framework AVFoundation \
 218               -framework CoreMedia \
 219               -framework Accelerate \
 220               -framework AudioUnit \
 221               -framework MediaToolbox
 222 
 223 AVF_CFLAGS = $(filter-out -mmacosx-version-min=%, $(CFLAGS)) \
 224              -isysroot "$(AVF_SYSROOT)" \
 225              -iframework"$(AVF_SYSROOT)/System/Library/Frameworks" \
 226              -mmacosx-version-min=10.8 \
 227              -DCA_AU_USE_FAST_DISPATCH=1 \
 228              -DCA_BASIC_AU_FEATURES=1 \
 229              -DCA_NO_AU_HOST_CALLBACKS=1 \
 230              -DCA_NO_AU_UI_FEATURES=1 \
 231              -DCA_USE_AUDIO_PLUGIN_ONLY=1 \
 232              -fobjc-arc
 233 
 234 # CoreAudio Utility Classes provided by Apple
 235 COREAUDIO_UTILITY_CLASSES = \
 236         platform/osx/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUBase.cpp \
 237         platform/osx/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUInputElement.cpp \
 238         platform/osx/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUOutputElement.cpp \
 239         platform/osx/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUPlugInDispatch.cpp \
 240         platform/osx/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUScopeElement.cpp \
 241         platform/osx/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/ComponentBase.cpp \
 242         platform/osx/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/OtherBases/AUEffectBase.cpp \
 243         platform/osx/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/Utility/AUBuffer.cpp \
 244         platform/osx/CoreAudioUtilityClasses/CoreAudio/PublicUtility/CAAudioChannelLayout.cpp \
 245         platform/osx/CoreAudioUtilityClasses/CoreAudio/PublicUtility/CASpectralProcessor.cpp \
 246         platform/osx/CoreAudioUtilityClasses/CoreAudio/PublicUtility/CAStreamBasicDescription.cpp \
 247         platform/osx/CoreAudioUtilityClasses/CoreAudio/PublicUtility/CAVectorUnit.cpp
 248 
 249 COREAUDIO_INCLUDES = \
 250         -I$(OSX_PLATFORM_BASE)/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase \
 251         -I$(OSX_PLATFORM_BASE)/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/OtherBases \
 252         -I$(OSX_PLATFORM_BASE)/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/Utility \
 253         -I$(OSX_PLATFORM_BASE)/CoreAudioUtilityClasses/CoreAudio/PublicUtility
 254 
 255 AVF_SOURCES = \
 256         platform/osx/avf/AVFMediaPlayer.mm \
 257         platform/osx/avf/AVFAudioProcessor.mm \
 258         platform/osx/avf/AVFAudioEqualizer.cpp \
 259         platform/osx/avf/AVFAudioSpectrumUnit.cpp \
 260         platform/osx/avf/AVFSoundLevelUnit.cpp \
 261         platform/osx/avf/AVFKernelProcessor.cpp \
 262         $(COREAUDIO_UTILITY_CLASSES)
 263 
 264 
 265 AVF_OBJECTS = $(patsubst %.mm,$(AVF_OBJBASE)/%.o,$(filter %.mm, $(AVF_SOURCES))) \
 266               $(patsubst %.cpp,$(AVF_OBJBASE)/%.o,$(filter %.cpp, $(AVF_SOURCES)))
 267 
 268 AVF_INCLUDES = \
 269     $(INCLUDES) \
 270     $(COREAUDIO_INCLUDES) \
 271     -I$(OSX_PLATFORM_BASE)
 272 
 273 -include $(AVF_OBJECTS:.o=.d)
 274 
 275 $(AVF_OBJBASE)/%.o: %.cpp
 276         @mkdir -p $(dir $@)
 277         $(AVF_CPP) $(AVF_CFLAGS) $(AVF_INCLUDES) -MD -MF $(AVF_OBJBASE)/$*.d -x c++ -c $< -o $@
 278 
 279 $(AVF_OBJBASE)/%.o: %.mm
 280         @mkdir -p $(dir $@)
 281         $(AVF_CPP) $(AVF_CFLAGS) $(AVF_INCLUDES) -MD -MF $(AVF_OBJBASE)/$*.d -x objective-c++ -c $< -o $@
 282 
 283 $(AVF_LIB): $(TARGET) $(AVF_OBJECTS)
 284         @mkdir -p $(dir $@)
 285         $(AVF_CPP)  $(AVF_LDFLAGS) -dynamiclib $(AVF_OBJECTS) -l$(BASE_NAME) -o $@
 286 
 287 
 288 # ------------------------------------------------------------------
 289 # QTKit platform lib rules
 290 
 291 QTK_OBJBASE = $(OBJBASE_DIR)/qtk
 292 QTK_LDFLAGS = $(LDFLAGS) \
 293           -Wl,-install_name,@rpath/$(QTK_NAME) \
 294           -framework QTKit
 295 
 296 QTK_SOURCES = platform/osx/QTKMediaPlayer.mm
 297 QTK_OBJECTS = $(patsubst %.mm,$(QTK_OBJBASE)/%.o,$(QTK_SOURCES))
 298 
 299 -include $(QTK_OBJECTS:.o=.d)
 300 
 301 $(QTK_OBJBASE)/%.o: %.mm
 302         @mkdir -p $(dir $@)
 303         $(CC) $(CFLAGS) $(INCLUDES) -MD -MF $(QTK_OBJBASE)/$*.d -x objective-c++ -c $< -o $@
 304 
 305 $(QTK_LIB): $(TARGET) $(QTK_OBJECTS)
 306         @mkdir -p $(dir $@)
 307         $(LINK)  $(QTK_LDFLAGS) -dynamiclib $(QTK_OBJECTS) -l$(BASE_NAME) -o $@