Make and multiple files? - Unix

This is a discussion on Make and multiple files? - Unix ; I am trying to write a makefile that converts all .ps and .eps files to pdf: # Contains all .eps files. EPSFILES=$(wildcard *.eps) # Contains all .ps files. PSFILES=$(wildcard *.ps) # Contains all .eps and .ps files TOPDF=$(PSFILES) $(EPSFILES) all: ...

+ Reply to Thread
Results 1 to 10 of 10

Thread: Make and multiple files?

  1. Make and multiple files?

    I am trying to write a makefile that converts all .ps and .eps files to pdf:

    # Contains all .eps files.
    EPSFILES=$(wildcard *.eps)

    # Contains all .ps files.
    PSFILES=$(wildcard *.ps)

    # Contains all .eps and .ps files
    TOPDF=$(PSFILES) $(EPSFILES)

    all: topdf


    topdf:
    epstopdf $(TOPDF)


    But when I run the makefile I get:

    !!! Error: Unknown option or too many input files!
    make: *** [topdf] Error 255


    How do I automatically run epstopdf on each .ps and .eps file if they
    are changed?

  2. Re: Make and multiple files?

    On Mar 6, 9:00 am, saneman wrote:
    > I am trying to write a makefile that converts all .ps and .eps files to pdf:
    >
    > # Contains all .eps files.
    > EPSFILES=$(wildcard *.eps)
    >
    > # Contains all .ps files.
    > PSFILES=$(wildcard *.ps)
    >
    > # Contains all .eps and .ps files
    > TOPDF=$(PSFILES) $(EPSFILES)
    >
    > all: topdf
    >
    > topdf:
    > epstopdf $(TOPDF)
    >
    > But when I run the makefile I get:
    >
    > !!! Error: Unknown option or too many input files!
    > make: *** [topdf] Error 255


    It looks like epstopdf can't take that many files.

    > How do I automatically run epstopdf on each .ps and .eps file if they
    > are changed?


    You could do something like this (untested):

    # All the files to convert:
    EPSFILES=$(wildcard *.eps)
    PSFILES=$(wildcard *.ps)

    # Output PDFs
    PDFFILES=$(EPSFILES:.eps=.pdf) $(PSFILES:.ps=.pdf)

    # Define suffixes to make
    ..SUFFIXES: .ps .eps .pdf

    ..PHONY: all # all is not an actual file

    all: $(PDFFILES)

    ..ps.pdf:
    epstopdf $<

    ..eps.pdf:
    epstopdf $<

    ----------

    That should work. That does use some older features of make, I think,
    but I am stuck in the past and don't know the new syntax (I'm pretty
    sure .SUFFIXES and .PHONY are obsolete and there's a new way to do it,
    maybe involving % signs or something).

    The problem with the above Makefile (you can't get around this) is
    that you can't have two eps and ps files with the same basename (like
    something.ps and something.eps), because they both have the same
    output file (something.pdf).

    Jason

  3. Re: Make and multiple files?

    On Mar 6, 9:43 am, "jason.cipri...@gmail.com"
    wrote:
    > On Mar 6, 9:00 am, saneman wrote:
    >
    >
    >
    > > I am trying to write a makefile that converts all .ps and .eps files to pdf:

    >
    > > # Contains all .eps files.
    > > EPSFILES=$(wildcard *.eps)

    >
    > > # Contains all .ps files.
    > > PSFILES=$(wildcard *.ps)

    >
    > > # Contains all .eps and .ps files
    > > TOPDF=$(PSFILES) $(EPSFILES)

    >
    > > all: topdf

    >
    > > topdf:
    > > epstopdf $(TOPDF)

    >
    > > But when I run the makefile I get:

    >
    > > !!! Error: Unknown option or too many input files!
    > > make: *** [topdf] Error 255

    >
    > It looks like epstopdf can't take that many files.
    >
    > > How do I automatically run epstopdf on each .ps and .eps file if they
    > > are changed?

    >
    > You could do something like this (untested):
    >
    > # All the files to convert:
    > EPSFILES=$(wildcard *.eps)
    > PSFILES=$(wildcard *.ps)
    >
    > # Output PDFs
    > PDFFILES=$(EPSFILES:.eps=.pdf) $(PSFILES:.ps=.pdf)
    >
    > # Define suffixes to make
    > .SUFFIXES: .ps .eps .pdf
    >
    > .PHONY: all # all is not an actual file
    >
    > all: $(PDFFILES)
    >
    > .ps.pdf:
    > epstopdf $<
    >
    > .eps.pdf:
    > epstopdf $<
    >
    > ----------
    >
    > That should work. That does use some older features of make, I think,
    > but I am stuck in the past and don't know the new syntax (I'm pretty
    > sure .SUFFIXES and .PHONY are obsolete


    Not AFAIK.

    > and there's a new way to do it,
    > maybe involving % signs or something).


    %.pdf : %.eps
    epstopdf $<

    >
    > The problem with the above Makefile (you can't get around this) is
    > that you can't have two eps and ps files with the same basename (like
    > something.ps and something.eps), because they both have the same
    > output file (something.pdf).
    >
    > Jason



  4. Re: Make and multiple files?

    In article ,
    jason.cipriani@gmail.com wrote:

    >The problem with the above Makefile (you can't get around this) is
    >that you can't have two eps and ps files with the same basename (like
    >something.ps and something.eps), because they both have the same
    >output file (something.pdf).


    You can hack around it by changing the output filename:
    --------
    PDFFILES=$(EPSFILES:.eps=-eps.pdf) $(PSFILES:.ps=-ps.pdf)

    %-ps.pdf: %.ps
    epstopdf $< -o $@

    %-eps.pdf: %.eps
    epstopdf $< -o $@
    --------

    Making this only happen when there would be an actual name collision is
    Left As An Exercise.


    dave

    --
    Dave Vandervies dj3vande at eskimo dot com
    > fork()?? ... Sounds interesting. Where can I get more info?

    See the documentation for knife() and spoon(). For international localized
    implementations, see chopsticks(). --John Smith and Eric Sosman in CLC

  5. Re: Make and multiple files?

    dj3vande@csclub.uwaterloo.ca.invalid wrote:
    > In article ,
    > jason.cipriani@gmail.com wrote:
    >
    >> The problem with the above Makefile (you can't get around this) is
    >> that you can't have two eps and ps files with the same basename (like
    >> something.ps and something.eps), because they both have the same
    >> output file (something.pdf).

    >
    > You can hack around it by changing the output filename:
    > --------
    > PDFFILES=$(EPSFILES:.eps=-eps.pdf) $(PSFILES:.ps=-ps.pdf)
    >
    > %-ps.pdf: %.ps
    > epstopdf $< -o $@
    >
    > %-eps.pdf: %.eps
    > epstopdf $< -o $@
    > --------
    >
    > Making this only happen when there would be an actual name collision is
    > Left As An Exercise.
    >
    >
    > dave
    >


    Thanks. In the line below:

    PDFFILES=$(EPSFILES:.eps=-eps.pdf) $(PSFILES:.ps=-ps.pdf)

    all eps and ps files gets their extension replaced with -eps.pdf and
    -ps.pdf correspondingly.

    I can't seem to find that rule in the gnu make manual. Where isit
    described that using 'a=b' replaces a with b?

    I have also seen the above line with '%':

    PDFFILES=$(EPSFILES:%.eps=%-eps.pdf) $(PSFILES:%.ps=%-ps.pdf)

    Are there any reason why the '%' are used?

  6. Re: Make and multiple files?

    toby wrote:
    > On Mar 6, 9:43 am, "jason.cipri...@gmail.com"
    > wrote:
    >> On Mar 6, 9:00 am, saneman wrote:
    >>
    >>
    >>
    >>> I am trying to write a makefile that converts all .ps and .eps files to pdf:
    >>> # Contains all .eps files.
    >>> EPSFILES=$(wildcard *.eps)
    >>> # Contains all .ps files.
    >>> PSFILES=$(wildcard *.ps)
    >>> # Contains all .eps and .ps files
    >>> TOPDF=$(PSFILES) $(EPSFILES)
    >>> all: topdf
    >>> topdf:
    >>> epstopdf $(TOPDF)
    >>> But when I run the makefile I get:
    >>> !!! Error: Unknown option or too many input files!
    >>> make: *** [topdf] Error 255

    >> It looks like epstopdf can't take that many files.
    >>
    >>> How do I automatically run epstopdf on each .ps and .eps file if they
    >>> are changed?

    >> You could do something like this (untested):
    >>
    >> # All the files to convert:
    >> EPSFILES=$(wildcard *.eps)
    >> PSFILES=$(wildcard *.ps)
    >>
    >> # Output PDFs
    >> PDFFILES=$(EPSFILES:.eps=.pdf) $(PSFILES:.ps=.pdf)
    >>
    >> # Define suffixes to make
    >> .SUFFIXES: .ps .eps .pdf
    >>
    >> .PHONY: all # all is not an actual file
    >>
    >> all: $(PDFFILES)
    >>
    >> .ps.pdf:
    >> epstopdf $<
    >>
    >> .eps.pdf:
    >> epstopdf $<
    >>
    >> ----------
    >>
    >> That should work. That does use some older features of make, I think,
    >> but I am stuck in the past and don't know the new syntax (I'm pretty
    >> sure .SUFFIXES and .PHONY are obsolete

    >
    > Not AFAIK.
    >
    >> and there's a new way to do it,
    >> maybe involving % signs or something).

    >
    > %.pdf : %.eps
    > epstopdf $<
    >


    Yes I am currently using that version. But it runs the command even
    though the file has not been changed:

    # =============================================
    # EPS and PS to PDF
    # =============================================

    # Contains all .eps files.
    EPSFILES=$(wildcard *.eps)

    # Contains all .ps files.
    PSFILES=$(wildcard *.ps)

    # Create target label for eps files
    EPSLABEL=$(EPSFILES:%.eps=%.eps2pdf)

    # Create target label for ps files
    PSLABEL=$(PSFILES:%.ps=%.ps2pdf)


    all: $(EPSLABEL) $(PSLABEL)


    %.eps2pdf: %.eps
    epstopdf $<


    %.ps2pdf: %.ps
    epstopdf $<


    How do I make sure that the commands are only run when the .eps or .ps
    files has been changed?


  7. Re: Make and multiple files?

    On Mar 7, 5:37 am, saneman wrote:
    > toby wrote:
    > > On Mar 6, 9:43 am, "jason.cipri...@gmail.com"
    > > wrote:
    > >> On Mar 6, 9:00 am, saneman wrote:

    >
    > >>> I am trying to write a makefile that converts all .ps and .eps files to pdf:
    > >>> # Contains all .eps files.
    > >>> EPSFILES=$(wildcard *.eps)
    > >>> # Contains all .ps files.
    > >>> PSFILES=$(wildcard *.ps)
    > >>> # Contains all .eps and .ps files
    > >>> TOPDF=$(PSFILES) $(EPSFILES)
    > >>> all: topdf
    > >>> topdf:
    > >>> epstopdf $(TOPDF)
    > >>> But when I run the makefile I get:
    > >>> !!! Error: Unknown option or too many input files!
    > >>> make: *** [topdf] Error 255
    > >> It looks like epstopdf can't take that many files.

    >
    > >>> How do I automatically run epstopdf on each .ps and .eps file if they
    > >>> are changed?
    > >> You could do something like this (untested):

    >
    > >> # All the files to convert:
    > >> EPSFILES=$(wildcard *.eps)
    > >> PSFILES=$(wildcard *.ps)

    >
    > >> # Output PDFs
    > >> PDFFILES=$(EPSFILES:.eps=.pdf) $(PSFILES:.ps=.pdf)

    >
    > >> # Define suffixes to make
    > >> .SUFFIXES: .ps .eps .pdf

    >
    > >> .PHONY: all # all is not an actual file

    >
    > >> all: $(PDFFILES)

    >
    > >> .ps.pdf:
    > >> epstopdf $<

    >
    > >> .eps.pdf:
    > >> epstopdf $<

    >
    > >> ----------

    >
    > >> That should work. That does use some older features of make, I think,
    > >> but I am stuck in the past and don't know the new syntax (I'm pretty
    > >> sure .SUFFIXES and .PHONY are obsolete

    >
    > > Not AFAIK.

    >
    > >> and there's a new way to do it,
    > >> maybe involving % signs or something).

    >
    > > %.pdf : %.eps
    > > epstopdf $<

    >
    > Yes I am currently using that version. But it runs the command even
    > though the file has not been changed:
    >
    > # =============================================
    > # EPS and PS to PDF
    > # =============================================
    >
    > # Contains all .eps files.
    > EPSFILES=$(wildcard *.eps)
    >
    > # Contains all .ps files.
    > PSFILES=$(wildcard *.ps)
    >
    > # Create target label for eps files
    > EPSLABEL=$(EPSFILES:%.eps=%.eps2pdf)
    >
    > # Create target label for ps files
    > PSLABEL=$(PSFILES:%.ps=%.ps2pdf)
    >
    > all: $(EPSLABEL) $(PSLABEL)
    >
    > %.eps2pdf: %.eps
    > epstopdf $<
    >
    > %.ps2pdf: %.ps
    > epstopdf $<
    >
    > How do I make sure that the commands are only run when the .eps or .ps
    > files has been changed?


    Because my version used the wrong extensions (I overlooked what Jason
    had specified). Regarding the assignments to EPSLABEL and PSLABEL, see
    the GNU Make manual on Substitution References:
    http://www.gnu.org/software/make/man...stitution-Refs

    Try something like:

    # Create target label for eps files
    EPSLABEL=$(EPSFILES:%.eps=%.eps.pdf)

    # Create target label for ps files
    PSLABEL=$(PSFILES:%.ps=%.ps.pdf)

    all: $(EPSLABEL) $(PSLABEL)

    %.eps.pdf: %.eps
    epstopdf $<

    %.ps.pdf: %.ps
    epstopdf $<

  8. Re: Make and multiple files?

    "saneman" wrote in message
    news:fqr5sq$2l8$1@news.net.uni-c.dk...> toby wrote:
    >>>> I am trying to write a makefile that converts all .ps and .eps files to
    >>>> pdf:

    [snip]
    >>>> How do I automatically run epstopdf on each .ps and .eps file if they
    >>>> are changed?

    [snip]
    > Yes I am currently using that version. But it runs the command even though
    > the file has not been changed:
    >
    > # =============================================
    > # EPS and PS to PDF
    > # =============================================
    >
    > # Contains all .eps files.
    > EPSFILES=$(wildcard *.eps)
    >
    > # Contains all .ps files.
    > PSFILES=$(wildcard *.ps)
    >
    > # Create target label for eps files
    > EPSLABEL=$(EPSFILES:%.eps=%.eps2pdf)
    >
    > # Create target label for ps files
    > PSLABEL=$(PSFILES:%.ps=%.ps2pdf)
    >
    >
    > all: $(EPSLABEL) $(PSLABEL)
    >
    >
    > %.eps2pdf: %.eps
    > epstopdf $<
    >
    >
    > %.ps2pdf: %.ps
    > epstopdf $<
    >
    >
    > How do I make sure that the commands are only run when the .eps or .ps
    > files has been changed?


    I am guessing that the eps2pdf utility's default output filename is
    the input file name with the extension changed to .pdf? So a rule like
    this:

    %.ps2pdf: %.ps
    epstopdf $<

    When run on an input file named, say, document.ps, would run:

    epstopdf document.ps

    Producing document.pdf, not document.ps2pdf. I do not know the syntax
    of epstopdf, but you will want to make sure that the PDF file it is
    writing out has the same name that you specify in your makefile rule.
    A $@ in a rule is substituted with the target filename; so say
    epstopdf takes an output file after a "-o" option, make sure you do:

    %.ps2pdf: %.ps
    epstopdf $< -o $@

    If you do *not* do this, and your epstopdf output filename is not
    the .ps2pdf file you are expecting, make sees that the target file
    (ending with .ps2pdf) was not created, and makes futile attempts to
    build it every time you run make.

    Here is a summary of all of this with a simpler example. If you have
    the following Makefile:

    all: hi.2 there.2
    %.2: %.1
    cp $< $@

    In a directory containing the files "hi.1" and "there.1", and you run
    make, it will create hi.2 and there.2. Running make again does not run
    the rules again. Touching either of the .1 files will cause the
    corresponding .2 file to be regenerated. Also, FYI, you do not have to
    specify .SUFFIXES when you use the % substitution syntax like that;
    that may have been the "new way" I had mentioned in a previous post.

    Jason


  9. Re: Make and multiple files?

    On Mar 7, 4:48 am, saneman wrote:
    > dj3va...@csclub.uwaterloo.ca.invalid wrote:
    > > In article ,
    > > jason.cipri...@gmail.com wrote:

    >
    > >> The problem with the above Makefile (you can't get around this) is
    > >> that you can't have two eps and ps files with the same basename (like
    > >> something.ps and something.eps), because they both have the same
    > >> output file (something.pdf).

    >
    > > You can hack around it by changing the output filename:
    > > --------
    > > PDFFILES=$(EPSFILES:.eps=-eps.pdf) $(PSFILES:.ps=-ps.pdf)

    >
    > > %-ps.pdf: %.ps
    > > epstopdf $< -o $@

    >
    > > %-eps.pdf: %.eps
    > > epstopdf $< -o $@
    > > --------

    >
    > > Making this only happen when there would be an actual name collision is
    > > Left As An Exercise.

    >
    > > dave

    >
    > Thanks. In the line below:
    >
    > PDFFILES=$(EPSFILES:.eps=-eps.pdf) $(PSFILES:.ps=-ps.pdf)
    >
    > all eps and ps files gets their extension replaced with -eps.pdf and
    > -ps.pdf correspondingly.
    >
    > I can't seem to find that rule in the gnu make manual. Where isit
    > described that using 'a=b' replaces a with b?


    It is mentioned briefly in the 'patsubst' function documentation in
    Functions -> Text Functions:

    http://uw714doc.sco.com/cgi-bin/info...ctions&lang=en

    The actual description, however, can be found in Using Variables ->
    Advanced -> Substitution References:

    http://uw714doc.sco.com/cgi-bin/info...20Refs&lang=en

    > I have also seen the above line with '%':
    >
    > PDFFILES=$(EPSFILES:%.eps=%-eps.pdf) $(PSFILES:%.ps=%-ps.pdf)
    >
    > Are there any reason why the '%' are used?


    See the Substitution References info page linked above.

    Jason

  10. Re: Make and multiple files?

    On Mar 6, 10:04 am, toby wrote:
    > On Mar 6, 9:43 am, "jason.cipri...@gmail.com"
    > > That should work. That does use some older features of make, I think,
    > > but I am stuck in the past and don't know the new syntax (I'm pretty
    > > sure .SUFFIXES and .PHONY are obsolete

    >
    > Not AFAIK.
    >
    > > and there's a new way to do it,
    > > maybe involving % signs or something).

    >
    > %.pdf : %.eps
    > epstopdf $<


    Thanks for that. It also seems like you don't have to
    specify .SUFFIXES explicitly if you use the % notation like that;
    maybe that is what I was thinking of. I wonder if it's a bad sign that
    I'm all pumped up to go write some Makefiles with % signs in them,
    now.

    Jason

+ Reply to Thread