Sphinx: specify html path distinct from BUILDDIR/html? - python-sphinx

In the sphinx Makefile, let's say I specify:
BUILDDIR = buildy_mcbuildface
So that make html creates the documentation webpage under buildy_mcbuildface/html. This is a slight annoyance in that the contents of the html folder must be copied to the server location after each build.
Can I specify the html path directly, or is it always built under $BUILDDIR/html? I have looked at the html options, and I see no such path option.

Here's the solution I came up with:
Add to the Makefile:
HTMLCOPYDIR = /path/to/server/location
and also in the Makefile change, add:
cp -rT $(BUILDDIR)/html $(HTMLCOPYDIR)
after the line:
#$(SPHINXBUILD) -M $# "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

Related

Makefile - pdf generation using LaTeX

I wrote a simple makefile to generate pdf using latex and I succeeded.
However, There are 2 point that irritates me:
when I run make the output PDF is in the same folder where the makefile is written and I want to change that
I want to copy the pdf file generated to another file with another name but I don't know how to do that
Here is a snippet of my code:
# Generating the file
$(FILE).pdf: $(IMAGES) $(PACKAGES) $(COMMON_TEX_SOURCES) $(FILE_TEX_SOURCES) $(FILE_IMAGES)
latexmk -lualatex $(FILE)
##############################################################################
#rule to generate file
file: $(FILE).pdf
Your help is appreciated
To make the target go into a another folder, change the target path:
some/dir/$(FILE).pdf: $(IMAGES) ...
To copy the file from one place to another:
some/other/dir/$(FILE).pdf: some/dir/$(FILE).pdf
cp $< $#

Makefile to process a folder's contents

I have a folder with some markdown files I want to process using pandoc and output them into another folder for a Jekyll site. I am attempting to use the following Makefile:
MARKDOWN = $(wildcard *.md)
jekyll-build : _posts/$(MARKDOWN)
bundle exec jekyll build
_posts/%.md : source/%.md
pandoc -s -t markdown-citations -o $# $<
However, instead of looking for the contents of the _posts folder, make is looking for any *.md files in the current working directory (where I have an index.md file), then complains it can't find _posts/index.md. From this question I gather it's the expected behavior of pattern rules, so my question is: how do I get make to look for all existing files in the source folder and run the recipe on each one of them?
MARKDOWN = $(wildcard source/*.md)
POSTS := $(patsubst source/%,_posts/%, $(MARKDOWN))
jekyll-build : $(POSTS)
...
_posts/%.md : source/%.md
...

Make file with multiple potential dependencies

I'm trying to make a make file for a static page generator, and I'm using jinja and pandoc so far, and the idea is to have a file structure as such
.
|-content
|-public
|-templates
|-Makefile
VPATH=public
TARGETS=$(find content -regex ".*(htm|md)" | sed -e "s/md$/htm/g;s/^content/public/g")
all: $(TARGETS)
#echo fullbuild
public/%: content/%
content/%.md:
# Pandoc script
pandoc -i $# -o ${${#:.md=.htm}:content=public}
content/%.htm:
# Jinja Script
The problem I'm having (At least I think that's it) is that according to me the syntax is
# For a final result
target: dependency
commands
# A rule for dependency
dependency:
commands
My dependencies are in the content dir and my targets are in the public dir that may or may not exist yet, and almost all the files I generate will be htm files, and in that case if the target is public/some/route/to/file.htm the dependency will be any of this two content/some/route/to/file.(htm|md).
I can easily generate by walking the content dir, and changing extensions.
How should I write the rules properly, so
- Make knows where to "watch" for changes every time I do a make, because right now it points that every file is up to date
- How do I indicate properly the dependency of a file to it's content file.
This rule:
public/%: content/%
does nothing because pattern rules without recipes delete existing pattern rules, they don't define new pattern rules.
It's very simple, you should write two rules like this:
public/%.htm: content/%.md:
# Pandoc script
pandoc -i $< -o $#
public/%.htm: content/%.htm
# Jinja Script
Here's a hint: whenever you're writing a makefile recipe and you discover that you need to create a target which is different than exactly $#, unmodified, immediately stop what you're doing and back up: you've taken a wrong turn.

How do you specify that a FreeBSD Makefile place the objects (*.o) into a different directory?

If I have some source files in another directory and I want to make some libraries using the source files, I want to have the *.o, *.po, and *.So files in the local directory. It isn't clear how to accomplish this. The transformation rules in bsd.lib.mk always point the .o into the source directory.
How do I get the results of the ${CC} -c to be in the local directory?
The file bsd.lib.mk inclused bsd.obj.mak, so you can use the MAKEOBJDIR environment variable.
Edit: If you cannot control how make is called, then don't use bsd.lib.mk and make explicit dependencies in your Makefile;
foo.o: ../bar/foo.c

(Auto)make dependency across multiple makefiles

I am wondering if this is possible at all. Here is the situation:
My project uses automake to build its targets. The top-directory contains the usual configure.ac and Makefile.am. Amongst others, the Makefile.am contains a SUBDIRS variable listing the subdirectories, important for my question is the doc and include directory. The include directory's makefile looks like:
nobase_include_HEADERS = <lot-of-headers>
so it basically installs the headers. The makefile in doc is supposed to generate html documentation out of those files:
doxygen-stamp: Doxyfile
$(DOXYGEN) $<
echo "timestamp for Doxyfile" > $#
all-local: doxygen-stamp
Everything works fine so far, but if I change any of the headers in include the documentation is still up-to-date - because I did not list them as dependencies. What I would like to have is to have a doxygen-stamp-target that is rebuilt once the headers change without again listing all headers as dependencies. Is that possible and if it is, how?
In this case, using a single Makefile would be hinted at — though you can split it up by using the automake include instruction (also see section 7.3 "An alternative approach to subdirectories" of the am manual). Therefore:
#can't use nobase_
include_HEADERS = include/foo.h include/bar.h
doc/doxygen-stamp: ${include_HEADERS}
I think if you make doxygen-stamp also depend on '$(top_srcdir)/include/*.h' (or .hpp or whatever) it will rebuild when doxygen-stamp is out of date relative to any .h file in the include directory.
doxygen-stamp: Doxyfile $(top_srcdir)/include/*.h

Resources