[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: help on simple makefile
From: |
J.T. Conklin |
Subject: |
Re: help on simple makefile |
Date: |
Wed, 05 Apr 2017 14:44:40 -0700 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) |
"address@hidden" <address@hidden> writes:
> Could you please help me on translate on working example.
>
> What I want to obtain is execute the python script on file present on
> my folder and output on RESHAPE2. thanks in advance for any help
How about something like this:
INDIR=indir
INFILES:=$(wildcard $(INDIR)/*.txt)
OUTDIR=outdir
OUTFILES=$(patsubst $(INDIR)/%.txt,$(OUTDIR)/%.xls,$(INFILES))
SCRIPT=python_script.py
$(OUTDIR)/%.xls: $(INDIR)/%.txt
$(SCRIPT) -i $^ -o $@
all: $(OUTFILES)
This creates a pattern rule to convrert your *.txt files to *.xls, and
then makes all the output *.xls files a prerequisite of "all".
Some advantages of this approach (compared with your attempt that used a
shell loop) is that multiple script invocations can be done in parallel
(using GNU make's -j flag). And that each conversion will only be done
if the corresponding *.txt file is updated (as there is now a dependency
relationship between the *.xls and *.txt files).
--jtc