summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt13
-rw-r--r--src/CMakeLists.txt23
-rw-r--r--src/decode.c14
-rw-r--r--src/decode.h8
-rw-r--r--src/encode.c6
-rw-r--r--src/encode.h8
-rw-r--r--src/encode_accessors.h8
-rw-r--r--src/libaec.h33
-rw-r--r--src/sz_compat.c4
-rw-r--r--src/szlib.h8
-rw-r--r--tests/CMakeLists.txt3
-rw-r--r--tests/check_aec.c1
-rw-r--r--tests/check_aec.h2
-rw-r--r--tests/check_buffer_sizes.c1
-rw-r--r--tests/check_code_options.c1
-rw-r--r--tests/check_long_fs.c1
16 files changed, 59 insertions, 75 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 1d62836..9c644eb 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -2,7 +2,6 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.8.6)
INCLUDE(CheckIncludeFiles)
INCLUDE(TestBigEndian)
INCLUDE(CheckCSourceCompiles)
-INCLUDE(GenerateExportHeader)
PROJECT(libaec)
SET(libaec_VERSION_MAJOR 0)
SET(libaec_VERSION_MINOR 2)
@@ -83,9 +82,19 @@ CONFIGURE_FILE(
${CMAKE_CURRENT_SOURCE_DIR}/config.h.in
${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}/src")
INCLUDE_DIRECTORIES("${PROJECT_SOURCE_DIR}/src")
ADD_SUBDIRECTORY(src)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index bbde090..d956a41 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,36 +1,25 @@
-INCLUDE(GenerateExportHeader)
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
VERSION 0
SOVERSION 0.0
)
-ADD_LIBRARY(sz sz_compat.c)
+ADD_LIBRARY(sz ${LIB_TYPE} sz_compat.c)
SET_TARGET_PROPERTIES(sz PROPERTIES
VERSION 0
SOVERSION 0.0
)
+TARGET_LINK_LIBRARIES(sz aec)
IF(WIN32)
- GENERATE_EXPORT_HEADER(aec
- BASE_NAME aec
- 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
- )
+ SET_TARGET_PROPERTIES (aec PROPERTIES DEFINE_SYMBOL "DLL_EXPORT")
+ SET_TARGET_PROPERTIES (sz PROPERTIES DEFINE_SYMBOL "DLL_EXPORT")
ENDIF(WIN32)
-TARGET_LINK_LIBRARIES(sz aec)
-
ADD_EXECUTABLE(aec_client aec.c)
SET_TARGET_PROPERTIES(aec_client PROPERTIES OUTPUT_NAME "aec")
TARGET_LINK_LIBRARIES(aec_client aec)
+
IF(UNIX)
ADD_EXECUTABLE(utime EXCLUDE_FROM_ALL utime.c)
ENDIF(UNIX)
diff --git a/src/decode.c b/src/decode.c
index d94f1bb..5c9a548 100644
--- a/src/decode.c
+++ b/src/decode.c
@@ -51,23 +51,17 @@
*
*/
-#include <config.h>
-
-#if HAVE_STDINT_H
-#include <stdint.h>
-#endif
-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#ifdef HAVE_BSR64
-#include <intrin.h>
-#endif
-
#include "libaec.h"
#include "decode.h"
+#if HAVE_BSR64
+# include <intrin.h>
+#endif
+
#define ROS 5
#define BUFFERSPACE(strm) (strm->avail_in >= strm->state->in_blklen \
diff --git a/src/decode.h b/src/decode.h
index fac60b8..32c4671 100644
--- a/src/decode.h
+++ b/src/decode.h
@@ -52,16 +52,12 @@
*/
#ifndef DECODE_H
-#define DECODE_H
-
-#include <config.h>
+#define DECODE_H 1
#if HAVE_STDINT_H
-# include <stdint.h>
+# include <stdint.h>
#endif
-#include "libaec.h"
-
#define M_CONTINUE 1
#define M_EXIT 0
#define M_ERROR (-1)
diff --git a/src/encode.c b/src/encode.c
index 4a03b49..6cbc766 100644
--- a/src/encode.c
+++ b/src/encode.c
@@ -51,12 +51,6 @@
*
*/
-#include <config.h>
-
-#if HAVE_STDINT_H
-# include <stdint.h>
-#endif
-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
diff --git a/src/encode.h b/src/encode.h
index db96d1c..264cd77 100644
--- a/src/encode.h
+++ b/src/encode.h
@@ -52,16 +52,12 @@
*/
#ifndef ENCODE_H
-#define ENCODE_H
-
-#include <config.h>
+#define ENCODE_H 1
#if HAVE_STDINT_H
-# include <stdint.h>
+# include <stdint.h>
#endif
-#include "libaec.h"
-
#define M_CONTINUE 1
#define M_EXIT 0
#define MIN(a, b) (((a) < (b))? (a): (b))
diff --git a/src/encode_accessors.h b/src/encode_accessors.h
index f94683a..88f9c05 100644
--- a/src/encode_accessors.h
+++ b/src/encode_accessors.h
@@ -51,16 +51,12 @@
*/
#ifndef ENCODE_ACCESSORS_H
-#define ENCODE_ACCESSORS_H
-
-#include <config.h>
+#define ENCODE_ACCESSORS_H 1
#if HAVE_STDINT_H
-# include <stdint.h>
+# include <stdint.h>
#endif
-#include "libaec.h"
-
uint32_t aec_get_8(struct aec_stream *strm);
uint32_t aec_get_lsb_16(struct aec_stream *strm);
uint32_t aec_get_msb_16(struct aec_stream *strm);
diff --git a/src/libaec.h b/src/libaec.h
index 9cacd99..49ec078 100644
--- a/src/libaec.h
+++ b/src/libaec.h
@@ -51,10 +51,25 @@
*/
#ifndef LIBAEC_H
-#define LIBAEC_H
+#define LIBAEC_H 1
#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 aec_stream {
@@ -124,16 +139,16 @@ struct aec_stream {
*/
/* Streaming encoding and decoding functions */
-int aec_encode_init(struct aec_stream *strm);
-int aec_encode(struct aec_stream *strm, int flush);
-int aec_encode_end(struct aec_stream *strm);
+AEC_SCOPE int aec_encode_init(struct aec_stream *strm);
+AEC_SCOPE int aec_encode(struct aec_stream *strm, int flush);
+AEC_SCOPE int aec_encode_end(struct aec_stream *strm);
-int aec_decode_init(struct aec_stream *strm);
-int aec_decode(struct aec_stream *strm, int flush);
-int aec_decode_end(struct aec_stream *strm);
+AEC_SCOPE int aec_decode_init(struct aec_stream *strm);
+AEC_SCOPE int aec_decode(struct aec_stream *strm, int flush);
+AEC_SCOPE int aec_decode_end(struct aec_stream *strm);
/* Utility functions for encoding or decoding a memory buffer. */
-int aec_buffer_encode(struct aec_stream *strm);
-int aec_buffer_decode(struct aec_stream *strm);
+AEC_SCOPE int aec_buffer_encode(struct aec_stream *strm);
+AEC_SCOPE int aec_buffer_decode(struct aec_stream *strm);
#endif /* LIBAEC_H */
diff --git a/src/sz_compat.c b/src/sz_compat.c
index 5c70cdf..bac36d2 100644
--- a/src/sz_compat.c
+++ b/src/sz_compat.c
@@ -1,9 +1,7 @@
#include <stdio.h>
-#include <stddef.h>
-#include <string.h>
#include <stdlib.h>
+#include <string.h>
#include "szlib.h"
-#include "libaec.h"
#define NOPTS 129
diff --git a/src/szlib.h b/src/szlib.h
index 4ad55cf..a448754 100644
--- a/src/szlib.h
+++ b/src/szlib.h
@@ -1,5 +1,5 @@
#ifndef SZLIB_H
-#define SZLIB_H
+#define SZLIB_H 1
#include "libaec.h"
@@ -30,13 +30,13 @@ typedef struct SZ_com_t_s
int pixels_per_scanline;
} 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,
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,
SZ_com_t *param);
-int SZ_encoder_enabled(void);
+AEC_SCOPE int SZ_encoder_enabled(void);
#endif /* SZLIB_H */
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index 5c5bf67..15b9433 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -1,4 +1,5 @@
-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)
TARGET_LINK_LIBRARIES(check_code_options check_aec aec)
diff --git a/tests/check_aec.c b/tests/check_aec.c
index f70a20c..e59da41 100644
--- a/tests/check_aec.c
+++ b/tests/check_aec.c
@@ -1,7 +1,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "libaec.h"
#include "check_aec.h"
static void out_lsb(unsigned char *dest, unsigned int val, int size)
diff --git a/tests/check_aec.h b/tests/check_aec.h
index 9cd34ae..f184686 100644
--- a/tests/check_aec.h
+++ b/tests/check_aec.h
@@ -1,5 +1,5 @@
#ifndef CHECK_AEC_H
-#define CHECK_AEC_H
+#define CHECK_AEC_H 1
#include "libaec.h"
struct test_state {
diff --git a/tests/check_buffer_sizes.c b/tests/check_buffer_sizes.c
index 8618b27..c9ca88b 100644
--- a/tests/check_buffer_sizes.c
+++ b/tests/check_buffer_sizes.c
@@ -1,7 +1,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "libaec.h"
#include "check_aec.h"
#define BUF_SIZE 1024 * 3
diff --git a/tests/check_code_options.c b/tests/check_code_options.c
index bda7fcd..0ec6006 100644
--- a/tests/check_code_options.c
+++ b/tests/check_code_options.c
@@ -1,7 +1,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "libaec.h"
#include "check_aec.h"
#define BUF_SIZE 1024 * 3
diff --git a/tests/check_long_fs.c b/tests/check_long_fs.c
index c83b08f..75206b9 100644
--- a/tests/check_long_fs.c
+++ b/tests/check_long_fs.c
@@ -1,7 +1,6 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
-#include "libaec.h"
#include "check_aec.h"
#define BUF_SIZE (64 * 4)