Sources from subdirectories in Makefile

后端 未结 7 1314
无人共我
无人共我 2020-11-29 19:06

I have a C++ library built using a Makefile. Until recently, all the sources were in a single directory, and the Makefile did something like this

SOURCES = $(w

7条回答
  •  北海茫月
    2020-11-29 19:55

    If you can use find shell command, you may define a function to use it.

    recurfind = $(shell find $(1) -name '$(2)')
    SRCS := $(call recurfind,subdir1,*.c) $(call recurfind,subdir2,*.cc) $(call recurfind,subdir2,*.cu) \
            ...
    

提交回复
热议问题