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