Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9306811
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 19, 20262026-06-19T00:15:16+00:00 2026-06-19T00:15:16+00:00

I have some trouble with my Makefile: # Manage rendering of images .PHONY: explode

  • 0

I have some trouble with my Makefile:

# Manage rendering of images
.PHONY: explode

all: explode anime.apng

out.ppm: file.code
    ./pgm -f $<

explode: out.ppm
    split -d -a 3 --lines=$(N) --additional-suffix=.ppm $< frame

# Convert to multiple png
%.png: %.ppm
    convert $< $@
    optipng $@

# Assemble in one animated png
anime.apng: %.png
    apngasm $@ frame000.png

My problem is: I don’t know how many intermediate files I will have to produce my final target, so I can’t specify them in advance. Schematically:

1 file.code -> 1 out.ppm |> LOADS of .ppm |> LOADS of .png -> 1 anime.apng
                         +> …             +> …
                         +> …             +> …

For that I use an implicit rule %.png: %.ppm. But then I cannot specify a prerequisite for my last merge step! Any ideas? With another tool than make? Anything elegant?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-19T00:15:17+00:00Added an answer on June 19, 2026 at 12:15 am

    I think a simple and rather clean approach would be to have a variable record the list of those ‘LOADS’ of ppm, in my example it’s variable STEP2.
    Surely you can use the program that gets you from ‘1 out.ppm’ to ‘LOADS of .ppm’ to list the .ppm files that you will obtain.

    With a very trivial exemple where out.ppm would be a text file listing the names of the .ppm to produce, you would write something like :

    SOURCE = file.code
    STEP1 = out.ppm
    STEP2 = $(shell cat $(STEP1))
    STEP3 = $(STEP2:%.ppm=%.png)
    TARGET = anime.apng
    

    Then you’ll need to write a rule to get all the files listed in STEP2 from the file $(STEP1). This is done file by file as if it was an implicit rule with a % pattern, assuming your program is called ‘extractor’ :

    $(STEP2): $(STEP1)
        extractor $^ $@
    

    This rule will be applied once for each file listed in STEP2. This assumes that your program only wants the names of the source and output files. Should you prefer to pass the stem of the output file, you can still use a plain ol’ implicit rule :

    $(STEP2):%.ppm: $(STEP1)
        extractor $^ $*
    

    (The $(STEP2): at the begining is to prevent make from using this rule to generate out.ppm)

    Then, everything is as usual when it comes to compilation and you can adapt rules for compiling and linking any C projet. The %.ppm -> %.png step is like compiling %.c to %.o :

    %.png: %.ppm
        convert $< $@
        optipng $@
    

    To group everything at the end (equivalent of linking several %.o into only one binary) :

    $(TARGET): $(STEP3)
        apngasm $@ $^
    

    I’m assuming here that apngasm can take the list of everything to put together as arguments à la tar.

    Hope it’s clear and helpful enough.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have some trouble with mysql query. I just figure out, how to get
I have some trouble reading from an ini file using boost program options. The
I have some trouble reading file in Java. What a file looks like: Answer
I have some trouble figuring out why the following crashes (MSVC9): //// the following
I have some trouble finding this. Actually I want to unregister / cancel all
I have some trouble figuring out the best way to store my programming todo
I have some trouble when I try to map object to int . My
I have some trouble with my trac installation (version 11.4). What should I do
I have some trouble with jquery ui-events: In my application, there are some sliders.
I have some trouble achieving adequate real-time performance from my application and wondering if

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.