Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 0 additions & 25 deletions .cvsignore

This file was deleted.

4 changes: 4 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.gitignore export-ignore
.gitattributes export-ignore
nsis/ export-ignore
data/references/ export-ignore
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
/libtool
/ltmain.sh
/configure
/configure~
/config.cache
/config.guess
/config.h
Expand Down
23 changes: 23 additions & 0 deletions INSTALL
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
Basic Installation
==================

libthai can be built by Autotools or Meson

Autotools build
---------------

# Build requirements:
# - libtool
# - libdatrie development package (or https://github.com/tlwg/libdatrie)
Expand All @@ -24,3 +29,21 @@ make install
# In order to uninstall
make uninstall

Meson build
-----------

# Build requirements:
# - meson 1.0 or better
# - doxygen (optional, for documentation generation)
#
# Meson will use local libdatrie if installed, otherwise will automatically
# download and build libdatrie.

# Add -Ddocs=disabled to disable documentation generation
meson setup builddir --buildtype release --default-library both --strip --prefix=...

cd builddir
ninja test

# With elevated permissions if required
ninja install
4 changes: 4 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ SUBDIRS = include src data tests doc

EXTRA_DIST = \
build-aux/git-version-gen \
build-aux/test.map \
meson.build \
meson_options.txt \
subprojects/libdatrie.wrap \
$(NULL)

MAINTAINERCLEANFILES = Makefile.in
Expand Down
8 changes: 8 additions & 0 deletions build-aux/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
compile
config.guess
config.sub
depcomp
install-sh
ltmain.sh
missing
test-driver
1 change: 1 addition & 0 deletions build-aux/test.map
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{global:hello; local:*;};
File renamed without changes.
2 changes: 1 addition & 1 deletion data/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ TDICT_SRC = \
$(srcdir)/tdict-std.txt \
$(srcdir)/tdict-std-compound.txt

EXTRA_DIST = thbrk.abm $(TDICT_SRC)
EXTRA_DIST = thbrk.abm $(TDICT_SRC) meson.build

tdict.txt: $(TDICT_SRC)
cat $(TDICT_SRC) | LC_ALL=C sort -u > tdict.txt
Expand Down
51 changes: 51 additions & 0 deletions data/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
dict_dir = get_option('datadir') / 'libthai'

if not get_option('dict')
subdir_done()
endif

sort = find_program('sort')
cp = find_program('cp')
trietool = find_program('trietool')

dictionary = custom_target(
'tdict',
command: [sort, '-u', '-o', '@OUTPUT@', '@INPUT@'],
env: {'LC_ALL': 'C'},
input: [
'tdict-common.txt',
'tdict-collection.txt',
'tdict-currency.txt',
'tdict-district.txt',
'tdict-city.txt',
'tdict-country.txt',
'tdict-geo.txt',
'tdict-history.txt',
'tdict-ict.txt',
'tdict-lang-ethnic.txt',
'tdict-proper.txt',
'tdict-science.txt',
'tdict-slang.txt',
'tdict-spell.txt',
'tdict-std.txt',
'tdict-std-compound.txt',
],
output: ['tdict.txt'],
)
# trietool look for thbrk.abm in the directory of thbrk.tri
# so we need to copy thbrk.abm into the build directory
alphamap = custom_target(
'alphabet_map',
command: [cp, '@INPUT@', '@OUTPUT@'],
input: ['thbrk.abm'],
output: ['thbrk.abm'],
)
tri = custom_target(
'tri',
command: [trietool, 'data/thbrk', 'add-list', '-e', 'utf-8', '@INPUT0@'],
input: [dictionary],
depends: [alphamap],
output: ['thbrk.tri'],
install: true,
install_dir: dict_dir,
)
File renamed without changes.
2 changes: 2 additions & 0 deletions doc/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
EXTRA_DIST = meson.build

if ENABLE_DOXYGEN_DOC

all-local: doxygen.stamp
Expand Down
34 changes: 34 additions & 0 deletions doc/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
if get_option('docs').disabled()
subdir_done()
endif

doxygen = find_program(
'doxygen',
required: get_option('docs'),
version: '>=1.9.1',
)
if not doxygen.found()
subdir_done()
endif

doxyfile_data = configuration_data()
doxyfile_data.set('VERSION', version)
doxyfile_data.set('PACKAGE', meson.project_name())
doxyfile_data.set('top_builddir', meson.project_build_root())
doxyfile_data.set('top_srcdir', meson.project_source_root())

doxyfile = configure_file(
input: 'Doxyfile.in',
output: 'Doxyfile',
configuration: doxyfile_data,
)

custom_target(
'docs',
input: doxyfile,
output: 'html',
command: [doxygen, doxyfile],
depend_files: thai_src + headers_src,
install: true,
install_dir: get_option('docsdir'),
)
File renamed without changes.
1 change: 1 addition & 0 deletions include/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ SUBDIRS = thai

MAINTAINERCLEANFILES = Makefile.in

EXTRA_DIST = meson.build
22 changes: 22 additions & 0 deletions include/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
headers_src = files(
'thai/thailib.h',
'thai/thbrk.h',
'thai/thcell.h',
'thai/thcoll.h',
'thai/thctype.h',
'thai/thinp.h',
'thai/thrend.h',
'thai/thstr.h',
'thai/thwbrk.h',
'thai/thwchar.h',
'thai/thwcoll.h',
'thai/thwctype.h',
'thai/thwinp.h',
'thai/thwrend.h',
'thai/thwstr.h',
'thai/tis.h',
'thai/wtt.h',
)
install_headers(headers_src, subdir: 'thai')

include_dir = include_directories('.')
File renamed without changes.
File renamed without changes.
1 change: 1 addition & 0 deletions man/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ SUBDIRS = man3

MAINTAINERCLEANFILES = Makefile.in

EXTRA_DIST = meson.build
File renamed without changes.
1 change: 1 addition & 0 deletions man/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
install_man('man3/libthai.3', 'man3/thctype.3', 'man3/wtt.3')
48 changes: 48 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
project(
'libthai',
'c',
meson_version: '>=1.0.0',
version: run_command(files('build-aux/git-version-gen'), check: true).stdout().strip(),
)

sh = find_program('sh')
compiler = meson.get_compiler('c')
datrie = dependency('datrie-0.2')

version = run_command(files('build-aux/git-version-gen'), check: true).stdout().strip()
meson.add_dist_script(
sh,
'-c',
'echo "@0@" > "$MESON_DIST_ROOT/VERSION"'.format(version),
)
meson.add_dist_script(sh, '-c', 'cd "$MESON_DIST_ROOT" && ./autogen.sh')
meson.add_dist_script(
sh,
'-c',
'cd "$MESON_DIST_ROOT" && rm -r autom4te.cache autogen.sh || true',
)

LT_CURRENT = 3
LT_REVISION = 1
LT_AGE = 3

soversion = LT_CURRENT - LT_AGE
libversion = '@0@.@1@.@2@'.format(soversion, LT_AGE, LT_REVISION)

# Detect for version-script support
ld_has_version_script = compiler.has_link_argument(
'-Wl,-version-script,@0@'.format(
meson.global_source_root() / 'build-aux' / 'test.map',
),
)

if get_option('buildtype') in ['debug', 'debugoptimized']
add_project_arguments('-DNDEBUG', language: ['c'])
endif

subdir('data')
subdir('include')
subdir('src')
subdir('man')
subdir('doc')
subdir('tests')
3 changes: 3 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
option('docs', type : 'feature', value : 'auto', description : 'Generate documents with Doxygen')
option('docsdir', type : 'string', value : 'share/doc/libthai', description : 'Where to install the Doxygen-generated HTML doc')
option('dict', type : 'boolean', value : true, description : 'Enable dictionary data generation (require libdatrie)')
File renamed without changes.
2 changes: 1 addition & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ SUBDIRS = thctype thstr thcell thinp thrend thcoll thbrk thwchar thwctype \

MAINTAINERCLEANFILES = Makefile.in

EXTRA_DIST = libthai.map libthai.def
EXTRA_DIST = libthai.map libthai.def meson.build

AM_CPPFLAGS = -I. -I$(top_srcdir)/include $(DATRIE_CFLAGS)

Expand Down
6 changes: 4 additions & 2 deletions src/libthai.c
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,10 @@

#include "thbrk/thbrk-priv.h"

__attribute__ ((destructor)) void
_libthai_on_unload ()
#if defined (__GNUC__) || defined (__clang__)
__attribute__ ((destructor))
#endif
void _libthai_on_unload ()
{
brk_free_shared_brk ();
}
Expand Down
85 changes: 85 additions & 0 deletions src/meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
ldflags = []
link_depends = ['libthai.map', 'libthai.def']

if ld_has_version_script
ldflags += [
'-Wl,--version-script,@0@'.format(
meson.current_source_dir() / 'libthai.map',
),
]
elif compiler.get_linker_id() in ['link', 'lld-link']
link_def = custom_target(
'link-def',
input: ['libthai.def'],
# This use ASCII as some PS version do not have UTF8NoBOM
command: [
find_program('powershell'),
'-Command',
'''& {
Write-Output "EXPORTS" | Out-File -Encoding ascii -FilePath @OUTPUT0@
Get-Content -Path @INPUT0@ | Out-File -Append -Encoding ascii -FilePath @OUTPUT0@
}''',
],
output: 'libthai.def',
)
ldflags += ['/def:@0@'.format(link_def.full_path())]
link_depends += [link_def]
else
ldflags += [
'-export-symbols @0@'.format(meson.current_source_dir() / 'libthai.def'),
]
endif

thai_src = files(
'thbrk/brk-common.c',
'thbrk/brk-common.h',
'thbrk/brk-ctype.c',
'thbrk/brk-ctype.h',
'thbrk/brk-maximal.c',
'thbrk/brk-maximal.h',
'thbrk/thbrk-priv.h',
'thbrk/thbrk-utils.h',
'thbrk/thbrk.c',
'thcell/thcell.c',
'thcoll/cweight.c',
'thcoll/cweight.h',
'thcoll/thcoll.c',
'thctype/thctype.c',
'thctype/wtt.c',
'thinp/thinp.c',
'thrend/thrend.c',
'thstr/thstr.c',
'thwbrk/thwbrk.c',
'thwchar/thwchar.c',
'thwctype/thwctype.c',
'thwstr/thwstr.c',
'libthai.c',
)

thai = library(
'thai',
thai_src,
install: true,
link_args: ldflags,
link_depends: link_depends,
c_args: ['-DDICT_DIR="@0@"'.format(dict_dir)],
dependencies: [datrie],
version: libversion,
soversion: soversion,
include_directories: include_dir,
)
libthai_dep = declare_dependency(
include_directories: include_dir,
link_with: thai,
)
meson.override_dependency('libthai', libthai_dep)

pkg = import('pkgconfig')
pkg.generate(
thai,
filebase: 'libthai',
name: 'libthai',
description: 'Thai support library',
version: version,
requires_private: ['datrie-0.2'],
)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading