Linux module "Hello world" Makefile is missing something
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Linux module "Hello world" Makefile is missing something
Hi!
I'm trying to run a "make" on a basic Makefile I created for a "Hello world" linux module, however if I run "make" or "make clean" it fails to work. I have to write more stuff in order to make it work (redundant stuff cause I define that stuff in the Makefile).
First, the Makefile:
Code:
obj-m := helloworld.o
KDIR=/lib/modules/$(shell uname -r)/build
PWD=$(shell pwd)
all:
make -C $(KDIR) M=$(PWD) modules
clean:
make -C $(KDIR) M=$(PWD) clean
Now, see what happens when I call make directly:
Code:
$ make
make: Nothing to be done for `all'.
$ make clean
make: Nothing to be done for `clean'.
I have to duplicate what's in the Makefile for it to work:
Distribution: Ubuntu 11.4,DD-WRT micro plus ssh,lfs-6.6,Fedora 15,Fedora 16
Posts: 3,233
Rep:
would you be invoking make from within a makefile? i would imagine you'de be invoking the compiler
here's an example makefile from Xcplay (i didn't write the makefile i just happened to have it on hand)
Here is an example of a Makefile for a kernel module.
Now the important thing here to note is that the red dots shown below must be replaced by a TAB, replacing them by spaces will cause Makefile to malfunction.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.