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 AVF_NAME = lib$(BASE_NAME)_avf.dylib
  21 AVF_LIB = $(BUILD_DIR)/$(AVF_NAME)
  22 
  23 # Set up base search path for source and headers
  24 VPATH = $(SRCBASE_DIR):$(GENERATED_HEADERS_DIR):$(JAVA_HOME)/include:$(JAVA_HOME)/include/darwin
  25 
  26 # ------------------------------------------------------------------
  27 # Base compile/link flags
  28 
  29 CFLAGS += -pipe \
  30          -fPIC                     \
  31          -Werror=implicit-function-declaration \
  32          -DTARGET_OS_MAC=1         \
  33          -D_GNU_SOURCE             \
  34          -msse2
  35 
  36 ifeq ($(BUILD_TYPE), Release)
  37     CFLAGS += -Os
  38 else
  39     CFLAGS += -O0 -g -Wall
  40 endif
  41 
  42 INCLUDES = -I$(JAVA_HOME)/include \
  43            -I$(JAVA_HOME)/include/darwin \
  44            -I$(SRCBASE_DIR) \
  45            -I$(SRCBASE_DIR)/jni \
  46            -I$(GENERATED_HEADERS_DIR)
  47 
  48 # We need to ensure everything builds with libc++, so add it here
  49 LDFLAGS += -stdlib=libc++ \
  50            -L$(BUILD_DIR) \
  51           -lobjc \
  52           -framework Cocoa \
  53           -framework CoreVideo
  54 
  55 # ------------------------------------------------------------------
  56 # jfxmedia compile/link flags
  57 
  58 JFXMEDIA_CFLAGS = $(CFLAGS) \
  59          -DGST_REMOVE_DEPRECATED   \
  60          -DGST_DISABLE_GST_DEBUG   \
  61          -DGST_DISABLE_LOADSAVE    \
  62          -DGST_DISABLE_XML         \
  63          -DGSTREAMER_LITE          \
  64          -DJFXMEDIA_JNI_EXPORTS    \
  65          -DHAVE_CONFIG_H           \
  66 
  67 JFXMEDIA_CCFLAGS = -std=c++11 -stdlib=libc++ $(JFXMEDIA_CFLAGS) 
  68 
  69 JFXMEDIA_INCLUDES = $(INCLUDES) \
  70            -I$(GLIB_LITE_DIR)/ \
  71            -I$(GLIB_LITE_DIR)/glib \
  72            -I$(GLIB_LITE_DIR)/gmodule \
  73            -I$(GLIB_LITE_DIR)/build/osx \
  74            -I$(GSTREAMER_LITE_DIR)/gstreamer \
  75            -I$(GSTREAMER_LITE_DIR)/gst-plugins-base/gst-libs \
  76            -I$(GSTREAMER_LITE_DIR)/gstreamer/libs
  77 
  78 JFXMEDIA_LDFLAGS = $(LDFLAGS) \
  79           -Wl,-install_name,@rpath/$(TARGET_NAME) \
  80           -lgstreamer-lite \
  81           -lglib-lite
  82 
  83 # ------------------------------------------------------------------
  84 # jfxmedia sources/objects
  85 
  86 JFXMEDIA_SOURCES =                                             \
  87               MediaManagement/Media.cpp                        \
  88               MediaManagement/MediaManager.cpp                 \
  89               Locator/Locator.cpp                              \
  90               Locator/LocatorStream.cpp                        \
  91               PipelineManagement/Pipeline.cpp                  \
  92               PipelineManagement/PipelineFactory.cpp           \
  93               PipelineManagement/VideoFrame.cpp                \
  94               PipelineManagement/Track.cpp                     \
  95               PipelineManagement/AudioTrack.cpp                \
  96               PipelineManagement/VideoTrack.cpp                \
  97               PipelineManagement/SubtitleTrack.cpp             \
  98               jni/JavaPlayerEventDispatcher.cpp                \
  99               jni/JniUtils.cpp                                 \
 100               jni/com_sun_media_jfxmedia_logging_Logger.cpp    \
 101               jni/Logger.cpp                                   \
 102               jni/JavaMediaWarningListener.cpp                 \
 103               jni/JavaInputStreamCallbacks.cpp                 \
 104               jni/JavaBandsHolder.cpp                          \
 105               jni/NativeVideoBuffer.cpp                        \
 106               jni/NativeAudioEqualizer.cpp                     \
 107               jni/NativeAudioSpectrum.cpp                      \
 108               jni/NativeEqualizerBand.cpp                      \
 109               Utils/MediaWarningDispatcher.cpp                 \
 110               Utils/LowLevelPerf.cpp                           \
 111               Utils/posix/posix_critical_section.cpp           \
 112               platform/gstreamer/GstAudioEqualizer.cpp         \
 113               platform/gstreamer/GstAudioPlaybackPipeline.cpp  \
 114               platform/gstreamer/GstAudioSpectrum.cpp          \
 115               platform/gstreamer/GstAVPlaybackPipeline.cpp     \
 116               platform/gstreamer/GstElementContainer.cpp       \
 117               platform/gstreamer/GstJniUtils.cpp               \
 118               platform/gstreamer/GstMediaManager.cpp           \
 119               platform/gstreamer/GstPipelineFactory.cpp        \
 120               platform/gstreamer/GstVideoFrame.cpp             \
 121               platform/gstreamer/GstPlatform.cpp               \
 122               platform/gstreamer/GstMedia.cpp                  \
 123               platform/gstreamer/GstMediaPlayer.cpp            \
 124               Utils/ColorConverter.c                           \
 125               Utils/JObjectPeers.m                             \
 126               Utils/JavaUtils.m                                \
 127               Utils/MTObjectProxy.m                            \
 128               platform/osx/OSXPlatform.mm                      \
 129               platform/osx/OSXMediaPlayer.mm                   \
 130               platform/osx/CVVideoFrame.mm
 131 
 132 JFXMEDIA_OBJECTS = \
 133     $(patsubst %.c, $(OBJBASE_DIR)/%.o, $(filter %.c, $(JFXMEDIA_SOURCES))) \
 134     $(patsubst %.m, $(OBJBASE_DIR)/%.o, $(filter %.m, $(JFXMEDIA_SOURCES))) \
 135     $(patsubst %.cpp, $(OBJBASE_DIR)/%.o, $(filter %.cpp, $(JFXMEDIA_SOURCES))) \
 136     $(patsubst %.mm, $(OBJBASE_DIR)/%.o, $(filter %.mm, $(JFXMEDIA_SOURCES)))
 137 
 138 # ------------------------------------------------------------------
 139 # Rules
 140 
 141 .PHONY: default, checklibs
 142 
 143 default: $(TARGET) $(AVF_LIB)
 144         @echo "Ensuring $(TARGET_NAME) does not link against QuickTime..."
 145         ! nm -m "$(TARGET)" | grep -E "(QTKit|QuickTime)"
 146         @echo "Ensuring $(AVF_NAME) does not link against QuickTime..."
 147         ! nm -m "$(AVF_LIB)" | grep -E "(QTKit|QuickTime)"
 148 
 149 
 150 # ------------------------------------------------------------------
 151 # jfxmedia rules
 152 
 153 # auto-dependencies
 154 -include $(JFXMEDIA_OBJECTS:.o=.d)
 155 
 156 $(OBJBASE_DIR)/%.o: %.cpp
 157         @mkdir -p $(dir $@)
 158         $(CC) $(JFXMEDIA_CCFLAGS) $(JFXMEDIA_INCLUDES) -MD -MF $(OBJBASE_DIR)/$*.d -x c++ -c $< -o $@
 159 
 160 $(OBJBASE_DIR)/%.o: %.c
 161         @mkdir -p $(dir $@)
 162         $(CC) $(JFXMEDIA_CFLAGS) $(JFXMEDIA_INCLUDES) -MD -MF $(OBJBASE_DIR)/$*.d -x c -c $< -o $@
 163 
 164 $(OBJBASE_DIR)/%.o: %.mm
 165         @mkdir -p $(dir $@)
 166         $(CC) $(JFXMEDIA_CCFLAGS) $(JFXMEDIA_INCLUDES) -MD -MF $(OBJBASE_DIR)/$*.d -x objective-c++ -c $< -o $@
 167 
 168 $(OBJBASE_DIR)/%.o: %.m
 169         @mkdir -p $(dir $@)
 170         $(CC) $(JFXMEDIA_CFLAGS) $(JFXMEDIA_INCLUDES) -MD -MF $(OBJBASE_DIR)/$*.d -x objective-c -c $< -o $@
 171 
 172 $(TARGET): $(JFXMEDIA_OBJECTS)
 173         @mkdir -p $(dir $@)
 174         $(LINK) -dynamiclib $(JFXMEDIA_LDFLAGS) $(JFXMEDIA_OBJECTS) -o $@
 175 
 176 
 177 # ------------------------------------------------------------------
 178 # AVFoundation platform lib rules
 179 
 180 AVF_OBJBASE = $(OBJBASE_DIR)/avf
 181 
 182 AVF_LDFLAGS = $(LDFLAGS) \
 183               -Wl,-install_name,@rpath/$(AVF_NAME) \
 184               -framework AVFoundation \
 185               -framework CoreMedia \
 186               -framework Accelerate \
 187               -framework AudioUnit \
 188               -framework MediaToolbox
 189 
 190 AVF_CFLAGS = $(CFLAGS) \
 191              -DCA_AU_USE_FAST_DISPATCH=1 \
 192              -DCA_BASIC_AU_FEATURES=1 \
 193              -DCA_NO_AU_HOST_CALLBACKS=1 \
 194              -DCA_NO_AU_UI_FEATURES=1 \
 195              -DCA_USE_AUDIO_PLUGIN_ONLY=1 \
 196              -fobjc-arc
 197 
 198 # CoreAudio Utility Classes provided by Apple
 199 COREAUDIO_UTILITY_CLASSES = \
 200         platform/osx/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUBase.cpp \
 201         platform/osx/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUInputElement.cpp \
 202         platform/osx/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUOutputElement.cpp \
 203         platform/osx/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUPlugInDispatch.cpp \
 204         platform/osx/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/AUScopeElement.cpp \
 205         platform/osx/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase/ComponentBase.cpp \
 206         platform/osx/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/OtherBases/AUEffectBase.cpp \
 207         platform/osx/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/Utility/AUBuffer.cpp \
 208         platform/osx/CoreAudioUtilityClasses/CoreAudio/PublicUtility/CAAudioChannelLayout.cpp \
 209         platform/osx/CoreAudioUtilityClasses/CoreAudio/PublicUtility/CASpectralProcessor.cpp \
 210         platform/osx/CoreAudioUtilityClasses/CoreAudio/PublicUtility/CAStreamBasicDescription.cpp \
 211         platform/osx/CoreAudioUtilityClasses/CoreAudio/PublicUtility/CAVectorUnit.cpp
 212 
 213 COREAUDIO_INCLUDES = \
 214         -I$(OSX_PLATFORM_BASE)/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/AUBase \
 215         -I$(OSX_PLATFORM_BASE)/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/OtherBases \
 216         -I$(OSX_PLATFORM_BASE)/CoreAudioUtilityClasses/CoreAudio/AudioUnits/AUPublic/Utility \
 217         -I$(OSX_PLATFORM_BASE)/CoreAudioUtilityClasses/CoreAudio/PublicUtility
 218 
 219 AVF_SOURCES = \
 220         platform/osx/avf/AVFMediaPlayer.mm \
 221         platform/osx/avf/AVFAudioProcessor.mm \
 222         platform/osx/avf/AVFAudioEqualizer.cpp \
 223         platform/osx/avf/AVFAudioSpectrumUnit.cpp \
 224         platform/osx/avf/AVFSoundLevelUnit.cpp \
 225         platform/osx/avf/AVFKernelProcessor.cpp \
 226         $(COREAUDIO_UTILITY_CLASSES)
 227 
 228 
 229 AVF_OBJECTS = $(patsubst %.mm,$(AVF_OBJBASE)/%.o,$(filter %.mm, $(AVF_SOURCES))) \
 230               $(patsubst %.cpp,$(AVF_OBJBASE)/%.o,$(filter %.cpp, $(AVF_SOURCES)))
 231 
 232 AVF_INCLUDES = \
 233     $(INCLUDES) \
 234     $(COREAUDIO_INCLUDES) \
 235     -I$(OSX_PLATFORM_BASE)
 236 
 237 -include $(AVF_OBJECTS:.o=.d)
 238 
 239 $(AVF_OBJBASE)/%.o: %.cpp
 240         @mkdir -p $(dir $@)
 241         $(CC) $(AVF_CFLAGS) $(AVF_INCLUDES) -MD -MF $(AVF_OBJBASE)/$*.d -x c++ -c $< -o $@
 242 
 243 $(AVF_OBJBASE)/%.o: %.mm
 244         @mkdir -p $(dir $@)
 245         $(CC) $(AVF_CFLAGS) $(AVF_INCLUDES) -MD -MF $(AVF_OBJBASE)/$*.d -x objective-c++ -c $< -o $@
 246 
 247 $(AVF_LIB): $(TARGET) $(AVF_OBJECTS)
 248         @mkdir -p $(dir $@)
 249         $(LINK)  $(AVF_LDFLAGS) -dynamiclib $(AVF_OBJECTS) -l$(BASE_NAME) -o $@