diff options
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 128 |
1 files changed, 53 insertions, 75 deletions
@@ -1,103 +1,81 @@ -# Copyright (c) 2002 - 2003 Oliver Kurth -# (c) 2003 - 2004 Jörg Albert <joerg.albert@gmx.de> -# -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of -# the License, or (at your option) any later version. -# - -# KERNEL_PATH is the path to the Linux kernel build tree. It is usually -# the same as the kernel tree, except when a separate directory was used -# for the binaries. By default, we try to compile the modules for the -# currently running kernel. -KERNEL_PATH ?= $(shell readlink -f /lib/modules/`uname -r`/build) - -ifeq (,$(KERNEL_PATH)) -$(error Kernel tree not found - please set KERNEL_PATH) -endif - -VERSION_HEADER = $(KERNEL_PATH)/include/linux/utsrelease.h -ifeq (,$(wildcard $(VERSION_HEADER))) -VERSION_HEADER = $(KERNEL_PATH)/include/linux/version.h -ifeq (,$(wildcard $(VERSION_HEADER))) -$(error Kernel in $(KERNEL_PATH) is not configured) -endif -endif +VERSION = 0.8pas1 -# Kernel Makefile doesn't always know the exact kernel version, so we -# get it from the kernel headers instead and pass it to make. -KERNELRELEASE = $(shell sed -ne 's/"//g;s/^\#define UTS_RELEASE //p' \ - $(VERSION_HEADER)) +CC=gcc +KERNEL_VERSION = $(shell uname -r) -obj-m = at76_usb.o +KERNEL_SRC = /lib/modules/$(KERNEL_VERSION)/build +KERNEL_HEADERS = $(KERNEL_SRC)/include -at76_usb-objs = at76c503.o +MODULES = at76c503.o usbdfu.o vnet503-rfmd.o -SRCS = at76c503.c at76c503.h +SRCS = at76c503.c usbdfu.c at76c503fw.c rom2h.c vnet503-rfmd.c +HDRS = at76c503.h ieee802_11.h usbdfu.h fw-rfmd-0.90.2-140.h fw-rfmd-0.100.4-16.h +MODULE_DIR = $(DESTDIR)/lib/modules/$(KERNEL_VERSION)/kernel/drivers/usb/ +CPPFLAGS = -D__KERNEL__ \ + -DMODULE -DEXPORT_SYMTAB \ + -DDRIVER_VERSION=\"v$(VERSION)\" \ + -I$(KERNEL_HEADERS) +CFLAGS = -O2 -Wall -Wstrict-prototypes -pipe -SPECFILE = at76c503a.spec +MODVER = $(shell if cat $(KERNEL_HEADERS)/linux/autoconf.h 2>/dev/null | \ +grep -q '^[[:space:]]*\#define[[:space:]]*CONFIG_MODVERSIONS[[:space:]]*1'; \ +then echo 1; else echo 0; fi) -DISTFILES = $(SRCS) Makefile README COPYING CHANGELOG kernel_patch.diff - -# get the version from at76c503.h -ifndef M -VERSION = $(shell sed -n 's/^\#define.*DRIVER_VERSION.*"\(.*\)".*$$/\1/p' at76c503.h) -DISTNAME = at76_usb-$(VERSION) -DISTDIR = $(DISTNAME) +ifeq ($(MODVER),1) +MFLAG = -DMODVERSIONS -include $(KERNEL_HEADERS)/linux/modversions.h endif -INSTALL_MOD_DIR = kernel/drivers/net/wireless -MODULE_DIR = $(INSTALL_MOD_PATH)/lib/modules/$(KERNELRELEASE)/$(INSTALL_MOD_DIR) -DEPMOD = /sbin/depmod - -SPARSE_FLAGS = -Wall -D__CHECK_ENDIAN__ +CCDEP = $(CC) $(CFLAGS) -M +TAR = tar -PWD = $(shell pwd) -KBUILD_FLAGS = -C $(KERNEL_PATH) M=$(PWD) KERNELRELEASE=$(KERNELRELEASE) +DISTFILES = $(SRCS) $(HDRS) Makefile README COPYING +TOPDISTFILES = +DISTNAME = at76c503-$(VERSION) +DISTDIR = ../dist +all: $(MODULES) -all: modules +at76c503fw: at76c503fw.c + $(CC) $(CFLAGS) -o $@ $< -lusb -modules: - $(MAKE) $(KBUILD_FLAGS) modules +rom2h: rom2h.c + $(CC) $(CFLAGS) -o $@ $< -check: - $(MAKE) $(KBUILD_FLAGS) C=2 CF="$(SPARSE_FLAGS)" +TAGS: + rm -f TAGS + find $(KERNEL_SRC)/ -name '*.[ch]' | xargs etags --append + etags --append $(SRCS) $(HDRS) -install: - rm -rf $(MODULE_DIR)/at76* - $(MAKE) $(KBUILD_FLAGS) modules_install \ - INSTALL_MOD_DIR="$(INSTALL_MOD_DIR)" - $(DEPMOD) -ae +install: all + mkdir -p $(MODULE_DIR) + for f in $(MODULES); do install -m 644 -o 0 -g 0 $$f $(MODULE_DIR)/$$f; done + /sbin/depmod -a uninstall: - rm -rf $(MODULE_DIR)/at76* - -TAGS: - rm -f TAGS - etags --append $(SRCS) + for f in $(MODULES); do rm $(MODULE_DIR)/$$f; done clean: + rm -f at76c503fw rom2h rm -f core *.o *~ a.out *.d - rm -f *.ko *.mod.c .*.cmd rm -f *.s *.i - rm -rf .tmp_versions - -ChangeLog: CVS/Entries - cvs2cl dist: - rm -rf $(DISTNAME) + [ -d $(DISTNAME) ] && rm -rf $(DISTNAME) || true mkdir $(DISTNAME) - cp -f $(DISTFILES) $(DISTNAME) - sed 's/^%define PACKVER.*$$/%define PACKVER $(VERSION)/' \ - $(SPECFILE) >$(DISTNAME)/$(SPECFILE) + cp -aR $(DISTFILES) $(DISTNAME) tar zcvf $(DISTNAME).tar.gz $(DISTNAME) rm -rf $(DISTNAME) -rmmod: - -rmmod $(obj-m:%.o=%) +.PHONY: dist + +%.o: %.c + $(CC) -MD $(CFLAGS) $(CPPFLAGS) $(MFLAG) -c $< + +%.s: %.c + $(CC) -MD $(CFLAGS) $(CPPFLAGS) -S $< + +%.i: %.c + $(CC) -MD $(CPPFLAGS) -E $< -o $@ -.PHONY: all modules check install uninstall clean dist rmmod +-include $(SRCS:%.c=%.d) |