LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Makefile missing for .c file. How to create (https://www.linuxquestions.org/questions/programming-9/makefile-missing-for-c-file-how-to-create-719395/)

pgb205 04-15-2009 04:05 PM

Makefile missing for .c file. How to create
 
I have a forcedeth.c (ver 0.62) code that i need to compile against a running kernel, and there are no rpms that i know for my distro(centos 5.3) Usually there is a Makefile in the directory but not this time, there is only forcedeth.c file. I'm not sure how to creat a makefile so that i could do ./configure;make;make install

thanks in advance for help.

dwhitney67 04-16-2009 03:58 AM

The most basic Makefile would perhaps look something like (note, this is a home-made Makefile):
Code:

SRCS  = forcedeth.c
OBJS  = $(SRCS:.c=.o)

obj-m += $(OBJS)

EXTRA_CFLAGS = -O2


all:
        $(MAKE) -C /lib/modules/`uname -r`/build M=$(PWD) modules

clean:
        $(MAKE) -C /lib/modules/`uname -r`/build M=$(PWD) clean
        $(RM) Module.markers modules.order

However, since I do not know anything about 'forcedeth.c' nor any dependencies it may have with other modules, I doubt this Makefile will work, but nevertheless, you may want to give it a try.

Btw, I am surprised that your kernel does not offer the forcedeth driver, since it appears that many modern Linux distros offer it with their kernels. Is it possible that your kernel has the source for 'forcedeth.c', but that it is not being built because of your kernel configuration? It would verify this first before proceeding down another path.

knudfl 04-18-2009 03:25 AM

This is the forcedeth Makefile, I found here
http://www.nvnews.net/vbulletin/showthread.php?t=96453
Code:

obj-m := forcedeth.o

KDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)

default:
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) clean
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules

So it seems rather simple to do, no dependencies mentioned ?
.....


All times are GMT -5. The time now is 04:27 PM.