3

I have this in makefile:

# find cpp files in subdirectories
SOURCES := $(shell find . -name '*.cpp')

So I wanted to make generic FIND command that behaves correctly on windows and linux:

ifeq ($(OS),Windows_NT)
   # WINDOWS
   RM = erase /Q
   FIND = ???
else
   # LINUX
   ifeq ($(shell uname), Linux)
      RM = rm -f
      # This is probably wrong too, but I have no idea how to do it right
      FIND = $(find . -name '$1')
   endif
endif

Of course, I don't even know how to make parametrized find template for linux. But more importantly, I cannot find command to find all files by pattern. Windows has this:

dir * /s/b | findstr \.cpp$

Which is beautiful, but that uses regular expression... How can I port this right, so that find behaves well on both systems? Doesn't makefile have it's own method for finding files?

Tomáš Zato
  • 4,790

0 Answers0