Jump to content

Failure to create sample module

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
3 replies to this topic

#1
Dahsar

Dahsar

    Newbie

  • Members
  • Pip
  • 6 posts
I am simply trying to make a standard "Hello world" module, as I am learning about Linux device drivers.

My module goes like this:
#include <linux/init.h>
#include <linux/module.h>
MODULE_LICENSE("Dual BSD/GPL");

static int hello_init(void)
{
printk(KERN_ALERT "Hello, world\n");
return 0;
}

static void hello_exit(void)
{
printk(KERN_ALERT "Goodbye, cruel world\n");
}

module_init(hello_init);
module_exit(hello_exit);


My Makefile goes like this:

obj-m += hello.o

all:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules
clean:
make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean


My error is this:

dahsar@UbuntuBook:~/drivers$ make
make -C /lib/modules/2.6.28-11-generic/build M=/home/dahsar/drivers modules
make: *** /lib/modules/2.6.28-11-generic/build: No such file or directory. Stop.
make: *** [all] Error 2


I clearly see build in that directory. However it seems to be a file, not a directory of its own. What am I doing wrong?

Any help will be much appreciated.

Thanks,

Rbro

Edited by WingedPanther, 20 June 2009 - 04:56 AM.
add code tags (the # button)


#2
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
two issues:
1) you haven't created a dependence in your makefile for the existence of the directory
2) as posted, you don't have the tabs that are required to make it work.

note: please use code tags (the # button) when posting code.
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog

#3
Dahsar

Dahsar

    Newbie

  • Members
  • Pip
  • 6 posts
The tabs have been set, but how do you set the dependence?

#4
WingedPanther

WingedPanther

    A spammer's worst nightmare

  • Moderators
  • 16,831 posts
It looks like you can just do a force create (mkdir) with an option. Issue 14 - qtd - mkdir in Makefile complains when directory exists - Google Code
Programming is a branch of mathematics.
My CodeCall Blog | My Personal Blog