Makefile run processes in background

后端 未结 3 1875
清歌不尽
清歌不尽 2020-12-19 01:03

I have this in my Makefile:

run:
     for x in *.bin ; do ./$$x ; done

such that it launches all executables one by one. I want to do this:

3条回答
  •  温柔的废话
    2020-12-19 01:46

    Try to execute via a subshell:

    run:
         for x in *.bin ; do (./$$x &); done
    

    Maybe make -j is a better option. Try a Makefile that looks something like this:

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

    And then execute with make -j where is number of simultaneous jobs to run.

提交回复
热议问题