News for hackers. Stuff that matters.
Re:Ask HN: In what creative ways are you using Makefiles? by new299 on Monday July 24, 2017 @04:10AM (#14836687)
My favorite use was during my PhD. My thesis could be regenerated from the source data, through to creating plots with gnuplot/GRI and finally assembled from the Latex and eps files into the final pdf.

It was quite simple really, but really powerful to be able to tweak/replace a dataset hit make, and have a fully updated version of my thesis ready to go.

Re:Ask HN: In what creative ways are you using Makefiles? by ISL on Monday July 24, 2017 @12:12PM (#14839681)
I'd go as far as to argue that such a plan is essential to reproducibility (and it makes your work faster and less error-prone).

My take on the same plan ( "make thesis" ):

It's not pretty, but it works. https://github.com/4kbt/PlateWash

Unblinding tweet: https://twitter.com/CharlieHagedorn/status/59565285891105177...

Finished product: https://digital.lib.washington.edu/researchworks/handle/1773...

Re:Ask HN: In what creative ways are you using Makefiles? by lordnacho on Monday July 24, 2017 @06:43AM (#14837302)
> My thesis could be regenerated from the source data, through to creating plots with gnuplot/GRI and finally assembled from the Latex and eps files into the final pdf.

All research should be like this. Explaining things in words is simply so imprecise you end up spending forever to show someone something that a program can tell you quickly.

"I used xyz transformation with abc parameters" can be gleaned easily from code.

Re:Ask HN: In what creative ways are you using Makefiles? by Faaak on Monday July 24, 2017 @04:21AM (#14836725)
I do the same with latex when generating contracts for my company. The makefile and its corresponding python program asks for various arguments (company name, xxx, yyy). Then it generates the contract with the associated prices. I even put some automatic reduction/gifts in place (free service) if the amount is bigger than X or Y.

I quite like it !

Re:Ask HN: In what creative ways are you using Makefiles? by tajd on Monday July 24, 2017 @04:49AM (#14836831)
Please could it be possible to view a snippet - just to get an idea of how you do this. Cheers!
Re:Ask HN: In what creative ways are you using Makefiles? by graphene on Monday July 24, 2017 @04:59AM (#14836873)
I do something similar, here's my Makefile -- I have scripts that build figures in a separate directory, /figures. I'm sure it could be terser, but it does the job for me.

    texfiles = acronyms.tex analytical_mecs_procedure.tex analytical_mecs.tex \
               anderson_old.tex background.tex chaincap.tex \
               conclusions.tex cvici.tex gold_chain_test.tex introduction.tex \
               main.tex mcci_manual.tex methods.tex moljunc.tex \
               tb_sum_test.tex times_procedure.tex tm_mcci_workflow.tex tmo.tex \
               vici_intro.tex
 
    # dynamically generated figures
 
 
    all: main.pdf
 
    main.pdf: $(texfiles) figures/junction_occupations.pdf figures/overlaps_barplot.pdf \
                          figures/transmission_comparison.pdf \
                          figures/wigner_distributions.pdf
        pdflatex main.tex && bibtex main && pdflatex main.tex && pdflatex main.tex
 
    figures/junction_occupations.pdf: figures/junction_occupations.hs
        ghc --make figures/junction_occupations.hs
        figures/junction_occupations -w 800 -h 400 -o figures/junction_occupations.svg
        inkscape -D -A figures/junction_occupations.pdf figures/junction_occupations.svg 
 
    figures/overlaps_barplot.pdf: figures/overlaps_barplot.py
        python figures/overlaps_barplot.py
 
    figures/transmission_comparison.pdf: figures/transmission_comparison.py
        python figures/transmission_comparison.py
 
    figures/wigner_distributions.pdf: figures/wigner_distributions.py
        python figures/transmission_comparison.py
 
    clean:
        rm *.log *.aux *.blg *.bbl *.dvi main.pdf
Re:Ask HN: In what creative ways are you using Makefiles? by xelxebar on Monday July 24, 2017 @08:10AM (#14837746)
I noticed that you have some file dependencies not encoded in the targets. Also, you might like reading up on Automatic Variables ($@, $^, $<, etc). Anyway, just for fun I tried rewriting your script in a way that should Just Work a little better.

    texfiles    = $(wildcard *.tex)

    figures_ink = figures/junction_occupations.pdf
    figures_py  = figures/overlaps_barplot.pdf        \
                  figures/transmission_comparison.pdf \
                  figures/wigner_distributions.pdf
    figures     = $(figures_ink) $(figures_py)


    main.pdf: main.tex $(texfiles) $(figures)
        pdflatex $<
        bibtex $(<:*.tex=*)
        pdflatex $<
        pdflatex $<

    figures/junction_occupations: %: %.hs
        ghc --make $^

    figures/junction_occupations.svg: figures/junction_occupations
        $< -w 800 -h 400 -o $@

    $(figures_ink): %.pdf: %.svg
        inkscape -D -A $@ $^

    $(figures_py): %.pdf: %.py
        python $^

    clean:
        rm *.log *.aux *.blg *.bbl *.dvi main.pdf
Re:Ask HN: In what creative ways are you using Makefiles? by kurlberg on Monday July 24, 2017 @12:11PM (#14839677)
Check out latexmk: it keeps track of having to run bibtex etc, and runs latex "enough times" so that all equation refs etc have stabilised. (Latexmk -pdf to build a pdf, default is dvi.)
Re:Ask HN: In what creative ways are you using Makefiles? by new299 on Monday July 24, 2017 @11:18AM (#14839133)
Yes, I don't think I'll get a chance to dig out my Makefile. But my Makefile was very much like this.
Re:Ask HN: In what creative ways are you using Makefiles? by majewsky on Monday July 24, 2017 @06:03AM (#14837139)

  figures/%.pdf: figures/%.py
      python $<
Re:Ask HN: In what creative ways are you using Makefiles? by auxym on Tuesday July 25, 2017 @07:58AM (#14847028)
For what it's worth, I did something similar for my master's dissertation, but couldn't be bothered to learn make, so I used a python library called pydoit:

http://pydoit.org/

All my analysis code, plots, etc were already in python, so it fit in well. Lyx has a CLI from where I exported .tex and compiled to pdf.