forked from Aquantia/AQtion
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
112 lines (93 loc) · 2.79 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
# SPDX-License-Identifier: GPL-2.0-only
################################################################################
#
# Atlantic Network Driver
#
# Copyright (C) 2014-2019 aQuantia Corporation
# Copyright (C) 2019-2020 Marvell International Ltd.
#
################################################################################
#
# Makefile for the AQtion(tm) Ethernet driver
#
ifneq ($(KERNELRELEASE),)
include $(src)/Kbuild
else
TARGET := atlantic
export DEBIAN=`/usr/bin/dpkg --search /usr/bin/dpkg >/dev/null 2>&1 && echo 1 || echo 0`
export KO_EXISTS=`cat /etc/modules 2>/dev/null | grep atlantic && echo 1 || echo 0`
ifndef KDIR
BUILD_DIR:=/lib/modules/$(shell uname -r)/build
else
BUILD_DIR:=$(KDIR)
endif
PWD:=$(shell pwd)
all:
$(MAKE) -j4 -C $(BUILD_DIR) M="$(PWD)" modules
dox: .doxygen
@doxygen $<
clean:
$(MAKE) -j4 -C $(BUILD_DIR) M="$(PWD)" clean
@-rm -rdf doc/html 2 > /dev/null
load:
modprobe ptp
modprobe crc_itu_t
modprobe -q macsec || true
insmod ./$(TARGET).ko
unload:
rmmod ./$(TARGET).ko
install:
@install -D -m 644 ${TARGET}.ko /lib/modules/$(shell uname -r)/updates/drivers/net/ethernet/aquantia/atlantic/${TARGET}.ko
@depmod -a $(shell uname -r)
@$(MAKE) -f $(lastword $(MAKEFILE_LIST)) updateramfs
updateramfs:
@if [ "${DEBIAN}" = "1" ]; then \
lsinitramfs /boot/initrd.img-$(shell uname -r)|grep ${TARGET}.ko >/dev/null 2>&1 ; \
export grep_result=$$? ;\
else \
lsinitrd|grep ${TARGET}.ko >/dev/null 2>&1 ; \
export grep_result=$$? ;\
fi ; \
if [ $$grep_result -eq 0 ]; then \
export inramfs=1 ; \
else \
export inramfs=0 ; \
fi ; \
if [ $$inramfs -eq 1 ]; then \
echo "${TARGET}.ko is in initramfs." ; \
echo "CAUTION! Updating initramfs is potentially dangerous." ; \
echo -n "Attempt initramfs update? [yN] " ; \
read yn ; \
case $$yn in \
[Yy]) export updateramfs=1; break;; \
*) export updateramfs=0; break;; \
esac ; \
else \
export updateramfs=1 ; \
fi ; \
if [ $$updateramfs -eq 1 -a "${DEBIAN}" = "1" ]; then \
update-initramfs -u ; \
if [ "${KO_EXISTS}" = "0" ]; then echo atlantic >> /etc/modules ; fi; \
elif [ $$updateramfs -eq 1 ]; then \
dracut --force ; \
fi
uninstall:
@modprobe -r -n --first-time ${TARGET} >/dev/null 2>&1 ; \
if [ $$? -eq 0 ]; then \
echo -n "The driver is in use. Uninstall will stop the traffic! Continue? [yN] " ; \
read yn ; \
case $$yn in \
[Yy]) export yn_y=1; break;; \
*) export yn_n=0; break;; \
esac ; \
if [ ! $$yn_y ]; then \
echo "Uninstall aborted." ; \
exit 1 ; \
fi \
fi
@modprobe -r ${TARGET}
@if [ "${KO_EXISTS}" != "0" ]; then sed -in '/${TARGET}/d' /etc/modules ; fi
@rm -f /lib/modules/$(shell uname -r)/updates/drivers/net/ethernet/aquantia/atlantic/${TARGET}.ko
@depmod -a $(shell uname -r)
@$(MAKE) -f $(lastword $(MAKEFILE_LIST)) updateramfs
endif