shiblon / latex-makefile

A Makefile for LaTeX - drop it in, type make, and magic happens.
Other
186 stars 30 forks source link

Makefile.ini user target is first target in Makefile (thus std. target) #134

Closed shiblon closed 8 years ago

shiblon commented 8 years ago

Originally reported on Google Code with ID 121

Hi,

first of all: Great work. I love the features and easy setup. Now the problem:
I am having a:
.PHONY: spell
spell:
       ispell $(onlysources.tex)

however now when I'm trying to run make it only runs this target (since it's the first
one). Sure I can edit your Makefile and append it to the end but I like to not having
to worry about that stuff when I update it.

Thanks!

Reported by andre.rauh on 2011-03-28 22:38:55

shiblon commented 8 years ago
We should probably make a wiki entry for this, as it is a thorny problem.  I can't move
the main target above Makefile.ini for various reasons (it used to be there, stuff
broke, it got moved back).

Not only does "all" not work implicitly anymore, but $(onlysources.tex) is not defined,
yet, so spell won't work properly, either.

I wonder if we should have a special Makefile.extratargets or something...

Reported by shiblon on 2011-04-06 18:16:46

shiblon commented 8 years ago
Actually, I just looked at this in more depth, and there is a way around the default
target issue, but not the variables-not-yet-specified issue.

So, here's the proposal, and it's implemented in the attached file for you to fiddle
with: we load files called "Targets.ini" and $(HOME)/.latex-makefile/Targets.ini (either
or both, as they happen to exist), and we do that after all main targets and variables
are specified.

Let me know how the attached file works for you.  If you like it, I'll push it.

Reported by shiblon on 2011-04-06 18:28:41


shiblon commented 8 years ago
Hi!

Thx for the update. I actually digged a little bit into the issue and found this:
http://www.gnu.org/software/make/manual/make.html#index-processing-a-makefile-27

So if you set this:
.DEFAULT_GOAL := all

in you Makefile then the all will still be the default target and my ispell stuff doesnt
brake it. Personally I think the Variables.ini, Targets.ini is cleaner but since most
users will likely not run into this issue it might be a better idea to just stick with
the Makefile.ini approach (IMHO).

Actually setting the .DEFAULT_GOAL variable in the Makefile.ini also solves the problem.
So maybe even a wiki entry is enough. (I would include it in the Makefile however).

Thanks again for you effort!

Reported by andre.rauh on 2011-04-06 19:28:02

shiblon commented 8 years ago
Thinking a little about it:
I think the most sens makes a 
.DEFAULT_GOAL ?= all

since then someone who actually wants the default goal to be the first target can overwrite
it in the Makefile.ini. But the most other ppl can easily extend it w/o having to know
about .DEFAULT_GOAL.

Reported by andre.rauh on 2011-04-06 19:31:12

shiblon commented 8 years ago
Cool.  I'll add that.  Can you verify that ?= does the right thing in your file?  If
so, I'll commit this change.

Reported by shiblon on 2011-04-06 19:49:58

shiblon commented 8 years ago
Ughh, good that you checked :)
'?=' doesnt work on this special variable. But this worked:
right after your version:
[...]
version     := 2.2.0-rc13
.DEFAULT_GOAL := all
[...]
-include Makefile.ini

And if I want to have a target in Makefile.ini as the default then I can still write
a:
.DEFAULT_GOAL := spell
in my Makefile.ini which overwrite the `all`...

Reported by andre.rauh on 2011-04-06 19:57:10

shiblon commented 8 years ago
Excellent.  I've attached my current makefile for you to try out with these fixes.

Reported by shiblon on 2011-04-06 20:00:00


shiblon commented 8 years ago
Works perfectly! Thx

Reported by andre.rauh on 2011-04-06 20:01:28

shiblon commented 8 years ago
OK.  re61108523ef5 has this change committed.  Pushing rc14 now.

Reported by shiblon on 2011-04-06 20:04:21