一个经典的makefile文件,该文件为PF_RING的makefile

来源:互联网 发布:java jdk环境配置 编辑:程序博客网 时间:2024/06/01 23:39

#
# (C) 2009-10 - Luca Deri <deri@ntop.org>
#

obj-m := pf_ring.o

SVNDEF := -DSVN_REV="/"$(shell svnversion -n .)/""

ifeq (,$(BUILD_KERNEL))
BUILD_KERNEL=$(shell uname -r)
endif

EXTRA_CFLAGS += -I$(PWD) $(SVNDEF)

HERE=$(PWD)

# set the install path
INSTDIR := $(DESTDIR)/lib/modules/$(BUILD_KERNEL)/kernel/net/pf_ring
TARGETDIR := /usr/src/$(BUILD_KERNEL)/include/linux/

all: Makefile pf_ring.c linux/pf_ring.h
    @if test "$(USER)" = "root"; then /
        echo "********** WARNING WARNING WARNING **********"; /
        echo "*"; /
        echo "* Compiling PF_RING as root might lead you to compile errors"; /
        echo "* Please compile PF_RING as unpriviliged user"; /
        echo "*"; /
        echo "*********************************************"; /
    fi
    make -C /lib/modules/$(BUILD_KERNEL)/build SUBDIRS=$(HERE) EXTRA_CFLAGS='$(EXTRA_CFLAGS)' modules
    cd plugins; make

clean:
    make -C /lib/modules/$(BUILD_KERNEL)/build SUBDIRS=$(HERE) clean
    /rm -f *~ Module.symvers  Module.markers  modules.order *#

install:
    mkdir -p $(INSTDIR)
    cp *.ko $(INSTDIR)
    cp linux/pf_ring.h $(DESTDIR)/usr/src/linux-headers-$(BUILD_KERNEL)/include/linux/
    @if test -d ${TARGETDIR}; then /
        cp linux/pf_ring.h ${TARGETDIR}; /
    fi
ifeq (,$(DESTDIR))
    /sbin/depmod $(BUILD_KERNEL)
endif