help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Getting list of source files from directory hierarchy


From: Paul Smith
Subject: Re: Getting list of source files from directory hierarchy
Date: Sat, 26 Sep 2009 21:58:18 -0400

On Fri, 2009-09-25 at 18:42 -0700, Michael Morrell wrote:
> I have some Makefiles that want to get a list of all source files in
> a directory hierarchy and currently use:
> 
> SRCS := $(shell find . -name '*.c')
> OBJS := $(SRCS:.c=.o)
> 
> The problem with this is that the output from find isn't deterministic,
> which means the objects files can get linked into the final executable in
> an arbitrary order and I want the result to be identical from run to run
> from the same source.
> 
> My current fix for this is:
> 
> SRCS := $(shell find . -name '*.c' | sort)
> 
> but I was wondering if anyone could suggest a better method.

I'm not sure what you mean by "better"; what would be better?

Anyway, I can't think of any other way to do it (you could use GNU
make's $(sort ...) function if you wanted but I don't think there's much
point... and it's probably less efficient than using the shell's sort in
this situation).

-- 
-------------------------------------------------------------------------------
 Paul D. Smith <address@hidden>          Find some GNU make tips at:
 http://www.gnu.org                      http://make.mad-scientist.net
 "Please remain calm...I may be mad, but I am a professional." --Mad Scientist




reply via email to

[Prev in Thread] Current Thread [Next in Thread]