Skip to content

Commit

Permalink
Merge pull request #5 from eddieantonio/directory-layout
Browse files Browse the repository at this point in the history
New directory layout. Closes #4
  • Loading branch information
eddieantonio committed Jan 31, 2016
2 parents afffeda + bd2260c commit 29eed5d
Show file tree
Hide file tree
Showing 118 changed files with 194 additions and 190 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
# Objects and dependencies.
*.o
*.a
*.d
# Debugging
*.dSYM/
core
41 changes: 41 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
120 changes: 93 additions & 27 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,58 +1,124 @@
include common.mk
# Copyright 2016 Eddie Antonio Santos <easantos@ualberta.ca>
#
# 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
./$< > $@
25 changes: 0 additions & 25 deletions Modules/Makefile

This file was deleted.

12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion accci/.gitignore

This file was deleted.

5 changes: 0 additions & 5 deletions accci/Makefile

This file was deleted.

1 change: 0 additions & 1 deletion accdist/.gitignore

This file was deleted.

5 changes: 0 additions & 5 deletions accdist/Makefile

This file was deleted.

1 change: 0 additions & 1 deletion accsum/.gitignore

This file was deleted.

5 changes: 0 additions & 5 deletions accsum/Makefile

This file was deleted.

1 change: 0 additions & 1 deletion accuracy/.gitignore

This file was deleted.

5 changes: 0 additions & 5 deletions accuracy/Makefile

This file was deleted.

1 change: 1 addition & 0 deletions bin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*
8 changes: 0 additions & 8 deletions common.mk

This file was deleted.

1 change: 0 additions & 1 deletion editop/.gitignore

This file was deleted.

5 changes: 0 additions & 5 deletions editop/Makefile

This file was deleted.

1 change: 0 additions & 1 deletion editopcost/.gitignore

This file was deleted.

5 changes: 0 additions & 5 deletions editopcost/Makefile

This file was deleted.

1 change: 0 additions & 1 deletion editopsum/.gitignore

This file was deleted.

5 changes: 0 additions & 5 deletions editopsum/Makefile

This file was deleted.

1 change: 0 additions & 1 deletion groupacc/.gitignore

This file was deleted.

5 changes: 0 additions & 5 deletions groupacc/Makefile

This file was deleted.

5 changes: 5 additions & 0 deletions lib/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Ensure that this directory exists in git
# but ignore every file that it will be used for.
*.a
*.so
*.so.*
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down
1 change: 0 additions & 1 deletion ngram/.gitignore

This file was deleted.

Loading

0 comments on commit 29eed5d

Please sign in to comment.