Hello fellow users,
I just recently started using Linux & now I have to fix a huge makefile which is used to compile a complex LaTeX document consisting of a number of Chapters with a sub-makefile for each. All used images are exported / converted on the fly. The problem is that this depends on a certain program (asymptote) which is installed in different directories depending on the system where we compile.
My Idea (it is pretty cheap) was to write insert a "config"-target (see code below) that detects and writes to correct directory into a configuration file. This file is then read into the variable ASYMPTOTE (which contains the path to the executable). Before, it was just a hardcoded assignment, i've left it as comment.
The Problem with my approach is that there are sub-makefiles for each chapter, and once I use my approach, they dont see anything inside ASYMPTOTE at all, . With the old way, everything works perfectly right. My modification works inside the main makefile, i have tested that with a echo (see target %.tex) which displays the contents of the variable. It echoes the correct path even with my modification. But in the submakefiles, ASYMPTOTE is empty - the line
evaluates to
I can only guess that this is a result of $(cat config) not getting evaluated properly in the sub-makefiles. Or is there anything I don't know about?
If you took the time to read until here, thank you very much already. If you have any ideas how to solve this, or know any better way to fix this, please let me know.
So here is the code. The whole thing is HUGE, so i cut it down a little, if you need the complete files, leave a message and I will post it. Im sorry for the foreign language in parts of it, but let me assure you, they are not really importand comments after all.
Makefile:
Code:
#! /usr/bin/make
#[...]
# Pfade zu den Bild-Quellen (exported to sub-makes)
#[...]
export BILDER:=$(shell pwd)/../../Bilder
export ASYBILDER:=$(BILDER)/Asymptote
# Paths to programs (exported to sub-makes)
#[...]
export ASYMPTOTE:=$(cat config) # old way is hardcoded: /usr/local/bin/asy
#[...]
.PHONY: ps pdf all clean
.SECONDARY: %.dvi
.PRECIOUS: %.tex %.ps
ps : $(SKRIPTNAME).ps
pdf : $(SKRIPTNAME).pdf
all : ps pdf
# write config
config:
if [ -e /usr/bin/asy ]; then echo /usr/bin/asy >> config ; else echo /usr/local/bin/asy >> config ; fi
# remove temporary files
clean:
#[...]
# remove all created files
distclean: clean
#[...]
# create master file
%.tex:
/bin/echo "%settings for Asymptote: $(ASYMPTOTE)"
#[...]
# create dvi file from master file
%.dvi : %.tex $(CHAPTERS)
# [...)
# create postscript file from dvi file
%.ps : %.dvi
#[...]
# create portable document format file from ps file
%.pdf : %.ps
#[...]
# print all possible targets mentioned in this Makefile
targets:
grep --before-context=1 '^[^[:space:].][^[:space:]]*:[[:space:]]' < Makefile
Sub-Makefiles:
Code:
#! /usr/bin/make
#[...]
.PHONY: clean eps
.PRECIOUS: %.eps
eps : $(addsuffix .eps, $(GFXFILES))
clean :
#[...]
distclean : clean
#[...]
# Make eps image from asy file
# can be done if asy is available
%.eps :: $(ASYBILDER)/%.asy
$(ASYMPTOTE) -v "$<"