# Makefile for kernel xxxx drivers.
#
####################################################
#linux:
#company:
#date:
###################################################
#Get work current path
#make
#make PLAT=ARM

TOPDIR := $(shell if [ "$$PWD" != "" ]; then echo $$PWD; else pwd; fi)
#CFLAGS += -Dxxxx
ifneq ($(KERNELRELEASE),)
obj-m = xxxxx.o
else

ifeq ("$(PLAT)","ARM")
KERNELDIR := xxxxxxx
CROSS_COM ?=arm-none-linux-gnueabi-
endif

ifeq ("$(PLAT)","X86")
KERNELDIR := /lib/modules/$(shell uname -r)/build
CROSS_COM ?=
endif

PWD := $(shell pwd)

all: clean
@echo $(KERNELDIR) $(MAKE)
$(MAKE) -C $(KERNELDIR) M=$(PWD) modules
#$(CROSS_COM)strip *.ko
@echo -e "\33[1;31m"
@echo -e "\t\t###################################"
@echo -e "\t\t#linux: xxxxxxxxxxxx #"
@echo -e "\t\t#company: xxxxx #"
@echo -e "\t\t#date: xxxxxxxxxxxxxxxxxxxx #"
@echo -e "\t\t#plat: <$(PLAT)> #"
@echo -e "\t\t#modifly: " $(shell date "+%Y:%m:%d %H:%M:%S")" #"
@echo -e "\t\t###################################\33[0m"
@echo
@echo -e "\33[1;34m\t\t\tCreate module oK ~_~ !\33[0m"
@echo
# @make install

install:
# rm -f /mnt/modules/*.ko
cp -rf *.ko /mnt/modules/
#ake -C ./test install
clean:
rm -rf .*.cmd *.o *.mod.c *.ko .tmp_versions *.mod.o

# make -C ./test clean
# make -C ./app clean
backup:
F=`basename $(TOPDIR)` ; cd .. ; \
gtar --force-local -zcvf `date "+$$F-%Y-%m-%d-%T.tar.gz"` $$F
endif