15. 驱动通用编译脚本

Makefile

#****************************************************************
#                                                               *
# Makefile for MB86M01/M02/M03 driver                   *
# COPYRIGHT FUJITSU SEMICONDUCTOR LIMITED 2012          *
#                                                               *
#****************************************************************
CROSS_COMPILE = arm-xilinx-linux-gnueabi-
ifdef CROSS_COMPILE
    KERN_RELEASE := 4.0.0-xilinx
else
    KERN_RELEASE := $(shell uname -r)
endif


KDIR    := /home/zynq/workspace/hi3521/kernel/linux-xlnx-xilinx-v2015.4
PWD    := $(shell pwd)
DEST    := $(ROOTFS_TOP)/lib/modules/$(KERN_RELEASE)/$(MDIR)


MASTERNAME= zynq_driver


#
EXTRA_CFLAGS += -DFMB_VERSION=\"2.0.0.6992\"
EXTRA_CFLAGS += -Wall
EXTRA_CFLAGS += -Werror
EXTRA_CFLAGS += -O3
#EXTRA_CFLAGS += -DMB86M31_DISABLE_VEI
#EXTRA_CFLAGS += -DMB86M31_ENABLE_KERNEL_PANIC


export EXTRA_CFLAGS


obj-m    := $(MASTERNAME).o
inst-m    := $(MASTERNAME).ko  


zynq_driver-objs := logic_driver.o FPGA.o gpio.o logic_api.o xil_io.o comm.o pcm.o


default::
#    $(MAKE) -C $(KDIR) M=$(PWD) V=1 modules
    $(MAKE) ARCH=arm CROSS_COMPILE=arm-xilinx-linux-gnueabi- -C $(KDIR) M=$(PWD) modules


install::
#    strip --strip-debug $(inst-m)
     ifdef CROSS_COMPILE
        -su -c "mkdir -p $(DEST); cp -v $(inst-m) $(DEST); /sbin/depmod -b $(ROOTFS_TOP) -a $(KERN_RELEASE)"
     else
        -su -c "mkdir -p $(DEST); cp -v $(inst-m) $(DEST); /sbin/depmod -a"
     endif


clean:
    $(RM) -r *.o *.ko *.mod.c Module.* modules.* .*.cmd .tmp_versions


uninstall::
     ifdef CROSS_COMPILE
        -su -c "rm $(DEST)$(inst-m); /sbin/depmod -b $(ROOTFS_TOP) -a $(KERN_RELEASE)"
     else
        -su -c "rm $(DEST)$(inst-m); /sbin/depmod -a"
     endif

posted @ 2020-03-23 11:38  standardzero  阅读(202)  评论(0编辑  收藏  举报