xref: /OK3568_Linux_fs/kernel/drivers/net/ethernet/realtek/r8168/Makefile_linux24x (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun# SPDX-License-Identifier: GPL-2.0-only
2*4882a593Smuzhiyun################################################################################
3*4882a593Smuzhiyun#
4*4882a593Smuzhiyun# r8168 is the Linux device driver released for Realtek Gigabit Ethernet
5*4882a593Smuzhiyun# controllers with PCI-Express interface.
6*4882a593Smuzhiyun#
7*4882a593Smuzhiyun# Copyright(c) 2021 Realtek Semiconductor Corp. All rights reserved.
8*4882a593Smuzhiyun#
9*4882a593Smuzhiyun# This program is free software; you can redistribute it and/or modify it
10*4882a593Smuzhiyun# under the terms of the GNU General Public License as published by the Free
11*4882a593Smuzhiyun# Software Foundation; either version 2 of the License, or (at your option)
12*4882a593Smuzhiyun# any later version.
13*4882a593Smuzhiyun#
14*4882a593Smuzhiyun# This program is distributed in the hope that it will be useful, but WITHOUT
15*4882a593Smuzhiyun# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16*4882a593Smuzhiyun# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
17*4882a593Smuzhiyun# more details.
18*4882a593Smuzhiyun#
19*4882a593Smuzhiyun# You should have received a copy of the GNU General Public License along with
20*4882a593Smuzhiyun# this program; if not, see <http://www.gnu.org/licenses/>.
21*4882a593Smuzhiyun#
22*4882a593Smuzhiyun# Author:
23*4882a593Smuzhiyun# Realtek NIC software team <nicfae@realtek.com>
24*4882a593Smuzhiyun# No. 2, Innovation Road II, Hsinchu Science Park, Hsinchu 300, Taiwan
25*4882a593Smuzhiyun#
26*4882a593Smuzhiyun################################################################################
27*4882a593Smuzhiyun
28*4882a593Smuzhiyun################################################################################
29*4882a593Smuzhiyun# This product is covered by one or more of the following patents:
30*4882a593Smuzhiyun# US6,570,884, US6,115,776, and US6,327,625.
31*4882a593Smuzhiyun################################################################################
32*4882a593Smuzhiyun
33*4882a593SmuzhiyunCC		:= gcc
34*4882a593SmuzhiyunLD		:= ld
35*4882a593SmuzhiyunARCH		:= $(shell uname -m | sed 's/i.86/i386/')
36*4882a593SmuzhiyunKSRC		:= /lib/modules/$(shell uname -r)/build
37*4882a593SmuzhiyunCONFIG_FILE	:= $(KSRC)/include/linux/autoconf.h
38*4882a593SmuzhiyunKMISC		:= /lib/modules/$(shell uname -r)/kernel/drivers/net/
39*4882a593Smuzhiyun
40*4882a593Smuzhiyun
41*4882a593Smuzhiyunifeq ($(ARCH),x86_64)
42*4882a593Smuzhiyun   MODCFLAGS	+= -mcmodel=kernel -mno-red-zone
43*4882a593Smuzhiyunendif
44*4882a593Smuzhiyun
45*4882a593Smuzhiyun#standard flags for module builds
46*4882a593SmuzhiyunMODCFLAGS	+= -DLINUX -D__KERNEL__ -DMODULE -O2 -pipe -Wall
47*4882a593SmuzhiyunMODCFLAGS	+= -I$(KSRC)/include -I.
48*4882a593SmuzhiyunMODCFLAGS	+= -DMODVERSIONS -DEXPORT_SYMTAB -include $(KSRC)/include/linux/modversions.h
49*4882a593SmuzhiyunSOURCE		:= r8168_n.c r8168_asf.c rtl_eeprom.c rtltool.c
50*4882a593SmuzhiyunOBJS		:= $(SOURCE:.c=.o)
51*4882a593Smuzhiyun
52*4882a593Smuzhiyun
53*4882a593SmuzhiyunSMP		:= $(shell $(CC) $(MODCFLAGS) -E -dM $(CONFIG_FILE) | \
54*4882a593Smuzhiyun   grep CONFIG_SMP | awk '{print $$3}')
55*4882a593Smuzhiyun
56*4882a593Smuzhiyunifneq ($(SMP),1)
57*4882a593Smuzhiyun   SMP		:= 0
58*4882a593Smuzhiyunendif
59*4882a593Smuzhiyun
60*4882a593Smuzhiyunifeq ($(SMP),1)
61*4882a593Smuzhiyun   MODCFLAGS	+= -D__SMP__
62*4882a593Smuzhiyunendif
63*4882a593Smuzhiyun
64*4882a593Smuzhiyunmodules: $(OBJS)
65*4882a593Smuzhiyun	$(LD) -r $^ -o r8168.o
66*4882a593Smuzhiyun	strip --strip-debug r8168.o
67*4882a593Smuzhiyun
68*4882a593Smuzhiyun%.o: %.c
69*4882a593Smuzhiyun	$(CC) $(MODCFLAGS) -c $< -o $@
70*4882a593Smuzhiyun
71*4882a593Smuzhiyunclean:
72*4882a593Smuzhiyun	rm *.o -f
73*4882a593Smuzhiyun
74*4882a593Smuzhiyuninstall:
75*4882a593Smuzhiyun	install -m 744 -c r8168.o $(KMISC)
76