I am trying to use the following Makefile in order to compile a LaTeX project.
# LaTeX Makefile
FILE=Tesis
all: $(FILE).pdf
.PHONY: clean
clean:
rm *.aux *.blg *.out *.bbl *.log *.dvi *.idx *.lof *.toc *.pdf
$(FILE).pdf: $(FILE).tex
$(FILE).tex: Generalidades.tex Analisis.tex Diseno.tex Construccion.tex Conclusiones.tex Tesis.bib
latex $(FILE).tex
bibtex $(FILE)
latex $(FILE)
dvipdfm $(FILE).dvi
The file Tesis.pdf doesn't exist. However after running make I get:
make: Nothing to be done for `all'
What is wrong? Thanks.
Your dependency
$(FILE).pdf: $(FILE).tex
has no rule associated with it – it's missing a sequence of indented lines which tell make how to make the PDF from the .tex file. That means it'll always be up to date.
Your second dependency, on the other hand:
$(FILE).tex: Generalidades.tex Analisis.tex ...
latex $(FILE).tex
says ‘$(FILE).tex depends on Generalidades.tex Analisis.tex ..., and to make it [ie, the .tex file] up to date, run latex’. That's not what you mean.
Try
$(FILE).pdf: $(FILE).tex Generalidades.tex Analisis.tex ...
latex $(FILE).tex
...
(By the way, if you use pdflatex then you can generate a PDF file directly from the .tex source. You'll have to use .pdf figures rather than .eps ones, but it's easy to convert .eps figures to .pdf).
Related
Need a fresh pair of eyes on this. Thanks in advance. Isn't the rule '%.html' ? I'm wanting to find all my wiki files and convert them with pandoc to html.
SOURCES = $(shell find $$wiki -name "*.wiki")
HTML=$(patsubst %.wiki,%.html,$(SOURCES))
all: $(HTML)
%.html: $(SOURCES)
#echo -e "Converting wiki file $# to html."
Problem - It was finding other files in directories that had files with spaces.
Solution - Restricted the search with the find command.
I have a Makefile that builds a shapefile as an intermediate steps.
.INTERMEDIATE : senate_boundaries.shp
senate_boundaries.shp : Senate\ shape\ files.zip
unzip -j "$<"
A full shapefile comes with more than just a .shp, but also a .prj file, a .dbf file, and a bunch of others. These files are created when "Senate shape files.zip" is unzipped.
These other files are never an explicit target or dependency.
.INTERMEDIATE : senate_boundaries.prj senate_boundaries.dbf
does not seem to do anything.
How can I tell Make to clean up these other files?
You can add something like this to your recipe:
rm -f $(wildcard Senate\shape\*.prj)
But that will only work for that one file and you would have to manually add each extension to get rid of.
so something like this might do the trick:
rm -f $(shell ls Senate\shape\ | grep -v .shp&)
Another option is to unzip into a temp directory and then copy the file you want out and remove the the temp directory.
Check out my Makefile below. We have a set of graphs that are included in our paper. These graphs can be auto-generated using python scripts. But not all collaborators have the python tools (or need them). What I'd like to do is add rules that lead to this behavior:
An explicit "make graphs" is required to rebuild the graph PDFs (which are also tracked by git).
If the graph PDFs are out of date (relative to their sources), a simple "make" will NOT attempt to rebuild them. Only the main document may be rebuilt.
If any graph PDFs have been updated LATER than the main document (either due to a pull or a "make graphs"), then a "make" will notice that the dependencies have changed and rebuild the document.
If a graph PDF is missing (even if it can be generated by "make graphs"), it's okay for the "make" to just fail.
In searching for a solution, I have found out about "Order-only prerequisites." But this is the converse of what I want. With an order-only prereq, "make" would implicitly cause "make graphs" to happen, but it would not rebuild the document. I don't want a "make graphs" to happen, but I DO want to rebuild the document.
Is it possible to do what I'm trying to do?
Thanks.
MAIN = main
TEXFILES = $(shell find . -name '*.tex')
BIBFILES = $(shell find . -name '*.bib')
FIGURES = $(shell find FIGS/ -name '*.pdf')
GRAPHS = $(shell find GRAPHS/ -name '*.py' | sed -e 's/py/pdf/')
LATEX = pdflatex
BIBTEX = bibtex
default: $(MAIN).pdf
$(MAIN).pdf: $(FIGURES) $(TEXFILES) $(BIBFILES)
$(LATEX) -output-format=pdf $(MAIN)
$(BIBTEX) $(MAIN)
$(LATEX) -output-format=pdf $(MAIN)
$(LATEX) -output-format=pdf $(MAIN)
$(MAIN).ps: $(MAIN).pdf
pdf2ps $(MAIN).pdf $(MAIN).ps
graphs: $(GRAPHS)
GRAPHS/%.pdf: GRAPHS/%.py
cd GRAPHS; python2 $*.py; cd -
clean:
rm -f *~ *.aux *.log *.bbl *.blg *.brf $(MAIN).dvi $(MAIN).ps $(MAIN).pdf
I think all you have to do is ensure make doesn't know how to rebuild the graphs unless the graphs target was requested. Something like this should be enough:
.PHONY: graphs
graphs: $(GRAPHS)
ifeq ($(filter graphs,$(MAKECMDGOALS)),graphs)
GRAPHS/%.pdf: GRAPHS/%.py
cd GRAPHS; python2 $*.py; cd -
endif
I have a number of binary files (images, etc.). I need to copy some of them to an output directory as part of my build process.
The list of files that need to be copied is based on some rather complex logic, and it are generated dynamically by a Python script.
Suppose I have the following in deps.txt:
a.png
b.gif
c.mp4
How could I use a makefile to copy any necessary files to the output directory?
For example, if the output directoryalready included c.mp4 and an out-of-date version of b.gif, running the makefile would copy a.png and b.gif to the output directory (but not c.mp4).
The simplest way, if you're using GNU make, is to use an auto-generated include file, like this:
deps.txt.mk: deps.txt
cat $< | while read f; do echo "\$$(OUTPUT_DIR)/$$f: $$f ; cp $$< $$#"; done > $#
-include deps.txt.mk
If you're not using GNU make, you'll have to use recursion instead: have a rule that creates the makefile (like above), then run $(MAKE) -f deps.txt.mk to actually do the installation. Let me know if you need that example.
I have an existing project where I am adding gettext support. Unfortunately, due to the project's structure and limitations, I cannot go through the recommended route of changing the project over to automake. Also unfortunately, my make-fu is pretty weak and I'm having troubles implementing rules to build my output archive:
Take all .po files in the msg subdir and run msgfmt on them to produce .mo files (in my target dir)
Put the .po files in the directory structure expected by gettext: (dir)/(locale)/LC_MESSAGES/(domainname).mo
Here's what I have so far
MSGSRC=msg/*.po
MSGOBJ=$(addprefix $(TARGET_BUILD_PATH)/$(target)/,$(MSG_SRC:.po=.mo))
$(TARGET_BUILD_PATH)/$(target)/msg/%.mo: msg/%.po
msgfmt -c $< -o $#
# Put in correct place
mkdir -p $(TARGET_BUILD_PATH)/$(target)/msg/$(*F)/LC_MESSAGES
cp $# $(TARGET_BUILD_PATH)/$(target)/msg/$(*F)/LC_MESSAGES/myapp.mo
archive: $(MSGOBJ) (other objs....)
(make the archive tarball...)
The problem with the existing code is that for some reason $(*F) comes out just * instead of the locale name (the .po files are named en_US.po, etc). It also seems incorrect because the target should be the real target, not the hacky msgfmt and copy I have. The directory structure is important because the makefile is run a few times for different cross-compiles ($(target)) and the output is archived into a tarball for installation on the devices.
I assume you can use GNU make.
First of all, let make expand the wildcards. This is important for later postprocessing:
MSGSRC=$(wildcard msg/*.po)
Now you should get lists of file names in MSGSRC and MSGOBJ. Additionally, the make manual marks $(F) as obsolete, and $ (the stem of the name) should contain just the locale. So,
mkdir -p $(TARGET_BUILD_PATH)/$(target)/msg/$*/LC_MESSAGES
should do the trick just fine, the same for the cp rule.
I do it slightly different. Here are my po files:
$ find msg -type f
msg/bg_BG.po
msg/de_DE.po
Here's the Makefile:
MSGLANGS=$(notdir $(wildcard msg/*po))
MSGOBJS=$(addprefix locale/,$(MSGLANGS:.po=.UTF-8/LC_MESSAGES/appname.mo))
gettext: $(MSGOBJS)
locale/%.UTF-8/LC_MESSAGES/appname.mo: msg/%.po
mkdir -p $(dir $#)
msgfmt -c -o $# msg/$*.po
And these are the resulting mo files:
$ find locale -type f
locale/bg_BG.UTF-8/LC_MESSAGES/appname.mo
locale/de_DE.UTF-8/LC_MESSAGES/appname.mo