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 9256905
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T12:05:20+00:00 2026-06-18T12:05:20+00:00

I have a Makefile which looks roughly like this: FIGURES = A1_B1_C1.eps A2_B2_C2.eps A3_B3_C3.eps

  • 0

I have a Makefile which looks roughly like this:

FIGURES = A1_B1_C1.eps A2_B2_C2.eps A3_B3_C3.eps
NUMBERS = 1 2 3

all : $(FIGURES)

%.eps : $(foreach num, $(NUMBERS), $(subst B, $(num), %).out)
    # my_program($+, $@);

%.out :

The point is that the file names of my figures contain certain information (A, B, C) and that each figure is created by my_program from several (in the example 3) files.
While the filename of each figure has the format Ax_Bx_Cx.eps, the names of the data files to create the figures from look like this:

Ax_1x_Cx.out
Ax_2x_Cx.out
Ax_3x_Cx.out

So for each figure, I need a dynamically created dependency list with several file names. In other words, my desired output for the example above would be:

# my_program(A1_11_C1.out A1_21_C1.out A1_31_C1.out, A1_B1_C1.eps);

# my_program(A2_12_C2.out A2_22_C2.out A2_32_C2.out, A2_B2_C2.eps);

# my_program(A3_13_C3.out A3_23_C3.out A3_33_C3.out, A3_B2_C3.eps);

Unfortunately, the subst command seems to be ignored, for the output looks like this:

# my_program(A1_B1_C1.out A1_B1_C1.out A1_B1_C1.out, A1_B1_C1.eps);

# my_program(A2_B2_C2.out A2_B2_C2.out A2_B2_C2.out, A2_B2_C2.eps);

# my_program(A3_B3_C3.out A3_B3_C3.out A3_B3_C3.out, A3_B3_C3.eps);

I had a look at this possible duplicate but figured that the answer cannot help me, since I am using % and not $@, which should be ok in the prerequisites.

Clearly I am getting something wrong here. Any help is greatly appreciated.

  • 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-18T12:05:22+00:00Added an answer on June 18, 2026 at 12:05 pm

    To do fancy prerequisite manipulations you need at least make-3.82 which supports Secondary Expansion feature:

    FIGURES = A1_B1_C1.eps A2_B2_C2.eps A3_B3_C3.eps
    NUMBERS = 1 2 3
    
    all : $(FIGURES)
    
    .SECONDEXPANSION:
    
    $(FIGURES) : %.eps : $$(foreach num,$$(NUMBERS),$$(subst B,$$(num),$$*).out)
        @echo "my_program($+, $@)"
    
    %.out :
        touch $@
    

    Output:

    $ make
    touch A1_11_C1.out
    touch A1_21_C1.out
    touch A1_31_C1.out
    my_program(A1_11_C1.out A1_21_C1.out A1_31_C1.out, A1_B1_C1.eps)
    touch A2_12_C2.out
    touch A2_22_C2.out
    touch A2_32_C2.out
    my_program(A2_12_C2.out A2_22_C2.out A2_32_C2.out, A2_B2_C2.eps)
    touch A3_13_C3.out
    touch A3_23_C3.out
    touch A3_33_C3.out
    my_program(A3_13_C3.out A3_23_C3.out A3_33_C3.out, A3_B3_C3.eps)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a Makefile that looks like this CXX = g++ -O2 -Wall all:
I m writing a simple Makefile which looks like this CC=gcc CXX=g++ DEBUG=-g COMPILER=${CXX}
I have this Makefile that has a variables named MODULES which lists all the
I have a source directory which uses makefile to compile the code. This makefile/configure
I currently have a make file, part of which looks like the following. ####################################################################
I have this C++ project which compiles using a Makefile, and sometimes when (
I have a makefile which builds a project composed of many files which all
We've got in a corporate environment an svn repository structure which looks like this:
I have a multi module maven project which looks something like: main component_one subcomponent_bob
I have a makefile which looks for .txt files in a directory and for

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.