help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help on makefile writing


From: Christian Hujer
Subject: Re: Help on makefile writing
Date: Fri, 21 Apr 2017 07:22:07 +0100

Hello jarod,

it seems your mail is incomplete..
Still I can see a few issues with your Makefile.

The biggest issues are these:
qc: %.list
This should probably instead be qc: $(RFILES)
And I don't see how $(OUTFILES) could be resolved, which command
should create fastqReport.html? The script? If so, replace qc with
$(OUTFILES). And also then rename $(OUTFILES) to $(OUTFILE) as it's
just a single file and your current Makefile would only work with a
single file.

A few more things to improve your Makefile:
* I would put .PHONY explicitly before each .PHONY target. As your
Makefile grows when it's doing more and more things for you, that's
easier to maintain, looks better in version control histories and
avoids merge conflicts.
* clean propbably is better written as
.PHONY: clean
clean::
$(RM) -r $(OUTDIR)
    As your Makefile grows, you might want to split it into multiple
Makefiles, each of which might have their own clean recipe. The double
colon tells GNU make to run all these recipes, not just one of them.
And the $(RM) makes your Makefile more portable.
* None of your variables contain target-specitic references, so I
would declare all of them with := instead of =.
* Your directory creation command could be mkdir -p $@, then you don't
need the test.
* I recommend to have directories in Makefiles always end with /, for
example ./ instead of /, that avoids some errors and makes them more
maintainable. It's easier to tell whether something is a directory in
that case.

Regards,
Christian

On Thu, Apr 20, 2017 at 11:15 AM, address@hidden <address@hidden> wrote:
> Dear all,
> I still try to learn make file  script. I have write this script:
> RDIR=.
> RFILES:=$(wildcard $(RDIR)/*.list)
> SCRIPT=~/Software/QC3.sh
> OUTDIR=RESULTS
> OUTFILES=RESULTS/fastqReport.html
> .PHONY: clean all qc
>
> all: $(OUTDIR) $(OUTFILES) qc
>
> qc: %.list
>         $(SCRIPT)  $<
>
>
> $(OUTDIR):
>         test -d $@ ||mkdir $@
>
>
>
> clean:
>         rm -rf $(OUTDIR)
>
>
>
> I would like to  launch every time I add new file ended with .list a comand  
> ~/Software/QC3.sh namefile.list and obtain  inside a RESULTS file an html
>
>
> This is the results
>
> _______________________________________________
> Help-make mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/help-make



-- 
Christian Hujer
E: address@hidden
T: @christianhujer
+91 77 2003 6661 (while in India)
+49 162 4124108 (while in Germany)
+44 7871 912444 (while in UK)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]