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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T08:01:58+00:00 2026-05-31T08:01:58+00:00

I am using GNU make 3.81. Here is a test makefile that demonstrates the

  • 0

I am using GNU make 3.81. Here is a test makefile that demonstrates the problem:

define BOZO

a$(1): b c
    touch a$(1)

endef

$(foreach i,1 2 3,$(call BOZO,$(i)))

The idea here is to use a macro template (BOZO) to generate rules that follow a predictable pattern.

Problem: when I run make on this makefile I get an error saying:

Makefile.fake:10: *** multiple target patterns.  Stop.

(where line 10 is the line with the foreach).

Now, I know what that error normally indicates. Let’s see what that line expands to by using the info function to send the expansion to standard out. I change line 10 to be:

$(info $(foreach i,1 2 3,$(call BOZO,$(i))))

and I run:

$ make -n

a1: b c
    touch a1

a2: b c
    touch a2

a3: b c
    touch a3

make: *** No targets.  Stop.

Note that the “no targets” message is expected, since the $(info …) function evaluates to empty but causes make to print the generated rules.

Let’s run those rules then shall we?

$make -n > out.txt
make: *** No targets.  Stop.
$make -f out.txt a1 a2 a3
touch a1
touch a2
touch a3
$

AAARGH! The rules work fine. So… is the bug in make, or in my understanding?

One final clue that might help diagnose: if I change the foreach line to:

$(foreach i,1,$(call BOZO,$(i)))

(so that foreach has only one iteration)

and then do

$make a1

I get a different error:

make: *** No rule to make target `a1'.  Stop.

I don’t know of any way to “see” the expansion of $(foreach ) that make sees except for $(info ), and its output is legal, so I’m quite stumped.

  • 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-05-31T08:01:59+00:00Added an answer on May 31, 2026 at 8:01 am
    $(foreach i,1 2 3,$(eval $(call BOZO,$(i))))
    

    The eval function tells Make to parse the structures as makefile syntax, to “enact” them. I’m not sure why Make objected to the un-eval’d rules this particular way, but that’s kind of academic.

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

Sidebar

Related Questions

I'm using (GNU) Make in my project. I'm currently putting one makefile per directory
I'm using GNU Make 3.81, and I have the following rule in my Makefile:
I am using gnu Make 3.82 and have an annoying problem. I have a
Here's a skeleton Makefile just to make it easier to describe the problem: all_tests
I have a C++ small project using GNU Make. I'd like to be able
I've recently started using GNU Screen but have run into a very annoying problem.
Note: using MinGW's make (should be GNU make) i have a couple of -include
Is there anything that should be done to make GNU Emacs 23.2 work well
I've noticed that the PHP make that I'm using on a dev box doesn't
I'm trying to set up an ETL system using GNU Make 3.81. The idea

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.