Updated `README.md` with instructions for building/using the kernel module.
[xeon-phi-kernel-module] / Makefile
CommitLineData
800f879a
AT
1# Copyright 2010-2017 Intel Corporation.
2#
3# This program is free software; you can redistribute it and/or modify
4# it under the terms of the GNU General Public License, version 2,
5# as published by the Free Software Foundation.
6#
7# This program is distributed in the hope that it will be useful,
8# but WITHOUT ANY WARRANTY; without even the implied warranty of
9# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10# General Public License for more details.
11#
12# Disclaimer: The codes contained in these modules may be specific to
13# the Intel Software Development Platform codenamed Knights Ferry,
14# and the Intel product codenamed Knights Corner, and are not backward
15# compatible with other Intel products. Additionally, Intel will NOT
16# support the codes or instruction set in future products.
17#
18# Intel offers no warranty of any kind regarding the code. This code is
19# licensed on an "AS IS" basis and Intel is not obligated to provide
20# any support, assistance, installation, training, or other services
21# of any kind. Intel is also not obligated to provide any updates,
22# enhancements or extensions. Intel specifically disclaims any warranty
23# of merchantability, non-infringement, fitness for any particular
24# purpose, and any other warranty.
25#
26# Further, Intel disclaims all liability of any kind, including but
27# not limited to liability for infringement of any proprietary rights,
28# relating to the use of the code, even if Intel is notified of the
29# possibility of such liability. Except as expressly stated in an Intel
30# license agreement provided with this code and agreed upon with Intel,
31# no license, express or implied, by estoppel or otherwise, to any
32# intellectual property rights is granted herein.
33
34MPSS_COMMIT ?= $(or $(shell sed -ne '2 p' .mpss-metadata 2>/dev/null), \
35 $(error .mpss-metadata file is missing or incorrect))
36MPSS_VERSION ?= $(or $(shell sed -ne '1 p' .mpss-metadata 2>/dev/null), \
37 $(error .mpss-metadata file is missing or incorrect))
38MPSS_BUILDNO ?= 0
39export MPSS_COMMIT := $(MPSS_COMMIT)
40export MPSS_VERSION := $(MPSS_VERSION)
41export MPSS_BUILDNO := $(MPSS_BUILDNO)
42export MPSS_BUILTBY := $(shell echo "`whoami`@`uname -n`")
43export MPSS_BUILTON := $(shell date +'%F %T %z')
44
45KERNEL_VERSION := $(shell uname -r)
46KERNEL_SRC = /lib/modules/$(KERNEL_VERSION)/build
47
48INSTALL = install
49INSTALL_d = $(INSTALL) -d
50INSTALL_x = $(INSTALL)
51INSTALL_f = $(INSTALL) -m644
52
53prefix = /usr/local
54sysconfdir = $(prefix)/etc
55includedir = $(prefix)/include
56
57kmodinstalldir = /lib/modules/$(KERNEL_VERSION)
58kmodincludedir = $(realpath $(KERNEL_SRC))/include/modules
59
60# If building the host's driver for a MIC co-processor card, which card
61# $(ARCH) it should support
11424294 62export MIC_CARD_ARCH = k1om
800f879a
AT
63
64.PHONY: all install modules
65.PHONY: modules_install conf_install dev_install kdev_install
66
67all: modules
68
69install: modules_install conf_install kdev_install
70
71modules modules_install: %:
72 $(MAKE) -C $(KERNEL_SRC) M=$(CURDIR) $* \
73 INSTALL_MOD_PATH=$(DESTDIR)
74
75conf_install:
76ifneq ($(MIC_CARD_ARCH),)
77 $(INSTALL_d) $(DESTDIR)$(sysconfdir)/sysconfig/modules
78 $(INSTALL_x) mic.modules $(DESTDIR)$(sysconfdir)/sysconfig/modules
79 $(INSTALL_d) $(DESTDIR)$(sysconfdir)/modprobe.d
80 $(INSTALL_f) mic.conf $(DESTDIR)$(sysconfdir)/modprobe.d
81endif
82 $(INSTALL_d) $(DESTDIR)$(sysconfdir)/udev/rules.d
83 $(INSTALL_f) udev-mic.rules $(DESTDIR)$(sysconfdir)/udev/rules.d/50-udev-mic.rules
84
85dev_install:
86 $(INSTALL_d) $(DESTDIR)$(includedir)/mic
87 $(INSTALL_f) include/scif_ioctl.h $(DESTDIR)$(includedir)
88 $(INSTALL_f) include/mic/io_interface.h $(DESTDIR)$(includedir)/mic
89 $(INSTALL_f) include/mic/mic_pm.h $(DESTDIR)$(includedir)/mic
90 $(INSTALL_f) ras/micras_api.h $(DESTDIR)$(includedir)/mic
91 $(INSTALL_f) ras/micmca_api.h $(DESTDIR)$(includedir)/mic
92ifeq ($(MIC_CARD_ARCH),) # Card side
93 $(INSTALL_f) ras/micpm_api.h $(DESTDIR)$(includedir)/mic
94 $(INSTALL_f) ras/micras.h $(DESTDIR)$(includedir)/mic
95else # Host side
96 $(INSTALL_f) include/mic/micbaseaddressdefine.h $(DESTDIR)$(includedir)/mic
97 $(INSTALL_f) include/mic/micsboxdefine.h $(DESTDIR)$(includedir)/mic
98 $(INSTALL_f) include/mic/micdboxdefine.h $(DESTDIR)$(includedir)/mic
99 $(INSTALL_f) ras/micpm_api.h $(DESTDIR)$(includedir)/mic
100endif
101
102kdev_install:
103 $(INSTALL_d) $(DESTDIR)$(kmodinstalldir)
104 $(INSTALL_f) Module.symvers $(DESTDIR)$(kmodinstalldir)/scif.symvers
105 $(INSTALL_d) $(DESTDIR)$(kmodincludedir)
106 $(INSTALL_f) include/scif.h $(DESTDIR)$(kmodincludedir)
121fcf15
AT
107
108clean:
339ca0d9 109 @rm -f ./*/*.o ./*/.*.o ./*/*/*.o ./*/*/.*.o
de748b13 110 @rm -f ./*/*.o.d ./*/.*.o.d ./*/*/.*.o.d
339ca0d9 111 @rm -f ./*/*.o.cmd ./*/.*.o.cmd ./*/*/.*.o.cmd
d9f83cfd
AT
112 @rm -f ./.mic*o.cmd
113 @rm -f ./modules.order ./Module.symvers
114 @rm -rf ./.tmp_versions
115 @rm -f ./mic.mod.* ./mic.o ./mic.ko