Search code examples
makefilegroff

GNU Make: permissions issue creating files


I'm using Make to get some data from a MySQL database, populate a report and email it using cron. I've run into a permissions issue when processing the groff file.

The Make:

get: $(DATA)

$(DATA):
        bash $(GET) $(SQL) > $@

format: $(CONTENT)

$(CONTENT): $(DATA)
        bash $(FORMAT) $(DATA) > $@

$(TROFF): $(CONTENT)
        cat $(TEMPLATE) $< > $@
        chmod a+rw $@

$(PS): $(TROFF)
        $(SED) -i '$$ a .TE' $<
        $(TROFF) -ms -t -Tps $< > $@
        chmod a+rw $@

report: $(REPORT)

$(REPORT): $(PS)
        $(PS2PDF) $< >$@
        chmod a+rw $@

As you can see I've experimented with permissions within the makefile. Here's the errors I get when running make:

/home/automation/scripts/nancy_list/reports/2015-08-11.roff -ms -t -Tps /home/automation/scripts/nancy_list/reports/2015-08-11.roff > /home/auto
/bin/sh: 1: /home/automation/scripts/nancy_list/reports/2015-08-11.roff: Permission denied
make: *** [/home/automation/scripts/nancy_list/reports/2015-08-11.ps] Error 126

So it successfully generates the roff but can't process it -- the postscript comes up as an empty file. I've done similar projects with Make before -- is there something new with regards to permissions?


Solution

  • TROFF is set wrongly not to /usr/bin/troff but to your generated troff file.

    You are trying to execute your generated file.