Skip to content

Commit

Permalink
Add Makefile
Browse files Browse the repository at this point in the history
  • Loading branch information
root committed May 13, 2015
1 parent 1605430 commit e41aadd
Show file tree
Hide file tree
Showing 2 changed files with 82 additions and 0 deletions.
58 changes: 58 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
################################################################################
# Makefile - Build Linux kernel modules with Makefile.kbuild receipe
# for building out-of-tree kernel modules
#
# Copyright (C) 2015 Advantech Corp., Irvine, CA, USA
# Author: Richard Vidal-Dorsch <richard.dorsch@advantech.com>
################################################################################

all: clean modules

EXTRA_CFLAGS += -Wall -O2 -g
# Uncomment below for Red Hat/CentOS/Scientific Linux <= 7.1
# EXTRA_CFLAGS += -D__RHEL7__

NAME := imanager

DEPMOD := $(shell which depmod)
STRIP := $(shell which strip)
DRVPATH := /lib/modules/$(shell uname -r)/extra/$(NAME)

# MFD driver is always anabled.
CONFIG_MFD := m
CONFIG_GPIO := m
CONFIG_I2C := m
CONFIG_SENSORS := m
CONFIG_BACKLIGHT := m
CONFIG_WDT := m

# If KERNELRELEASE is defined, we've been invoked from the
# kernel build system and can use its language.
ifneq ($(KERNELRELEASE), )

ccflags-y += $(EXTRA_CFLAGS) -I$(src)/include
include $(src)/Makefile.kbuild
else

# Otherwise we were called directly from the command
# line; invoke the kernel build system.
KDIR := /lib/modules/$(shell uname -r)/build
PWD := $(shell pwd)

endif

modules:
$(MAKE) -C $(KDIR) M=$(PWD) modules

clean:
$(MAKE) -C $(KDIR) M=$(PWD) clean
$(RM) -rf *.bak include/linux/mfd/imanager/*.bak

install: modules
$(MAKE) -C $(KDIR) M=$(PWD) INSTALL_MOD_DIR=extra/$(NAME) modules_install
$(DEPMOD) -a

uninstall:
$(RM) -r $(DRVPATH)
$(DEPMOD) -a

24 changes: 24 additions & 0 deletions Makefile.kbuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
################################################################################
# Makefile.kbuild - Build receipe for Linux kernel modules
#
# Copyright (C) 2015 Advantech Corp., Irvine, CA, USA
# Author: Richard Vidal-Dorsch <richard.dorsch@advantech.com>
################################################################################

$(NAME)-objs := $(NAME)-core.o $(NAME)-ec.o
obj-$(CONFIG_MFD) += $(NAME).o

gpio-$(NAME)-objs := $(NAME)-gpio.o $(NAME)-ec-gpio.o
obj-$(CONFIG_GPIO) += gpio-$(NAME).o

i2c-$(NAME)-objs := $(NAME)-i2c.o $(NAME)-ec-i2c.o
obj-$(CONFIG_I2C) += i2c-$(NAME).o

$(NAME)_hwmon-objs := $(NAME)-hwmon.o $(NAME)-ec-hwmon.o
obj-$(CONFIG_SENSORS) += $(NAME)_hwmon.o

$(NAME)_bl-objs := $(NAME)-bl.o $(NAME)-ec-bl.o
obj-$(CONFIG_BACKLIGHT) += $(NAME)_bl.o

$(NAME)_wdt-objs := $(NAME)-wdt.o $(NAME)-ec-wdt.o
obj-$(CONFIG_WDT) += $(NAME)_wdt.o

0 comments on commit e41aadd

Please sign in to comment.