Srini
Srini

Reputation: 1

makefile putting objs in separate directory

Why does

$(OBJDIR)\%.o:$(SRDDIR)\%.s
    $(GCC) -c -g -I$(SRCDIR) $(ASFLAGS) $< -o $@

$(OBJDIR)\%.o:$(SRDDIR)\%.c
    $(GCC) -c -g -I$(SRCDIR) $(CFLAGS) $< -o $@

gives warning (says ignoring the first rule) where as

%.o:%.s
    $(GCC) -c -g -I$(SRCDIR) $(ASFLAGS) $< -o $@

%.o:%.c
    $(GCC) -c -g -I$(SRCDIR) $(CFLAGS) $< -o $@

works fine but I will have all my sources and objs in the same directory. I would like to put the objs (generated from assembly files and c files) in a separate directory( and I am running make on windows).

Upvotes: 0

Views: 270

Answers (2)

Beta
Beta

Reputation: 99104

Try using forward slashes ("/") instead of backward ones ("\").

Upvotes: 1

Matt Williamson
Matt Williamson

Reputation: 40193

The -o flag of GCC determines where the output file are made.

So this may work if you change:

%.o:%.s $(GCC) -c -g -I$(SRCDIR) $(ASFLAGS) $< -o $@

TO

%.o:%.s $(GCC) -c -g -I$(SRCDIR) $(ASFLAGS) $< -o myoutputdir/$@

Upvotes: 0

Related Questions