Discussion:
[Latex2rtf-users] Installing LaTeX2rtf (Unix/Mac)
S. Noble
2017-01-16 14:50:51 UTC
Permalink
Hello,

This is a question from a Unix novice. I've searched for clarification but found precious little.

Would anyone be able and willing to post a detailed explanation of how to install LaTeX2rtf on the MAC (10.7 Lion & 10.11 El Cap.)? I use TeX and need to collaborate with people who want RTF files.

I've read closely the instructions in the LaTeX2rtf manual, but, my apologies, I'm a Unix novice and much of the instructions are just not that easy to follow.

I know I have to install the developer tools, but after that the procedure gets cloudy.

For example, §2.3.1 of the manual reads as follows:
"1. Edit Makefile for your local configuration. In particular, pay attention to the PREFIX variable. If you do not have root access you might wish to set the makefile variable PREFIX to be your home directory. 
On some machines the cc compiler will issue errors. Therefore the default compiler command in the Makefile is CC=gcc".

First of all, what does "Edit Makefile for your local configuration" actually mean, or, in other words, how do you do this? Secondly, what edits do you actually have to make to Makefile? Thirdly, what is the "PREFIX variable"?

I gather that, in Terminal, you then have to type "make", then "make install" then "make check" and "make install -info" (§2.3.3--§2.3.6). So do you just type the first command on a Terminal line, press return, then the second, and so on, or should the commands "make" etc. be followed by something else? I know how to use Terminal, but I'm not familiar with installing software from source.

Thanks in advance for any clarification anyone might be able to provide.

Steve
Drew McDermott
2017-01-18 05:17:16 UTC
Permalink
[S. Noble]
This is a question from a Unix novice. I've searched for clarification but found precious little.
I'll try to help. I'm not a Unix expert, so hopefully what I say will
be less cryptic than what an expert would say.
Would anyone be able and willing to post a detailed explanation of how to install LaTeX2rtf on the MAC (10.7 Lion & 10.11 El Cap.)? I use TeX and need to collaborate with people who want RTF files.
I've read closely the instructions in the LaTeX2rtf manual, but, my apologies, I'm a Unix novice and much of the instructions are just not that easy to follow.
I know I have to install the developer tools, but after that the procedure gets cloudy.
"1. Edit Makefile for your local configuration. In particular, pay attention to the PREFIX variable. If you do not have root access you might wish to set the makefile variable PREFIX to be your home directory. 
On some machines the cc compiler will issue errors. Therefore the default compiler command in the Makefile is CC=gcc".
First of all, what does "Edit Makefile for your local configuration" actually mean, or, in other words, how do you do this?
A brief description of the 'make' program: 'make' is the principle
tool for defining and building software packages in Unix. When you
run 'make' (at the command line, or in a shell, as we say in
Unix-land), what actually happens is governed by a file normally
called 'Makefile' (no extension). This file contains a set of "goal
definitions," which gives a set of shell commands for (re)building a
piece of a software package; plus a set of subgoals. All 'make G'
does is look up G in the Makefile, first recursively achieve all its
subgoals, then follow the commands defining G. The normal case is
that these commands compile and combine various C programs, but they
can do anything at all. For instance, by convention 'make clean' just
deletes a lot of files. (Sometimes it uninstalls the application, but
sometimes it means "delete files generated along the way that are no
longer useful and have become clutter.")

Okay, to edit the Makefile it is important to use a text editor, NOT a
word processor. You want to see the chracters in a "naked" text file,
with no formatting commands of any kind. You can use 'emacs', 'vi',
'vim', or 'Textedit' (but make sure you set Textedit to edit plain
text, not Rich Text), or any of hundreds of other editors.
Secondly, what edits do you actually have to make to Makefile? Thirdly, what is the "PREFIX variable"?
Variables are used in a Makefile so the same strings don't have to be
typed repeatedly. This makes it easy to change program versions,
directory locations, command-line options, or any other string. I'm
looking at the Makefile for latex2rtf-2.3.12. The first line is

CC?=gcc

which means "set the variable CC to 'gcc' if it isn't set to something
else (usually in your .profile or .bash_profile file)." Variables are
uppercase, and behave like regular shell variables.

The first goal where CC occurs is latex2rtf, defined thus:

latex2rtf: $(OBJS) $(HDRS)
$(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) $(LIBS) -o $(BINARY_NAME)

The first line gives all the subgoals, after a colon. These are the
files that are the values of the OBJS variable and the HDRS variable.

The next line says "Call the compiler (CC) with options given by the
FLAGS variables, output file given by the BINARY_NAME variable,
etc. etc. The default compiler will be 'gcc', because the CC variable
is set to 'gcc'.

What's crazy is that there is no PREFIX variable! It looks to me like
someone decided DESTDIR was a much more mnemonic name, and changed
every occurrence of PREFIX to DESTDIR. Sure enough, in the Changelog
it says "Change PREFIX to DESTDIR to follow the GNU standard".
Unfortunately, they didn't change the README file. You have to be
forgiving to deal with open-source software.

Okay, so let's pretend they did make that change, so that the README
file said "If you do not have root access you might need to set
DESTDIR ...". (If you have an old enough distribution, you'll stick
with PREFIX.) The relevant line of the Makefile is

