2014-01-27 12:33:19 +00:00
|
|
|
# Simple Makefile for Kvazaar HEVC encoder
|
|
|
|
|
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)
|
|
|
|
ASMFLAGS =
|
2014-07-18 13:55:18 +00:00
|
|
|
DFLAGS = -O2 -g -Werror -ftree-vectorize
|
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-05-28 12:47:24 +00:00
|
|
|
DFLAGS += -m$(TARGET_CPU_BITS)
|
|
|
|
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)
|
|
|
|
ASMFLAGS += -f win64
|
2014-07-30 13:26:23 +00:00
|
|
|
ASMFLAGS += -DHAVE_ALIGNED_STACK=1
|
2014-01-30 15:56:52 +00:00
|
|
|
else
|
2014-02-03 12:27:19 +00:00
|
|
|
ASMFLAGS += -f win32
|
2014-02-21 12:53:47 +00:00
|
|
|
ASMFLAGS += -DPREFIX
|
2014-07-30 13:26:23 +00:00
|
|
|
ASMFLAGS += -DHAVE_ALIGNED_STACK=0
|
2014-01-30 15:56:52 +00:00
|
|
|
endif
|
2014-04-28 16:29:01 +00:00
|
|
|
DFLAGS += -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)
|
2014-02-03 12:27:19 +00:00
|
|
|
ASMFLAGS += -f macho64
|
2014-01-30 15:56:52 +00:00
|
|
|
else
|
2014-02-03 12:27:19 +00:00
|
|
|
ASMFLAGS += -f macho32
|
2014-01-30 15:56:52 +00:00
|
|
|
endif
|
2014-10-14 06:45:18 +00:00
|
|
|
ASMFLAGS += -DPREFIX
|
2014-02-03 12:27:19 +00:00
|
|
|
# Default to Linux/elf specific flags
|
|
|
|
else
|
2014-02-21 12:53:47 +00:00
|
|
|
ifeq ($(ARCH), x86_64)
|
2014-10-14 06:45:18 +00:00
|
|
|
ASMFLAGS += -f elf64
|
2014-02-03 12:27:19 +00:00
|
|
|
else
|
2014-10-14 06:45:18 +00:00
|
|
|
ASMFLAGS += -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)
|
|
|
|
ASMFLAGS += -DARCH_X86_64=1
|
|
|
|
else
|
|
|
|
ASMFLAGS += -DARCH_X86_64=0
|
|
|
|
endif
|
2014-01-27 12:33:19 +00:00
|
|
|
|
2014-06-12 06:57:08 +00:00
|
|
|
# Do not use variable length arrays because they don't work in Visual Studio 2013.
|
|
|
|
WARNINGS = -Wall -Wtype-limits -Wvla
|
|
|
|
|
2014-07-22 12:36:54 +00:00
|
|
|
INCLUDEDIRS = -I. -I./strategies -I./extras
|
|
|
|
|
2014-05-13 09:19:52 +00:00
|
|
|
CC = gcc
|
2014-07-22 12:36:54 +00:00
|
|
|
CCFLAGS = $(DFLAGS) -std=gnu99 $(INCLUDEDIRS) $(WARNINGS)
|
2014-02-03 12:27:19 +00:00
|
|
|
LDFLAGS += -lm
|
2014-05-16 06:47:04 +00:00
|
|
|
LD = gcc -pthread -lrt
|
2014-07-18 14:31:18 +00:00
|
|
|
OBJS = interface_main.o \
|
|
|
|
encmain.o \
|
|
|
|
bitstream.o \
|
|
|
|
cabac.o \
|
|
|
|
checkpoint.o \
|
|
|
|
config.o \
|
|
|
|
context.o \
|
|
|
|
cu.o \
|
|
|
|
encoder.o \
|
|
|
|
encoderstate.o \
|
|
|
|
filter.o \
|
|
|
|
inter.o \
|
|
|
|
intra.o \
|
|
|
|
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 \
|
|
|
|
strategies/strategies-picture.o \
|
|
|
|
strategies/strategies-nal.o \
|
2014-07-29 15:10:47 +00:00
|
|
|
strategies/strategies-dct.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 \
|
|
|
|
strategies/avx2/dct-avx2.o
|
2014-07-22 12:36:54 +00:00
|
|
|
|
|
|
|
ASMFLAGS += $(INCLUDEDIRS)
|
2014-07-21 07:54:33 +00:00
|
|
|
ASMOBJS =
|
|
|
|
|
2014-07-23 11:55:06 +00:00
|
|
|
AS = yasm
|
|
|
|
|
|
|
|
# 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
|
2014-07-21 07:54:33 +00:00
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
|
|
|
|
2014-01-27 12:33:19 +00:00
|
|
|
PROG = ./kvazaar
|
|
|
|
PROGS = $(PROG)
|
|
|
|
|
2014-04-15 11:47:24 +00:00
|
|
|
DEPS = $(OBJS:.o=.d)
|
|
|
|
|
2014-02-03 12:27:19 +00:00
|
|
|
all: $(PROGS)
|
|
|
|
.PHONY: all clean
|
2014-01-30 15:56:52 +00:00
|
|
|
|
2014-07-18 13:55:18 +00:00
|
|
|
# Compile files in strategy directories with appropriate flags.
|
|
|
|
EXTRA_FLAGS =
|
|
|
|
ifeq ($(ARCH), ppc64)
|
|
|
|
strategies/altivec/%.o: EXTRA_FLAGS += -maltivec
|
|
|
|
else
|
|
|
|
strategies/sse2/%.o: EXTRA_FLAGS += -msse2
|
|
|
|
strategies/sse41/%.o: EXTRA_FLAGS += -msse4.1
|
2014-07-14 13:08:19 +00:00
|
|
|
strategies/avx2/%.o: EXTRA_FLAGS += -mavx2
|
2014-07-18 13:55:18 +00:00
|
|
|
endif
|
|
|
|
|
2014-07-23 11:55:06 +00:00
|
|
|
ifndef KVZ_DISABLE_ASM
|
|
|
|
ASMOBJS += strategies/x86_asm/picture-x86-asm-sad.o
|
|
|
|
ASMOBJS += strategies/x86_asm/picture-x86-asm-satd.o
|
|
|
|
strategies/x86_asm/%.o: EXTRA_FLAGS += -DKVZ_COMPILE_ASM
|
|
|
|
endif
|
|
|
|
|
2014-07-18 13:55:18 +00:00
|
|
|
|
2014-01-27 12:33:19 +00:00
|
|
|
$(PROG): $(OBJS) $(ASMOBJS)
|
2014-01-29 15:34:31 +00:00
|
|
|
$(LD) $^ $(LDFLAGS) -o $@
|
2014-01-27 12:33:19 +00:00
|
|
|
|
2014-07-14 12:30:08 +00:00
|
|
|
%.o: %.asm Makefile
|
2014-07-23 11:55:06 +00:00
|
|
|
$(AS) $(ASMFLAGS) -o $@ $<
|
2014-07-21 07:54:33 +00:00
|
|
|
|
|
|
|
%.d: %.asm Makefile
|
2014-07-23 11:55:06 +00:00
|
|
|
$(AS) $(ASMFLAGS) -M -o $@ > $<
|
2014-07-21 07:54:33 +00:00
|
|
|
|
2014-04-15 13:47:17 +00:00
|
|
|
%.o: %.c Makefile
|
2014-07-18 13:55:18 +00:00
|
|
|
$(CC) $(CCFLAGS) $(EXTRA_FLAGS) -c $< -o $@
|
2014-01-27 12:33:19 +00:00
|
|
|
|
2014-04-15 13:47:17 +00:00
|
|
|
%.d: %.c Makefile
|
2014-04-15 11:47:24 +00:00
|
|
|
$(CC) $(CCFLAGS) -MF"$@" -MG -MM -MP -MT"$@" -MT"$(<:.c=.o)" "$<"
|
|
|
|
|
2014-04-16 06:09:10 +00:00
|
|
|
|
2014-02-03 12:27:19 +00:00
|
|
|
clean:
|
2014-04-15 11:47:24 +00:00
|
|
|
rm -f $(OBJS) $(PROGS) $(ASMOBJS) $(DEPS)
|
|
|
|
|
|
|
|
-include $(DEPS)
|