yochju / latex-makefile

Automatically exported from code.google.com/p/latex-makefile
Other
0 stars 0 forks source link

Cygwin support #57

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
The makefile produces errors within Cygwin. 

findtexmf: -: unknown option
thesis.d:3: *** target pattern contains no `%'.  Stop.

It might be because of spaces within the path ("Program Files") that are
not parenthesized properly. 

I will inspect this deeper but I would love to hear the opinion of the
package manager first: Has it been tried before? If yes, is it an hopeless
goal?

Thanks

Original issue reported on code.google.com by fdemes...@gmail.com on 18 Nov 2009 at 5:08

GoogleCodeExporter commented 9 years ago
I haven't heard of this being used under Cygwin before, but that doesn't mean 
it 
hasn't been done :).  If it doesn't work for some reason, then I'd like to 
figure out why 
and fix it.  Proper path quoting is something I'd like to have throughout my 
makefile.

Try running

make VERBOSE=1 SHELL_DEBUG=1 thesis 2>&1

And attach the output here, if you would.

Original comment by shiblon on 19 Nov 2009 at 1:39

GoogleCodeExporter commented 9 years ago
By the way, I found this:

http://stackoverflow.com/questions/601516/cygwin-make-error-target-pattern-
contains-no

Original comment by shiblon on 19 Nov 2009 at 1:41

GoogleCodeExporter commented 9 years ago
To summarize, it looks like you need to download make 3.80 and install that 
over 
make.exe - the presence of : in the path name is causing this issue.

Let me know if that helps :)

Original comment by shiblon on 19 Nov 2009 at 1:42

GoogleCodeExporter commented 9 years ago
Okay, so you got the first bug. make 3.80 has to be installed over make 3.81 to
remove the "target pattern contains no `%'.  Stop." (instructions can be found 
here
https://developer.mozilla.org/En/Windows_build_prerequisites_using_cygwin)

The second bug is triggered by the spaces inside the names that are not handled
properly. "make: *** No rule to make target `C:/Program', needed by `thesis.d'. 
Stop.". 

For instance, here is my third line of thesis.d:
thesis.aux thesis.aux.make thesis.d thesis.dvi: C:/Program Files/MiKTeX
2.6/tex/generic/oberdiek/etexcmds.sty

I played a little bit with the file and it looks like quoting does not help, but
escaping does. This goes through:
thesis.aux thesis.aux.make thesis.d thesis.dvi: C:/Program\ Files/MiKTeX\
2.6/tex/generic/oberdiek/etexcmds.sty

I'm not sure if the problem can be reproduced under linux but it might so a 
Makefile
fix might be needed here.

Now, after this, the makefile seems to go much better, at least with a minimal 
document.

Minor issues:
- There's a "findtexmf: -: unknown option" that seems to appear, with no 
apparent effect.
- There's a "mv: cannot stat `test.pdf.temp': No such file or directory" but a 
pdf
file still appears. Might be caused by the test for the binary dir.

Not so minor issue:
- Make unfortunately looks at the file creation date to rebuild graphics. The 
problem
is that I checked out everything (sources and built graphics) from SVN, so it 
tries
to rebuild things that are correct. Might be the same under linux.
- Makefile doesn't run bibtex, it's very difficult to debug because of the 
current
protected space bug.

Original comment by fdemes...@gmail.com on 19 Nov 2009 at 9:37

GoogleCodeExporter commented 9 years ago
A couple of things I've found.

1) I wasn't escaping spaces in the generated .d file.  rf71c5b6cae63 fixes this 
- give 
it a try
2) Your bibtex issue is caused by your kpsewhich program.  The kpsewhich 
program 
must be a link to findtexmf on your system, and it is not accepting the '-' 
option, 
which tells it to read from stdin.  Could you verify that for me?  If that's 
the problem, 
I'll need to look into using it in a different way for cygwin users.

Thanks!  Let me know if the linked revision above helps, and I'll do some 
digging 
about findtexmf - perhaps you can help me with that, as well.

Original comment by shiblon on 19 Nov 2009 at 2:35

GoogleCodeExporter commented 9 years ago
I just finished tackling the bibliography problem, too.  I think this will get 
you going 
again.

Try r847c0b4da83a and let me know if it fixes your issues.

Original comment by shiblon on 19 Nov 2009 at 2:56