DESTDIR?=/usr/local

If you install compiled files there, then all users will profit from
your action. (Check to make sure no one has already done this; if
they have, and if make sure '/usr/local' is in your PATH, then you
don't need to install Latex2rtf, unless you're installing a later
version.)

Let me explain that parenthesis a bit more. You can check the value
of PATH by executing

echo $PATH

This will print out the value of PATH, which should be a list of
directories separated by colons. E.g., when I do this I see a long
string that includes this substring:

...:/opt/local/bin:/usr/local/bin:/Applications/scala/bin:...

meaning that when I execute a Unix command, if it starts with the name
of a program, that program will be searched for in all these
directories. /usr/local/bin will be searched after /opt/local/bin and
before /Applications/scala/bin . The order usually reflect the
vagaries of how the (code setting the) PATH variable has been modified
over the years, and is usually irrelevant, because the program will be
found in at most one of these directories. (E.g., 'scalac' is found in
/Applications/scala/bin and nowhere else.)

If /usr/local is not in your PATH, and you want it to be, add the line

export PATH=/usr/local/bin:$PATH

to your .bash_profile file, assuming you use the 'bash' shell. (The
instructions are slightly different for the C shell and other shells.
These initializations files are executed when you create a shell; they
are ordinary shell scripts. The details of exactly which
initialization file is run when are intricate and painful to read
about, which is why the PATH variable is often set more than once and
contains duplicate occurrences of many directory names.)

The only problem with using /usr/local as your DESTDIR is that
ordinary users do not have write access to it. You can get around
this by using the 'sudo' program, but that's not always available.
Ask your local system administrator (who may volunteer to install
latex2rtf for you, which will solve all your problems). If it's a
computer you own all by yourself, then you _are_ the system
administrator, and you _do_ have access to all the directories, at
least if you log in as root, which you normally wouldn't do, but
installing software, at least the 'make install' step, might be an
exception.

The other way to get around the access problem is to install latex2rtf
in a directory you do control. You can create a directory 'software'
in your home directory, /Users/noble, say. Then in the Makefile you
would edit the DESTDIR line to:

DESTDIR?=/Users/noble/software

