assem
assem

Reputation: 3213

Why can make work here?

Makefile:

KERNEL_DIR := /usr/src/linux-2.6.32.9

obj-m := try.o

driver:     try.c
    make -C $(KERNEL_DIR) SUBDIRS=`pwd` modules
clean:
    rm -rf *.o *.ko *.mod.c

When I type make,make -C $(KERNEL_DIR) SUBDIRS=pwdmodules is run,as if make driver is run ,why?

Upvotes: 4

Views: 333

Answers (2)

jho
jho

Reputation: 2253

make runs the first possible thing from a makefile if called without an argument. obj-m and KERNEL_DIR are not rules, they are variables. driver is the first rule to follow.

Upvotes: 3

Lars Noschinski
Lars Noschinski

Reputation: 3667

If make is invoked without specifying a goal, make chooses the first target in the makefile as a goal. In this cases, it is driver. obj-m and KERNEL_DIR are only variable assignments, not targets.

Upvotes: 1

Related Questions