[Omake] output dir not the same as source dir
Sashan Govender
sashang at gmail.com
Tue Nov 11 03:41:13 PST 2008
I ended up writing some rules of my own to do this several months ago.
I've pasted them below. I'm assuming there's 101 things wrong with
them that I'm missing otherwise this wouldn't be an issue.
public.CBuildObjs(SOURCES, OUTDIR, FLAGS) =
#what a pain - you can't have a path in an implict rule for some reason
#so this while foreach construct is there to convert what should be an
#implicit rule into a set of explicit rules for all the files in CFILES
mkdir -p $(OUTDIR)
foreach (SOURCE, $(SOURCES))
$(OUTDIR)/$(replacesuffixes .c, .o, $(SOURCE)) : $(SOURCE)
:scanner: scan-c-$(SOURCE)
$(CC) -c $(FLAGS) -o $@ $<
public.CLinkObjs(NAME, OBJFILES, OUTDIR, FLAGS, LIBS) =
mkdir -p $(OUTDIR)
$(OUTDIR)/$(NAME): $(OBJFILES) $(LIBS)
$(CC) $(LFLAGS) -o $(OUTDIR)/$(NAME) $(OBJFILES) $(LIBS)
public.CBuildProgram(NAME, SOURCES, OUTDIR, CFLAGS, LFLAGS) =
mkdir -p $(OUTDIR)
private.COFILES = $(addprefix $(OUTDIR)/, $(replacesuffixes .c,
.o, $(SOURCES)))
CBuildObjs($(SOURCES), $(OUTDIR), $(CFLAGS))
CLinkObjs($(NAME), $(COFILES), $(OUTDIR), $(LFLAGS))
I use them in sections in other OMakefiles in my tree as shown below.
section
CFLAGS += -O2
CBuildProgram($(PROGRAM), $(SOURCES), release, $(CFLAGS),
$(LDFLAGS), $(LIBS))
section
CFLAGS += -g -O0
CBuildProgram($(PROGRAM), $(SOURCES), debug, $(CFLAGS), $(LDFLAGS), $(LIBS))
On Fri, Nov 7, 2008 at 12:17 PM, Aleksey Nogin <nogin at metaprl.org> wrote:
> Sashan,
>
> If we ever get around to writing an OMake FAQ, this would probably be
> the first question. The short answer is that there is no good built-in
> mechanism yet, but as it's probably one of the most commonly requested
> features, it's definitely on our TODO list.
>
> There are two possibilities that are far from perfect, but could be a
> reasonable workaround:
>
> - Live with output files in the source directories. If you've built a
> release build and suddenly need a debug one, or vise versa, just go
> ahead and rebuild. Note that since OMake considers the text of the
> command used to build a file as the file's dependency, it will
> automatically know which files need rebuilding when you switch from one
> kind of build to another.
>
> - Use the vmount feature. There are lots of potential problems with it,
> but it might work for you.
>
> Aleksey
>
> On 03.11.2008 18:49, Sashan Govender wrote:
>
>> Hi
>>
>> Does omake support a built in way of generating the output files into
>> a different directory from the source code files. By default the build
>> output goes into the same directory as the source code files. This is
>> a problem when I have 2 different build types, for example a debug or
>> release build. I've written my own rules to get around this and they
>> let me specify a output directory for intermediate files but was
>> wondering if I was missing some built-in way for omake to do this.
>>
>
More information about the Omake
mailing list