(Make sure /Users/noble/software is in your PATH. Left as an
exercise.) The latext2rtf goal compiles the entire program (most of
which has been compiled in the course of achieving subgoals). It puts
the resulting executable file (named simply 'latex2rtf' in Unix) in
the same directory as the Makefile. 'make install' moves the
executable to $DESTDIR. If you don't have write permission in that
directory, the goal will fail. (Unix programs return an integer
corresponding to how they fail. There's only one success value: 0.
Any other value describes some error condition. As Tolstoy said, "All
successful programs are alike, every unsuccessful programs is
unsuccessful in its own way.")
I gather that, in Terminal, you then have to type "make", then "make install" then "make check" and "make install -info" (§2.3.3--§2.3.6). So do you just type the first command on a Terminal line, press return, then the second, and so on, or should the commands "make" etc. be followed by something else? I know how to use Terminal, but I'm not familiar with installing software from source.
You guessed right. However, if any step failed, there's no point in
continuing with the sequence, because, if the Makefile is designed
appropriately, every followup goal will have an unachieved subgoal if
the step designed to achieve that subgoal failed.

I hope this was the right amount and kind of information.

-- Drew McDermott
Professor of Computer Science
Yale Computer Science Department
S.N.
2017-01-20 09:35:45 UTC
Permalink
Thanks indeed for that detailed, and very generous, reply.
Steve
Post by Drew McDermott
[S. Noble]
This is a question from a Unix novice. I've searched for clarification but found precious little.
I'll try to help. I'm not a Unix expert, so hopefully what I say will
be less cryptic than what an expert would say.
Would anyone be able and willing to post a detailed explanation of how to install LaTeX2rtf on the MAC (10.7 Lion & 10.11 El Cap.)? I use TeX and need to collaborate with people who want RTF files.
I've read closely the instructions in the LaTeX2rtf manual, but, my apologies, I'm a Unix novice and much of the instructions are just not that easy to follow.
I know I have to install the developer tools, but after that the procedure gets cloudy.
"1. Edit Makefile for your local configuration. In particular, pay attention to the PREFIX variable. If you do not have root access you might wish to set the makefile variable PREFIX to be your home directory. ‹On some machines the cc compiler will issue errors. Therefore the default compiler command in the Makefile is CC=gcc".
First of all, what does "Edit Makefile for your local configuration" actually mean, or, in other words, how do you do this?
A brief description of the 'make' program: 'make' is the principle
tool for defining and building software packages in Unix. When you
run 'make' (at the command line, or in a shell, as we say in
Unix-land), what actually happens is governed by a file normally
called 'Makefile' (no extension). This file contains a set of "goal
definitions," which gives a set of shell commands for (re)building a
piece of a software package; plus a set of subgoals. All 'make G'
does is look up G in the Makefile, first recursively achieve all its
subgoals, then follow the commands defining G. The normal case is
that these commands compile and combine various C programs, but they
can do anything at all. For instance, by convention 'make clean' just
deletes a lot of files. (Sometimes it uninstalls the application, but
sometimes it means "delete files generated along the way that are no
longer useful and have become clutter.")
Okay, to edit the Makefile it is important to use a text editor, NOT a
word processor. You want to see the chracters in a "naked" text file,
with no formatting commands of any kind. You can use 'emacs', 'vi',
'vim', or 'Textedit' (but make sure you set Textedit to edit plain
text, not Rich Text), or any of hundreds of other editors.
Secondly, what edits do you actually have to make to Makefile? Thirdly, what is the "PREFIX variable"?
Variables are used in a Makefile so the same strings don't have to be
typed repeatedly. This makes it easy to change program versions,
directory locations, command-line options, or any other string. I'm
looking at the Makefile for latex2rtf-2.3.12. The first line is
CC?=gcc
which means "set the variable CC to 'gcc' if it isn't set to something
else (usually in your .profile or .bash_profile file)." Variables are
uppercase, and behave like regular shell variables.
latex2rtf: $(OBJS) $(HDRS)
$(CC) $(CFLAGS) $(LDFLAGS) $(OBJS) $(LIBS) -o $(BINARY_NAME)
The first line gives all the subgoals, after a colon. These are the
files that are the values of the OBJS variable and the HDRS variable.
The next line says "Call the compiler (CC) with options given by the
FLAGS variables, output file given by the BINARY_NAME variable,
etc. etc. The default compiler will be 'gcc', because the CC variable
is set to 'gcc'.
What's crazy is that there is no PREFIX variable! It looks to me like
someone decided DESTDIR was a much more mnemonic name, and changed
every occurrence of PREFIX to DESTDIR. Sure enough, in the Changelog
it says "Change PREFIX to DESTDIR to follow the GNU standard".
Unfortunately, they didn't change the README file. You have to be
forgiving to deal with open-source software.
Okay, so let's pretend they did make that change, so that the README
file said "If you do not have root access you might need to set
DESTDIR ...". (If you have an old enough distribution, you'll stick
with PREFIX.) The relevant line of the Makefile is
DESTDIR?=/usr/local
If you install compiled files there, then all users will profit from
your action. (Check to make sure no one has already done this; if
they have, and if make sure '/usr/local' is in your PATH, then you
don't need to install Latex2rtf, unless you're installing a later
version.)
Let me explain that parenthesis a bit more. You can check the value
of PATH by executing
echo $PATH
This will print out the value of PATH, which should be a list of
directories separated by colons. E.g., when I do this I see a long
...:/opt/local/bin:/usr/local/bin:/Applications/scala/bin:...
meaning that when I execute a Unix command, if it starts with the name
of a program, that program will be searched for in all these
directories. /usr/local/bin will be searched after /opt/local/bin and
before /Applications/scala/bin . The order usually reflect the
vagaries of how the (code setting the) PATH variable has been modified
over the years, and is usually irrelevant, because the program will be
found in at most one of these directories. (E.g., 'scalac' is found in
/Applications/scala/bin and nowhere else.)
If /usr/local is not in your PATH, and you want it to be, add the line
export PATH=/usr/local/bin:$PATH
to your .bash_profile file, assuming you use the 'bash' shell. (The
instructions are slightly different for the C shell and other shells.
These initializations files are executed when you create a shell; they
are ordinary shell scripts. The details of exactly which
initialization file is run when are intricate and painful to read
about, which is why the PATH variable is often set more than once and
contains duplicate occurrences of many directory names.)
The only problem with using /usr/local as your DESTDIR is that
ordinary users do not have write access to it. You can get around
this by using the 'sudo' program, but that's not always available.
Ask your local system administrator (who may volunteer to install
latex2rtf for you, which will solve all your problems). If it's a
computer you own all by yourself, then you _are_ the system
administrator, and you _do_ have access to all the directories, at
least if you log in as root, which you normally wouldn't do, but
installing software, at least the 'make install' step, might be an
exception.
The other way to get around the access problem is to install latex2rtf
in a directory you do control. You can create a directory 'software'
in your home directory, /Users/noble, say. Then in the Makefile you
DESTDIR?=/Users/noble/software
(Make sure /Users/noble/software is in your PATH. Left as an
exercise.) The latext2rtf goal compiles the entire program (most of
which has been compiled in the course of achieving subgoals). It puts
the resulting executable file (named simply 'latex2rtf' in Unix) in
the same directory as the Makefile. 'make install' moves the
executable to $DESTDIR. If you don't have write permission in that
directory, the goal will fail. (Unix programs return an integer
corresponding to how they fail. There's only one success value: 0.
Any other value describes some error condition. As Tolstoy said, "All
successful programs are alike, every unsuccessful programs is
unsuccessful in its own way.")
I gather that, in Terminal, you then have to type "make", then "make install" then "make check" and "make install -info" (§2.3.3--§2.3.6). So do you just type the first command on a Terminal line, press return, then the second, and so on, or should the commands "make" etc. be followed by something else? I know how to use Terminal, but I'm not familiar with installing software from source.
You guessed right. However, if any step failed, there's no point in
continuing with the sequence, because, if the Makefile is designed
appropriately, every followup goal will have an unachieved subgoal if
the step designed to achieve that subgoal failed.
I hope this was the right amount and kind of information.
-- Drew McDermott
Professor of Computer Science
Yale Computer Science Department
Loading...