Commit a57748e3 authored by Mathis Rosenhauer's avatar Mathis Rosenhauer
Browse files

DLL support for Windows.

parent 99291d6c
...@@ -2,7 +2,6 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8.6) ...@@ -2,7 +2,6 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8.6)
INCLUDE(CheckIncludeFiles) INCLUDE(CheckIncludeFiles)
INCLUDE(TestBigEndian) INCLUDE(TestBigEndian)
INCLUDE(CheckCSourceCompiles) INCLUDE(CheckCSourceCompiles)
INCLUDE(GenerateExportHeader)
PROJECT(libaec) PROJECT(libaec)
SET(libaec_VERSION_MAJOR 0) SET(libaec_VERSION_MAJOR 0)
SET(libaec_VERSION_MINOR 2) SET(libaec_VERSION_MINOR 2)
...@@ -83,9 +82,19 @@ CONFIGURE_FILE( ...@@ -83,9 +82,19 @@ CONFIGURE_FILE(
${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
${CMAKE_CURRENT_BINARY_DIR}/config.h ${CMAKE_CURRENT_BINARY_DIR}/config.h
) )
ADD_DEFINITIONS("-DHAVE_CONFIG_H")
# Allow the developer to select if Dynamic or Static libraries are built
OPTION (BUILD_SHARED_LIBS "Build Shared Libraries" OFF)
SET (LIB_TYPE STATIC)
IF (BUILD_SHARED_LIBS)
# User wants to build Dynamic Libraries,
# so change the LIB_TYPE variable to CMake keyword 'SHARED'
SET (LIB_TYPE SHARED)
ENDIF (BUILD_SHARED_LIBS)
SET(BUILD_SHARED_LIBS FALSE)
INCLUDE_DIRECTORIES("${PROJECT_BINARY_DIR}") INCLUDE_DIRECTORIES("${PROJECT_BINARY_DIR}")
INCLUDE_DIRECTORIES("${PROJECT_BINARY_DIR}/src")
INCLUDE_DIRECTORIES("${PROJECT_SOURCE_DIR}/src") INCLUDE_DIRECTORIES("${PROJECT_SOURCE_DIR}/src")
ADD_SUBDIRECTORY(src) ADD_SUBDIRECTORY(src)
......
INCLUDE(GenerateExportHeader)
SET(libaec_SRCS encode.c encode_accessors.c decode.c) SET(libaec_SRCS encode.c encode_accessors.c decode.c)
ADD_LIBRARY(aec ${libaec_SRCS}) ADD_LIBRARY(aec ${LIB_TYPE} ${libaec_SRCS})
SET_TARGET_PROPERTIES(aec PROPERTIES SET_TARGET_PROPERTIES(aec PROPERTIES
VERSION 0 VERSION 0
SOVERSION 0.0 SOVERSION 0.0
) )
ADD_LIBRARY(sz sz_compat.c) ADD_LIBRARY(sz ${LIB_TYPE} sz_compat.c)
SET_TARGET_PROPERTIES(sz PROPERTIES SET_TARGET_PROPERTIES(sz PROPERTIES
VERSION 0 VERSION 0
SOVERSION 0.0 SOVERSION 0.0
) )
TARGET_LINK_LIBRARIES(sz aec)
IF(WIN32) IF(WIN32)
GENERATE_EXPORT_HEADER(aec SET_TARGET_PROPERTIES (aec PROPERTIES DEFINE_SYMBOL "DLL_EXPORT")
BASE_NAME aec SET_TARGET_PROPERTIES (sz PROPERTIES DEFINE_SYMBOL "DLL_EXPORT")
EXPORT_MACRO_NAME aec_EXPORT
EXPORT_FILE_NAME aec_Export.h
STATIC_DEFINE aec_BUILT_AS_STATIC
)
GENERATE_EXPORT_HEADER(sz
BASE_NAME sz
EXPORT_MACRO_NAME sz_EXPORT
EXPORT_FILE_NAME sz_Export.h
STATIC_DEFINE sz_BUILT_AS_STATIC
)
ENDIF(WIN32) ENDIF(WIN32)
TARGET_LINK_LIBRARIES(sz aec)
ADD_EXECUTABLE(aec_client aec.c) ADD_EXECUTABLE(aec_client aec.c)
SET_TARGET_PROPERTIES(aec_client PROPERTIES OUTPUT_NAME "aec") SET_TARGET_PROPERTIES(aec_client PROPERTIES OUTPUT_NAME "aec")
TARGET_LINK_LIBRARIES(aec_client aec) TARGET_LINK_LIBRARIES(aec_client aec)
IF(UNIX) IF(UNIX)
ADD_EXECUTABLE(utime EXCLUDE_FROM_ALL utime.c) ADD_EXECUTABLE(utime EXCLUDE_FROM_ALL utime.c)
ENDIF(UNIX) ENDIF(UNIX)
......
...@@ -51,23 +51,17 @@ ...@@ -51,23 +51,17 @@
* *
*/ */
#include <config.h>
#if HAVE_STDINT_H
#include <stdint.h>
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#ifdef HAVE_BSR64
#include <intrin.h>
#endif
#include "libaec.h" #include "libaec.h"
#include "decode.h" #include "decode.h"
#if HAVE_BSR64
# include <intrin.h>
#endif
#define ROS 5 #define ROS 5
#define BUFFERSPACE(strm) (strm->avail_in >= strm->state->in_blklen \ #define BUFFERSPACE(strm) (strm->avail_in >= strm->state->in_blklen \
......
...@@ -52,16 +52,12 @@ ...@@ -52,16 +52,12 @@
*/ */
#ifndef DECODE_H #ifndef DECODE_H
#define DECODE_H #define DECODE_H 1
#include <config.h>
#if HAVE_STDINT_H #if HAVE_STDINT_H
# include <stdint.h> # include <stdint.h>
#endif #endif
#include "libaec.h"
#define M_CONTINUE 1 #define M_CONTINUE 1
#define M_EXIT 0 #define M_EXIT 0
#define M_ERROR (-1) #define M_ERROR (-1)
......
...@@ -51,12 +51,6 @@ ...@@ -51,12 +51,6 @@
* *
*/ */
#include <config.h>
#if HAVE_STDINT_H
# include <stdint.h>
#endif
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
......
...@@ -52,16 +52,12 @@ ...@@ -52,16 +52,12 @@
*/ */
#ifndef ENCODE_H #ifndef ENCODE_H
#define ENCODE_H #define ENCODE_H 1
#include <config.h>
#if HAVE_STDINT_H #if HAVE_STDINT_H
# include <stdint.h> # include <stdint.h>
#endif #endif
#include "libaec.h"
#define M_CONTINUE 1 #define M_CONTINUE 1
#define M_EXIT 0 #define M_EXIT 0
#define MIN(a, b) (((a) < (b))? (a): (b)) #define MIN(a, b) (((a) < (b))? (a): (b))
......
...@@ -51,16 +51,12 @@ ...@@ -51,16 +51,12 @@
*/ */
#ifndef ENCODE_ACCESSORS_H #ifndef ENCODE_ACCESSORS_H
#define ENCODE_ACCESSORS_H #define ENCODE_ACCESSORS_H 1
#include <config.h>
#if HAVE_STDINT_H #if HAVE_STDINT_H
# include <stdint.h> # include <stdint.h>
#endif #endif
#include "libaec.h"
uint32_t aec_get_8(struct aec_stream *strm); uint32_t aec_get_8(struct aec_stream *strm);
uint32_t aec_get_lsb_16(struct aec_stream *strm); uint32_t aec_get_lsb_16(struct aec_stream *strm);
uint32_t aec_get_msb_16(struct aec_stream *strm); uint32_t aec_get_msb_16(struct aec_stream *strm);
......
...@@ -51,10 +51,25 @@ ...@@ -51,10 +51,25 @@
*/ */
#ifndef LIBAEC_H #ifndef LIBAEC_H
#define LIBAEC_H #define LIBAEC_H 1
#include <stddef.h> #include <stddef.h>
#if HAVE_CONFIG_H
# include <config.h>
#endif
#ifdef _WIN32
# ifdef DLL_EXPORT
# define AEC_SCOPE __declspec(dllexport)
# else
# define AEC_SCOPE extern __declspec(dllimport)
# endif
#endif
#ifndef AEC_SCOPE
# define AEC_SCOPE extern
#endif
struct internal_state; struct internal_state;
struct aec_stream { struct aec_stream {
...@@ -124,16 +139,16 @@ struct aec_stream { ...@@ -124,16 +139,16 @@ struct aec_stream {
*/ */
/* Streaming encoding and decoding functions */ /* Streaming encoding and decoding functions */
int aec_encode_init(struct aec_stream *strm); AEC_SCOPE int aec_encode_init(struct aec_stream *strm);
int aec_encode(struct aec_stream *strm, int flush); AEC_SCOPE int aec_encode(struct aec_stream *strm, int flush);
int aec_encode_end(struct aec_stream *strm); AEC_SCOPE int aec_encode_end(struct aec_stream *strm);
int aec_decode_init(struct aec_stream *strm); AEC_SCOPE int aec_decode_init(struct aec_stream *strm);
int aec_decode(struct aec_stream *strm, int flush); AEC_SCOPE int aec_decode(struct aec_stream *strm, int flush);
int aec_decode_end(struct aec_stream *strm); AEC_SCOPE int aec_decode_end(struct aec_stream *strm);
/* Utility functions for encoding or decoding a memory buffer. */ /* Utility functions for encoding or decoding a memory buffer. */
int aec_buffer_encode(struct aec_stream *strm); AEC_SCOPE int aec_buffer_encode(struct aec_stream *strm);
int aec_buffer_decode(struct aec_stream *strm); AEC_SCOPE int aec_buffer_decode(struct aec_stream *strm);
#endif /* LIBAEC_H */ #endif /* LIBAEC_H */
#include <stdio.h> #include <stdio.h>
#include <stddef.h>
#include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h>
#include "szlib.h" #include "szlib.h"
#include "libaec.h"
#define NOPTS 129 #define NOPTS 129
......
#ifndef SZLIB_H #ifndef SZLIB_H
#define SZLIB_H #define SZLIB_H 1
#include "libaec.h" #include "libaec.h"
...@@ -30,13 +30,13 @@ typedef struct SZ_com_t_s ...@@ -30,13 +30,13 @@ typedef struct SZ_com_t_s
int pixels_per_scanline; int pixels_per_scanline;
} SZ_com_t; } SZ_com_t;
int SZ_BufftoBuffCompress(void *dest, size_t *destLen, AEC_SCOPE int SZ_BufftoBuffCompress(void *dest, size_t *destLen,
const void *source, size_t sourceLen, const void *source, size_t sourceLen,
SZ_com_t *param); SZ_com_t *param);
int SZ_BufftoBuffDecompress(void *dest, size_t *destLen, AEC_SCOPE int SZ_BufftoBuffDecompress(void *dest, size_t *destLen,
const void *source, size_t sourceLen, const void *source, size_t sourceLen,
SZ_com_t *param); SZ_com_t *param);
int SZ_encoder_enabled(void); AEC_SCOPE int SZ_encoder_enabled(void);
#endif /* SZLIB_H */ #endif /* SZLIB_H */
ADD_LIBRARY(check_aec check_aec.c) ADD_LIBRARY(check_aec STATIC check_aec.c)
TARGET_LINK_LIBRARIES(check_aec aec)
ADD_EXECUTABLE(check_code_options check_code_options.c) ADD_EXECUTABLE(check_code_options check_code_options.c)
TARGET_LINK_LIBRARIES(check_code_options check_aec aec) TARGET_LINK_LIBRARIES(check_code_options check_aec aec)
......
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "libaec.h"
#include "check_aec.h" #include "check_aec.h"
static void out_lsb(unsigned char *dest, unsigned int val, int size) static void out_lsb(unsigned char *dest, unsigned int val, int size)
......
#ifndef CHECK_AEC_H #ifndef CHECK_AEC_H
#define CHECK_AEC_H #define CHECK_AEC_H 1
#include "libaec.h" #include "libaec.h"
struct test_state { struct test_state {
......
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "libaec.h"
#include "check_aec.h" #include "check_aec.h"
#define BUF_SIZE 1024 * 3 #define BUF_SIZE 1024 * 3
......
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "libaec.h"
#include "check_aec.h" #include "check_aec.h"
#define BUF_SIZE 1024 * 3 #define BUF_SIZE 1024 * 3
......
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include "libaec.h"
#include "check_aec.h" #include "check_aec.h"
#define BUF_SIZE (64 * 4) #define BUF_SIZE (64 * 4)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment