|
|
|
# libutf8proc Makefile
|
|
|
|
|
|
|
|
# programs
|
|
|
|
AR?=ar
|
|
|
|
CC?=gcc
|
|
|
|
INSTALL=install
|
|
|
|
FIND=find
|
|
|
|
PERL=perl
|
|
|
|
|
|
|
|
# compiler settings
|
|
|
|
CFLAGS ?= -O2
|
|
|
|
PICFLAG = -fPIC
|
|
|
|
C99FLAG = -std=c99
|
Fix Sign-Conversion warnings in library and test code (#214)
* JuliaStrings#169 turn on sign-conversion warnings
Signed-off-by: Mike Glorioso <mike.glorioso@gmail.com>
* JuliaStrings#169 fix sign-conversion warnings for utf8proc.c
fix sign-converstion warnings for utf8proc_iterate
uc requires at most 21 bits to identify a unicode codepoint, so there is no need for it to be unsigned
multiple locations use, modify, or store uc with a signed value
the only exception is line 137 where uc is compared with an unsigned value
fix sign-converstion warnings for utf8proc_tolower, utf8proc_toupper, utf8proc_totitle
all three methods have sign conversion warnings when calling seqindex_decode_index
seqindex_decode_index uses the passed value as an index to an array utf8proc_sequences
as utf8proc_sequences is hard-coded and smaller than 2^31 - 1 we can safely cast to unsigned
fix sign-converstion warnings for utf8proc_decompose_char
lines with this warning use the defined function utf8proc_decompose_lump
in the function, a hardcoded unsigned value (1<<12) is complemented then cast as a signed value
as the intent is to remove the 12th bit flag from options, a signed value, and explicit cast is safe
fix sign-conversion warnings for utf8proc_map_custom
result is declared as signed, but is only expected to contain values between 0 and 4
sizeof returns an unsigned value. result must be cast to unsigned
Signed-off-by: Mike Glorioso <mike.glorioso@gmail.com>
* JuliaStrings#169 fix sign-conversion warnings for test/*
fix sign-conversion warnings for test/tests.c encode
change type for d to match return value of utf8proc_encode_char
fix sign-conversion warnings for test/graphemetest.c checkline
si, i, and j are unsigned size types, utf8proc_map and utf8proc_iterate accept and return signed size types
utf8proc_map treats negative strlen values as 0. the strlen used by the test must be similarly limited
utf8proc_iterate treats negative strlen values as 4 which will be less than the unsigned size
fix unused-but-set-variable warning by checking the glen value
fix sign-conversion warnings for test/case.c main
the if block ensures that tested codepoint fits in wint_t, but needs to include u and l as well
c, u, and l can be safely cast to wint_t
fix sign-conversion warnings for test/iterate.c
all values used for len are below 8, so an explicit cast is safe
updated types for more portable test code
fix sign-conversion warnings for test/printproperty.c main
change type of c to signed to resolve all sign-converstion warnings.
replace sscanf(... &c) wiht sscanf(... &x) followed by explicit sign converstion
Signed-off-by: Mike Glorioso <mike.glorioso@gmail.com>
4 years ago
|
|
|
WCFLAGS = -Wsign-conversion -Wall -Wextra -pedantic
|
|
|
|
UCFLAGS = $(CPPFLAGS) $(CFLAGS) $(PICFLAG) $(C99FLAG) $(WCFLAGS) -DUTF8PROC_EXPORTS $(UTF8PROC_DEFINES)
|
|
|
|
LDFLAG_SHARED = -shared
|
|
|
|
SOFLAG = -Wl,-soname
|
|
|
|
|
|
|
|
# shared-library version MAJOR.MINOR.PATCH ... this may be *different*
|
|
|
|
# from the utf8proc version number because it indicates ABI compatibility,
|
|
|
|
# not API compatibility: MAJOR should be incremented whenever *binary*
|
|
|
|
# compatibility is broken, even if the API is backward-compatible.
|
|
|
|
# The API version number is defined in utf8proc.h.
|
|
|
|
# Be sure to also update these ABI versions in MANIFEST and CMakeLists.txt!
|
|
|
|
MAJOR=3
|
|
|
|
MINOR=0
|
|
|
|
PATCH=0
|
|
|
|
|
|
|
|
# api version (also in utf8proc.h and CMakeLists.txt)
|
|
|
|
VERSION=2.9.0
|
|
|
|
|
|
|
|
OS := $(shell uname)
|
|
|
|
ifeq ($(OS),Darwin) # MacOS X
|
|
|
|
SHLIB_EXT = dylib
|
|
|
|
SHLIB_VERS_EXT = $(MAJOR).dylib
|
|
|
|
else # GNU/Linux, at least (Windows should probably use cmake)
|
|
|
|
SHLIB_EXT = so
|
|
|
|
SHLIB_VERS_EXT = so.$(MAJOR).$(MINOR).$(PATCH)
|
|
|
|
endif
|
|
|
|
|
|
|
|
# installation directories (for 'make install')
|
|
|
|
prefix=/usr/local
|
|
|
|
libdir=$(prefix)/lib
|
|
|
|
includedir=$(prefix)/include
|
|
|
|
pkgconfigdir=$(libdir)/pkgconfig
|
|
|
|
|
|
|
|
pkglibdir=$(libdir:$(prefix)/%=%)
|
|
|
|
pkgincludedir=$(includedir:$(prefix)/%=%)
|
|
|
|
|
|
|
|
# meta targets
|
|
|
|
|
|
|
|
.PHONY: all clean data update manifest install
|
|
|
|
|
|
|
|
all: libutf8proc.a libutf8proc.$(SHLIB_EXT)
|
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -f utf8proc.o libutf8proc.a libutf8proc.$(SHLIB_VERS_EXT) libutf8proc.$(SHLIB_EXT)
|
|
|
|
rm -f libutf8proc.pc
|
|
|
|
ifneq ($(OS),Darwin)
|
|
|
|
rm -f libutf8proc.so.$(MAJOR)
|
|
|
|
endif
|
|
|
|
rm -f test/tests.o test/normtest test/graphemetest test/printproperty test/charwidth test/valid test/iterate test/case test/custom test/misc test/iscase
|
|
|
|
rm -rf MANIFEST.new tmp
|
|
|
|
$(MAKE) -C bench clean
|
|
|
|
$(MAKE) -C data clean
|
|
|
|
|
|
|
|
data: data/utf8proc_data.c.new
|
|
|
|
|
|
|
|
update: data/utf8proc_data.c.new
|
|
|
|
cp -f data/utf8proc_data.c.new utf8proc_data.c
|
|
|
|
|
|
|
|
manifest: MANIFEST.new
|
|
|
|
|
|
|
|
# real targets
|
|
|
|
|
|
|
|
data/utf8proc_data.c.new: libutf8proc.$(SHLIB_EXT) data/data_generator.rb data/charwidths.jl
|
|
|
|
$(MAKE) -C data utf8proc_data.c.new
|
|
|
|
|
|
|
|
utf8proc.o: utf8proc.h utf8proc.c utf8proc_data.c
|
|
|
|
$(CC) $(UCFLAGS) -c -o utf8proc.o utf8proc.c
|
|
|
|
|
|
|
|
libutf8proc.a: utf8proc.o
|
|
|
|
rm -f libutf8proc.a
|
|
|
|
$(AR) crs libutf8proc.a utf8proc.o
|
|
|
|
|
|
|
|
libutf8proc.so.$(MAJOR).$(MINOR).$(PATCH): utf8proc.o
|
|
|
|
$(CC) $(LDFLAGS) $(LDFLAG_SHARED) -o $@ $(SOFLAG) -Wl,libutf8proc.so.$(MAJOR) utf8proc.o
|
|
|
|
chmod a-x $@
|
|
|
|
|
|
|
|
libutf8proc.so: libutf8proc.so.$(MAJOR).$(MINOR).$(PATCH)
|
|
|
|
ln -f -s libutf8proc.so.$(MAJOR).$(MINOR).$(PATCH) $@
|
|
|
|
ln -f -s libutf8proc.so.$(MAJOR).$(MINOR).$(PATCH) $@.$(MAJOR)
|
|
|
|
|
|
|
|
libutf8proc.$(MAJOR).dylib: utf8proc.o
|
|
|
|
$(CC) $(LDFLAGS) -dynamiclib -o $@ $^ -install_name $(libdir)/$@ -Wl,-compatibility_version -Wl,$(MAJOR) -Wl,-current_version -Wl,$(MAJOR).$(MINOR).$(PATCH)
|
|
|
|
|
|
|
|
libutf8proc.dylib: libutf8proc.$(MAJOR).dylib
|
|
|
|
ln -f -s libutf8proc.$(MAJOR).dylib $@
|
|
|
|
|
|
|
|
libutf8proc.pc: libutf8proc.pc.in
|
|
|
|
sed \
|
|
|
|
-e 's#PREFIX#$(prefix)#' \
|
|
|
|
-e 's#LIBDIR#$(pkglibdir)#' \
|
|
|
|
-e 's#INCLUDEDIR#$(pkgincludedir)#' \
|
|
|
|
-e 's#VERSION#$(MAJOR).$(MINOR).$(PATCH)#' \
|
|
|
|
libutf8proc.pc.in > libutf8proc.pc
|
|
|
|
|
|
|
|
install: libutf8proc.a libutf8proc.$(SHLIB_EXT) libutf8proc.$(SHLIB_VERS_EXT) libutf8proc.pc
|
|
|
|
mkdir -m 755 -p $(DESTDIR)$(includedir)
|
|
|
|
$(INSTALL) -m 644 utf8proc.h $(DESTDIR)$(includedir)
|
|
|
|
mkdir -m 755 -p $(DESTDIR)$(libdir)
|
|
|
|
$(INSTALL) -m 644 libutf8proc.a $(DESTDIR)$(libdir)
|
|
|
|
$(INSTALL) -m 755 libutf8proc.$(SHLIB_VERS_EXT) $(DESTDIR)$(libdir)
|
|
|
|
mkdir -m 755 -p $(DESTDIR)$(pkgconfigdir)
|
|
|
|
$(INSTALL) -m 644 libutf8proc.pc $(DESTDIR)$(pkgconfigdir)/libutf8proc.pc
|
|
|
|
ln -f -s libutf8proc.$(SHLIB_VERS_EXT) $(DESTDIR)$(libdir)/libutf8proc.$(SHLIB_EXT)
|
|
|
|
ifneq ($(OS),Darwin)
|
|
|
|
ln -f -s libutf8proc.$(SHLIB_VERS_EXT) $(DESTDIR)$(libdir)/libutf8proc.so.$(MAJOR)
|
|
|
|
endif
|
|
|
|
|
|
|
|
MANIFEST.new:
|
|
|
|
rm -rf tmp
|
|
|
|
$(MAKE) install prefix=/usr DESTDIR=$(PWD)/tmp
|
|
|
|
$(FIND) tmp/usr -mindepth 1 -type l -printf "%P -> %l\n" -or -type f -printf "%P\n" -or -type d -printf "%P/\n" | LC_ALL=C sort > $@
|
|
|
|
rm -rf tmp
|
|
|
|
|
|
|
|
# Test programs
|
|
|
|
|
|
|
|
data/NormalizationTest.txt:
|
|
|
|
$(MAKE) -C data NormalizationTest.txt
|
|
|
|
|
|
|
|
data/GraphemeBreakTest.txt:
|
|
|
|
$(MAKE) -C data GraphemeBreakTest.txt
|
|
|
|
|
|
|
|
data/Lowercase.txt:
|
|
|
|
$(MAKE) -C data Lowercase.txt
|
|
|
|
|
|
|
|
data/Uppercase.txt:
|
|
|
|
$(MAKE) -C data Uppercase.txt
|
|
|
|
|
|
|
|
test/tests.o: test/tests.c test/tests.h utf8proc.h
|
|
|
|
$(CC) $(UCFLAGS) -c -o test/tests.o test/tests.c
|
|
|
|
|
|
|
|
test/normtest: test/normtest.c test/tests.o utf8proc.o utf8proc.h test/tests.h
|
|
|
|
$(CC) $(UCFLAGS) $(LDFLAGS) test/normtest.c test/tests.o utf8proc.o -o $@
|
|
|
|
|
|
|
|
test/graphemetest: test/graphemetest.c test/tests.o utf8proc.o utf8proc.h test/tests.h
|
|
|
|
$(CC) $(UCFLAGS) $(LDFLAGS) test/graphemetest.c test/tests.o utf8proc.o -o $@
|
|
|
|
|
|
|
|
test/printproperty: test/printproperty.c test/tests.o utf8proc.o utf8proc.h test/tests.h
|
|
|
|
$(CC) $(UCFLAGS) $(LDFLAGS) test/printproperty.c test/tests.o utf8proc.o -o $@
|
|
|
|
|
|
|
|
test/charwidth: test/charwidth.c test/tests.o utf8proc.o utf8proc.h test/tests.h
|
|
|
|
$(CC) $(UCFLAGS) $(LDFLAGS) test/charwidth.c test/tests.o utf8proc.o -o $@
|
|
|
|
|
|
|
|
test/valid: test/valid.c test/tests.o utf8proc.o utf8proc.h test/tests.h
|
|
|
|
$(CC) $(UCFLAGS) $(LDFLAGS) test/valid.c test/tests.o utf8proc.o -o $@
|
|
|
|
|
|
|
|
test/iterate: test/iterate.c test/tests.o utf8proc.o utf8proc.h test/tests.h
|
|
|
|
$(CC) $(UCFLAGS) $(LDFLAGS) test/iterate.c test/tests.o utf8proc.o -o $@
|
|
|
|
|
|
|
|
test/iscase: test/iscase.c test/tests.o utf8proc.o utf8proc.h test/tests.h
|
|
|
|
$(CC) $(UCFLAGS) $(LDFLAGS) test/iscase.c test/tests.o utf8proc.o -o $@
|
|
|
|
|
|
|
|
test/case: test/case.c test/tests.o utf8proc.o utf8proc.h test/tests.h
|
|
|
|
$(CC) $(UCFLAGS) $(LDFLAGS) test/case.c test/tests.o utf8proc.o -o $@
|
|
|
|
|
|
|
|
test/custom: test/custom.c test/tests.o utf8proc.o utf8proc.h test/tests.h
|
|
|
|
$(CC) $(UCFLAGS) $(LDFLAGS) test/custom.c test/tests.o utf8proc.o -o $@
|
|
|
|
|
|
|
|
test/misc: test/misc.c test/tests.o utf8proc.o utf8proc.h test/tests.h
|
|
|
|
$(CC) $(UCFLAGS) $(LDFLAGS) -DUNICODE_VERSION='"'`$(PERL) -ne "/^UNICODE_VERSION=/ and print $$';" data/Makefile`'"' test/misc.c test/tests.o utf8proc.o -o $@
|
|
|
|
|
|
|
|
# make release tarball from master branch
|
|
|
|
dist:
|
|
|
|
git archive master --prefix=utf8proc-$(VERSION)/ -o utf8proc-$(VERSION).tar.gz
|
|
|
|
|
|
|
|
check: test/normtest data/NormalizationTest.txt data/Lowercase.txt data/Uppercase.txt test/graphemetest data/GraphemeBreakTest.txt test/printproperty test/case test/iscase test/custom test/charwidth test/misc test/valid test/iterate bench/bench.c bench/util.c bench/util.h utf8proc.o
|
|
|
|
$(MAKE) -C bench
|
|
|
|
test/normtest data/NormalizationTest.txt
|
|
|
|
test/graphemetest data/GraphemeBreakTest.txt
|
|
|
|
test/charwidth
|
|
|
|
test/misc
|
|
|
|
test/valid
|
|
|
|
test/iterate
|
|
|
|
test/case
|
|
|
|
test/iscase data/Lowercase.txt data/Uppercase.txt
|
|
|
|
test/custom
|