yochju / latex-makefile

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

Post-copy patch #47

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
Suggested feature: allow to add a directory that automatically gets the
final objects or allow to call a script each time final objects are built. 

Reason: Allow to do something with the final targets. In my case, I need to
pass them on a different machine... etc.

Suggested patch:

POSTCOPY := whateverdir

for the pdf, ps and dvi targets, add this:

if [ -d $(POSTCOPY) ]; then \
     $(CP) $@ $(POSTCOPY); \
fi

Original issue reported on code.google.com by fdemes...@gmail.com on 18 Oct 2009 at 9:21

GoogleCodeExporter commented 9 years ago
This is a great idea.  I'll look into it.

Original comment by shiblon on 20 Oct 2009 at 6:20

GoogleCodeExporter commented 9 years ago
I just commited r59.  Please let me know if this works for you.

Right now it defaults to _out in the current directory.  You should be able to 
customize 
it to *anything* by creating Makefile.ini and saying BINARY_TARGET_DIR := 
my/favorite/dir

Original comment by shiblon on 20 Oct 2009 at 6:46

GoogleCodeExporter commented 9 years ago
Great! I'm really happy this thing goes in the trunk (this Makefile is such a 
great
piece of code!) and your implementation is better than mine. 

Minor bug 1: Is there any good reason why you add apostrophes to protect
$(BINARY_TARGET_DIR), $1 and $2 in the function body? If not, then please 
remove them
since it prevents interpretation from things like "~" 

$ if [ -d ~ ]; then echo "works"; else echo "fails"; fi;
works
$ if [ -d '~' ]; then echo "works"; else echo "fails"; fi;
fails

Minor bug 2: copy-binaries-with-logging moves $1 to $2 but checks for existence 
of
$(BINARY_TARGET_DIR), should be $2

Suggested final code:

define copy-binaries-with-logging
if [ -d $2 ]; then \
    if $(CP) $1 $2; then \
        $(ECHO) "$(C_INFO)Copied $1 to $2$(C_RESET)"; \
    else \
        $(ECHO) "$(C_ERROR)Failed to copy $1 to $2$(C_RESET)"; \
    fi; \
fi
endef

Original comment by fdemes...@gmail.com on 21 Oct 2009 at 10:33

GoogleCodeExporter commented 9 years ago
There is, it turns out, a really good reason for using single quotes: ensuring 
that 
directory names work when they have spaces in them, and that accidental 
expansions 
don't occur late in the process.  This has bitten me and others in the past.

If you want to specify files in your home directory, use $HOME in the shell or 
$(HOME) in the makefile (or Makefile.ini) instead of ~.  That will always get 
expanded 
correctly.

Also, I fixed the copy-with-logging function (renamed) to do the right thing as 
you 
suggested, with a minor change.

Let me know how r61 works out for you.

Original comment by shiblon on 21 Oct 2009 at 1:34

GoogleCodeExporter commented 9 years ago
Ok, I see your point for #1, but your fix (using either $HOME or $(HOME)), does 
not
cut it since it doesn't allow any subdirectories.

$ if [ -d `dirname '$HOME'` ]; then echo "works"; else echo "fails"; fi;
works
$ if [ -d `dirname '$HOME/whatever/dir'` ]; then echo "works"; else echo 
"fails"; fi;
fails
$ if [ -d `dirname '$HOME/.'` ]; then echo "works"; else echo "fails"; fi;
fails

Original comment by fdemes...@gmail.com on 21 Oct 2009 at 1:59

GoogleCodeExporter commented 9 years ago
Did you try it?  It works fine:

make BINARY_TARGET_DIR=$HOME/my_dir myfile.pdf

Alternatively, put the following into Makefile.ini:

BINARY_TARGET_DIR := $(HOME)/my_dir

It just has to be fully specified before it gets there.  The shell expansion 
happens 
before the makefile is invoked, so your test commands above are meaningless in 
this 
context.

Original comment by shiblon on 21 Oct 2009 at 2:04

GoogleCodeExporter commented 9 years ago
I swear I tried every combination but now it works... I probably goofed the 
directory
name somehow...

Sorry it works perfectly now. <- me feels stupid :)

Original comment by fdemes...@gmail.com on 21 Oct 2009 at 2:20

GoogleCodeExporter commented 9 years ago
That's fine!  I'm glad it works for you.  Can we consider this bug fixed, then? 
 I'm 
marking it as such, but feel free to reopen if there is another issue.

Original comment by shiblon on 21 Oct 2009 at 3:14

GoogleCodeExporter commented 9 years ago
Hi again!

There is a bug with the test that checks for directory existence, it's always 
true

$ if [ -d `dirname 'doesnotexist'` ]; then echo "yet it fires"; fi;
yet it fires

I just retrieved the last version, created a dummy tex file and here is what i 
get:
= test.tex --> test.d test.dvi (1) =
=  test.aux --> test.bbl =
= test.tex --> test.dvi (2) =
= test.tex --> test.dvi (3) =
Copied 'test.dvi' to '_out_'
Success!  Wrote 1 page, 640 bytes

= test.dvi --> test.ps =
Copied 'test.ps' to '_out_'
= test.ps --> test.pdf =
Copied 'test.pdf' to '_out_'
rm test.paper.make test.embed.make

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

GoogleCodeExporter commented 9 years ago
Define "latest version"?  The dirname invocation has been removed for several 
source 
revisions, now, so I believe you have an old version.

Please try 2.1.35 from the downloads page, or get rd66a68be7f and let me know 
if it is 
still broken.

Original comment by shiblon on 7 Nov 2009 at 3:39

GoogleCodeExporter commented 9 years ago
My bad. I just did an SVN up and well, it obviously wasn't enough since you 
changed
to mercurial.

Original comment by fdemes...@gmail.com on 8 Nov 2009 at 10:13

GoogleCodeExporter commented 9 years ago
Sigh.  I would have hoped that codesite would do a better job of telling people 
that I 
made the switch.  Please accept my apologies.  I'm glad you got it working, 
though!

Original comment by shiblon on 12 Nov 2009 at 1:38