mirror of
https://github.com/ultravideo/uvg266.git
synced 2024-11-23 18:14:06 +00:00
Add static library target to Makefile.
Adds targets libkvazaar.a and install-static to the Makefile.
This commit is contained in:
parent
23159e45b7
commit
cb49586d36
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -20,6 +20,7 @@
|
|||
*.log
|
||||
.kdev4
|
||||
src/kvazaar
|
||||
src/libkvazaar.a
|
||||
src/libkvazaar.so.*
|
||||
src/kvazaar.dll
|
||||
src/libkvazaar.dll.a
|
||||
|
|
48
src/Makefile
48
src/Makefile
|
@ -21,6 +21,7 @@ DEBUG = kvazaar_debug
|
|||
TESTS = kvazaar_tests
|
||||
|
||||
NAME = libkvazaar
|
||||
STATIC = $(NAME).a
|
||||
SO = $(NAME).so
|
||||
LIB = $(SO).$(VER_MAJOR).$(VER_MINOR).$(VER_RELEASE)
|
||||
DYLIB = $(NAME).$(VER_MAJOR).dylib
|
||||
|
@ -34,6 +35,7 @@ AS = yasm
|
|||
LD = $(CC)
|
||||
INSTALL = install
|
||||
LN_S = ln -s
|
||||
RANLIB = ranlib
|
||||
|
||||
# Do not use variable length arrays because they don't work in Visual Studio 2013.
|
||||
WARNINGS = -Werror -Wall -Wtype-limits -Wvla
|
||||
|
@ -137,13 +139,17 @@ endif
|
|||
|
||||
# Compile files in strategy directories with appropriate flags.
|
||||
ifeq ($(ARCH), ppc64)
|
||||
strategies/altivec/%.o: EXTRA_FLAGS += -maltivec -fno-lto
|
||||
strategies/altivec/%.o: EXTRA_FLAGS += -maltivec -fno-lto
|
||||
strategies/altivec/%.lo: EXTRA_FLAGS += -maltivec -fno-lto
|
||||
else
|
||||
strategies/sse2/%.o: EXTRA_FLAGS += -msse2 -fno-lto
|
||||
strategies/sse41/%.o: EXTRA_FLAGS += -msse4.1 -fno-lto
|
||||
strategies/sse2/%.o: EXTRA_FLAGS += -msse2 -fno-lto
|
||||
strategies/sse41/%.o: EXTRA_FLAGS += -msse4.1 -fno-lto
|
||||
strategies/sse2/%.lo: EXTRA_FLAGS += -msse2 -fno-lto
|
||||
strategies/sse41/%.lo: EXTRA_FLAGS += -msse4.1 -fno-lto
|
||||
# Needs to be defined on Travis
|
||||
ifndef KVZ_DISABLE_AVX2
|
||||
strategies/avx2/%.o: EXTRA_FLAGS += -mavx2 -fno-lto
|
||||
strategies/avx2/%.o: EXTRA_FLAGS += -mavx2 -fno-lto
|
||||
strategies/avx2/%.lo: EXTRA_FLAGS += -mavx2 -fno-lto
|
||||
endif
|
||||
endif
|
||||
|
||||
|
@ -218,12 +224,8 @@ MAIN_OBJS := \
|
|||
yuv_io.o
|
||||
|
||||
RELEASE_OBJS = $(MAIN_OBJS) $(OBJS)
|
||||
# Compile separate PIC objects for Linux/OSX.
|
||||
ifeq ($(SYSTEM), Windows)
|
||||
SHARED_OBJS = $(OBJS)
|
||||
else
|
||||
SHARED_OBJS = $(OBJS:.o=.lo)
|
||||
endif
|
||||
# Compile separate PIC objects for shared libraries
|
||||
SHARED_OBJS = $(OBJS:.o=.lo)
|
||||
DEBUG_OBJS = $(RELEASE_OBJS:.o=_debug.o)
|
||||
TESTS_OBJS = $(TEST_OBJS) $(OBJS)
|
||||
|
||||
|
@ -232,7 +234,7 @@ DEPS = $(RELEASE_OBJS:.o=.d) $(DEBUG_OBJS:.o=.d) $(TESTS_OBJS:.o=.d)
|
|||
.PHONY: cli lib-shared lib-static debug tests build_tests
|
||||
cli: $(PROG)
|
||||
lib-shared: $(LIBKVAZAAR_SHARED)
|
||||
lib-static: # TODO
|
||||
lib-static: $(STATIC)
|
||||
|
||||
debug: LDFLAGS := $(filter-out -O3 -O2 -flto, $(LDFLAGS))
|
||||
debug: CFLAGS := $(filter-out -O3 -O2 -flto, $(CFLAGS))
|
||||
|
@ -254,6 +256,11 @@ $(DYLIB): LDFLAGS += -dynamiclib \
|
|||
$(PROG): $(RELEASE_OBJS)
|
||||
$(LD) $^ $(LDFLAGS) $(LIBS) -o $@
|
||||
|
||||
$(STATIC): $(OBJS)
|
||||
$(RM) $@
|
||||
$(AR) rcD $@ $^
|
||||
$(RANLIB) $@
|
||||
|
||||
$(LIB) $(DLL) $(DYLIB): $(SHARED_OBJS)
|
||||
$(LD) $^ $(LDFLAGS) $(LIBS) -o $@
|
||||
|
||||
|
@ -275,15 +282,22 @@ $(TESTS): $(TESTS_OBJS)
|
|||
%_debug.lo: %.asm Makefile
|
||||
$(AS) $(ASFLAGS) -o $@ $<
|
||||
|
||||
# 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
|
||||
%.o: %.c Makefile
|
||||
$(CC) $(CFLAGS) $(EXTRA_FLAGS) -MMD -MP -c $< -o $@
|
||||
%_debug.o: %.c Makefile
|
||||
$(CC) $(CFLAGS) $(EXTRA_FLAGS) -MMD -MP -c $< -o $@
|
||||
|
||||
ifneq ($(SYSTEM), Windows)
|
||||
# Only use -fpic when not on Windows
|
||||
%.lo: CFLAGS += -fpic
|
||||
endif
|
||||
%.lo: %.c Makefile
|
||||
$(CC) -fpic $(CFLAGS) $(EXTRA_FLAGS) -MMD -MP -c $< -o $@
|
||||
$(CC) $(CFLAGS) $(EXTRA_FLAGS) -MMD -MP -c $< -o $@
|
||||
%_debug.lo: %.c Makefile
|
||||
$(CC) -fpic $(CFLAGS) $(EXTRA_FLAGS) -MMD -MP -c $< -o $@
|
||||
$(CC) $(CFLAGS) $(EXTRA_FLAGS) -MMD -MP -c $< -o $@
|
||||
|
||||
|
||||
.PHONY: kvazaar.pc init_submodules install install-pc install-prog install-lib
|
||||
|
@ -307,6 +321,12 @@ install-prog: $(PROG)
|
|||
$(INSTALL) -d $(DESTDIR)$(BINDIR)
|
||||
$(INSTALL) -m755 $(PROG) $(DESTDIR)$(BINDIR)
|
||||
|
||||
install-static: $(STATIC)
|
||||
$(INSTALL) -d $(DESTDIR)$(INCDIR)
|
||||
$(INSTALL) -d $(DESTDIR)$(LIBDIR)
|
||||
$(INSTALL) -m644 $(INC) $(DESTDIR)$(INCDIR)
|
||||
$(INSTALL) -m644 $(STATIC) $(DESTDIR)$(LIBDIR)
|
||||
|
||||
install-lib: $(LIB)
|
||||
$(INSTALL) -d $(DESTDIR)$(INCDIR)
|
||||
$(INSTALL) -d $(DESTDIR)$(LIBDIR)
|
||||
|
@ -332,7 +352,7 @@ install-dll: $(DLL)
|
|||
|
||||
clean:
|
||||
$(RM) $(RELEASE_OBJS) $(SHARED_OBJS) $(DEBUG_OBJS) $(TESTS_OBJS) $(DEPS)
|
||||
$(RM) $(PROG) $(DEBUG) $(TESTS) $(LIB) $(DLL) $(IMPLIB) $(DYLIB)
|
||||
$(RM) $(PROG) $(DEBUG) $(TESTS) $(STATIC) $(LIB) $(DLL) $(IMPLIB) $(DYLIB)
|
||||
|
||||
ifneq ($(MAKECMDGOALS),clean)
|
||||
-include $(DEPS)
|
||||
|
|
|
@ -34,13 +34,19 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32) || defined(__CYGWIN__)
|
||||
#if defined(KVZ_STATIC_LIB)
|
||||
// Using or building kvazaar as a static library.
|
||||
#define KVZ_PUBLIC
|
||||
#elif defined(_WIN32) || defined(__CYGWIN__)
|
||||
#ifdef KVZ_DLL_EXPORTS
|
||||
// Building kvazaar on windows.
|
||||
#define KVZ_PUBLIC __declspec(dllexport)
|
||||
#else
|
||||
// Using kvazaar as a DLL on windows.
|
||||
#define KVZ_PUBLIC __declspec(dllimport)
|
||||
#endif
|
||||
#elif defined(__GNUC__)
|
||||
// Using GCC and not on windows.
|
||||
#define KVZ_PUBLIC __attribute__ ((visibility ("default")))
|
||||
#else
|
||||
#define KVZ_PUBLIC
|
||||
|
|
Loading…
Reference in a new issue