2014-01-27 12:33:19 +00:00
|
|
|
# Simple Makefile for Kvazaar HEVC encoder
|
|
|
|
|
2015-07-31 12:51:53 +00:00
|
|
|
all: cli lib-shared
|
|
|
|
.PHONY: all
|
|
|
|
|
2015-07-01 05:17:21 +00:00
|
|
|
# Installation locations
|
|
|
|
DESTDIR =
|
|
|
|
PREFIX = /usr/local
|
|
|
|
BINDIR = $(PREFIX)/bin
|
|
|
|
INCDIR = $(PREFIX)/include
|
|
|
|
LIBDIR = $(PREFIX)/lib
|
2015-07-01 08:40:14 +00:00
|
|
|
DLLDIR = $(BINDIR)
|
2015-07-01 05:17:21 +00:00
|
|
|
|
2015-07-13 07:08:05 +00:00
|
|
|
# Library version number
|
2015-09-30 12:20:57 +00:00
|
|
|
VER_MAJOR = 1
|
2015-07-13 07:08:05 +00:00
|
|
|
VER_MINOR = 0
|
|
|
|
VER_RELEASE = 0
|
|
|
|
|
|
|
|
PROG = kvazaar
|
|
|
|
DEBUG = kvazaar_debug
|
|
|
|
TESTS = kvazaar_tests
|
2015-07-17 17:44:20 +00:00
|
|
|
|
|
|
|
NAME = libkvazaar
|
2015-08-20 11:45:38 +00:00
|
|
|
STATIC = $(NAME).a
|
2015-07-17 17:44:20 +00:00
|
|
|
SO = $(NAME).so
|
2015-07-13 07:08:05 +00:00
|
|
|
LIB = $(SO).$(VER_MAJOR).$(VER_MINOR).$(VER_RELEASE)
|
2015-07-20 11:49:25 +00:00
|
|
|
DYLIB = $(NAME).$(VER_MAJOR).dylib
|
2015-07-13 07:08:05 +00:00
|
|
|
DLL = kvazaar.dll
|
|
|
|
IMPLIB = libkvazaar.dll.a
|
|
|
|
INC = kvazaar.h \
|
|
|
|
kvazaar_version.h
|
2015-07-01 05:17:21 +00:00
|
|
|
|
|
|
|
# Compilers and other tools
|
|
|
|
AS = yasm
|
2015-07-29 10:42:48 +00:00
|
|
|
LD = $(CC)
|
2015-07-01 05:17:21 +00:00
|
|
|
INSTALL = install
|
2015-07-13 07:08:05 +00:00
|
|
|
LN_S = ln -s
|
2015-08-20 11:45:38 +00:00
|
|
|
RANLIB = ranlib
|
2015-07-01 05:17:21 +00:00
|
|
|
|
|
|
|
# Do not use variable length arrays because they don't work in Visual Studio 2013.
|
2015-07-31 12:53:31 +00:00
|
|
|
WARNINGS = -Werror -Wall -Wtype-limits -Wvla
|
2015-07-01 05:17:21 +00:00
|
|
|
INCLUDEDIRS = -I. -I./strategies -I./extras -I..
|
|
|
|
|
2015-07-17 09:42:26 +00:00
|
|
|
# nasm requires trailing slashes in include directories
|
|
|
|
ASFLAGS += $(patsubst %,%/,$(INCLUDEDIRS))
|
2015-07-29 10:42:48 +00:00
|
|
|
|
|
|
|
# Notes about optimization levels:
|
2015-08-22 14:00:26 +00:00
|
|
|
# Overall, kvazaar seems to run 15-20 % faster when compiled with gcc.
|
2015-07-29 10:42:48 +00:00
|
|
|
# gcc-5.1.1: no benefit from -flto, slight harm from -O3
|
|
|
|
# clang-4.3.0: slight benefit from -O3, more from -flto
|
2015-07-31 12:53:31 +00:00
|
|
|
CFLAGS += -O2 -g -ftree-vectorize
|
|
|
|
|
|
|
|
CFLAGS += -fvisibility=hidden -std=gnu99
|
2015-07-13 11:20:21 +00:00
|
|
|
CFLAGS += -DKVZ_DLL_EXPORTS
|
2015-07-01 05:17:21 +00:00
|
|
|
CFLAGS += $(INCLUDEDIRS) $(WARNINGS)
|
2015-07-29 10:42:48 +00:00
|
|
|
LDFLAGS += -O2 -fvisibility=hidden -lm -pthread
|
2015-01-29 14:20:24 +00:00
|
|
|
|
2015-07-16 11:15:09 +00:00
|
|
|
ARCH ?= $(shell uname -m)
|
|
|
|
|
|
|
|
ifneq ($(findstring Windows, $(OS)),)
|
|
|
|
SYSTEM ?= Windows
|
|
|
|
else
|
|
|
|
SYSTEM ?= $(shell uname -s)
|
2014-02-03 12:27:19 +00:00
|
|
|
endif
|
2014-01-27 12:33:19 +00:00
|
|
|
|
2014-01-30 15:56:52 +00:00
|
|
|
# ARCH related flags
|
2015-09-18 12:13:13 +00:00
|
|
|
ifeq (, $(filter-out i386 i686 x86_64 amd64, $(ARCH)))
|
|
|
|
TARGET_CPU_ARCH := x86
|
|
|
|
else ifeq (, $(filter-out ppc ppc64, $(ARCH)))
|
|
|
|
TARGET_CPU_ARCH := ppc
|
|
|
|
else ifeq (, $(filter-out armv7l armv6l, $(ARCH)))
|
|
|
|
TARGET_CPU_ARCH := arm
|
2014-01-27 12:33:19 +00:00
|
|
|
else
|
2015-09-18 12:13:13 +00:00
|
|
|
TARGET_CPU_ARCH := x86
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq (, $(filter-out i386 i686 ppc, $(ARCH)))
|
|
|
|
TARGET_CPU_BITS := 32
|
|
|
|
else ifeq (, $(filter-out x86_64 amd64 ppc64, $(ARCH)))
|
|
|
|
TARGET_CPU_BITS := 64
|
|
|
|
else
|
|
|
|
TARGET_CPU_BITS := 0
|
2014-01-27 12:33:19 +00:00
|
|
|
endif
|
|
|
|
|
2015-09-17 21:23:49 +00:00
|
|
|
# The -m32 and -m64 flags are used for making sure the C files use the same
|
|
|
|
# instruction set as the ASM files. They can't be used on ARM processors.
|
2015-09-18 12:13:13 +00:00
|
|
|
ifneq (0, $(TARGET_CPU_BITS))
|
|
|
|
CFLAGS += -m$(TARGET_CPU_BITS)
|
|
|
|
LDFLAGS += -m$(TARGET_CPU_BITS)
|
2015-09-17 21:23:49 +00:00
|
|
|
endif
|
2014-05-28 12:47:24 +00:00
|
|
|
|
2015-07-29 00:26:20 +00:00
|
|
|
INSTALL_TARGETS = install-prog install-pc
|
|
|
|
|
2014-02-03 12:27:19 +00:00
|
|
|
# Windows (cygwin/mingw) specific flags
|
2015-07-16 11:15:09 +00:00
|
|
|
ifeq ($(SYSTEM), Windows)
|
2015-09-18 12:13:13 +00:00
|
|
|
ifeq ($(TARGET_CPU_BITS), 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
|
2015-07-31 12:51:53 +00:00
|
|
|
LIBKVAZAAR_SHARED = $(DLL)
|
2015-07-29 00:26:20 +00:00
|
|
|
INSTALL_TARGETS += install-dll
|
2015-07-16 11:15:09 +00:00
|
|
|
|
2014-01-30 15:56:52 +00:00
|
|
|
# OS X specific flags
|
2015-07-16 11:15:09 +00:00
|
|
|
else ifeq ($(SYSTEM), Darwin)
|
2015-09-18 12:13:13 +00:00
|
|
|
ifeq ($(TARGET_CPU_BITS), 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
|
2015-07-31 12:51:53 +00:00
|
|
|
LIBKVAZAAR_SHARED = $(DYLIB)
|
2015-07-29 00:26:20 +00:00
|
|
|
INSTALL_TARGETS += install-dylib
|
2015-07-16 11:15:09 +00:00
|
|
|
|
2014-02-03 12:27:19 +00:00
|
|
|
# Default to Linux/elf specific flags
|
|
|
|
else
|
2015-07-29 00:26:20 +00:00
|
|
|
LIBS += -lrt
|
2015-08-22 14:00:26 +00:00
|
|
|
LDFLAGS += -Wl,-z,noexecstack
|
2015-09-18 12:13:13 +00:00
|
|
|
ifeq ($(TARGET_CPU_BITS), 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
|
2015-07-31 12:51:53 +00:00
|
|
|
LIBKVAZAAR_SHARED = $(LIB)
|
2015-08-22 14:00:26 +00:00
|
|
|
INSTALL_TARGETS += install-lib install-static
|
2014-01-27 12:33:19 +00:00
|
|
|
endif
|
2015-07-16 11:15:09 +00:00
|
|
|
|
2014-10-14 06:45:18 +00:00
|
|
|
# Flags shared across systems
|
2015-09-18 12:13:13 +00:00
|
|
|
ifeq ($(TARGET_CPU_ARCH) $(TARGET_CPU_BITS), 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-09-18 12:13:13 +00:00
|
|
|
# Disable ASM optimizations if YASM is not found on path.
|
2015-07-01 05:17:21 +00:00
|
|
|
ifndef KVZ_DISABLE_ASM
|
|
|
|
has_as := $(shell type $(AS) 2>/dev/null)
|
|
|
|
ifeq ($(has_as),)
|
|
|
|
KVZ_DISABLE_ASM := 1
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2015-07-03 08:10:27 +00:00
|
|
|
ifdef CHECKPOINTS
|
|
|
|
CFLAGS += -DCHECKPOINTS
|
|
|
|
endif
|
|
|
|
|
2015-09-18 12:13:13 +00:00
|
|
|
# The optimized functions reside in these instruction set specific
|
|
|
|
# directories. If the instruction set is supported by the
|
|
|
|
# architecture, compile the files in these directories with the
|
|
|
|
# apropriate flags to cause the intrinsics to work.
|
2015-10-05 16:34:56 +00:00
|
|
|
# Note: Using LTO on strategies caused issues on some older
|
|
|
|
# compilers, -fno-lto on these files seemed to fix the issue.
|
|
|
|
# LTO is no longer used and -fno-lto shouldn't be needed.
|
2015-09-18 12:13:13 +00:00
|
|
|
ifeq ($(TARGET_CPU_ARCH), ppc)
|
2015-10-05 16:34:56 +00:00
|
|
|
strategies/altivec/%.o: EXTRA_FLAGS += -maltivec
|
|
|
|
strategies/altivec/%.lo: EXTRA_FLAGS += -maltivec
|
2015-09-18 12:13:13 +00:00
|
|
|
else ifeq ($(TARGET_CPU_ARCH), x86)
|
2015-10-05 16:34:56 +00:00
|
|
|
strategies/sse2/%.o: EXTRA_FLAGS += -msse2
|
|
|
|
strategies/sse41/%.o: EXTRA_FLAGS += -msse4.1
|
|
|
|
strategies/sse2/%.lo: EXTRA_FLAGS += -msse2
|
|
|
|
strategies/sse41/%.lo: EXTRA_FLAGS += -msse4.1
|
2015-09-18 12:13:13 +00:00
|
|
|
# To disable avx2 on old compilers that don't support it.
|
2015-07-01 05:17:21 +00:00
|
|
|
ifndef KVZ_DISABLE_AVX2
|
2015-10-05 16:34:56 +00:00
|
|
|
strategies/avx2/%.o: EXTRA_FLAGS += -mavx2
|
|
|
|
strategies/avx2/%.lo: EXTRA_FLAGS += -mavx2
|
2015-07-01 05:17:21 +00:00
|
|
|
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 \
|
|
|
|
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 \
|
2015-09-08 05:36:52 +00:00
|
|
|
input_frame_buffer.o \
|
2014-07-18 14:31:18 +00:00
|
|
|
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 \
|
2015-07-21 08:49:04 +00:00
|
|
|
search_intra.o \
|
|
|
|
search_inter.o \
|
2014-07-18 14:31:18 +00:00
|
|
|
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 \
|
2015-01-21 16:06:57 +00:00
|
|
|
strategies/strategies-ipol.o \
|
2015-09-25 06:10:12 +00:00
|
|
|
strategies/strategies-quant.o \
|
2015-10-08 06:54:15 +00:00
|
|
|
strategies/strategies-intra.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-09-25 06:10:12 +00:00
|
|
|
strategies/avx2/ipol-avx2.o \
|
2015-10-02 11:28:49 +00:00
|
|
|
strategies/generic/quant-generic.o \
|
|
|
|
strategies/avx2/quant-avx2.o \
|
2015-10-08 07:02:29 +00:00
|
|
|
strategies/generic/intra-generic.o \
|
|
|
|
strategies/avx2/intra-avx2.o
|
2014-10-29 13:02:35 +00:00
|
|
|
|
2015-07-01 05:17:21 +00:00
|
|
|
ifndef KVZ_DISABLE_ASM
|
2015-09-18 12:13:13 +00:00
|
|
|
# Compile C files in x86_asm folder with KVZ_COMPILE_ASM, which will cause
|
2015-10-10 10:42:10 +00:00
|
|
|
# the registration function to register the function pointers in the ASM
|
2015-09-18 12:13:13 +00:00
|
|
|
# files.
|
2015-07-01 05:17:21 +00:00
|
|
|
strategies/x86_asm/%.o: EXTRA_FLAGS += -DKVZ_COMPILE_ASM
|
|
|
|
|
2015-09-18 12:13:13 +00:00
|
|
|
# Add ASM files to the list of objects to be compiled.
|
2015-07-01 05:17:21 +00:00
|
|
|
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-08-13 05:56:23 +00:00
|
|
|
MAIN_OBJS := \
|
|
|
|
encmain.o \
|
|
|
|
cli.o \
|
|
|
|
yuv_io.o
|
2014-10-30 12:00:54 +00:00
|
|
|
|
2015-07-01 05:17:21 +00:00
|
|
|
RELEASE_OBJS = $(MAIN_OBJS) $(OBJS)
|
2015-08-20 11:45:38 +00:00
|
|
|
# Compile separate PIC objects for shared libraries
|
|
|
|
SHARED_OBJS = $(OBJS:.o=.lo)
|
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-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-31 12:51:53 +00:00
|
|
|
.PHONY: cli lib-shared lib-static debug tests build_tests
|
|
|
|
cli: $(PROG)
|
|
|
|
lib-shared: $(LIBKVAZAAR_SHARED)
|
2015-08-20 11:45:38 +00:00
|
|
|
lib-static: $(STATIC)
|
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
|
2015-07-15 08:00:45 +00:00
|
|
|
./$(TESTS)
|
2015-04-17 15:08:58 +00:00
|
|
|
|
|
|
|
build_tests: CFLAGS := $(filter-out -Werror, $(CFLAGS))
|
|
|
|
build_tests: init_submodules $(TESTS)
|
2014-01-27 12:33:19 +00:00
|
|
|
|
2015-07-31 12:53:31 +00:00
|
|
|
$(LIB): LDFLAGS += -shared -Wl,-soname,$(SO).$(VER_MAJOR)
|
2015-07-16 11:15:09 +00:00
|
|
|
$(DLL): LDFLAGS += -shared -Wl,--out-implib,$(IMPLIB) -o $@
|
2015-07-31 12:53:31 +00:00
|
|
|
$(DYLIB): LDFLAGS += -dynamiclib \
|
2015-07-20 11:40:58 +00:00
|
|
|
-current_version $(VER_MAJOR).$(VER_MINOR).$(VER_RELEASE) \
|
|
|
|
-compatibility_version $(VER_MAJOR) \
|
|
|
|
-install_name $(LIBDIR)/$@
|
2015-07-29 08:24:52 +00:00
|
|
|
|
2015-08-13 06:59:58 +00:00
|
|
|
$(PROG): $(MAIN_OBJS) $(STATIC)
|
2015-07-29 08:24:52 +00:00
|
|
|
$(LD) $^ $(LDFLAGS) $(LIBS) -o $@
|
|
|
|
|
2015-08-20 11:45:38 +00:00
|
|
|
$(STATIC): $(OBJS)
|
|
|
|
$(RM) $@
|
2015-08-29 08:38:10 +00:00
|
|
|
$(AR) rc $@ $^
|
2015-08-20 11:45:38 +00:00
|
|
|
$(RANLIB) $@
|
|
|
|
|
2015-08-20 11:39:18 +00:00
|
|
|
$(LIB) $(DLL) $(DYLIB): $(SHARED_OBJS)
|
2015-07-29 00:26:20 +00:00
|
|
|
$(LD) $^ $(LDFLAGS) $(LIBS) -o $@
|
2015-07-01 08:40:14 +00:00
|
|
|
|
2015-04-17 15:08:58 +00:00
|
|
|
$(DEBUG): $(DEBUG_OBJS)
|
2015-07-29 00:26:20 +00:00
|
|
|
$(LD) $^ $(LDFLAGS) $(LIBS) -o $@
|
2015-07-01 05:17:21 +00:00
|
|
|
|
2015-04-17 15:08:58 +00:00
|
|
|
$(TESTS): $(TESTS_OBJS)
|
2015-07-29 00:26:20 +00:00
|
|
|
$(LD) $^ $(LDFLAGS) $(LIBS) -o $@
|
2014-10-29 13:02:35 +00:00
|
|
|
|
2015-07-29 13:54:32 +00:00
|
|
|
|
|
|
|
%.o: %.asm Makefile
|
|
|
|
$(AS) $(ASFLAGS) -o $@ $<
|
|
|
|
%_debug.o: %.asm Makefile
|
|
|
|
$(AS) $(ASFLAGS) -o $@ $<
|
|
|
|
|
2015-07-29 10:05:56 +00:00
|
|
|
# Hopefully the ASM code is PIC. If not, we have to disable for the .so and .dylib.
|
2015-07-29 13:54:32 +00:00
|
|
|
%.lo: %.asm Makefile
|
|
|
|
$(AS) $(ASFLAGS) -o $@ $<
|
|
|
|
%_debug.lo: %.asm Makefile
|
2015-07-01 05:17:21 +00:00
|
|
|
$(AS) $(ASFLAGS) -o $@ $<
|
|
|
|
|
2015-08-20 11:45:38 +00:00
|
|
|
# Object files not meant for shared libs need KVZ_STATIC_LIB defined so
|
|
|
|
# that the names of the API functions don't get mangled on Windows.
|
|
|
|
%.o: CFLAGS += -DKVZ_STATIC_LIB
|
2015-07-29 13:54:32 +00:00
|
|
|
%.o: %.c Makefile
|
2015-08-22 14:00:26 +00:00
|
|
|
$(CC) $(CFLAGS) $(CPPFLAGS) $(EXTRA_FLAGS) -MMD -MP -c $< -o $@
|
2015-07-29 13:54:32 +00:00
|
|
|
%_debug.o: %.c Makefile
|
2015-08-22 14:00:26 +00:00
|
|
|
$(CC) $(CFLAGS) $(CPPFLAGS) $(EXTRA_FLAGS) -MMD -MP -c $< -o $@
|
2014-07-21 07:54:33 +00:00
|
|
|
|
2015-08-20 11:45:38 +00:00
|
|
|
ifneq ($(SYSTEM), Windows)
|
|
|
|
# Only use -fpic when not on Windows
|
|
|
|
%.lo: CFLAGS += -fpic
|
|
|
|
endif
|
2015-07-29 13:54:32 +00:00
|
|
|
%.lo: %.c Makefile
|
2015-08-22 14:00:26 +00:00
|
|
|
$(CC) $(CFLAGS) $(CPPFLAGS) $(EXTRA_FLAGS) -MMD -MP -c $< -o $@
|
2015-07-29 13:54:32 +00:00
|
|
|
%_debug.lo: %.c Makefile
|
2015-08-22 14:00:26 +00:00
|
|
|
$(CC) $(CFLAGS) $(CPPFLAGS) $(EXTRA_FLAGS) -MMD -MP -c $< -o $@
|
2015-07-29 13:54:32 +00:00
|
|
|
|
2015-07-29 10:05:56 +00:00
|
|
|
|
2015-07-31 12:51:53 +00:00
|
|
|
.PHONY: kvazaar.pc init_submodules install install-pc install-prog install-lib
|
|
|
|
.PHONY: install-dylib install-dll clean
|
2015-08-17 13:11:46 +00:00
|
|
|
kvazaar.pc: KVZ_VERSION = $(shell sed -n 's/^#define\s\+KVZ_VERSION\s\+\(.*\)/\1/ p' global.h)
|
2015-07-29 00:26:20 +00:00
|
|
|
kvazaar.pc: kvazaar.pc.in Makefile
|
|
|
|
sed -e "s;@prefix@;$(PREFIX);" -e "s;@libdir@;$(LIBDIR);" \
|
2015-08-17 13:11:46 +00:00
|
|
|
-e "s;@VERSION@;$(KVZ_VERSION);" \
|
2015-07-29 00:26:20 +00:00
|
|
|
-e "s;@LIBS@;$(LIBS);" kvazaar.pc.in > $@
|
|
|
|
|
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-16 11:15:09 +00:00
|
|
|
install: $(INSTALL_TARGETS)
|
2015-07-01 05:17:21 +00:00
|
|
|
|
2015-07-29 00:26:20 +00:00
|
|
|
install-pc: kvazaar.pc
|
|
|
|
$(INSTALL) -d $(DESTDIR)$(LIBDIR)/pkgconfig
|
|
|
|
$(INSTALL) -m644 $^ $(DESTDIR)$(LIBDIR)/pkgconfig
|
|
|
|
|
2015-07-01 05:17:21 +00:00
|
|
|
install-prog: $(PROG)
|
|
|
|
$(INSTALL) -d $(DESTDIR)$(BINDIR)
|
2015-07-16 14:50:09 +00:00
|
|
|
$(INSTALL) -m755 $(PROG) $(DESTDIR)$(BINDIR)
|
2015-07-01 05:17:21 +00:00
|
|
|
|
2015-08-20 11:45:38 +00:00
|
|
|
install-static: $(STATIC)
|
|
|
|
$(INSTALL) -d $(DESTDIR)$(INCDIR)
|
|
|
|
$(INSTALL) -d $(DESTDIR)$(LIBDIR)
|
|
|
|
$(INSTALL) -m644 $(INC) $(DESTDIR)$(INCDIR)
|
|
|
|
$(INSTALL) -m644 $(STATIC) $(DESTDIR)$(LIBDIR)
|
|
|
|
|
2015-07-01 05:17:21 +00:00
|
|
|
install-lib: $(LIB)
|
|
|
|
$(INSTALL) -d $(DESTDIR)$(INCDIR)
|
|
|
|
$(INSTALL) -d $(DESTDIR)$(LIBDIR)
|
2015-07-16 14:50:09 +00:00
|
|
|
$(INSTALL) -m644 $(INC) $(DESTDIR)$(INCDIR)
|
|
|
|
$(INSTALL) -m644 $(LIB) $(DESTDIR)$(LIBDIR)
|
2015-07-13 07:08:05 +00:00
|
|
|
$(LN_S) -f -T $(LIB) $(DESTDIR)$(LIBDIR)/$(SO).$(VER_MAJOR)
|
|
|
|
$(LN_S) -f -T $(LIB) $(DESTDIR)$(LIBDIR)/$(SO)
|
2015-07-01 05:17:21 +00:00
|
|
|
|
2015-07-17 17:44:20 +00:00
|
|
|
install-dylib: $(DYLIB)
|
|
|
|
$(INSTALL) -d $(DESTDIR)$(INCDIR)
|
|
|
|
$(INSTALL) -d $(DESTDIR)$(LIBDIR)
|
|
|
|
$(INSTALL) -m644 $(INC) $(DESTDIR)$(INCDIR)
|
|
|
|
$(INSTALL) -m644 $(DYLIB) $(DESTDIR)$(LIBDIR)
|
|
|
|
$(LN_S) -f $(DYLIB) $(DESTDIR)$(LIBDIR)/$(NAME).dylib
|
|
|
|
|
2015-07-01 08:40:14 +00:00
|
|
|
install-dll: $(DLL)
|
|
|
|
$(INSTALL) -d $(DESTDIR)$(DLLDIR)
|
|
|
|
$(INSTALL) -d $(DESTDIR)$(INCDIR)
|
|
|
|
$(INSTALL) -d $(DESTDIR)$(LIBDIR)
|
2015-07-16 14:50:09 +00:00
|
|
|
$(INSTALL) -m644 $(DLL) $(DESTDIR)$(DLLDIR)
|
|
|
|
$(INSTALL) -m644 $(INC) $(DESTDIR)$(INCDIR)
|
|
|
|
$(INSTALL) -m644 $(IMPLIB) $(DESTDIR)$(LIBDIR)
|
2015-07-01 08:40:14 +00:00
|
|
|
|
2014-02-03 12:27:19 +00:00
|
|
|
clean:
|
2015-08-20 11:39:18 +00:00
|
|
|
$(RM) $(RELEASE_OBJS) $(SHARED_OBJS) $(DEBUG_OBJS) $(TESTS_OBJS) $(DEPS)
|
2015-08-20 11:45:38 +00:00
|
|
|
$(RM) $(PROG) $(DEBUG) $(TESTS) $(STATIC) $(LIB) $(DLL) $(IMPLIB) $(DYLIB)
|
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
|
2015-07-01 08:40:14 +00:00
|
|
|
.PHONY: install install-prog install-lib install-dll
|