openh264/Makefile

311 lines
9.8 KiB
Makefile
Raw Normal View History

SRC_PATH=$(word 1, $(dir $(MAKEFILE_LIST)))
vpath %.c $(SRC_PATH)
vpath %.cc $(SRC_PATH)
vpath %.cpp $(SRC_PATH)
vpath %.asm $(SRC_PATH)
vpath %.S $(SRC_PATH)
2014-02-19 02:54:27 +01:00
OS=$(shell uname | tr A-Z a-z | tr -d \\-[:digit:].)
ARCH=$(shell uname -m)
LIBPREFIX=lib
LIBSUFFIX=a
CCAS=$(CC)
CXX_O=-o $@
CXX_LINK_O=-o $@
AR_OPTS=cr $@
LINK_LOCAL_DIR=-L.
LINK_LIB=-l$(1)
CFLAGS_OPT=-O3
CFLAGS_DEBUG=-g
BUILDTYPE=Release
V=Yes
2014-01-27 13:54:47 +01:00
PREFIX=/usr/local
SHARED=-shared
OBJ=o
SHAREDLIB_DIR=$(PREFIX)/lib
PROJECT_NAME=openh264
2014-06-18 04:54:16 +02:00
MODULE_NAME=gmpopenh264
2014-12-04 19:24:36 +01:00
GMP_API_BRANCH=Firefox36
CCASFLAGS=$(CFLAGS)
2014-10-28 10:57:57 +01:00
VERSION=1.2
2013-12-12 05:24:55 +01:00
ifeq (,$(wildcard $(SRC_PATH)gmp-api))
2014-06-18 04:54:16 +02:00
HAVE_GMP_API=No
else
HAVE_GMP_API=Yes
endif
ifeq (,$(wildcard $(SRC_PATH)gtest))
2013-12-12 05:24:55 +01:00
HAVE_GTEST=No
else
2013-12-12 03:56:52 +01:00
HAVE_GTEST=Yes
2013-12-12 05:24:55 +01:00
endif
# Configurations
ifeq ($(BUILDTYPE), Release)
CFLAGS += $(CFLAGS_OPT)
USE_ASM = Yes
else
CFLAGS = $(CFLAGS_DEBUG)
USE_ASM = No
endif
2014-01-03 07:49:45 +01:00
2014-01-09 19:25:15 +01:00
ifeq ($(USE_ASAN), Yes)
CFLAGS += -fsanitize=address
LDFLAGS += -fsanitize=address
endif
SHAREDLIBVERSION=0
include $(SRC_PATH)build/platform-$(OS).mk
CFLAGS +=
LDFLAGS +=
ifeq (Yes, $(GCOV))
CFLAGS += -fprofile-arcs -ftest-coverage
LDFLAGS += -lgcov
endif
#### No user-serviceable parts below this line
ifneq ($(V),Yes)
QUIET_CXX = @printf "CXX\t$@\n";
QUIET_CC = @printf "CC\t$@\n";
QUIET_CCAS = @printf "CCAS\t$@\n";
QUIET_ASM = @printf "ASM\t$@\n";
QUIET_AR = @printf "AR\t$@\n";
QUIET = @
endif
INCLUDES += -I$(SRC_PATH)codec/api/svc -I$(SRC_PATH)codec/common/inc
DECODER_INCLUDES += \
-I$(SRC_PATH)codec/decoder/core/inc \
-I$(SRC_PATH)codec/decoder/plus/inc
ENCODER_INCLUDES += \
-I$(SRC_PATH)codec/encoder/core/inc \
-I$(SRC_PATH)codec/encoder/plus/inc \
-I$(SRC_PATH)codec/processing/interface
PROCESSING_INCLUDES += \
-I$(SRC_PATH)codec/processing/interface \
-I$(SRC_PATH)codec/processing/src/common \
-I$(SRC_PATH)codec/processing/src/adaptivequantization \
2014-08-27 09:40:14 +02:00
-I$(SRC_PATH)codec/processing/src/downsample \
2014-08-27 07:53:18 +02:00
-I$(SRC_PATH)codec/processing/src/scrolldetection \
-I$(SRC_PATH)codec/processing/src/vaacalc
GTEST_INCLUDES += \
-I$(SRC_PATH)gtest \
-I$(SRC_PATH)gtest/include
2014-01-19 15:54:10 +01:00
CODEC_UNITTEST_INCLUDES += \
-I$(SRC_PATH)gtest/include \
-I$(SRC_PATH)codec/common/inc \
CONSOLE_COMMON_INCLUDES += \
-I$(SRC_PATH)codec/console/common/inc
H264DEC_INCLUDES += $(DECODER_INCLUDES) $(CONSOLE_COMMON_INCLUDES) -I$(SRC_PATH)codec/console/dec/inc
H264DEC_LDFLAGS = $(LINK_LOCAL_DIR) $(call LINK_LIB,decoder) $(call LINK_LIB,common) $(call LINK_LIB,console_common)
H264DEC_DEPS = $(LIBPREFIX)decoder.$(LIBSUFFIX) $(LIBPREFIX)common.$(LIBSUFFIX) $(LIBPREFIX)console_common.$(LIBSUFFIX)
H264ENC_INCLUDES += $(ENCODER_INCLUDES) $(CONSOLE_COMMON_INCLUDES) -I$(SRC_PATH)codec/console/enc/inc
H264ENC_LDFLAGS = $(LINK_LOCAL_DIR) $(call LINK_LIB,encoder) $(call LINK_LIB,processing) $(call LINK_LIB,common) $(call LINK_LIB,console_common)
H264ENC_DEPS = $(LIBPREFIX)encoder.$(LIBSUFFIX) $(LIBPREFIX)processing.$(LIBSUFFIX) $(LIBPREFIX)common.$(LIBSUFFIX) $(LIBPREFIX)console_common.$(LIBSUFFIX)
CODEC_UNITTEST_LDFLAGS = $(LINK_LOCAL_DIR) $(call LINK_LIB,gtest) $(call LINK_LIB,decoder) $(call LINK_LIB,encoder) $(call LINK_LIB,processing) $(call LINK_LIB,common) $(CODEC_UNITTEST_LDFLAGS_SUFFIX)
CODEC_UNITTEST_DEPS = $(LIBPREFIX)gtest.$(LIBSUFFIX) $(LIBPREFIX)decoder.$(LIBSUFFIX) $(LIBPREFIX)encoder.$(LIBSUFFIX) $(LIBPREFIX)processing.$(LIBSUFFIX) $(LIBPREFIX)common.$(LIBSUFFIX)
DECODER_UNITTEST_INCLUDES += $(CODEC_UNITTEST_INCLUDES) $(DECODER_INCLUDES) -I$(SRC_PATH)test -I$(SRC_PATH)test/decoder
ENCODER_UNITTEST_INCLUDES += $(CODEC_UNITTEST_INCLUDES) $(ENCODER_INCLUDES) -I$(SRC_PATH)test -I$(SRC_PATH)test/encoder
PROCESSING_UNITTEST_INCLUDES += $(CODEC_UNITTEST_INCLUDES) $(PROCESSING_INCLUDES) -I$(SRC_PATH)test -I$(SRC_PATH)test/processing
API_TEST_INCLUDES += $(CODEC_UNITTEST_INCLUDES) -I$(SRC_PATH)test -I$(SRC_PATH)test/api
COMMON_UNITTEST_INCLUDES += $(CODEC_UNITTEST_INCLUDES) $(DECODER_INCLUDES) -I$(SRC_PATH)test -I$(SRC_PATH)test/common
MODULE_INCLUDES += -I$(SRC_PATH)gmp-api
2014-06-18 04:54:16 +02:00
.PHONY: test gtest-bootstrap clean $(PROJECT_NAME).pc
2013-12-13 22:09:59 +01:00
all: libraries binaries
generate-version:
$(QUIET)cd $(SRC_PATH) && sh ./codec/common/generate_version.sh
codec/decoder/plus/src/welsDecoderExt.$(OBJ): | generate-version
codec/encoder/plus/src/welsEncoderExt.$(OBJ): | generate-version
clean:
ifeq (android,$(OS))
2014-06-05 03:23:19 +02:00
clean: clean_Android
endif
$(QUIET)rm -f $(OBJS) $(OBJS:.$(OBJ)=.d) $(OBJS:.$(OBJ)=.obj) $(LIBRARIES) $(BINARIES) *.lib *.a *.dylib *.dll *.so
2014-06-18 04:54:16 +02:00
gmp-bootstrap:
2014-07-09 23:51:16 +02:00
if [ ! -d gmp-api ] ; then git clone https://github.com/mozilla/gmp-api gmp-api ; fi
cd gmp-api && git fetch origin && git checkout $(GMP_API_BRANCH)
2014-06-18 04:54:16 +02:00
2013-12-12 05:24:55 +01:00
gtest-bootstrap:
svn co https://googletest.googlecode.com/svn/trunk/ gtest
ifeq ($(HAVE_GTEST),Yes)
2014-05-20 08:19:23 +02:00
test: codec_unittest$(EXEEXT)
2014-06-05 10:40:28 +02:00
ifneq (android,$(OS))
2014-06-05 10:20:50 +02:00
ifneq (ios,$(OS))
2013-12-13 22:09:59 +01:00
./codec_unittest
2014-05-20 08:19:23 +02:00
endif
2014-06-05 10:20:50 +02:00
endif
else
test:
@echo "./gtest : No such file or directory."
@echo "You do not have gtest. Run make gtest-bootstrap to get gtest"
endif
2013-12-13 22:09:59 +01:00
include $(SRC_PATH)codec/common/targets.mk
include $(SRC_PATH)codec/decoder/targets.mk
include $(SRC_PATH)codec/encoder/targets.mk
include $(SRC_PATH)codec/processing/targets.mk
2014-02-19 02:54:27 +01:00
2014-06-18 04:54:16 +02:00
ifeq ($(HAVE_GMP_API),Yes)
include $(SRC_PATH)module/targets.mk
2014-06-18 04:54:16 +02:00
endif
2014-02-19 02:54:27 +01:00
ifneq (android, $(OS))
ifneq (ios, $(OS))
include $(SRC_PATH)codec/console/dec/targets.mk
include $(SRC_PATH)codec/console/enc/targets.mk
include $(SRC_PATH)codec/console/common/targets.mk
2014-02-19 02:54:27 +01:00
endif
endif
2014-06-05 10:20:50 +02:00
ifneq (ios, $(OS))
libraries: $(LIBPREFIX)$(PROJECT_NAME).$(LIBSUFFIX) $(LIBPREFIX)$(PROJECT_NAME).$(SHAREDLIBSUFFIX)
2014-06-05 10:20:50 +02:00
else
libraries: $(LIBPREFIX)$(PROJECT_NAME).$(LIBSUFFIX)
endif
LIBRARIES += $(LIBPREFIX)$(PROJECT_NAME).$(LIBSUFFIX) $(LIBPREFIX)$(PROJECT_NAME).$(SHAREDLIBSUFFIXVER)
$(LIBPREFIX)$(PROJECT_NAME).$(LIBSUFFIX): $(ENCODER_OBJS) $(DECODER_OBJS) $(PROCESSING_OBJS) $(COMMON_OBJS)
$(QUIET)rm -f $@
$(QUIET_AR)$(AR) $(AR_OPTS) $+
$(LIBPREFIX)$(PROJECT_NAME).$(SHAREDLIBSUFFIXVER): $(ENCODER_OBJS) $(DECODER_OBJS) $(PROCESSING_OBJS) $(COMMON_OBJS)
$(QUIET)rm -f $@
$(QUIET_CXX)$(CXX) $(SHARED) $(CXX_LINK_O) $+ $(LDFLAGS) $(SHLDFLAGS)
ifneq ($(SHAREDLIBSUFFIXVER),$(SHAREDLIBSUFFIX))
$(LIBPREFIX)$(PROJECT_NAME).$(SHAREDLIBSUFFIX): $(LIBPREFIX)$(PROJECT_NAME).$(SHAREDLIBSUFFIXVER)
$(QUIET)ln -sfn $+ $@
endif
2014-02-19 02:54:27 +01:00
2014-06-18 04:54:16 +02:00
ifeq ($(HAVE_GMP_API),Yes)
plugin: $(LIBPREFIX)$(MODULE_NAME).$(SHAREDLIBSUFFIX)
LIBRARIES += $(LIBPREFIX)$(MODULE_NAME).$(SHAREDLIBSUFFIXVER)
2014-06-18 04:54:16 +02:00
else
plugin:
@echo "./gmp-api : No such file or directory."
@echo "You do not have gmp-api. Run make gmp-bootstrap to get the gmp-api headers."
endif
$(LIBPREFIX)$(MODULE_NAME).$(SHAREDLIBSUFFIXVER): $(MODULE_OBJS) $(ENCODER_OBJS) $(DECODER_OBJS) $(PROCESSING_OBJS) $(COMMON_OBJS)
2014-06-18 04:54:16 +02:00
$(QUIET)rm -f $@
$(QUIET_CXX)$(CXX) $(SHARED) $(CXX_LINK_O) $+ $(LDFLAGS) $(SHLDFLAGS) $(MODULE_LDFLAGS)
ifneq ($(SHAREDLIBSUFFIXVER),$(SHAREDLIBSUFFIX))
$(LIBPREFIX)$(MODULE_NAME).$(SHAREDLIBSUFFIX): $(LIBPREFIX)$(MODULE_NAME).$(SHAREDLIBSUFFIXVER)
$(QUIET)ln -sfn $+ $@
endif
2014-06-18 04:54:16 +02:00
2014-10-26 23:25:15 +01:00
$(PROJECT_NAME).pc: $(PROJECT_NAME).pc.in
@sed -e 's;@prefix@;$(PREFIX);' -e 's;@VERSION@;$(VERSION);' < $(PROJECT_NAME).pc.in > $(PROJECT_NAME).pc
install-headers:
2014-01-27 13:54:47 +01:00
mkdir -p $(PREFIX)/include/wels
install -m 644 codec/api/svc/codec*.h $(PREFIX)/include/wels
install-static: $(LIBPREFIX)$(PROJECT_NAME).$(LIBSUFFIX) install-headers
mkdir -p $(PREFIX)/lib
install -m 644 $(LIBPREFIX)$(PROJECT_NAME).$(LIBSUFFIX) $(PREFIX)/lib
install-shared: $(LIBPREFIX)$(PROJECT_NAME).$(SHAREDLIBSUFFIX) install-headers $(PROJECT_NAME).pc
mkdir -p $(SHAREDLIB_DIR)
install -m 755 $(LIBPREFIX)$(PROJECT_NAME).$(SHAREDLIBSUFFIXVER) $(SHAREDLIB_DIR)
if [ "$(SHAREDLIBSUFFIXVER)" != "$(SHAREDLIBSUFFIX)" ]; then \
cp -a $(LIBPREFIX)$(PROJECT_NAME).$(SHAREDLIBSUFFIX) $(SHAREDLIB_DIR); \
fi
mkdir -p $(PREFIX)/lib/pkgconfig
2014-10-26 23:25:15 +01:00
install -m 444 $(PROJECT_NAME).pc $(PREFIX)/lib/pkgconfig
ifneq ($(EXTRA_LIBRARY),)
install -m 644 $(EXTRA_LIBRARY) $(PREFIX)/lib
endif
install: install-static install-shared
@:
2013-12-12 05:24:55 +01:00
ifeq ($(HAVE_GTEST),Yes)
include $(SRC_PATH)build/gtest-targets.mk
include $(SRC_PATH)test/api/targets.mk
include $(SRC_PATH)test/decoder/targets.mk
include $(SRC_PATH)test/encoder/targets.mk
include $(SRC_PATH)test/processing/targets.mk
include $(SRC_PATH)test/common/targets.mk
2014-05-20 08:19:23 +02:00
2014-06-06 11:44:22 +02:00
LIBRARIES += $(LIBPREFIX)ut.$(LIBSUFFIX)
2014-06-12 03:37:30 +02:00
$(LIBPREFIX)ut.$(LIBSUFFIX): $(DECODER_UNITTEST_OBJS) $(ENCODER_UNITTEST_OBJS) $(PROCESSING_UNITTEST_OBJS) $(COMMON_UNITTEST_OBJS) $(API_TEST_OBJS)
2014-06-05 10:20:50 +02:00
$(QUIET)rm -f $@
$(QUIET_AR)$(AR) $(AR_OPTS) $+
2014-05-20 08:19:23 +02:00
LIBRARIES +=$(LIBPREFIX)ut.$(SHAREDLIBSUFFIX)
2014-06-12 03:37:30 +02:00
$(LIBPREFIX)ut.$(SHAREDLIBSUFFIX): $(DECODER_UNITTEST_OBJS) $(ENCODER_UNITTEST_OBJS) $(PROCESSING_UNITTEST_OBJS) $(API_TEST_OBJS) $(COMMON_UNITTEST_OBJS) $(CODEC_UNITTEST_DEPS)
2014-05-20 08:19:23 +02:00
$(QUIET)rm -f $@
$(QUIET_CXX)$(CXX) $(SHARED) $(CXX_LINK_O) $+ $(LDFLAGS) $(CODEC_UNITTEST_LDFLAGS)
2014-05-20 08:19:23 +02:00
2014-03-25 04:11:53 +01:00
binaries: codec_unittest$(EXEEXT)
BINARIES += codec_unittest$(EXEEXT)
2014-05-20 08:19:23 +02:00
2014-06-05 10:20:50 +02:00
ifeq (ios,$(OS))
codec_unittest$(EXEEXT): $(LIBPREFIX)ut.$(LIBSUFFIX) $(LIBPREFIX)gtest.$(LIBSUFFIX) $(LIBPREFIX)$(PROJECT_NAME).$(LIBSUFFIX)
2014-05-20 08:19:23 +02:00
2014-06-05 10:20:50 +02:00
else
ifeq (android,$(OS))
ifeq (./,$(SRC_PATH))
2014-06-05 10:20:50 +02:00
codec_unittest$(EXEEXT): $(LIBPREFIX)ut.$(SHAREDLIBSUFFIX)
2014-05-20 08:19:23 +02:00
cd ./test/build/android && $(NDKROOT)/ndk-build -B APP_ABI=$(APP_ABI) && android update project -t $(TARGET) -p . && ant debug
2014-06-05 03:23:19 +02:00
clean_Android: clean_Android_ut
clean_Android_ut:
-cd ./test/build/android && $(NDKROOT)/ndk-build APP_ABI=$(APP_ABI) clean && ant clean
2014-05-20 08:19:23 +02:00
else
codec_unittest$(EXEEXT):
@:
endif
else
codec_unittest$(EXEEXT): $(DECODER_UNITTEST_OBJS) $(ENCODER_UNITTEST_OBJS) $(PROCESSING_UNITTEST_OBJS) $(API_TEST_OBJS) $(COMMON_UNITTEST_OBJS) $(CODEC_UNITTEST_DEPS) | res
2014-03-25 03:58:52 +01:00
$(QUIET)rm -f $@
$(QUIET_CXX)$(CXX) $(CXX_LINK_O) $+ $(CODEC_UNITTEST_LDFLAGS) $(LDFLAGS)
2014-06-05 10:20:50 +02:00
res:
$(QUIET)if [ ! -e res ]; then ln -s $(SRC_PATH)res .; fi
2014-05-20 08:19:23 +02:00
endif
2014-06-05 10:20:50 +02:00
endif
else
binaries:
@:
2014-03-26 02:01:00 +01:00
endif
-include $(OBJS:.$(OBJ)=.d)
OBJDIRS = $(sort $(dir $(OBJS)))
$(OBJDIRS):
$(QUIET)mkdir -p $@
$(OBJS): | $(OBJDIRS)