gcc - Cannot compile to a seperate directory using make -


i trying compile binaries directory... works if compile root directly. @ first, attempted let gcc handle passing bin/ under -o flag. make appears (infuriatingly) remove path target , compile root anyway...

then tried letting make handle it, fails find rule compile anything.

the other thing tried adding:

$(objects): 

to first rule, make calls gcc no arguments.

this version let make handle paths:

cc = gcc dir = bin targets = cloud controller objects = $(addprefix $(dir)/, $(targets))  all: $(objects)  $(dir)/%: $@.c         $(cc) $< -o $@  $(dir):         mkdir $(dir) 

this version let gcc handle paths:

cc = gcc dir = bin targets = cloud controller  all: $(targets)     mkdir $(dir) -p  %: $@.c         $(cc) $< -o $(dir)/$@ 

changed $@ %, per @etanreisner's comment.


Comments