-
Notifications
You must be signed in to change notification settings - Fork 47
/
Makefile
62 lines (52 loc) · 2.82 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
# SPDX-License-Identifier: GPL-2.0-or-later
#
# Copyright (c) 2023 Tesla Inc. All rights reserved.
#
# Makefile for the Tesla Transport Protocol (TTP) Kernel Module
#
# Authors: Diwakar Tundlam <[email protected]>
#
# This software is licensed under the terms of the GNU General Public License version 2
# as published by the Free Software Foundation, and may be copied, distributed, and
# modified under those terms.
#
# This program is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; Without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE. See the GNU General Public License for more details.
#
PWD ?= $(pwd)
KVER ?= $(shell uname -r)
KDIR ?= /lib/modules/$(KVER)/build
all:: include/ver.h
make -C $(KDIR) M=$(PWD) modules
clean::
-make -C $(KDIR) M=$(PWD) clean
-rm -f include/ver.h modttpoe/Module.symvers modttpip/Module.symvers
install:: all
make /mnt/mac/modttpoe.ko /mnt/mac/modttpip.ko /mnt/mac/tests/.timestamp
/mnt/mac/modttpoe.ko: all
-sudo cp modttpoe/modttpoe.ko /mnt/mac/modttpoe-$(KVER).ko
-sudo ln -sf /mnt/mac/modttpoe-$(KVER).ko /mnt/mac/modttpoe.ko
/mnt/mac/modttpip.ko: all
-sudo cp modttpip/modttpip.ko /mnt/mac/modttpip-$(KVER).ko
-sudo ln -sf /mnt/mac/modttpip-$(KVER).ko /mnt/mac/modttpip.ko
/mnt/mac/tests/.timestamp: /mnt/mac/modttpoe.ko /mnt/mac/modttpip.ko
-sudo cp -r tests /mnt/mac
-sudo su -c "touch /mnt/mac/tests/.timestamp"
.PHONY: /mnt/mac/tests/.timestamp /mnt/mac/modttpoe.ko /mnt/mac/modttpip.ko
# Pass env VER="1.0" from command line for official builds
VER ?= "eng"
include/ver.h: Makefile
@echo "/* Autogenerated file. PLEASE DO NOT EDIT */" > $(PWD)/$@
@echo >> $(PWD)/$@
@echo "#define TTP_KERNEL_VERSION \"$(KVER)\"" >> $(PWD)/$@
@echo "#define TTP_STR(ss) #ss" >> $(PWD)/$@
@echo "#define TTP_MKSTR(ss) TTP_STR(ss)" >> $(PWD)/$@
@echo "#define AUTO_MODTTP_VERSION TTP_BUILD_BASE \".\" TTP_MKSTR(TTP_BUILD_NUM)" >> $(PWD)/$@
@echo >> $(PWD)/$@
@date -u +\#define\ TTP_BUILD_BASE\ \ \ \"$(VER)0.%y%m\" >> $(PWD)/$@
@echo -n "#define TTP_BUILD_NUM " >> $(PWD)/$@
@git log --oneline --since='\$\(date\ \-u\ \+\"\%m/1/\%Y\"\)' | wc -l >> $(PWD)/$@
@echo >> $(PWD)/$@
@echo "/* Hint: const char *const ttp_version_string = AUTO_MODTTP_VERSION; */" >> $(PWD)/$@
@echo "extern const char *const ttp_version_string;" >> $(PWD)/$@