GoogleCodeExporter commented 9 years ago
1) Escaping works great now! Looks like you're a sed master :)
2) You were right, it looks like kpsewhich.exe and findtexmf.exe are indeed
duplicates in Cygwin. (Not links, just duplicates.)
$ ls -la /cygdrive/c/Program\ Files/MiKTeX\ 2.6/miktex/bin/kpsewhich.exe
-rwx------+ 1 Administrators None 16384 Apr 29  2007 /cygdrive/c/Program 
Files/MiKTeX
2.6/miktex/bin/kpsewhich.exe
$ ls -la /cygdrive/c/Program\ Files/MiKTeX\ 2.6/miktex/bin/findtexmf.exe
-rwx------+ 1 Administrators None 16384 Apr 29  2007 /cygdrive/c/Program 
Files/MiKTeX
2.6/miktex/bin/findtexmf.exe
3)For some reason, even under linux I can't reproduce the effect of your "-"
$ echo "psfonts.map"|kpsewhich -
$ echo "psfonts.map"|kpsewhich -interactive stdin
/usr/local/texlive/2008/texmf-var/fonts/map/dvips/updmap/psfonts.map

Original comment by fdemes...@gmail.com on 19 Nov 2009 at 2:59

GoogleCodeExporter commented 9 years ago
Despite your (terrific) job, the pdf doesn't seem to build properly, at least 
on my
thesis. The reason is that ps2pdf14 (powered by the MiKTeX GPL Ghostscript 8.60)
doesn't seem to take any of your fancy options (adding any single one of them 
crashes
the program). I don't know what is at stake here (ps2pdf, ps2pdf13 and so on), 
so I
can't make any valid guess about what should be really done

Using your make shell debug verbose I got this:

+ ps2pdf14 -dPDFSETTINGS=/printer -dEmbedAllFonts=true -dSubsetFonts=true
-dMaxSubsetPct=100 thesis.ps thesis.pdf.temp
+ '[' x0 = x0 ']'
+ cat thesis.pdf.log
MiKTeX GPL Ghostscript 8.60 (2007-08-01)
Copyright (C) 2007 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Unrecoverable error: undefined in get
Operand stack:
    --nostringval--  true
+ rm -f -f thesis.pdf
+ mv -f thesis.pdf.temp thesis.pdf
mv: cannot stat `thesis.pdf.temp': No such file or directory

Original comment by fdemes...@gmail.com on 19 Nov 2009 at 3:19

GoogleCodeExporter commented 9 years ago
I forgot to say that it works fine if none of your "-dXXXX" options are there.

Original comment by fdemes...@gmail.com on 19 Nov 2009 at 3:21

GoogleCodeExporter commented 9 years ago
Okay, to clarify, if add the following to the top of your .tex file:

%% NOEMBED

does it then work properly (all of it, including bibliography, etc.)?

Original comment by shiblon on 19 Nov 2009 at 3:58

GoogleCodeExporter commented 9 years ago
Everything works with NOEMBED. I'm not sure what the real difference is though.

Original comment by fdemes...@gmail.com on 19 Nov 2009 at 4:58

GoogleCodeExporter commented 9 years ago
The difference is that NO EMBED uses "ps2pdf" with none of those special -d 
options 
(they make fonts embedded, among other things).

So, that's a workaround for now.  If you could send me the output of ps2pdf14 
--help, 
that might give me a good idea of how to fix this issue properly.

Original comment by shiblon on 19 Nov 2009 at 5:21

GoogleCodeExporter commented 9 years ago
Out of curiosity, does it work if you swap -d for -D?  (lowercase to uppercase?)

Original comment by shiblon on 19 Nov 2009 at 6:22

GoogleCodeExporter commented 9 years ago
nope uppercase D doesn't help. I tried updating to Miktex 2.8 it did not change
anything. 

Original comment by fdemes...@gmail.com on 19 Nov 2009 at 10:41

GoogleCodeExporter commented 9 years ago
Interesting.  Yeah, I have read a lot of stuff about cygwin and LaTeX that 
shows that 
there are numerous compatibility issues.

Is ps2pdf not a link to gs in cygwin?  Most ps2pdf scripts are just invocations 
of 
ghostscript with a few options set.  The -d option just passes through to 
ghostscript.

So, if you have "gs" on your system, I might be able to reproduce all of the 
regular 
embedding stuff by just calling out to it directly and bypassing ps2pdf 
completely.  In 
fact, that's a generally better solution anyway.

Any information you can give me along those lines would be great, including 
where 
ps2pdf and friends live, whether they are shell scripts (and their contents), 
and 
whether you have a functioning gs binary on your system.  Knowing its version 
would 
also be helpful.

Meanwhile, NO EMBED should keep you hobbling along.

Original comment by shiblon on 20 Nov 2009 at 2:52

GoogleCodeExporter commented 9 years ago
Okay, so, it looks like the following happens:
-Miktex embeds some version of ghostscript "MiKTeX GPL Ghostscript 8.60 
(2007-08-01)"
in an executable named mgs.exe that has not been updated for a long time, even 
in
Miktex 2.8. This is what gets called automatically when you do a ps2pdf and it
doesn't support your options which gets the Makefile into troubles.
-I also  installed the latest GPL Ghostscript, 8.64, which has en executable 
named
gswin32.exe. After some $PATH stuff, I manage to have the ps2pdf command call 
it and
it does exactly the same error than above except the program version

$ ps2pdf.bat -dPDFSETTINGS=/printer -dEmbedAllFonts=true -dSubsetFonts=true
-dMaxSubsetPct=100 thesis.ps
GPL Ghostscript 8.64 (2009-02-03)
Copyright (C) 2009 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
Unrecoverable error: undefined in get
Operand stack:
    --nostringval--  true

It looks to me that MikTex GPL Ghotscript 8.60 is probably extremely close to 
the
older version of GPL Ghostscript since both of them have a ps2pdf.bat and a
ps2pdf.exe that seem to channel to their executables.

So I have actually 2 versions of Ghostscript, I have no idea what to do with 
them
though to mimic ps2pdf.

Original comment by fdemes...@gmail.com on 20 Nov 2009 at 3:18

GoogleCodeExporter commented 9 years ago
Okay, that gets us on the path.  Can you post the contents of ps2pdf.bat here?

Original comment by shiblon on 20 Nov 2009 at 3:49

GoogleCodeExporter commented 9 years ago
Here you go. I included ps2pdfxx.bat since it might be called. Note that there 
are
also ps2pdf.exe and ps2pdfxx.exe (and ps2pdf14 and others...)

ps2pdf.bat
==========
@echo off
@rem $Id: ps2pdf.bat 6300 2005-12-28 19:56:24Z giles $

rem Convert PostScript to PDF 1.4 (Acrobat 4-and-later compatible).
rem The default PDF compatibility level may change in the future:
rem use ps2pdf12 or ps2pdf13 if you want a specific level.

rem The current default compatibility level is PDF 1.4.
echo -dCompatibilityLevel#1.4 >_.at
goto bot

rem Pass arguments through a file to avoid overflowing the command line.
:top
echo %1 >>_.at
shift
:bot
if not %3/==/ goto top
call ps2pdfxx %1 %2

ps2pdfxx.bat
========
@echo off
@rem $Id: ps2pdfxx.bat 6300 2005-12-28 19:56:24Z giles $
rem Internal batch file for calling pdfwrite driver.

rem The files that call this one (ps2pdf*.bat) write the command-line
rem options into _.at, and then pass the last 2 (or fewer) arguments
rem to this file.

call gssetgs.bat
echo -q -dSAFER -dNOPAUSE -dBATCH -sDEVICE#pdfwrite >_.at2

if "%OS%"=="Windows_NT" goto nt

rem     Run ps2pdf on any Microsoft OS.

if %1/==/ goto usage
if %2/==/ goto usage

rem Watcom C deletes = signs, so use # instead.
rem We have to include the options twice because -I only takes effect if it
rem appears before other options.

:run
echo -sOutputFile#%2 >>_.at2
copy /b /y _.at2+_.at >NUL
echo -c .setpdfwrite -f %1 >>_.at2
%GSC% @_.at @_.at2
goto end

:usage
echo Usage: ps2pdf [options...] input.[e]ps output.pdf
goto end

rem     Run ps2pdf on Windows NT.

:nt
if not CMDEXTVERSION 1 goto run
if %1/==/ goto ntusage
if %2/==/ goto nooutfile
goto run

:ntusage
echo Usage: ps2pdf input.ps [output.pdf]
echo    or: ps2pdf [options...] input.[e]ps output.pdf
goto end

:nooutfile
rem We don't know why the circumlocution with _1 is needed....
set _1=%1
set _outf=%_1:.PS=.pdf%
if %_1%==%_outf% goto addsuff
call ps2pdfxx %1 %_outf%
goto postsuff

:addsuff
call ps2pdfxx %1 %1%.pdf

:postsuff
set _1=
set _outf=

:end
rem     Clean up.
if exist _.at erase _.at
if exist _.at2 erase _.at2

Original comment by fdemes...@gmail.com on 20 Nov 2009 at 3:54

GoogleCodeExporter commented 9 years ago
Wow, I can't see any reason that your ghostscript wouldn't be accepting the -d 
options, but it's been a while since I wrote .bat.  As a workaround, until we 
can figure 
this out using straight ghostscript, I have uploaded r584929918b5d, which 
allows 
you to override the EMBED_OPTIONS to be empty, fixing this issue while still 
allowing 
you to use ps2pdf14.

Give it a spin thusly:

Remove NO EMBED from the top of your file.
Create Makefile.ini and put the following line in it:

EMBED_OPTIONS :=

And give it a try!

Original comment by shiblon on 23 Nov 2009 at 6:12

GoogleCodeExporter commented 9 years ago
OK - sorry for the rapid-fire changes here, but try rd95086cb203d without the 
NOEMBED comment.

What I have done is set up the Makefile to just call "gs" directly with 
appropriate options 
instead of going through whatever madness exists in the form of ps2pdf on the 
system.  
This should work fine for you.

Hopefully.  Fingers crossed.

Original comment by shiblon on 23 Nov 2009 at 6:53

GoogleCodeExporter commented 9 years ago
And it... WORKS!

Perfectly!

The only catch, which is not really one is that gs needed to point to something
sensible with was, in my case, the GPL ghostscript gswin32c. Also note that the 
gs
bundled with miktex doesn't seem to work out of the box so it can't be used for 
this
purpose.

$ mgs
MiKTeX GPL Ghostscript 8.60: Can't find initialization file gs_init.ps.

Great great, Makefile works perfectly on Cygwin!

Original comment by fdemes...@gmail.com on 24 Nov 2009 at 11:27

GoogleCodeExporter commented 9 years ago
Excellent news!  Now, I'd like your opinion on whether we can make this fully 
automatic 
or not.  For example, we could have a fallback strategy for gs, like searching 
for 
gswin32c first, then mgs, then gs.

Thoughts?

Original comment by shiblon on 26 Nov 2009 at 3:10

GoogleCodeExporter commented 9 years ago
Well, I think it's totally possible (and whishable) but I would use the 
following order:
1)$(GS) first, obviously, which should default to gs. After all if there is a 
user
ghostscript set it should be used.
2)gswin32c if there is one (use which). works out of the box like gs
3)mgs if there is one (use which). It's a pain because to avoid the error in my 
above
comment, you will need to run it in a specific directory that depends on its 
path.

$ which mgs
/cygdrive/c/Program Files/MiKTeX 2.8/miktex/bin/mgs
$ pwd
/cygdrive/c/Program Files/MiKTeX 2.8/ghostscript/base
$ mgs
MiKTeX GPL Ghostscript 8.60 (2007-08-01)
Copyright (C) 2007 Artifex Software, Inc.  All rights reserved.
This software comes with NO WARRANTY: see the file PUBLIC for details.
GS>
GS>quit
$ cd ..
$ mgs
MiKTeX GPL Ghostscript 8.60: Can't find initialization file gs_init.ps.

Original comment by fdemes...@gmail.com on 26 Nov 2009 at 7:52

GoogleCodeExporter commented 9 years ago
[deleted comment]
GoogleCodeExporter commented 9 years ago
Reposting from proper account :)

Interesting.  I think for now that I'm going to leave it alone.  I would love 
it if you 
have any amazing ideas about how we can both honor the existence of a user-
specified GS and still fall back in a reasonable way for Cygwin users.  
Meanwhile, I'm 
very happy that you got it working!

I'm uploading 2.1.39 now with the fixes in the revision you tested.  Thanks for 
all of 
your patience with this process.

Original comment by shiblon on 1 Dec 2009 at 3:39

GoogleCodeExporter commented 9 years ago
not sure whether this applies to your case but I ran into the same problem and 
this 
fixed it for me: note that windows doesnt support = in commandline options (!). 
If 
you replace = with # all is fine, so for instance 

ps2pdf14 --dEmbedAllFonts=true -dSubsetFonts=true
-dMaxSubsetPct=100 thesis.ps thesis.pdf

becomes
ps2pdf14 -dEmbedAllFonts#true -dSubsetFonts#true
-dMaxSubsetPct#100 thesis.ps thesis.pdf

That said, my next problem now is -dPDFSETTINGS=/printer. Windows doesnt seem 
to 
like the forward slash.... ideas welcome.

Original comment by pvdput...@gmail.com on 13 Dec 2009 at 1:01

GoogleCodeExporter commented 9 years ago
Two questions:

1) Does the # work on non-Windows platforms? (I'll have to try that)
2) If you quote the options, do they then work properly?

E.g.:

'-dEmbedAllFonts=true' '-dSubsetFonts=true' '-dMaxSubsetPct=100' '-
dPDFSETTINGS=/printer'

Original comment by shiblon on 13 Dec 2009 at 1:39

GoogleCodeExporter commented 9 years ago
# does not work on Unix.  I kind of figured.  I bet the equal sign works on 
Windows 
when quoted.

Original comment by shib...@google.com on 13 Dec 2009 at 1:41

GoogleCodeExporter commented 9 years ago
Try r3bf66c10867d and let me know if it works.

Original comment by shiblon on 13 Dec 2009 at 1:42

GoogleCodeExporter commented 9 years ago
Why bother with this? Your previous patch using gs directly works perfectly!

Original comment by fdemes...@gmail.com on 13 Dec 2009 at 8:49

GoogleCodeExporter commented 9 years ago
Oh, right.  I misread the original post, thinking that the new gs solution was 
not 
working properly.  I am going to revert these changes and leave this bug closed.

Thanks for your help in debugging this, and please do not hesitate to file 
issues as you 
have them.

Original comment by shiblon on 16 Dec 2009 at 4:00