karthik
karthik

Reputation: 355

makefile concepts

can anyoone help me. this is the code for make file i'm just trying to save different objective files at different directories is that possible? in the below code.

OBJECTS = objj/mall.o objj/fall.o 

BACK = kajj/ball.o kajj/call.o

DIR = objj kajj rajj 

execc/gola : $(OBJECTS) $(BACK)
    gcc $^  -o  $@
$(OBJECTS):objj/%.o:%.c
    mkdir   $(DIR)
    gcc -c  $<  -o  $@
$(BACK) : kajj/%.o

i want to save the mall.o fall.o in objj and ball.o and call.o in kajj i'm stucked up here i dont know how to cotinue further can anyone help me if we use %.o:%.c it replaces all obj files one on one but how to seperate them. and anyone please tell me what these line really does $(OBJECTS):objj/%.o:%.c.im unable to understand we can have only one colon in our line but here we have two im confused help me out guys

Upvotes: 0

Views: 169

Answers (1)

Didier Trosset
Didier Trosset

Reputation: 37477

For the two column rules, consider what is before the first as the actual targets, and what is after the first column as a pattern rule.

Thus, to compile the objects in kajj, you could replace your last rule by:

$(BACK): kajj/%.o: %.c
    mkdir   $(DIR)
    gcc -c  $<  -o  $@

Upvotes: 1

Related Questions