2014-01-27 12:33:19 +00:00
|
|
|
# Simple Makefile for Kvazaar HEVC encoder
|
|
|
|
|
2015-07-01 05:17:21 +00:00
|
|
|
# Installation locations
|
|
|
|
DESTDIR =
|
|
|
|
PREFIX = /usr/local
|
|
|
|
BINDIR = $(PREFIX)/bin
|
|
|
|
INCDIR = $(PREFIX)/include
|
|
|
|
LIBDIR = $(PREFIX)/lib
|
|
|
|
|
|
|
|
PROG = ./kvazaar
|
|
|
|
DEBUG = ./kvazaar_debug
|
|
|
|
TESTS = ./kvazaar_tests
|
|
|
|
LIB = ./libkvazaar.so.0.0.0
|
|
|
|
SONAME = libkvazaar.so.0
|
|
|
|
INC = ./kvazaar.h \
|
|
|
|
./kvazaar_version.h
|
|
|
|
|
|
|
|
# Compilers and other tools
|
|
|
|
AS = yasm
|
|
|
|
LD = gcc
|
|
|
|
INSTALL = install
|
|
|
|
|
|
|
|
# Do not use variable length arrays because they don't work in Visual Studio 2013.
|
|
|
|
WARNINGS = -Wall -Wtype-limits -Wvla
|
|
|
|
INCLUDEDIRS = -I. -I./strategies -I./extras -I..
|
|
|
|
|
|
|
|
ASFLAGS += $(INCLUDEDIRS)
|
|
|
|
CFLAGS += -O2 -g -Werror -ftree-vectorize -fpic -std=gnu99
|
|
|
|
CFLAGS += $(INCLUDEDIRS) $(WARNINGS)
|
|
|
|
LDFLAGS += -lm -pthread
|
2015-01-29 14:20:24 +00:00
|
|
|
|
2014-02-03 12:27:19 +00:00
|
|
|
ifeq (, $(ARCH))
|
2014-02-03 13:53:21 +00:00
|
|
|
ARCH = $(shell uname -m)
|
2014-02-03 12:27:19 +00:00
|
|
|
endif
|
2014-01-30 15:56:52 +00:00
|
|
|
SYSTEM = $(shell uname -s)
|
2014-01-27 12:33:19 +00:00
|
|
|
|
2014-01-30 15:56:52 +00:00
|
|
|
# ARCH related flags
|
|
|
|
ifeq ($(ARCH), x86_64)
|
2014-05-28 12:47:24 +00:00
|
|
|
TARGET_CPU_BITS := 64
|
|
|
|
TARGET_CPU_ARCH := x86
|
|
|
|
else ifeq ($(ARCH), ppc64)
|
|
|
|
TARGET_CPU_BITS := 64
|
|
|
|
TARGET_CPU_ARCH := ppc
|
2014-01-27 12:33:19 +00:00
|
|
|
else
|
2014-05-28 12:47:24 +00:00
|
|
|
#safe (?) defaults
|
|
|
|
TARGET_CPU_BITS := 32
|
|
|
|
TARGET_CPU_ARCH := x86
|
2014-01-27 12:33:19 +00:00
|
|
|
endif
|
|
|
|
|
2014-10-27 16:19:05 +00:00
|
|
|
CFLAGS += -m$(TARGET_CPU_BITS)
|
2014-05-28 12:47:24 +00:00
|
|
|
LDFLAGS += -m$(TARGET_CPU_BITS)
|
|
|
|
|
2014-02-03 12:27:19 +00:00
|
|
|
# Windows (cygwin/mingw) specific flags
|
|
|
|
ifneq ( ,$(findstring Windows, $(OS)))
|
|
|
|
ifeq ($(ARCH), x86_64)
|
2015-07-01 05:17:21 +00:00
|
|
|
ASFLAGS += -f win64
|
|
|
|
ASFLAGS += -DHAVE_ALIGNED_STACK=1
|
2014-01-30 15:56:52 +00:00
|
|
|
else
|
2015-07-01 05:17:21 +00:00
|
|
|
ASFLAGS += -f win32
|
|
|
|
ASFLAGS += -DPREFIX
|
|
|
|
ASFLAGS += -DHAVE_ALIGNED_STACK=0
|
2014-01-30 15:56:52 +00:00
|
|
|
endif
|
2014-10-27 16:19:05 +00:00
|
|
|
CFLAGS += -D__USE_MINGW_ANSI_STDIO=1
|
2014-01-30 15:56:52 +00:00
|
|
|
# OS X specific flags
|
2014-02-03 12:27:19 +00:00
|
|
|
else ifeq ($(SYSTEM),Darwin)
|
2014-01-30 15:56:52 +00:00
|
|
|
ifeq ($(ARCH), x86_64)
|
2015-07-01 05:17:21 +00:00
|
|
|
ASFLAGS += -f macho64
|
2014-01-30 15:56:52 +00:00
|
|
|
else
|
2015-07-01 05:17:21 +00:00
|
|
|
ASFLAGS += -f macho32
|
2014-01-30 15:56:52 +00:00
|
|
|
endif
|
2015-07-01 05:17:21 +00:00
|
|
|
ASFLAGS += -DPREFIX
|
2014-02-03 12:27:19 +00:00
|
|
|
# Default to Linux/elf specific flags
|
|
|
|
else
|
2014-10-23 11:37:28 +00:00
|
|
|
LDFLAGS += -lrt
|
2014-02-21 12:53:47 +00:00
|
|
|
ifeq ($(ARCH), x86_64)
|
2015-07-01 05:17:21 +00:00
|
|
|
ASFLAGS += -f elf64
|
2014-02-03 12:27:19 +00:00
|
|
|
else
|
2015-07-01 05:17:21 +00:00
|
|
|
ASFLAGS += -f elf32
|
2014-02-03 12:27:19 +00:00
|
|
|
endif
|
2014-01-27 12:33:19 +00:00
|
|
|
endif
|
2014-10-14 06:45:18 +00:00
|
|
|
# Flags shared across systems
|
|
|
|
ifeq ($(ARCH), x86_64)
|
2015-07-01 05:17:21 +00:00
|
|
|
ASFLAGS += -DARCH_X86_64=1
|
2014-10-14 06:45:18 +00:00
|
|
|
else
|
2015-07-01 05:17:21 +00:00
|
|
|
ASFLAGS += -DARCH_X86_64=0
|
2014-10-14 06:45:18 +00:00
|
|
|
endif
|
2014-01-27 12:33:19 +00:00
|
|
|
|
2015-01-29 14:20:24 +00:00
|
|
|
#Detect if cc is gcc for the link time optimization flag
|
|
|
|
GCCVERSION = $(shell $(CC) --version | grep GCC)
|
|
|
|
ifneq (, $(GCCVERSION))
|
|
|
|
CFLAGS += -flto
|
|
|
|
LDFLAGS += -flto -O3
|
2014-10-23 09:59:49 +00:00
|
|
|
endif
|
2015-07-01 05:17:21 +00:00
|
|
|
|
|
|
|
# Compile asm files by default if yasm is present.
|
|
|
|
ifndef KVZ_DISABLE_ASM
|
|
|
|
has_as := $(shell type $(AS) 2>/dev/null)
|
|
|
|
ifeq ($(has_as),)
|
|
|
|
KVZ_DISABLE_ASM := 1
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
# Compile files in strategy directories with appropriate flags.
|
|
|
|
ifeq ($(ARCH), ppc64)
|
|
|
|
strategies/altivec/%.o: EXTRA_FLAGS += -maltivec -fno-lto
|
|
|
|
else
|
|
|
|
strategies/sse2/%.o: EXTRA_FLAGS += -msse2 -fno-lto
|
|
|
|
strategies/sse41/%.o: EXTRA_FLAGS += -msse4.1 -fno-lto
|
|
|
|
# Needs to be defined on Travis
|
|
|
|
ifndef KVZ_DISABLE_AVX2
|
|
|
|
strategies/avx2/%.o: EXTRA_FLAGS += -mavx2 -fno-lto
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2015-04-17 15:08:58 +00:00
|
|
|
OBJS = \
|
2014-07-18 14:31:18 +00:00
|
|
|
bitstream.o \
|
|
|
|
cabac.o \
|
|
|
|
checkpoint.o \
|
2015-05-13 09:45:11 +00:00
|
|
|
cli.o \
|
2014-07-18 14:31:18 +00:00
|
|
|
config.o \
|
|
|
|
context.o \
|
|
|
|
cu.o \
|
|
|
|
encoder.o \
|
|
|
|
encoderstate.o \
|
2015-03-13 12:23:54 +00:00
|
|
|
rate_control.o \
|
2014-07-18 14:31:18 +00:00
|
|
|
filter.o \
|
|
|
|
inter.o \
|
|
|
|
intra.o \
|
2015-05-18 08:43:10 +00:00
|
|
|
kvazaar.o \
|
2014-07-18 14:31:18 +00:00
|
|
|
nal.o \
|
|
|
|
imagelist.o \
|
|
|
|
rdo.o \
|
|
|
|
sao.o \
|
|
|
|
scalinglist.o \
|
|
|
|
search.o \
|
|
|
|
strategyselector.o \
|
|
|
|
tables.o \
|
|
|
|
threadqueue.o \
|
|
|
|
transform.o \
|
|
|
|
encoder_state-bitstream.o \
|
|
|
|
encoder_state-ctors_dtors.o \
|
|
|
|
encoder_state-geometry.o \
|
|
|
|
image.o \
|
|
|
|
videoframe.o \
|
2015-06-17 12:24:07 +00:00
|
|
|
yuv_io.o \
|
2014-07-18 14:31:18 +00:00
|
|
|
strategies/strategies-picture.o \
|
|
|
|
strategies/strategies-nal.o \
|
2014-07-29 15:10:47 +00:00
|
|
|
strategies/strategies-dct.o \
|
2015-01-21 16:06:57 +00:00
|
|
|
strategies/strategies-ipol.o \
|
2014-07-18 14:31:18 +00:00
|
|
|
strategies/generic/nal-generic.o \
|
|
|
|
strategies/generic/picture-generic.o \
|
|
|
|
strategies/sse2/picture-sse2.o \
|
|
|
|
strategies/sse41/picture-sse41.o \
|
2014-07-14 13:08:19 +00:00
|
|
|
strategies/altivec/picture-altivec.o \
|
2014-07-21 13:34:55 +00:00
|
|
|
strategies/avx2/picture-avx2.o \
|
2014-07-23 12:15:09 +00:00
|
|
|
strategies/x86_asm/picture-x86-asm.o \
|
2014-07-29 15:10:47 +00:00
|
|
|
strategies/generic/dct-generic.o \
|
2015-01-21 16:06:57 +00:00
|
|
|
strategies/avx2/dct-avx2.o \
|
|
|
|
strategies/generic/ipol-generic.o \
|
2015-04-17 15:08:58 +00:00
|
|
|
strategies/avx2/ipol-avx2.o
|
2014-10-29 13:02:35 +00:00
|
|
|
|
2015-07-01 05:17:21 +00:00
|
|
|
ifndef KVZ_DISABLE_ASM
|
|
|
|
strategies/x86_asm/%.o: EXTRA_FLAGS += -DKVZ_COMPILE_ASM
|
|
|
|
|
|
|
|
OBJS += \
|
|
|
|
strategies/x86_asm/picture-x86-asm-sad.o \
|
|
|
|
strategies/x86_asm/picture-x86-asm-satd.o
|
|
|
|
endif
|
2014-10-29 13:02:35 +00:00
|
|
|
|
2015-04-17 15:08:58 +00:00
|
|
|
TESTDIR := ../tests
|
|
|
|
TEST_OBJS := \
|
|
|
|
$(TESTDIR)/dct_tests.o \
|
|
|
|
$(TESTDIR)/intra_sad_tests.o \
|
|
|
|
$(TESTDIR)/sad_tests.o \
|
|
|
|
$(TESTDIR)/satd_tests.o \
|
|
|
|
$(TESTDIR)/speed_tests.o \
|
|
|
|
$(TESTDIR)/tests_main.o \
|
|
|
|
$(TESTDIR)/test_strategies.o
|
2014-10-29 13:02:35 +00:00
|
|
|
|
2015-07-01 05:17:21 +00:00
|
|
|
MAIN_OBJS := encmain.o interface_main.o
|
2014-10-30 12:00:54 +00:00
|
|
|
|
2015-07-01 05:17:21 +00:00
|
|
|
RELEASE_OBJS = $(MAIN_OBJS) $(OBJS)
|
2015-04-17 15:08:58 +00:00
|
|
|
DEBUG_OBJS = $(RELEASE_OBJS:.o=_debug.o)
|
2015-07-01 05:17:21 +00:00
|
|
|
TESTS_OBJS = $(TEST_OBJS) $(OBJS)
|
2014-04-15 11:47:24 +00:00
|
|
|
|
2015-07-01 05:17:21 +00:00
|
|
|
PROGS = $(PROG) $(DEBUG) $(TESTS)
|
2014-10-29 13:02:35 +00:00
|
|
|
|
2015-04-17 15:08:58 +00:00
|
|
|
DEPS = $(RELEASE_OBJS:.o=.d) $(DEBUG_OBJS:.o=.d) $(TESTS_OBJS:.o=.d)
|
2014-10-29 13:02:35 +00:00
|
|
|
|
2015-07-01 05:17:21 +00:00
|
|
|
all: $(PROG) $(LIB)
|
2014-07-23 11:55:06 +00:00
|
|
|
|
2015-04-17 15:08:58 +00:00
|
|
|
debug: LDFLAGS := $(filter-out -O3 -O2 -flto, $(LDFLAGS))
|
|
|
|
debug: CFLAGS := $(filter-out -O3 -O2 -flto, $(CFLAGS))
|
|
|
|
debug: $(DEBUG)
|
2014-07-18 13:55:18 +00:00
|
|
|
|
2015-04-17 15:08:58 +00:00
|
|
|
tests: build_tests
|
|
|
|
$(TESTS)
|
|
|
|
|
|
|
|
build_tests: CFLAGS := $(filter-out -Werror, $(CFLAGS))
|
|
|
|
build_tests: init_submodules $(TESTS)
|
2014-01-27 12:33:19 +00:00
|
|
|
|
2015-04-17 15:08:58 +00:00
|
|
|
$(PROG): $(RELEASE_OBJS)
|
|
|
|
$(LD) $^ $(LDFLAGS) -o $@
|
2015-07-01 05:17:21 +00:00
|
|
|
|
|
|
|
$(LIB): $(RELEASE_OBJS)
|
|
|
|
$(LD) $^ $(LDFLAGS) -shared -Wl,-soname,$(SONAME) -o $@
|
|
|
|
|
2015-04-17 15:08:58 +00:00
|
|
|
$(DEBUG): $(DEBUG_OBJS)
|
|
|
|
$(LD) $^ $(LDFLAGS) -o $@
|
2015-07-01 05:17:21 +00:00
|
|
|
|
2015-04-17 15:08:58 +00:00
|
|
|
$(TESTS): $(TESTS_OBJS)
|
2014-10-29 13:02:35 +00:00
|
|
|
$(LD) $^ $(LDFLAGS) -o $@
|
|
|
|
|
2015-04-17 15:08:58 +00:00
|
|
|
%.o %_debug.o: %.asm Makefile
|
2015-07-01 05:17:21 +00:00
|
|
|
$(AS) $(ASFLAGS) -o $@ $<
|
|
|
|
|
2015-04-17 15:08:58 +00:00
|
|
|
%.o %_debug.o: %.c Makefile
|
|
|
|
$(CC) $(CFLAGS) $(EXTRA_FLAGS) -MMD -MP -c $< -o $@
|
2014-07-21 07:54:33 +00:00
|
|
|
|
2015-04-17 15:08:58 +00:00
|
|
|
init_submodules:
|
|
|
|
git submodule init
|
|
|
|
git submodule update
|
2014-04-16 06:09:10 +00:00
|
|
|
|
2015-07-01 05:17:21 +00:00
|
|
|
install: install-prog install-lib
|
|
|
|
|
|
|
|
install-prog: $(PROG)
|
|
|
|
$(INSTALL) -d $(DESTDIR)$(BINDIR)
|
|
|
|
$(INSTALL) -m755 $(PROG) -t $(DESTDIR)$(BINDIR)
|
|
|
|
|
|
|
|
install-lib: $(LIB)
|
|
|
|
$(INSTALL) -d $(DESTDIR)$(INCDIR)
|
|
|
|
$(INSTALL) -d $(DESTDIR)$(LIBDIR)
|
|
|
|
$(INSTALL) -m644 $(INC) -t $(DESTDIR)$(INCDIR)
|
|
|
|
$(INSTALL) -m644 $(LIB) -t $(DESTDIR)$(LIBDIR)
|
|
|
|
|
2014-02-03 12:27:19 +00:00
|
|
|
clean:
|
2015-07-01 05:17:21 +00:00
|
|
|
$(RM) $(RELEASE_OBJS) $(DEBUG_OBJS) $(TESTS_OBJS) $(DEPS) $(PROGS) $(LIB)
|
2014-04-15 11:47:24 +00:00
|
|
|
|
2014-10-30 12:00:54 +00:00
|
|
|
ifneq ($(MAKECMDGOALS),clean)
|
2015-04-17 15:08:58 +00:00
|
|
|
-include $(DEPS)
|
2014-10-30 12:00:54 +00:00
|
|
|
endif
|
2015-07-01 05:17:21 +00:00
|
|
|
|
|
|
|
# Disable default rules
|
|
|
|
.SUFFIXES:
|
|
|
|
|
|
|
|
.PHONY: all clean build_tests tests debug init_submodules
|
|
|
|
.PHONY: install install-prog install-lib
|