The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
multiple search keyword in grep saifurshaon Shell Programming and Scripting 11 03-19-2009 05:56 AM
not able to export the Variables smartgupta SUN Solaris 6 09-29-2008 04:51 PM
export env variables varun.81 Shell Programming and Scripting 2 04-30-2007 08:39 AM
How can I print variables im using in makefiles? umen Shell Programming and Scripting 1 05-07-2006 10:57 AM
export variables srishan Shell Programming and Scripting 4 07-06-2004 01:53 PM

Reply
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-04-2009
dahavy dahavy is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 2
Variables across multiple Makefiles (export keyword)

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

Quote:
$(ASYMPTOTE) -v "$<"
evaluates to

Quote:
-v "_filename_"
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 "$<"
  #2 (permalink)  
Old 06-05-2009
spirtle spirtle is offline
Registered User
  
 

Join Date: Jun 2008
Location: Scotland
Posts: 150
I thought you would need
Code:
export ASYMPTOTE:=$(shell cat config)
to read the file.
You would also have to make sure that the dependency of everything on the "config" target is correctly expressed. I would avoid this extra config file entirely by just writing
Code:
export ASYMPTOTE:=asy
and letting make work out where asy is on all your various systems, which it can do if asy is in a directory in $PATH.

Are other exported variables e.g. $(ASYBILDER) correct in the sub-makefile?

P.S. Don't worry about the foreign language - ich kann ein bisschen deutsch!
  #3 (permalink)  
Old 06-06-2009
dahavy dahavy is offline
Registered User
  
 

Join Date: Jun 2009
Posts: 2
Thank you very much for your reply, guess that will do it. I will investigate once I return to my workstation.


Best Regards
dahavy
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:36 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0