| 1 |
This package consists of two related programs. |
| 2 |
The first, msort, is the actual sort program. |
| 3 |
It has a command-line interface and is written in C. |
| 4 |
The code is quite standard and no exotic libraries |
| 5 |
are required, so it should compile and run on |
| 6 |
any POSIX-compliant system. |
| 7 |
|
| 8 |
The one non-standard library required is |
| 9 |
Ville Laurikari's TRE regular expression library, |
| 10 |
available at http://laurikari.net/tre/. |
| 11 |
|
| 12 |
The second program, msg, is a graphical front end |
| 13 |
to msort. It isn't of any real use without msort, |
| 14 |
but it doesn't literally depend on it. You can |
| 15 |
run it on a system lacking msort. When it starts |
| 16 |
up it will report that it cannot find msort, and |
| 17 |
therefore of course it will not actually sort |
| 18 |
anything, but if it amuses you, you can still play |
| 19 |
with it. msg is written in Tcl and uses the |
| 20 |
Tk toolkit. It is meant to be run under wish, the |
| 21 |
Tcl/Tk windowing shell. So long as you have |
| 22 |
Tcl/Tk/wish available, there is nothing much |
| 23 |
to be done to install msg. Since Tcl is |
| 24 |
interpreted, no compilation is necessary. |
| 25 |
|
| 26 |
If you do not have Tcl/Tk, don't worry, it is easy |
| 27 |
to obtain and install. For most platforms, the easiest |
| 28 |
approach is to obtain the ActiveTcl distribution from: |
| 29 |
http://www.activestate.com/Products/ActiveTcl |
| 30 |
Further information is available at: |
| 31 |
http://billposer.org/Software/msort.html |
| 32 |
|
| 33 |
|
| 34 |
FURTHER DETAILS ON MSORT |
| 35 |
|
| 36 |
Msort has been developed and tested primarily under |
| 37 |
GNU/Linux. I also have access to a machine running |
| 38 |
FreeBSD and am able to test it there. According to |
| 39 |
reports from others, it compiles and runs under |
| 40 |
Solaris and Mac OS X. |
| 41 |
|
| 42 |
The man page only gives basic information. |
| 43 |
The real reference manual is Doc/msort.pdf. |
| 44 |
|
| 45 |
DEPENDENCIES |
| 46 |
|
| 47 |
Msort makes use of several libraries that are not routinely installed. |
| 48 |
The first is Ville Laurikari's regular expression library, wihch may be |
| 49 |
obtained from: http://laurikari.net/tre/. This library is reported to |
| 50 |
work on pretty much all varieties of Unix, including Mac OS X, as well |
| 51 |
as MS Windows XP. |
| 52 |
|
| 53 |
Second, msort requires support for Unicode normalization. It can be compiled to |
| 54 |
use either libicu (International Components for Unicode), which may be obtained |
| 55 |
from http://www.icu-project.org/, or libutf8proc, which may be obtained from |
| 56 |
http://www.flexiguided.de/publications.utf8proc.en.html. ICU is fairly widely |
| 57 |
used, so you already have it on your system. To use it, give the option |
| 58 |
--disable-utf8proc to configure. msort defaults to using utf8proc because |
| 59 |
utf8proc is smaller and easier to install. |
| 60 |
|
| 61 |
Third, msort optionally uses libuninum to handle numbers in systems other than |
| 62 |
the usual Indo-Arabic system. Libuninum is my own library and may be obtained |
| 63 |
from http://billposer.org/Software/libuninum.html. Packages for a variey of systems |
| 64 |
are available. If you do not need support for exotic number systems, you may build |
| 65 |
msort without libuninum. To do this, give the option --disable-uninum to configure. |
| 66 |
|
| 67 |
Libuninum in turn uses the GNU MP library for arbitrary precision arithmetic. |
| 68 |
It is available from http://www.swox.com/gmp/. libgmp is required if libuninum is linked. |
| 69 |
|
| 70 |
To summarize, if you want to build msort with the minimum of trouble, |
| 71 |
you will need libtre and either libutf8proc or libicu. If the latter is |
| 72 |
not already installed, you will probably find it easier to go with the |
| 73 |
libutf8, which is the default. If you do not need to handle exotic number |
| 74 |
systems, you can forgo libuninum and libgmp. To build this minimal configuration, |
| 75 |
call configure as follows: |
| 76 |
|
| 77 |
configure --disable-uninum |
| 78 |
|
| 79 |
On some systems, the autoconfiguration system will not detect the need to link |
| 80 |
to libintl. If this happens to you, give the flag: |
| 81 |
|
| 82 |
LIBS="-lintl" |
| 83 |
|
| 84 |
to configure, e.g.: |
| 85 |
|
| 86 |
./configure LIBS="-lintl" |
| 87 |
|
| 88 |
|
| 89 |
INSTALLATION |
| 90 |
|
| 91 |
If you have the GNU autoconf system available, follow the |
| 92 |
generic installation instructions in INSTALL. In short, these are: |
| 93 |
|
| 94 |
./configure |
| 95 |
make |
| 96 |
make test |
| 97 |
(su) |
| 98 |
make install-strip |
| 99 |
|
| 100 |
The last command arranges for the symbol table to be removed from |
| 101 |
the executable file when it is installed, which results in a substantial |
| 102 |
reduction in size. If you want to be able to use a debugger on msort |
| 103 |
you will want to preserve the symbol table, in which case you should |
| 104 |
give the command: |
| 105 |
|
| 106 |
make install |
| 107 |
|
| 108 |
instead. |
| 109 |
|
| 110 |
"make test" is optional. It executes a set of regression tests. |
| 111 |
The tests run very quickly so don't hesitate to try it. |
| 112 |
The results will be written to the file RegressionTests/TestResults. |
| 113 |
|
| 114 |
There are a few additional tests that are not executed by "make test". |
| 115 |
These are tests that depend on the correct functioning of the locale |
| 116 |
system, including the ability to switch into certain particular locales. |
| 117 |
They are kept separate because they can fail even if msort itself is |
| 118 |
working perfectly. To execute these tests, give the command: |
| 119 |
|
| 120 |
make localetest |
| 121 |
|
| 122 |
The results will be written to the file RegressionTests/LocaleTestResults. |
| 123 |
|
| 124 |
|
| 125 |
There are several non-standard options to configure: |
| 126 |
|
| 127 |
--disable-allocaok |
| 128 |
|
| 129 |
By default, in certain situations msort uses the alloca routine to allocate |
| 130 |
storage on the stack, which is faster than allocating it on the heap. |
| 131 |
However, alloca is buggy on some systems. If you give configure the option |
| 132 |
--disable-allocaok, msort will not use alloca. If you know that alloca |
| 133 |
is funky on your system, or if msort seems to behave strangely, configuring |
| 134 |
msort with this flag is wise. |
| 135 |
|
| 136 |
--disable-uninum |
| 137 |
|
| 138 |
Build without reliance on libuninum. This eliminates the ability to handle |
| 139 |
exotic number systems. |
| 140 |
|
| 141 |
--disable-utf8proc |
| 142 |
|
| 143 |
Use libicu rather than the default of utf8proc for Unicode normalization. |
| 144 |
|
| 145 |
--disable-comparison-count |
| 146 |
|
| 147 |
Eliminates the comparison count. In theory this will speed things up slightly, |
| 148 |
but the speed-up is unlikely to be noticable. |
| 149 |
|
| 150 |
--enable-debugbuild |
| 151 |
|
| 152 |
This adds replaces the default compiler options "-g -O2" with "-ggdb -g3", |
| 153 |
causing the resulting executable to contain the maximum amount of useful |
| 154 |
information for gdb and disabling optimazation. This eliminates the need |
| 155 |
for manual editing of the Makefile. It also defines the MACRO DEBUGBUILD |
| 156 |
in the C files, allowing conditional compilation of code for debugging. |
| 157 |
|
| 158 |
|
| 159 |
For generic details on installation using the the autoconf system, see the |
| 160 |
file "INSTALLATION". The standard option you are most likely to be |
| 161 |
interested in is: --prefix=foo, which changes the directories in which |
| 162 |
msort is installed. For example, by default the executables will be installed |
| 163 |
in /usr/local/bin. If you prefer to install the executables in your personal |
| 164 |
bin, in my case, /home/poser/bin, you can configure msort using the command: |
| 165 |
|
| 166 |
./configure --prefix=/home/poser |
| 167 |
|
| 168 |
This will result in the executables being put in /home/poser/bin, the manual page |
| 169 |
in /home/poser/man/man1, etc. |
| 170 |
|
| 171 |
If you do not have autoconf/automake, or if a problem arises, |
| 172 |
look in the Doc directory for the file OriginalMakefile |
| 173 |
and make a copy of it in this directory named Makefile. |
| 174 |
|
| 175 |
To compile, first see if there is anything in the Makefile |
| 176 |
that you want to change. You may wish to change the default |
| 177 |
installation directories BINDIR, where the executable goes, |
| 178 |
and MANDIR, where the manual page goes. The compiler is also |
| 179 |
set to gcc. If you don't have gcc, or want to use another |
| 180 |
compiler, change the value of CC. |
| 181 |
|
| 182 |
Then a simple "make" should suffice to compile msort. |
| 183 |
|
| 184 |
To install, su if necessary, then "make install". |
| 185 |
|
| 186 |
Msort uses the TRE regular expression library to match tags |
| 187 |
and to perform substitutions on keys. This library is |
| 188 |
available for a wide range of systems but in source form. It |
| 189 |
must be compiled and installed. Clear instructions for |
| 190 |
compiling and installing it are provided with the |
| 191 |
package. However, those not experienced with installing |
| 192 |
libraries may encounter difficulties. |
| 193 |
|
| 194 |
One problem that you may encounter is that, even after you |
| 195 |
install the library, the linker (part of the compilation |
| 196 |
process) says that it cannot find it. This is probably the |
| 197 |
result of the library having been installed in a directory |
| 198 |
that the linker does not know about. |
| 199 |
|
| 200 |
To remedy this, you need to run the ldconfig program. On |
| 201 |
Linux systems this should be located in /sbin, a directory |
| 202 |
that contains programs normally used only by the system |
| 203 |
administrator. You will need to be root to run ldconfig. |
| 204 |
|
| 205 |
Ldconfig indexes the standard directories /usr/lib and /lib, |
| 206 |
any directories listed in the file /etc/ld.so.conf, and |
| 207 |
directories listed on the command line. If you install the |
| 208 |
TRE library in a directory other than /lib or /usr/lib, such |
| 209 |
as the default /usr/local/lib, you will need to tell |
| 210 |
ldconfig to search that directory. You can do this either by |
| 211 |
adding the name of the directory to /etc/ld.so.conf or |
| 212 |
supplying the directory name on the command line, e.g.: |
| 213 |
|
| 214 |
/sbin/ldconfig /usr/local/lib |
| 215 |
|
| 216 |
Another approach is to give the compiler options that it will |
| 217 |
pass on to the linker to tell it where to look. |
| 218 |
There are two such options: -L and -rpath. |
| 219 |
On some systems -L is used for static libraries and -rpath |
| 220 |
for shared libraries, but there is some variation. It appears |
| 221 |
always to work if you just use both. |
| 222 |
|
| 223 |
This is especially useful if you do not have root privileges |
| 224 |
on the system. |
| 225 |
|
| 226 |
In the msort Makefile, the relevant portion looks like this: |
| 227 |
|
| 228 |
|
| 229 |
msort: ${OBJS} |
| 230 |
${CC} -o msort ${OBJS} -ltre |
| 231 |
|
| 232 |
This says that "msort" depends on the files listed in the |
| 233 |
variable OBJS, namely msort.o, misc.o, etc., and that |
| 234 |
"msort" is created from these files by running the command |
| 235 |
that is the value of the variable CC. The value of CC will |
| 236 |
generally be "gcc". The flag -ltre indicates that the TRE |
| 237 |
library should be loaded. To tell the linker that the files |
| 238 |
for the TRE library are located in /usr/local/lib/, change |
| 239 |
the second line above to: |
| 240 |
|
| 241 |
${CC} -o msort ${OBJS} -L /usr/local/lib -rpath /usr/local/lib -ltre |
| 242 |
|
| 243 |
Of course, if you don't have root privileges you probably can't install |
| 244 |
TRE in /usr/local/lib. If you install it in one of your own directories, |
| 245 |
give that directory as argument to -L and -rpath instead, e.g.: |
| 246 |
|
| 247 |
${CC} -o msort ${OBJS} -L /home/wjposer/Src/lib -rpath /home/wjposer/Src/lib -ltre |
| 248 |
|
| 249 |
|
| 250 |
Some sample sort order definition files are provided in the SortOrders subdirectory. |
| 251 |
In addition to serving as examples, some of them may be useful, if, for example, |
| 252 |
you need to sort country names in United Nations order, sort by the Chinese |
| 253 |
Heavenly Stems, or handle traditional Armenian dates. |
| 254 |
|