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

  • Home
  • SEARCH
  • 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 6659577
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T02:03:02+00:00 2026-05-26T02:03:02+00:00

I have this in my Makefile: BINS = $(shell echo *.bin) .PHONY: $(BINS) run:

  • 0

I have this in my Makefile:

BINS = $(shell echo *.bin)

.PHONY: $(BINS)
run: $(BINS)

*.bin:
    ./$@

I run it as make -j 8

This way it looks for all files ending with .bin, and runs them in parallel using make’s -j option (Makefile run processes in background)

I need to modify the makefile so that it runs all files of the type mpi*.bin as mpirun -np 2 ./mpi*.bin, and the remaining executable files as ./<filename>.bin

Thanks for your help.

  • 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-26T02:03:02+00:00Added an answer on May 26, 2026 at 2:03 am

    Here is a simple example I used to test my answer:

    touch {a,b,c,d}.bin mpi{a,b,c,d}.bin
    

    to create some empty test files, and my Makefile based on yours:

    BINS = $(shell echo *.bin)
    
    .PHONY: $(BINS)
    run: $(BINS)
    
    *.bin:
        echo "bin file: " ./$@
    
    mpi*.bin:
        echo "mpi file: " ./$@
    

    It is key here that the rule for the prefixed files follows the non-prefixed rule. If not, the prefixed rule will be overridden.

    This seems to work for distinguishing between the prefixed and non-prefixed files, but gives the following output:

    ~/tmp$ make
    Makefile:10: warning: overriding commands for target `mpia.bin'
    Makefile:7: warning: ignoring old commands for target `mpia.bin'
    Makefile:10: warning: overriding commands for target `mpib.bin'
    Makefile:7: warning: ignoring old commands for target `mpib.bin'
    Makefile:10: warning: overriding commands for target `mpic.bin'
    Makefile:7: warning: ignoring old commands for target `mpic.bin'
    Makefile:10: warning: overriding commands for target `mpid.bin'
    Makefile:7: warning: ignoring old commands for target `mpid.bin'
    echo "bin file: " ./a.bin
    bin file:  ./a.bin
    echo "bin file: " ./b.bin
    bin file:  ./b.bin
    echo "bin file: " ./c.bin
    bin file:  ./c.bin
    echo "bin file: " ./d.bin
    bin file:  ./d.bin
    echo "mpi file: " ./mpia.bin
    mpi file:  ./mpia.bin
    echo "mpi file: " ./mpib.bin
    mpi file:  ./mpib.bin
    echo "mpi file: " ./mpic.bin
    mpi file:  ./mpic.bin
    echo "mpi file: " ./mpid.bin
    mpi file:  ./mpid.bin
    

    I’m sure that there’s a way to suppress those warnings or do it better, but this approach seems to work.

    • 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 have this makefile: SHELL=/bin/zsh COMPILER=g++ -g COMPILERSO=g++ -a +a1 -b LIBDIR=/Users/romeovs/Desktop/rootex CFLAGS=$(root-config --cflags)
I have Makefile like this: b: @echo b a: @echo a @make b I
I have this in my Makefile: run: for x in *.bin ; do ./$$x
For example, I have something like this in my makefile: all: cd some_directory But
I have this Makefile code: %.spf: @echo $@; runMe.sh $1 $2 $3 $4 $5;
I have this Makefile and each line run OK separately, but when I do
At the beginning of a makefile I have this line : PATH := $(PATH):/other/dir
I have a section of makefile that has this sort of structure: bob: ifdef
I have created a really basic project (Make) like this: (ede-proj-project zrm :name zrm

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.