xref: /freebsd-14.2/sys/modules/linux/Makefile (revision 125a2a6b)
1c21dee17SSøren Schmidt
2c09808d0SWarner Losh.if ${MACHINE_CPUARCH} == "amd64"
3adfa0adeSAlexander LeidingerSFX= 32
4841c0c7eSNathan WhitehornCFLAGS+=-DCOMPAT_FREEBSD32 -DCOMPAT_LINUX32
5adfa0adeSAlexander Leidinger.endif
6adfa0adeSAlexander Leidinger
7193d9e76SEnji Cooper.PATH: ${SRCTOP}/sys/compat/linux ${SRCTOP}/sys/${MACHINE_CPUARCH}/linux${SFX}
8e9b13c66SConrad Meyer.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
9e9b13c66SConrad Meyer.PATH: ${SRCTOP}/sys/x86/linux
10e9b13c66SConrad Meyer.endif
11c68159a6SDavid E. O'Brien
12a654d072SPeter WemmKMOD=	linux
1333178488SMitchell HorneSRCS=	linux${SFX}_dummy_machdep.c \
14cc1b0f7dSDmitry Chagin	linux_elf32.c \
1533178488SMitchell Horne	linux_event.c \
1633178488SMitchell Horne	linux_file.c \
1733178488SMitchell Horne	linux_fork.c \
1833178488SMitchell Horne	linux_futex.c \
1933178488SMitchell Horne	linux_getcwd.c \
2033178488SMitchell Horne	linux_ioctl.c \
2133178488SMitchell Horne	linux_ipc.c \
2233178488SMitchell Horne	linux${SFX}_machdep.c \
2333178488SMitchell Horne	linux_misc.c \
2433178488SMitchell Horne	linux_rseq.c \
2533178488SMitchell Horne	linux_signal.c \
2633178488SMitchell Horne	linux_socket.c \
2733178488SMitchell Horne	linux_stats.c \
28f396f9b6SMitchell Horne	linux${SFX}_syscalls.c \
2933178488SMitchell Horne	linux_sysctl.c \
3033178488SMitchell Horne	linux${SFX}_sysent.c \
3133178488SMitchell Horne	linux${SFX}_sysvec.c \
3233178488SMitchell Horne	linux_time.c \
3333178488SMitchell Horne	linux_timer.c \
3433178488SMitchell Horne	linux_uid16.c \
3533178488SMitchell Horne	linux_vdso.c \
3622dca7acSDmitry Chagin	linux_xattr.c \
37*125a2a6bSWarner Losh	opt_inet.h \
3833178488SMitchell Horne	opt_inet6.h \
39010175a7SWarner Losh	opt_ktrace.h \
4033178488SMitchell Horne	opt_posix.h \
41*125a2a6bSWarner Losh	opt_usb.h \
4233178488SMitchell Horne	bus_if.h \
4333178488SMitchell Horne	device_if.h \
4433178488SMitchell Horne	vnode_if.h
45e9b13c66SConrad Meyer.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
462b378d59SDmitry ChaginSRCS+=	linux_dummy_x86.c
479931033bSDmitry ChaginVDSODEPS=linux_vdso_gettc_x86.inc
48e9b13c66SConrad Meyer.endif
490cde66afSKonstantin Belousov.if ${MACHINE_CPUARCH} == "amd64"
50ccd9b49fSElliott MitchellSRCS+=	linux${SFX}_support.S
510cde66afSKonstantin Belousov.endif
52fc2a8776SEd MasteDPSRCS=	assym.inc linux${SFX}_genassym.c
531c182de9SKonstantin Belousov
54fc2a8776SEd Maste# XXX: for assym.inc
556469bdcdSBrooks DavisSRCS+=  opt_kstack_pages.h opt_nfs.h opt_hwpmc_hooks.h
56c09808d0SWarner Losh.if ${MACHINE_CPUARCH} == "i386"
5733178488SMitchell HorneSRCS+=	opt_apic.h opt_cpu.h
58b2cc900aSDag-Erling Smørgrav.endif
591c182de9SKonstantin Belousov
609931033bSDmitry ChaginOBJS=	linux${SFX}_vdso.so
61bdc37934SDmitry Chagin
62c09808d0SWarner Losh.if ${MACHINE_CPUARCH} == "i386"
6333178488SMitchell HorneSRCS+=	imgact_linux.c \
6433178488SMitchell Horne	linux.c \
6533178488SMitchell Horne	linux_dummy.c \
6633178488SMitchell Horne	linux_emul.c \
6733178488SMitchell Horne	linux_errno.c \
6833178488SMitchell Horne	linux_mib.c \
6933178488SMitchell Horne	linux_mmap.c \
7033178488SMitchell Horne	linux_ptrace_machdep.c \
7133178488SMitchell Horne	linux_util.c \
7233178488SMitchell Horne	linux_vdso_selector_x86.c \
73126df352SDmitry Chagin	linux_x86.c \
74126df352SDmitry Chagin	linux_copyout.c \
75ff154988SKristof Provost	linux_netlink.c
76849baab8SDavid E. O'Brien.endif
77849baab8SDavid E. O'Brien
7867d39748SDmitry Chagin.if ${MACHINE_CPUARCH} == "i386"
79bea8bf95SDag-Erling SmørgravEXPORT_SYMS=
80bea8bf95SDag-Erling SmørgravEXPORT_SYMS+=	linux_get_osname
81bea8bf95SDag-Erling SmørgravEXPORT_SYMS+=	linux_get_osrelease
82bea8bf95SDag-Erling SmørgravEXPORT_SYMS+=	linux_ioctl_register_handler
83bea8bf95SDag-Erling SmørgravEXPORT_SYMS+=	linux_ioctl_unregister_handler
8467d39748SDmitry Chagin.endif
85bea8bf95SDag-Erling Smørgrav
867c28c7e8SDmitry ChaginCLEANFILES=	linux${SFX}_assym.h linux${SFX}_genassym.o linux${SFX}_locore.o \
879931033bSDmitry Chagin		genassym.o linux${SFX}_vdso_gtod.o linux${SFX}_vdso.so.o
88785d64c4SPeter Wemm
89adfa0adeSAlexander Leidingerlinux${SFX}_assym.h: linux${SFX}_genassym.o
90528013d5SWarner Losh	sh ${SYSDIR}/kern/genassym.sh linux${SFX}_genassym.o > ${.TARGET}
91785d64c4SPeter Wemm
929931033bSDmitry Chagin.if ${MACHINE_CPUARCH} == "amd64"
93e36d0e86SKonstantin BelousovVDSOFLAGS=-DCOMPAT_FREEBSD32 -DCOMPAT_LINUX32 -m32
94b0fa09a0SDmitry Chagin.else
95b0fa09a0SDmitry ChaginVDSOFLAGS=-mregparm=0
969931033bSDmitry Chagin.endif
979931033bSDmitry Chagin
98fc2a8776SEd Mastelinux${SFX}_locore.o: linux${SFX}_assym.h assym.inc
999931033bSDmitry Chagin	${CC} -c -x assembler-with-cpp -DLOCORE -fPIC -pipe -O2 -Werror \
100b0fa09a0SDmitry Chagin	-msoft-float \
101de273c83SDmitry Chagin	-fno-common -nostdinc -fasynchronous-unwind-tables \
1029931033bSDmitry Chagin	-fno-omit-frame-pointer -foptimize-sibling-calls ${VDSOFLAGS} \
1039931033bSDmitry Chagin	-fno-stack-protector -I. -I${SYSDIR} -I${SRCTOP}/include \
104c11bd941SBruce Evans	    ${.IMPSRC} -o ${.TARGET}
105785d64c4SPeter Wemm
1069931033bSDmitry Chaginlinux${SFX}_vdso_gtod.o: linux_vdso_gtod.inc ${VDSODEPS}
107b0fa09a0SDmitry Chagin	${CC} -c -fPIC -pipe -O2 -Werror -msoft-float \
108de273c83SDmitry Chagin	-fno-common -nostdinc -fasynchronous-unwind-tables \
1099931033bSDmitry Chagin	-fno-omit-frame-pointer -foptimize-sibling-calls ${VDSOFLAGS} \
1109931033bSDmitry Chagin	-fno-stack-protector -I. -I${SYSDIR} -I${SRCTOP}/include \
1119931033bSDmitry Chagin	    ${.IMPSRC} -o ${.TARGET}
1129931033bSDmitry Chagin
1139931033bSDmitry Chaginlinux${SFX}_vdso.so.o: linux${SFX}_locore.o linux${SFX}_vdso_gtod.o
1149931033bSDmitry Chagin	${LD} -m elf_i386 --shared --eh-frame-hdr -soname=linux-gate.so.1 \
1159931033bSDmitry Chagin	--no-undefined --hash-style=both -warn-common -nostdlib \
1169931033bSDmitry Chagin	--strip-debug -s --build-id=sha1 --Bsymbolic \
1179931033bSDmitry Chagin	-T${SRCTOP}/sys/${MACHINE}/linux${SFX}/linux${SFX}_vdso.lds.s \
1189931033bSDmitry Chagin	-o ${.TARGET} ${.ALLSRC:M*.o}
1199931033bSDmitry Chagin
1209931033bSDmitry Chagin.if ${MACHINE_CPUARCH} == "amd64"
1219931033bSDmitry ChaginOBJCOPY_TARGET=--output-target elf64-x86-64-freebsd --binary-architecture i386
1229931033bSDmitry Chagin.elif ${MACHINE_CPUARCH} == "i386"
1239931033bSDmitry ChaginOBJCOPY_TARGET=--output-target elf32-i386-freebsd --binary-architecture i386
1249931033bSDmitry Chagin.else
1259931033bSDmitry Chagin.error ${MACHINE_CPUARCH} not yet supported by linux
1269931033bSDmitry Chagin.endif
1279931033bSDmitry Chagin
1289931033bSDmitry Chaginlinux${SFX}_vdso.so: linux${SFX}_vdso.so.o
1299931033bSDmitry Chagin	${OBJCOPY} --input-target binary ${OBJCOPY_TARGET} \
1309931033bSDmitry Chagin	    linux${SFX}_vdso.so.o ${.TARGET}
1319931033bSDmitry Chagin	${STRIPBIN} -N _binary_linux${SFX}_vdso_so_o_size ${.TARGET}
1329931033bSDmitry Chagin
1330cde66afSKonstantin Belousov.if ${MACHINE_CPUARCH} == "amd64"
13435548e48SEd Mastelinux${SFX}_support.o: linux${SFX}_support.S linux${SFX}_assym.h assym.inc
1351c182de9SKonstantin Belousov	${CC} -c -x assembler-with-cpp -DLOCORE ${CFLAGS} \
13635548e48SEd Maste	    ${.ALLSRC:M*.S:u} -o ${.TARGET}
137bdc37934SDmitry Chagin.endif
138bdc37934SDmitry Chagin
139ccca101fSBryan Drewerylinux${SFX}_genassym.o: offset.inc
1404db3ef4cSAlex Richardson	${CC} -c ${CFLAGS:N-flto:N-fno-common} -fcommon ${.IMPSRC}
141785d64c4SPeter Wemm
1426e4cf32eSDmitry Chagin.if !defined(KERNBUILDDIR)
1436e4cf32eSDmitry Chagin.warning Building Linuxulator outside of a kernel does not make sense
1446e4cf32eSDmitry Chagin.endif
1456e4cf32eSDmitry Chagin
1465bb3134aSKonstantin BelousovEXPORT_SYMS=	YES
1475bb3134aSKonstantin Belousov
14864db83a8SPeter Wemm.include <bsd.kmod.mk>
149