diff --git a/.gitignore b/.gitignore index 98d04e5..bb5a955 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ +# Objects and dependencies. *.o -*.a *.d +# Debugging *.dSYM/ core diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 0000000..7b3e1ed --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,41 @@ +# Change Log +All notable changes to this project will be documented in this file. +This project adheres to [Semantic Versioning](http://semver.org/). +This file is inspired by [Keep a `CHANGELOG`](http://keepachangelog.com/). + +## [Unreleased] +### Added +- `Make exports` which outputs shell `export` commands (to avoid global installation) + +### Changed +- More conventional directory layout (#4) + +## [6.0.0] - 2016-01-04 +### Fixed +- Bug in implementation of [WB6](http://unicode.org/reports/tr29/#WB6) +- Special case U+0020 SPACE ' ' as a graphic character +- Clang warnings + +## [6.0.0] - 2016-01-04 +### Added +- Word segmentation using [Unicode word boundaries](http://unicode.org/reports/tr29/#Word_Boundaries). + +### Changed +- Start following [SemVer](http://semver.org) properly. +- All input and output is in UTF-8 +- Fixes to handle non-BMP code points (code points beyond U+FFFF) + +### Removed +- `uni2asc` and `asc2uni` (redundant due to change to UTF-8) + +## [5.1.3] - 2015-11-15 +### Changed +- More idiomatic `make` build system + +### Fixed +- Compiles on modern OS X and Ubuntu + +[Unreleased]: https://github.com/eddieantonio/isri-ocr-evaluation-tools/compare/v6.0.1...HEAD +[6.0.1]: https://github.com/eddieantonio/isri-ocr-evaluation-tools/compare/v6.0.0...v6.0.1 +[6.0.0]: https://github.com/eddieantonio/isri-ocr-evaluation-tools/compare/v5.1.3...v6.0.0 +[5.1.3]: https://github.com/eddieantonio/isri-ocr-evaluation-tools/compare/v5.1.0...v5.1.3 diff --git a/Makefile b/Makefile index ed033ab..59ccb94 100644 --- a/Makefile +++ b/Makefile @@ -1,58 +1,124 @@ -include common.mk +# Copyright 2016 Eddie Antonio Santos +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Install prefix, if installing globally. +# See also: `exports` target +PREFIX = /usr/local +BINDIR = $(PREFIX)/bin +MANDIR = $(PREFIX)/share/man/man1 +# List of all the tools (executables + manual pages) TOOLS = accci accdist accsum accuracy editop editopcost editopsum \ groupacc ngram nonstopacc synctext vote wordacc wordaccci \ wordaccdist wordaccsum wordfreq -PREFIX = /usr/local -BINDIR = $(PREFIX)/bin -MANDIR = $(PREFIX)/share/man/man1 +# Name: libisri, or -lisri +NAME = isri +MAJOR_VERSION = 6 +MINOR_VERSION = 1 + +# All the executables go in bin/ +EXECUTABLES = $(addprefix bin/,$(TOOLS)) +# All manual pages go in share/man/man1 +MANPAGES = $(foreach TOOL,$(TOOLS),share/man/man1/$(TOOL).1) + +include use-libisri-internal.mk -EXECUTABLES = $(foreach D,$(TOOLS),$D/$D) -MANPAGES = $(EXECUTABLES:=.1) -LIB = Modules +LIBRARY.a = lib/lib$(NAME).a +ifeq ($(shell uname -s),Darwin) +LIBRARY.so = $(LIBRARY.a:.a=.dylib) +else +LIBRARY.so = $(LIBRARY.a:.a=.so.$(MAJOR_VERSION).$(MINOR_VERSION)) +endif -all: $(TOOLS) +################################################################################ -# Create every subexecutable. -$(TOOLS): $(LIB) - $(MAKE) -C $@ +# Allows for proper compilation and linking settings for libisri -$(LIB): Modules/word_break_property.h - $(MAKE) -C $@ +all: $(EXECUTABLES) install: install-bin install-man -install-bin: $(TOOLS) +install-bin: $(EXECUTABLES) mkdir -p $(BINDIR) cp $(EXECUTABLES) $(BINDIR)/ -install-man: $(TOOLS) +install-man: $(MANPAGES) mkdir -p $(MANDIR) cp $(MANPAGES) $(MANDIR)/ -clean: clean-lib clean-execs +# Prints a bunch of exports you can source in your shell's startup file. +exports: + @echo '#' ISRI Evaluation Tools + @echo export PATH='$(TOP)bin:$$PATH' + @echo export MANPATH='$(TOP)share/man:$$MANPATH' +ifeq ($(shell uname -s),Darwin) + @echo export DYLD_LIBRARY_PATH='$(TOP)lib:$$DYLD_LIBRARY_PATH' +else + @echo export LD_LIBRARY_PATH='$(TOP)lib:$$LD_LIBRARY_PATH' +endif + +clean: clean-objs clean-execs clean-libs clean-deps clean-test + +clean-libs: + $(RM) $(LIBRARY.a) $(LIBRARY.so) -clean-lib: - $(MAKE) -C Modules clean +clean-objs: + $(RM) $(MODULES:.c=.o) + +clean-deps: + $(RM) $(DEPENDENCIES) clean-execs: $(RM) $(EXECUTABLES) +clean-test: + $(MAKE) -C test clean + TEST_ARGS = -test: $(LIB) - $(MAKE) -C Tests +test: $(LIBRARY.a) + $(MAKE) -C test # Uses https://github.com/alexch/rerun # $ gem install rerun watch: rerun --clear --exit --pattern '**/*.{c,h}' -- make test -# Generate the include file, required by libisri.a -Modules/word_break_property.h: Supplement/generate_word_break.py Supplement/WordBreakProperty.txt.gz - ./$< > $@ - -.PHONY: all clean clean-lib clean-execs install install-bin install-bin +.PHONY: all +.PHONY: install install-bin install-man +.PHONY: clean clean-deps clean-execs clean-lib clean-objs clean-test .PHONY: test watch -# Always remake subdirs. -.PHONY: $(LIB) $(MODULES) +################################################################################ + +# Executable sources are C files that provide a main() for executables. +EXECUTABLE_SOURCES := $(foreach TOOL,$(TOOLS),src/$(TOOL).c) +# Modules are all object files exclusively for inclusion in libisri +MODULE_SOURCES := $(filter-out $(EXECUTABLE_SOURCES),$(wildcard src/*.c)) +MODULES := $(MODULE_SOURCES:.c=.o) +# Dependencies are .d files included by Make +DEPENDENCIES := $(EXECUTABLES:=.d) $(MODULES:.o=.d) + +-include $(DEPENDENCIES) + +# Rules for building executables; they are statically linked with the library. +bin/%: src/%.c $(LIBRARY.a) + $(LINK.c) -o $@ $< $(LDLIBS) + +$(LIBRARY.a): $(MODULES) + $(AR) $(ARFLAGS) -s $@ $^ + +# Special case: Generate this include file, required by libisri.a +$(TOP)src/word_break_property.h src/word_break_property.h: \ + libexec/generate_word_break.py libexec/WordBreakProperty.txt.gz + ./$< > $@ diff --git a/Modules/Makefile b/Modules/Makefile deleted file mode 100644 index 10ec342..0000000 --- a/Modules/Makefile +++ /dev/null @@ -1,25 +0,0 @@ -# Get LOCAL_INCLUDE_DIR -include ../common.mk - -CPPFLAGS += -MMD - -LIB = libisri.a -SRCS = $(wildcard *.c) -OBJS = $(patsubst %.c,%.o,$(SRCS)) -DEPS := $(patsubst %.c,%.d,$(SRCS)) - -# Standard targets. -all: $(LIB) - -$(LIB): $(OBJS) - $(AR) $(ARFLAGS) -s $@ $^ - -# Include dependencies from -d --include $(DEPS) - -clean: - -$(RM) $(LIB) - -$(RM) *.o - -$(RM) *.d - -.PHONY: all clean diff --git a/README.md b/README.md index 6d76b2b..2cc2be8 100644 --- a/README.md +++ b/README.md @@ -20,8 +20,6 @@ Using [Homebrew][brew]: Building ======== -Each subdirectory contains the source for one program, a Unix man -page, and a Makefile. Most programs depend on a library in Modules/ To build the library and all of the programs, simply type `make`. ## Dependencies @@ -61,12 +59,20 @@ The manual way: make -## Installing +## Installing globally Install to `/usr/local/`: make install +## Installing "locally" + +This will not copy any files at all, but instead create the appropriate +shell commands to add all executables, man pages, and libraries to +the correct path (replace `~/.bashrc` with your start-up file): + + make exports >> ~/.bashrc + # Porting Credits Ported by Eddie Antonio Santos, 2015, 2016. See analytical-tools/NOTICE diff --git a/accci/.gitignore b/accci/.gitignore deleted file mode 100644 index ecb92c5..0000000 --- a/accci/.gitignore +++ /dev/null @@ -1 +0,0 @@ -accci diff --git a/accci/Makefile b/accci/Makefile deleted file mode 100644 index 7f3f505..0000000 --- a/accci/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -include ../use_lib.mk - -# The name of this directory is also the name of the binary: -BIN = $(notdir $(abspath .)) -$(BIN): $(BIN).c diff --git a/accdist/.gitignore b/accdist/.gitignore deleted file mode 100644 index 932cbaa..0000000 --- a/accdist/.gitignore +++ /dev/null @@ -1 +0,0 @@ -accdist diff --git a/accdist/Makefile b/accdist/Makefile deleted file mode 100644 index 7f3f505..0000000 --- a/accdist/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -include ../use_lib.mk - -# The name of this directory is also the name of the binary: -BIN = $(notdir $(abspath .)) -$(BIN): $(BIN).c diff --git a/accsum/.gitignore b/accsum/.gitignore deleted file mode 100644 index d42ffa6..0000000 --- a/accsum/.gitignore +++ /dev/null @@ -1 +0,0 @@ -accsum diff --git a/accsum/Makefile b/accsum/Makefile deleted file mode 100644 index 7f3f505..0000000 --- a/accsum/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -include ../use_lib.mk - -# The name of this directory is also the name of the binary: -BIN = $(notdir $(abspath .)) -$(BIN): $(BIN).c diff --git a/accuracy/.gitignore b/accuracy/.gitignore deleted file mode 100644 index 6259720..0000000 --- a/accuracy/.gitignore +++ /dev/null @@ -1 +0,0 @@ -accuracy diff --git a/accuracy/Makefile b/accuracy/Makefile deleted file mode 100644 index 7f3f505..0000000 --- a/accuracy/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -include ../use_lib.mk - -# The name of this directory is also the name of the binary: -BIN = $(notdir $(abspath .)) -$(BIN): $(BIN).c diff --git a/bin/.gitignore b/bin/.gitignore new file mode 100644 index 0000000..72e8ffc --- /dev/null +++ b/bin/.gitignore @@ -0,0 +1 @@ +* diff --git a/common.mk b/common.mk deleted file mode 100644 index e79b194..0000000 --- a/common.mk +++ /dev/null @@ -1,8 +0,0 @@ -# Compilation flags for all files. -override CFLAGS := $(CFLAGS) -ansi -# X/Open 6.0 standardizes features used in this K&R C source... -CPPDEFINES = -D_XOPEN_SOURCE=600 -# utf8proc lib usually lives in here: -CPPFLAGS := $(CPPFLAGS) -I/usr/local/include $(CPPDEFINES) -LDFLAGS += -L/usr/local/lib -LDLIBS = -lm -lutf8proc diff --git a/editop/.gitignore b/editop/.gitignore deleted file mode 100644 index de292fb..0000000 --- a/editop/.gitignore +++ /dev/null @@ -1 +0,0 @@ -editop diff --git a/editop/Makefile b/editop/Makefile deleted file mode 100644 index 7f3f505..0000000 --- a/editop/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -include ../use_lib.mk - -# The name of this directory is also the name of the binary: -BIN = $(notdir $(abspath .)) -$(BIN): $(BIN).c diff --git a/editopcost/.gitignore b/editopcost/.gitignore deleted file mode 100644 index 4ab8ed0..0000000 --- a/editopcost/.gitignore +++ /dev/null @@ -1 +0,0 @@ -editopcost diff --git a/editopcost/Makefile b/editopcost/Makefile deleted file mode 100644 index 7f3f505..0000000 --- a/editopcost/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -include ../use_lib.mk - -# The name of this directory is also the name of the binary: -BIN = $(notdir $(abspath .)) -$(BIN): $(BIN).c diff --git a/editopsum/.gitignore b/editopsum/.gitignore deleted file mode 100644 index 55c6b53..0000000 --- a/editopsum/.gitignore +++ /dev/null @@ -1 +0,0 @@ -editopsum diff --git a/editopsum/Makefile b/editopsum/Makefile deleted file mode 100644 index 7f3f505..0000000 --- a/editopsum/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -include ../use_lib.mk - -# The name of this directory is also the name of the binary: -BIN = $(notdir $(abspath .)) -$(BIN): $(BIN).c diff --git a/groupacc/.gitignore b/groupacc/.gitignore deleted file mode 100644 index d285f86..0000000 --- a/groupacc/.gitignore +++ /dev/null @@ -1 +0,0 @@ -groupacc diff --git a/groupacc/Makefile b/groupacc/Makefile deleted file mode 100644 index 7f3f505..0000000 --- a/groupacc/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -include ../use_lib.mk - -# The name of this directory is also the name of the binary: -BIN = $(notdir $(abspath .)) -$(BIN): $(BIN).c diff --git a/lib/.gitignore b/lib/.gitignore new file mode 100644 index 0000000..94963ce --- /dev/null +++ b/lib/.gitignore @@ -0,0 +1,5 @@ +# Ensure that this directory exists in git +# but ignore every file that it will be used for. +*.a +*.so +*.so.* diff --git a/Supplement/WordBreakProperty.txt.gz b/libexec/WordBreakProperty.txt.gz similarity index 100% rename from Supplement/WordBreakProperty.txt.gz rename to libexec/WordBreakProperty.txt.gz diff --git a/Supplement/generate_word_break.py b/libexec/generate_word_break.py similarity index 91% rename from Supplement/generate_word_break.py rename to libexec/generate_word_break.py index bdd9a26..147a310 100755 --- a/Supplement/generate_word_break.py +++ b/libexec/generate_word_break.py @@ -25,31 +25,31 @@ import sys import gzip -PROLOGUE = r''' +PROLOGUE = '''\ /* AUTOGENERATED FILE! DO NOT MODIFY. * See Supplement/generate_word_break.py */ -'''.lstrip() +''' -STRUCT_DEF = r''' +STRUCT_DEF = '''\ typedef struct { Charvalue start, end; wb_property value; } wb_range; -'''.lstrip() +''' -ENUM_TEMP = r''' +ENUM_TEMP = '''\ typedef enum { %s } %s; -'''.lstrip() +''' -TABLE_TEMP = r''' +TABLE_TEMP = '''\ static const wb_range WORD_BREAK_PROPERTY[] = { %s }; -'''.lstrip() +''' -CATEGORY_NAMES = r''' +CATEGORY_NAMES = '''\ Other CR LF @@ -128,8 +128,11 @@ def to_c_header(values): yield generate_table(values) def enum_name(name): - #return 'WB_' + name - # I don't think the prefix is necessary... + """ + Originally, this added a prefix, but since this file generates a header + that is only included internally and only in *one* file, this is + unnecessary and just clutters up things. + """ return name def generate_enum(name, categories): diff --git a/ngram/.gitignore b/ngram/.gitignore deleted file mode 100644 index a822c3d..0000000 --- a/ngram/.gitignore +++ /dev/null @@ -1 +0,0 @@ -ngram diff --git a/ngram/Makefile b/ngram/Makefile deleted file mode 100644 index 7f3f505..0000000 --- a/ngram/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -include ../use_lib.mk - -# The name of this directory is also the name of the binary: -BIN = $(notdir $(abspath .)) -$(BIN): $(BIN).c diff --git a/nonstopacc/.gitignore b/nonstopacc/.gitignore deleted file mode 100644 index 0098704..0000000 --- a/nonstopacc/.gitignore +++ /dev/null @@ -1 +0,0 @@ -nonstopacc diff --git a/nonstopacc/Makefile b/nonstopacc/Makefile deleted file mode 100644 index 7f3f505..0000000 --- a/nonstopacc/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -include ../use_lib.mk - -# The name of this directory is also the name of the binary: -BIN = $(notdir $(abspath .)) -$(BIN): $(BIN).c diff --git a/accci/accci.1 b/share/man/man1/accci.1 similarity index 100% rename from accci/accci.1 rename to share/man/man1/accci.1 diff --git a/accdist/accdist.1 b/share/man/man1/accdist.1 similarity index 100% rename from accdist/accdist.1 rename to share/man/man1/accdist.1 diff --git a/accsum/accsum.1 b/share/man/man1/accsum.1 similarity index 100% rename from accsum/accsum.1 rename to share/man/man1/accsum.1 diff --git a/accuracy/accuracy.1 b/share/man/man1/accuracy.1 similarity index 100% rename from accuracy/accuracy.1 rename to share/man/man1/accuracy.1 diff --git a/editop/editop.1 b/share/man/man1/editop.1 similarity index 100% rename from editop/editop.1 rename to share/man/man1/editop.1 diff --git a/editopcost/editopcost.1 b/share/man/man1/editopcost.1 similarity index 100% rename from editopcost/editopcost.1 rename to share/man/man1/editopcost.1 diff --git a/editopsum/editopsum.1 b/share/man/man1/editopsum.1 similarity index 100% rename from editopsum/editopsum.1 rename to share/man/man1/editopsum.1 diff --git a/groupacc/groupacc.1 b/share/man/man1/groupacc.1 similarity index 100% rename from groupacc/groupacc.1 rename to share/man/man1/groupacc.1 diff --git a/ngram/ngram.1 b/share/man/man1/ngram.1 similarity index 100% rename from ngram/ngram.1 rename to share/man/man1/ngram.1 diff --git a/nonstopacc/nonstopacc.1 b/share/man/man1/nonstopacc.1 similarity index 100% rename from nonstopacc/nonstopacc.1 rename to share/man/man1/nonstopacc.1 diff --git a/synctext/synctext.1 b/share/man/man1/synctext.1 similarity index 100% rename from synctext/synctext.1 rename to share/man/man1/synctext.1 diff --git a/vote/vote.1 b/share/man/man1/vote.1 similarity index 100% rename from vote/vote.1 rename to share/man/man1/vote.1 diff --git a/wordacc/wordacc.1 b/share/man/man1/wordacc.1 similarity index 100% rename from wordacc/wordacc.1 rename to share/man/man1/wordacc.1 diff --git a/wordaccci/wordaccci.1 b/share/man/man1/wordaccci.1 similarity index 100% rename from wordaccci/wordaccci.1 rename to share/man/man1/wordaccci.1 diff --git a/wordaccdist/wordaccdist.1 b/share/man/man1/wordaccdist.1 similarity index 100% rename from wordaccdist/wordaccdist.1 rename to share/man/man1/wordaccdist.1 diff --git a/wordaccsum/wordaccsum.1 b/share/man/man1/wordaccsum.1 similarity index 100% rename from wordaccsum/wordaccsum.1 rename to share/man/man1/wordaccsum.1 diff --git a/wordfreq/wordfreq.1 b/share/man/man1/wordfreq.1 similarity index 100% rename from wordfreq/wordfreq.1 rename to share/man/man1/wordfreq.1 diff --git a/accci/accci.c b/src/accci.c similarity index 100% rename from accci/accci.c rename to src/accci.c diff --git a/accdist/accdist.c b/src/accdist.c similarity index 100% rename from accdist/accdist.c rename to src/accdist.c diff --git a/Modules/accrpt.c b/src/accrpt.c similarity index 100% rename from Modules/accrpt.c rename to src/accrpt.c diff --git a/Modules/accrpt.h b/src/accrpt.h similarity index 100% rename from Modules/accrpt.h rename to src/accrpt.h diff --git a/accsum/accsum.c b/src/accsum.c similarity index 100% rename from accsum/accsum.c rename to src/accsum.c diff --git a/accuracy/accuracy.c b/src/accuracy.c similarity index 100% rename from accuracy/accuracy.c rename to src/accuracy.c diff --git a/Modules/charclass.c b/src/charclass.c similarity index 100% rename from Modules/charclass.c rename to src/charclass.c diff --git a/Modules/charclass.h b/src/charclass.h similarity index 100% rename from Modules/charclass.h rename to src/charclass.h diff --git a/Modules/ci.c b/src/ci.c similarity index 100% rename from Modules/ci.c rename to src/ci.c diff --git a/Modules/ci.h b/src/ci.h similarity index 100% rename from Modules/ci.h rename to src/ci.h diff --git a/Modules/dist.c b/src/dist.c similarity index 100% rename from Modules/dist.c rename to src/dist.c diff --git a/Modules/dist.h b/src/dist.h similarity index 100% rename from Modules/dist.h rename to src/dist.h diff --git a/editop/editop.c b/src/editop.c similarity index 100% rename from editop/editop.c rename to src/editop.c diff --git a/editopcost/editopcost.c b/src/editopcost.c similarity index 100% rename from editopcost/editopcost.c rename to src/editopcost.c diff --git a/editopsum/editopsum.c b/src/editopsum.c similarity index 100% rename from editopsum/editopsum.c rename to src/editopsum.c diff --git a/Modules/edorpt.c b/src/edorpt.c similarity index 100% rename from Modules/edorpt.c rename to src/edorpt.c diff --git a/Modules/edorpt.h b/src/edorpt.h similarity index 100% rename from Modules/edorpt.h rename to src/edorpt.h diff --git a/groupacc/groupacc.c b/src/groupacc.c similarity index 100% rename from groupacc/groupacc.c rename to src/groupacc.c diff --git a/Modules/isri_version.h b/src/isri_version.h similarity index 100% rename from Modules/isri_version.h rename to src/isri_version.h diff --git a/Modules/list.c b/src/list.c similarity index 100% rename from Modules/list.c rename to src/list.c diff --git a/Modules/list.h b/src/list.h similarity index 100% rename from Modules/list.h rename to src/list.h diff --git a/ngram/ngram.c b/src/ngram.c similarity index 100% rename from ngram/ngram.c rename to src/ngram.c diff --git a/nonstopacc/nonstopacc.c b/src/nonstopacc.c similarity index 100% rename from nonstopacc/nonstopacc.c rename to src/nonstopacc.c diff --git a/Modules/sort.c b/src/sort.c similarity index 100% rename from Modules/sort.c rename to src/sort.c diff --git a/Modules/sort.h b/src/sort.h similarity index 100% rename from Modules/sort.h rename to src/sort.h diff --git a/Modules/stopword.c b/src/stopword.c similarity index 100% rename from Modules/stopword.c rename to src/stopword.c diff --git a/Modules/stopword.h b/src/stopword.h similarity index 100% rename from Modules/stopword.h rename to src/stopword.h diff --git a/Modules/sync.c b/src/sync.c similarity index 100% rename from Modules/sync.c rename to src/sync.c diff --git a/Modules/sync.h b/src/sync.h similarity index 100% rename from Modules/sync.h rename to src/sync.h diff --git a/synctext/synctext.c b/src/synctext.c similarity index 100% rename from synctext/synctext.c rename to src/synctext.c diff --git a/Modules/table.c b/src/table.c similarity index 100% rename from Modules/table.c rename to src/table.c diff --git a/Modules/table.h b/src/table.h similarity index 100% rename from Modules/table.h rename to src/table.h diff --git a/Modules/text.c b/src/text.c similarity index 100% rename from Modules/text.c rename to src/text.c diff --git a/Modules/text.h b/src/text.h similarity index 100% rename from Modules/text.h rename to src/text.h diff --git a/Modules/util.c b/src/util.c similarity index 100% rename from Modules/util.c rename to src/util.c diff --git a/Modules/util.h b/src/util.h similarity index 100% rename from Modules/util.h rename to src/util.h diff --git a/vote/vote.c b/src/vote.c similarity index 100% rename from vote/vote.c rename to src/vote.c diff --git a/Modules/wacrpt.c b/src/wacrpt.c similarity index 100% rename from Modules/wacrpt.c rename to src/wacrpt.c diff --git a/Modules/wacrpt.h b/src/wacrpt.h similarity index 100% rename from Modules/wacrpt.h rename to src/wacrpt.h diff --git a/Modules/word.c b/src/word.c similarity index 100% rename from Modules/word.c rename to src/word.c diff --git a/Modules/word.h b/src/word.h similarity index 100% rename from Modules/word.h rename to src/word.h diff --git a/Modules/word_break_property.h b/src/word_break_property.h similarity index 100% rename from Modules/word_break_property.h rename to src/word_break_property.h diff --git a/wordacc/wordacc.c b/src/wordacc.c similarity index 100% rename from wordacc/wordacc.c rename to src/wordacc.c diff --git a/wordaccci/wordaccci.c b/src/wordaccci.c similarity index 100% rename from wordaccci/wordaccci.c rename to src/wordaccci.c diff --git a/wordaccdist/wordaccdist.c b/src/wordaccdist.c similarity index 100% rename from wordaccdist/wordaccdist.c rename to src/wordaccdist.c diff --git a/wordaccsum/wordaccsum.c b/src/wordaccsum.c similarity index 100% rename from wordaccsum/wordaccsum.c rename to src/wordaccsum.c diff --git a/wordfreq/wordfreq.c b/src/wordfreq.c similarity index 100% rename from wordfreq/wordfreq.c rename to src/wordfreq.c diff --git a/synctext/.gitignore b/synctext/.gitignore deleted file mode 100644 index c7a3d12..0000000 --- a/synctext/.gitignore +++ /dev/null @@ -1 +0,0 @@ -synctext diff --git a/synctext/Makefile b/synctext/Makefile deleted file mode 100644 index 7f3f505..0000000 --- a/synctext/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -include ../use_lib.mk - -# The name of this directory is also the name of the binary: -BIN = $(notdir $(abspath .)) -$(BIN): $(BIN).c diff --git a/Tests/.gitignore b/test/.gitignore similarity index 100% rename from Tests/.gitignore rename to test/.gitignore diff --git a/Tests/Makefile b/test/Makefile similarity index 67% rename from Tests/Makefile rename to test/Makefile index dd2da94..8c7505a 100644 --- a/Tests/Makefile +++ b/test/Makefile @@ -1,9 +1,12 @@ -include ../use_lib.mk +include ../use-libisri-internal.mk test: run ./$< $(TEST_ARGS) + +clean: + $(RM) run run: run.c $(wildcard *_test.c) $(LIBISRI) test_utils.c test_utils.h $(LINK.c) test_utils.c $< -lisri -lutf8proc -o $@ -.PHONY: test +.PHONY: test clean diff --git a/Tests/greatest.h b/test/greatest.h similarity index 100% rename from Tests/greatest.h rename to test/greatest.h diff --git a/Tests/run.c b/test/run.c similarity index 100% rename from Tests/run.c rename to test/run.c diff --git a/Tests/test_utils.c b/test/test_utils.c similarity index 100% rename from Tests/test_utils.c rename to test/test_utils.c diff --git a/Tests/test_utils.h b/test/test_utils.h similarity index 100% rename from Tests/test_utils.h rename to test/test_utils.h diff --git a/Tests/text_test.c b/test/text_test.c similarity index 100% rename from Tests/text_test.c rename to test/text_test.c diff --git a/Tests/word_test.c b/test/word_test.c similarity index 100% rename from Tests/word_test.c rename to test/word_test.c diff --git a/use-libisri-internal.mk b/use-libisri-internal.mk new file mode 100644 index 0000000..6d07668 --- /dev/null +++ b/use-libisri-internal.mk @@ -0,0 +1,24 @@ +# Get absolute path to containing directory: http://stackoverflow.com/a/324782 +TOP := $(dir $(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))) +# For INTERNAL headers! +LOCAL_INCLUDE_DIR := $(abspath $(TOP)src) +# For use with the -L option. +LOCAL_LINK_DIR := $(abspath $(TOP)lib) + +LIBISRI = $(LOCAL_LINK_DIR)/libisri.a + +# Compilation flags for all files. +override CFLAGS += -ansi +# X/Open 6.0 standardizes features used in this K&R C source... +CPPDEFINES = -D_XOPEN_SOURCE=600 +# Create dependency files. +CPPFLAGS = -MMD +# utf8proc lib usually lives in here: +override CPPFLAGS += -I/usr/local/include $(CPPDEFINES) +LDFLAGS += -L/usr/local/lib +LDLIBS = -lm -lutf8proc + +# Use libisri, created in lib/ +override CPPFLAGS += -I$(LOCAL_INCLUDE_DIR) +LDFLAGS += -L$(LOCAL_LINK_DIR) +LDLIBS := -lisri $(LDLIBS) diff --git a/use_lib.mk b/use_lib.mk deleted file mode 100644 index 75f5960..0000000 --- a/use_lib.mk +++ /dev/null @@ -1,11 +0,0 @@ -# Get absolute path to containing directory: http://stackoverflow.com/a/324782 -TOP := $(dir $(CURDIR)/$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))) -LOCAL_INCLUDE_DIR := $(abspath $(TOP)Modules) -LIBISRI = $(LOCAL_INCLUDE_DIR)/libisri.a - -include $(TOP)/common.mk - -# Use libisri, created in Modules/ -CPPFLAGS += -I$(LOCAL_INCLUDE_DIR) -LDFLAGS += -L$(LOCAL_INCLUDE_DIR) -LDLIBS := -lisri $(LDLIBS) diff --git a/vote/.gitignore b/vote/.gitignore deleted file mode 100644 index 3ac35ab..0000000 --- a/vote/.gitignore +++ /dev/null @@ -1 +0,0 @@ -vote diff --git a/vote/Makefile b/vote/Makefile deleted file mode 100644 index 7f3f505..0000000 --- a/vote/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -include ../use_lib.mk - -# The name of this directory is also the name of the binary: -BIN = $(notdir $(abspath .)) -$(BIN): $(BIN).c diff --git a/wordacc/.gitignore b/wordacc/.gitignore deleted file mode 100644 index b39a87d..0000000 --- a/wordacc/.gitignore +++ /dev/null @@ -1 +0,0 @@ -wordacc diff --git a/wordacc/Makefile b/wordacc/Makefile deleted file mode 100644 index 7f3f505..0000000 --- a/wordacc/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -include ../use_lib.mk - -# The name of this directory is also the name of the binary: -BIN = $(notdir $(abspath .)) -$(BIN): $(BIN).c diff --git a/wordaccci/.gitignore b/wordaccci/.gitignore deleted file mode 100644 index 94f395b..0000000 --- a/wordaccci/.gitignore +++ /dev/null @@ -1 +0,0 @@ -wordaccci diff --git a/wordaccci/Makefile b/wordaccci/Makefile deleted file mode 100644 index 7f3f505..0000000 --- a/wordaccci/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -include ../use_lib.mk - -# The name of this directory is also the name of the binary: -BIN = $(notdir $(abspath .)) -$(BIN): $(BIN).c diff --git a/wordaccdist/.gitignore b/wordaccdist/.gitignore deleted file mode 100644 index c91fbc8..0000000 --- a/wordaccdist/.gitignore +++ /dev/null @@ -1 +0,0 @@ -wordaccdist diff --git a/wordaccdist/Makefile b/wordaccdist/Makefile deleted file mode 100644 index 7f3f505..0000000 --- a/wordaccdist/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -include ../use_lib.mk - -# The name of this directory is also the name of the binary: -BIN = $(notdir $(abspath .)) -$(BIN): $(BIN).c diff --git a/wordaccsum/.gitignore b/wordaccsum/.gitignore deleted file mode 100644 index 2f1757a..0000000 --- a/wordaccsum/.gitignore +++ /dev/null @@ -1 +0,0 @@ -wordaccsum diff --git a/wordaccsum/Makefile b/wordaccsum/Makefile deleted file mode 100644 index 7f3f505..0000000 --- a/wordaccsum/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -include ../use_lib.mk - -# The name of this directory is also the name of the binary: -BIN = $(notdir $(abspath .)) -$(BIN): $(BIN).c diff --git a/wordfreq/.gitignore b/wordfreq/.gitignore deleted file mode 100644 index 5595274..0000000 --- a/wordfreq/.gitignore +++ /dev/null @@ -1 +0,0 @@ -wordfreq diff --git a/wordfreq/Makefile b/wordfreq/Makefile deleted file mode 100644 index 7f3f505..0000000 --- a/wordfreq/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -include ../use_lib.mk - -# The name of this directory is also the name of the binary: -BIN = $(notdir $(abspath .)) -$(BIN): $(BIN).c