This package consists of two related programs. The first, msort, is the actual sort program. It has a command-line interface and is written in C. The code is quite standard and no exotic libraries are required, so it should compile and run on any POSIX-compliant system.
The one non-standard library required is Ville Laurikari's TRE regular expression library, available at http://laurikari.net/tre/.
The second program, msg, is a graphical front end to msort. It isn't of any real use without msort, but it doesn't literally depend on it. You can run it on a system lacking msort. When it starts up it will report that it cannot find msort, and therefore of course it will not actually sort anything, but if it amuses you, you can still play with it. msg is written in Tcl and uses the Tk toolkit. It is meant to be run under wish, the Tcl/Tk windowing shell. So long as you have Tcl/Tk/wish available, there is nothing much to be done to install msg. Since Tcl is interpreted, no compilation is necessary.
If you do not have Tcl/Tk, don't worry, it is easy
to obtain and install. For most platforms, the easiest
approach is to obtain the ActiveTcl distribution from:
http://www.activestate.com/Products/ActiveTcl
Further information is available at:
http://billposer.org/Software/msort.html
FURTHER DETAILS ON MSORT
Msort has been developed and tested under GNU/Linux. It is known to compile and run without modification under Solaris, FreeBSD, and Mac OS X.
The man page only gives basic information. The real reference manual is Doc/msort.pdf.
INSTALLATION
If you have the GNU autoconf system available, follow the generic installation instructions in INSTALL. In short, these are:
./configure
make
(su)
make install-strip
The last command arranges for the symbol table to be removed from the executable file when it is installed, which results in a substantial reduction in size. If you want to be able to use a debugger on msort you will want to preserve the symbol table, in which case you should give the command:
make install
instead.
There is one non-standard option to configure: --disable-allocaok. By default, in certain situations msort uses the alloca routine to allocate storage on the stack, which is faster than allocating it on the heap. However, alloca is buggy on some systems. If you give configure the option --disable-allocaok, msort will not use alloca. If you know that alloca is funky on your system, or if msort seems to behave strangely, configuring msort with this flag is wise.
For generic details on installation using the the autoconf system, see the file "INSTALLATION". The standard option you are most likely to be interested in is: --prefix=foo, which changes the directories in which msort is installed. For example, by default the executables will be installed in /usr/local/bin. If you prefer to install the executables in your personal bin, in my case, /home/poser/bin, you can configure msort using the command:
./configure --prefix=/home/poser
This will result in the executables being put in /home/poser/bin, the manual page in /home/poser/man/man1, etc.
If you do not have autoconf/automake, or if a problem arises, look in the Doc directory for the file OriginalMakefile and make a copy of it in this directory named Makefile.
To compile, first see if there is anything in the Makefile that you want to change. You may wish to change the default installation directories BINDIR, where the executable goes, and MANDIR, where the manual page goes. The compiler is also set to gcc. If you don't have gcc, or want to use another compiler, change the value of CC.
Then a simple "make" should suffice to compile msort.
To install, su if necessary, then "make install".
Msort uses the TRE regular expression library to match tags and to perform substitutions on keys. This library is available for a wide range of systems but in source form. It must be compiled and installed. Clear instructions for compiling and installing it are provided with the package. However, those not experienced with installing libraries may encounter difficulties.
One problem that you may encounter is that, even after you install the library, the linker (part of the compilation process) says that it cannot find it. This is probably the result of the library having been installed in a directory that the linker does not know about.
To remedy this, you need to run the ldconfig program. On Linux systems this should be located in /sbin, a directory that contains programs normally used only by the system administrator. You will need to be root to run ldconfig.
Ldconfig indexes the standard directories /usr/lib and /lib, any directories listed in the file /etc/ld.so.conf, and directories listed on the command line. If you install the TRE library in a directory other than /lib or /usr/lib, such as the default /usr/local/lib, you will need to tell ldconfig to search that directory. You can do this either by adding the name of the directory to /etc/ld.so.conf or supplying the directory name on the command line, e.g.:
/sbin/ldconfig /usr/local/lib
Another approach is to give the compiler options that it will pass on to the linker to tell it where to look. There are two such options: -L and -rpath. On some systems -L is used for static libraries and -rpath for shared libraries, but there is some variation. It appears always to work if you just use both.
This is especially useful if you do not have root privileges on the system.
In the msort Makefile, the relevant portion looks like this:
msort: ${OBJS}
${CC} -o msort ${OBJS} -ltre
This says that "msort" depends on the files listed in the variable OBJS, namely msort.o, misc.o, etc., and that "msort" is created from these files by running the command that is the value of the variable CC. The value of CC will generally be "gcc". The flag -ltre indicates that the TRE library should be loaded. To tell the linker that the files for the TRE library are located in /usr/local/lib/, change the second line above to:
${CC} -o msort ${OBJS} -L /usr/local/lib -rpath /usr/local/lib -ltre
Of course, if you don't have root privileges you probably can't install TRE in /usr/local/lib. If you install it in one of your own directories, give that directory as argument to -L and -rpath instead, e.g.:
${CC} -o msort ${OBJS} -L /home/wjposer/Src/lib -rpath /home/wjposer/Src/lib -ltre
