Recursive make in subdirectories

前端 未结 4 704
清歌不尽
清歌不尽 2021-02-04 01:37

How can I order make command in the Makefile to execute recursively in all subdirectories make commands (defined in the Makefile in the subdirectories)

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-04 02:02

    @eldar-abusalimov, the first link you posted assumes the makefile knows what are the subfolders. This is not always true, and I guess thats what @tyranitar would like to know. In that case, such a solution can do the job: (took me some time, but I needed it too)

    SHELL=/bin/bash
    
    all:
        @for a in $$(ls); do \
            if [ -d $$a ]; then \
                echo "processing folder $$a"; \
                $(MAKE) -C $$a; \
            fi; \
        done;
        @echo "Done!"
    

提交回复
热议问题