diff options
author | yuta.256 <yuta.256@b7c3aa3b-274f-0410-ae0b-edc9d07c929d> | 2008-07-03 11:34:07 +0000 |
---|---|---|
committer | yuta.256 <yuta.256@b7c3aa3b-274f-0410-ae0b-edc9d07c929d> | 2008-07-03 11:34:07 +0000 |
commit | 0b0d08bc414f9152b0f7afac36b56b4b30e2679f (patch) | |
tree | e16f192f3e8cfab1a5443b6b62cbd4711fba965b /include | |
parent | 176b6c50446b4f7ae1e284ae2287f8b1c62811fd (diff) | |
download | libdivsufsort-0b0d08bc414f9152b0f7afac36b56b4b30e2679f.tar.gz |
The build system was changed to CMake. (http://www.cmake.org/)
Diffstat (limited to 'include')
-rw-r--r-- | include/CMakeLists.txt | 101 | ||||
-rw-r--r-- | include/Makefile.am | 4 | ||||
-rw-r--r-- | include/config.h.cmake | 57 | ||||
-rw-r--r-- | include/divsufsort.h.cmake (renamed from include/divsufsort.h.in) | 56 | ||||
-rw-r--r-- | include/divsufsort_private.h (renamed from include/divsufsort_private.h.in) | 16 |
5 files changed, 201 insertions, 33 deletions
diff --git a/include/CMakeLists.txt b/include/CMakeLists.txt new file mode 100644 index 0000000..3a4f2af --- /dev/null +++ b/include/CMakeLists.txt @@ -0,0 +1,101 @@ +include(CheckIncludeFiles) +include(CheckIncludeFile) +include(CheckSymbolExists) +include(CheckTypeSize) +include(CheckFunctionKeywords) + +## Checks for header files ## +check_include_file("inttypes.h" HAVE_INTTYPES_H) +check_include_file("memory.h" HAVE_MEMORY_H) +check_include_file("stddef.h" HAVE_STDDEF_H) +check_include_file("stdint.h" HAVE_STDINT_H) +check_include_file("stdlib.h" HAVE_STDLIB_H) +check_include_file("string.h" HAVE_STRING_H) +check_include_file("strings.h" HAVE_STRINGS_H) +check_include_file("sys/types.h" HAVE_SYS_TYPES_H) +check_include_file("sys/stat.h" HAVE_SYS_STAT_H) +if(HAVE_INTTYPES_H) + set(INCFILE "#include <inttypes.h>") +elseif(HAVE_STDINT_H) + set(INCFILE "#include <stdint.h>") +else(HAVE_INTTYPES_H) + set(INCFILE "") +endif(HAVE_INTTYPES_H) + +## create configuration files from .cmake file ## + +## generate config.h ## +check_function_keywords("inline;__inline;__inline__;__declspec(dllexport);__declspec(dllimport)") +if(HAVE_INLINE) + set(INLINE "inline") +elseif(HAVE___INLINE) + set(INLINE "__inline") +elseif(HAVE___INLINE__) + set(INLINE "__inline__") +else(HAVE_INLINE) + set(INLINE "") +endif(HAVE_INLINE) +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake" "${CMAKE_CURRENT_BINARY_DIR}/config.h") + +## Checks for types ## +# sauchar_t (8bit) +check_type_size("uint8_t" UINT8_T) +if(HAVE_UINT8_T) + set(SAUCHAR_TYPE "uint8_t") +else(HAVE_UINT8_T) + check_type_size("unsigned char" SIZEOF_UNSIGNED_CHAR) + if(${SIZEOF_UNSIGNED_CHAR} STREQUAL "1") + set(SAUCHAR_TYPE "unsigned char") + else(${SIZEOF_UNSIGNED_CHAR} STREQUAL "1") + message(FATAL_ERROR "Cannot find unsigned 8-bit integer type") + endif(${SIZEOF_UNSIGNED_CHAR} STREQUAL "1") +endif(HAVE_UINT8_T) +# saint_t (32bit) +check_type_size("int32_t" INT32_T) +if(HAVE_INT32_T) + set(SAINT32_TYPE "int32_t") + check_symbol_exists("PRId32" "inttypes.h" HAVE_PRID32) + if(HAVE_PRID32) + set(SAINT32_PRId "PRId32") + else(HAVE_PRID32) + set(SAINT32_PRId "\"d\"") + endif(HAVE_PRID32) +else(HAVE_INT32_T) + check_type_size("int" SIZEOF_INT) + check_type_size("long" SIZEOF_LONG) + check_type_size("short" SIZEOF_SHORT) + check_type_size("__int32" SIZEOF___INT32) + if(${SIZEOF_INT} STREQUAL "4") + set(SAINT32_TYPE "int") + set(SAINT32_PRId "\"d\"") + elseif(${SIZEOF_LONG} STREQUAL "4") + set(SAINT32_TYPE "long") + set(SAINT32_PRId "\"ld\"") + elseif(${SIZEOF_SHORT} STREQUAL "4") + set(SAINT32_TYPE "short") + set(SAINT32_PRId "\"d\"") + elseif(${SIZEOF___INT32} STREQUAL "4") + set(SAINT32_TYPE "__int32") + set(SAINT32_PRId "\"d\"") + else(${SIZEOF_INT} STREQUAL "4") + message(FATAL_ERROR "Cannot find 32-bit integer type") + endif(${SIZEOF_INT} STREQUAL "4") +endif(HAVE_INT32_T) + +## generate divsufsort.h ## +set(DIVSUFSORT_IMPORT "") +set(DIVSUFSORT_EXPORT "") +if(BUILD_SHARED_LIBS) + if(HAVE___DECLSPEC_DLLIMPORT_) + set(DIVSUFSORT_IMPORT "__declspec(dllimport)") + endif(HAVE___DECLSPEC_DLLIMPORT_) + if(HAVE___DECLSPEC_DLLEXPORT_) + set(DIVSUFSORT_EXPORT "__declspec(dllexport)") + endif(HAVE___DECLSPEC_DLLEXPORT_) +endif(BUILD_SHARED_LIBS) +set(SAINDEX_TYPE "${SAINT32_TYPE}") +set(SAINDEX_PRId "${SAINT32_PRId}") +set(SAINT_PRId "${SAINT32_PRId}") +configure_file("${CMAKE_CURRENT_SOURCE_DIR}/divsufsort.h.cmake" + "${CMAKE_CURRENT_BINARY_DIR}/divsufsort.h" @ONLY) +install(FILES "${CMAKE_CURRENT_BINARY_DIR}/divsufsort.h" DESTINATION include) diff --git a/include/Makefile.am b/include/Makefile.am deleted file mode 100644 index 3bd3b45..0000000 --- a/include/Makefile.am +++ /dev/null @@ -1,4 +0,0 @@ -# Makefile.am for libdivsufsort - -nodist_include_HEADERS = divsufsort.h -EXTRA_DIST = divsufsort_private.h.in divsufsort.h.in diff --git a/include/config.h.cmake b/include/config.h.cmake new file mode 100644 index 0000000..a2223da --- /dev/null +++ b/include/config.h.cmake @@ -0,0 +1,57 @@ +/* + * config.h for libdivsufsort + * Copyright (c) 2003-2008 Yuta Mori All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person + * obtaining a copy of this software and associated documentation + * files (the "Software"), to deal in the Software without + * restriction, including without limitation the rights to use, + * copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following + * conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES + * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR + * OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef _CONFIG_H +#define _CONFIG_H 1 + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** Define to the version of this package. **/ +#cmakedefine PROJECT_VERSION_FULL "${PROJECT_VERSION_FULL}" + +/** Define to 1 if you have the header files. **/ +#cmakedefine HAVE_INTTYPES_H 1 +#cmakedefine HAVE_STDDEF_H 1 +#cmakedefine HAVE_STDINT_H 1 +#cmakedefine HAVE_STDLIB_H 1 +#cmakedefine HAVE_STRING_H 1 +#cmakedefine HAVE_STRINGS_H 1 +#cmakedefine HAVE_MEMORY_H 1 +#cmakedefine HAVE_SYS_TYPES_H 1 + +/** for inline **/ +#ifndef INLINE +# define INLINE @INLINE@ +#endif + + +#ifdef __cplusplus +} /* extern "C" */ +#endif /* __cplusplus */ + +#endif /* _CONFIG_H */ diff --git a/include/divsufsort.h.in b/include/divsufsort.h.cmake index 742880c..73feefe 100644 --- a/include/divsufsort.h.in +++ b/include/divsufsort.h.cmake @@ -24,36 +24,42 @@ * OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef _DIVSUFSORT_H_ -#define _DIVSUFSORT_H_ +#ifndef _DIVSUFSORT_H +#define _DIVSUFSORT_H 1 #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ -#if @_HAVE_INTTYPES_H_@ /* _HAVE_INTTYPES_H_ */ -# include <inttypes.h> -#else -# if @_HAVE_STDINT_H_@ /* _HAVE_STDINT_H_ */ -# include <stdint.h> -# else - -#ifndef _UINT8_T -#define _UINT8_T -typedef unsigned char uint8_t; -#endif /* _UINT8_T */ -#ifndef _INT32_T -#define _INT32_T -typedef int int32_t; -#endif /* _INT32_T */ +@INCFILE@ +#ifndef DIVSUFSORT_API +# ifdef DIVSUFSORT_BUILD_DLL +# define DIVSUFSORT_API @DIVSUFSORT_EXPORT@ +# else +# define DIVSUFSORT_API @DIVSUFSORT_IMPORT@ # endif #endif /*- Datatypes -*/ -typedef int32_t saint_t; -typedef int32_t saidx_t; -typedef uint8_t sauchar_t; +#ifndef SAUCHAR_T +#define SAUCHAR_T +typedef @SAUCHAR_TYPE@ sauchar_t; +#endif /* SAUCHAR_T */ +#ifndef SAINT_T +#define SAINT_T +typedef @SAINT32_TYPE@ saint_t; +#endif /* SAINT_T */ +#ifndef SAIDX_T +#define SAIDX_T +typedef @SAINDEX_TYPE@ saidx_t; +#endif /* SAIDX_T */ +#ifndef PRIdSAINT_T +#define PRIdSAINT_T @SAINT_PRId@ +#endif /* PRIdSAINT_T */ +#ifndef PRIdSAIDX_T +#define PRIdSAIDX_T @SAINDEX_PRId@ +#endif /* PRIdSAIDX_T */ /*- Prototypes -*/ @@ -65,6 +71,7 @@ typedef uint8_t sauchar_t; * @param n The length of the given string. * @return 0 if no error occurred, -1 or -2 otherwise. */ +DIVSUFSORT_API saint_t divsufsort(const sauchar_t *T, saidx_t *SA, saidx_t n); @@ -76,6 +83,7 @@ divsufsort(const sauchar_t *T, saidx_t *SA, saidx_t n); * @param n The length of the given string. * @return The primary index if no error occurred, -1 or -2 otherwise. */ +DIVSUFSORT_API saidx_t divbwt(const sauchar_t *T, sauchar_t *U, saidx_t *A, saidx_t n); @@ -83,17 +91,20 @@ divbwt(const sauchar_t *T, sauchar_t *U, saidx_t *A, saidx_t n); * Returns the version of the divsufsort library. * @return The version number string. */ +DIVSUFSORT_API const char * divsufsort_version(void); /* Burrows-Wheeler transform. */ +DIVSUFSORT_API saint_t bw_transform(const sauchar_t *T, sauchar_t *U, saidx_t *SA /* can NULL */, saidx_t n, saidx_t *idx); /* Inverse Burrows-Wheeler transform. */ +DIVSUFSORT_API saint_t inverse_bw_transform(const sauchar_t *T, sauchar_t *U, saidx_t *A /* can NULL */, @@ -107,11 +118,13 @@ inverse_bw_transform(const sauchar_t *T, sauchar_t *U, * @param verbose The verbose mode. * @return 0 if no error occurred. */ +DIVSUFSORT_API saint_t sufcheck(const sauchar_t *T, const saidx_t *SA, saidx_t n, saint_t verbose); /* Search for the pattern P in the string T. */ +DIVSUFSORT_API saidx_t sa_search(const sauchar_t *T, saidx_t Tsize, const sauchar_t *P, saidx_t Psize, @@ -119,6 +132,7 @@ sa_search(const sauchar_t *T, saidx_t Tsize, saidx_t *left); /* Search for the character c in the string T. */ +DIVSUFSORT_API saidx_t sa_simplesearch(const sauchar_t *T, saidx_t Tsize, const saidx_t *SA, saidx_t SAsize, @@ -129,4 +143,4 @@ sa_simplesearch(const sauchar_t *T, saidx_t Tsize, } /* extern "C" */ #endif /* __cplusplus */ -#endif /* _DIVSUFSORT_H_ */ +#endif /* _DIVSUFSORT_H */ diff --git a/include/divsufsort_private.h.in b/include/divsufsort_private.h index f0d5e02..538e2c0 100644 --- a/include/divsufsort_private.h.in +++ b/include/divsufsort_private.h @@ -24,31 +24,31 @@ * OTHER DEALINGS IN THE SOFTWARE. */ -#ifndef _DIVSUFSORT_PRIVATE_H_ -#define _DIVSUFSORT_PRIVATE_H_ +#ifndef _DIVSUFSORT_PRIVATE_H +#define _DIVSUFSORT_PRIVATE_H 1 #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ -#ifdef HAVE_CONFIG_H +#if HAVE_CONFIG_H # include "config.h" #endif #include <assert.h> #include <stdio.h> #if STDC_HEADERS # include <stdlib.h> -# include <stddef.h> +# include <string.h> #else # if HAVE_STDLIB_H # include <stdlib.h> # endif -#endif -#if HAVE_STRING_H -# if !STDC_HEADERS && HAVE_MEMORY_H +# if HAVE_MEMORY_H # include <memory.h> # endif -# include <string.h> +#endif +#if HAVE_STDDEF_H +# include <stddef.h> #endif #if HAVE_STRINGS_H # include <strings.h> |