xref: /freebsd-14.2/sys/modules/linux/Makefile (revision 07db1f36)
1c3aac50fSPeter Wemm# $FreeBSD$
2c21dee17SSøren Schmidt
3c09808d0SWarner Losh.if ${MACHINE_CPUARCH} == "amd64"
4adfa0adeSAlexander LeidingerSFX= 32
5841c0c7eSNathan WhitehornCFLAGS+=-DCOMPAT_FREEBSD32 -DCOMPAT_LINUX32
6adfa0adeSAlexander Leidinger.endif
7adfa0adeSAlexander Leidinger
8193d9e76SEnji Cooper.PATH: ${SRCTOP}/sys/compat/linux ${SRCTOP}/sys/${MACHINE_CPUARCH}/linux${SFX}
9e9b13c66SConrad Meyer.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
10e9b13c66SConrad Meyer.PATH: ${SRCTOP}/sys/x86/linux
11e9b13c66SConrad Meyer.endif
12c68159a6SDavid E. O'Brien
13a654d072SPeter WemmKMOD=	linux
1433178488SMitchell HorneSRCS=	linux${SFX}_dummy_machdep.c \
15cc1b0f7dSDmitry Chagin	linux_elf32.c \
1633178488SMitchell Horne	linux_event.c \
1733178488SMitchell Horne	linux_file.c \
1833178488SMitchell Horne	linux_fork.c \
1933178488SMitchell Horne	linux_futex.c \
2033178488SMitchell Horne	linux_getcwd.c \
2133178488SMitchell Horne	linux_ioctl.c \
2233178488SMitchell Horne	linux_ipc.c \
2333178488SMitchell Horne	linux${SFX}_machdep.c \
2433178488SMitchell Horne	linux_misc.c \
2533178488SMitchell Horne	linux_rseq.c \
2633178488SMitchell Horne	linux_signal.c \
2733178488SMitchell Horne	linux_socket.c \
2833178488SMitchell Horne	linux_stats.c \
29f396f9b6SMitchell Horne	linux${SFX}_syscalls.c \
3033178488SMitchell Horne	linux_sysctl.c \
3133178488SMitchell Horne	linux${SFX}_sysent.c \
3233178488SMitchell Horne	linux${SFX}_sysvec.c \
3333178488SMitchell Horne	linux_time.c \
3433178488SMitchell Horne	linux_timer.c \
3533178488SMitchell Horne	linux_uid16.c \
3633178488SMitchell Horne	linux_vdso.c \
3733178488SMitchell Horne	opt_compat.h \
3833178488SMitchell Horne	opt_inet6.h \
39010175a7SWarner Losh	opt_ktrace.h \
4033178488SMitchell Horne	opt_posix.h \
4133178488SMitchell Horne	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.else
520cde66afSKonstantin BelousovSRCS+=	linux_copyout.c
53*07db1f36SDmitry ChaginSRCS+=	linux_netlink.c
540cde66afSKonstantin Belousov.endif
55fc2a8776SEd MasteDPSRCS=	assym.inc linux${SFX}_genassym.c
561c182de9SKonstantin Belousov
57fc2a8776SEd Maste# XXX: for assym.inc
586469bdcdSBrooks DavisSRCS+=  opt_kstack_pages.h opt_nfs.h opt_hwpmc_hooks.h
59c09808d0SWarner Losh.if ${MACHINE_CPUARCH} == "i386"
6033178488SMitchell HorneSRCS+=	opt_apic.h opt_cpu.h
61b2cc900aSDag-Erling Smørgrav.endif
621c182de9SKonstantin Belousov
639931033bSDmitry ChaginOBJS=	linux${SFX}_vdso.so
64bdc37934SDmitry Chagin
65c09808d0SWarner Losh.if ${MACHINE_CPUARCH} == "i386"
6633178488SMitchell HorneSRCS+=	imgact_linux.c \
6733178488SMitchell Horne	linux.c \
6833178488SMitchell Horne	linux_dummy.c \
6933178488SMitchell Horne	linux_emul.c \
7033178488SMitchell Horne	linux_errno.c \
7133178488SMitchell Horne	linux_mib.c \
7233178488SMitchell Horne	linux_mmap.c \
7333178488SMitchell Horne	linux_ptrace_machdep.c \
7433178488SMitchell Horne	linux_util.c \
7533178488SMitchell Horne	linux_vdso_selector_x86.c \
7633178488SMitchell Horne	linux_x86.c
77849baab8SDavid E. O'Brien.endif
78849baab8SDavid E. O'Brien
7967d39748SDmitry Chagin.if ${MACHINE_CPUARCH} == "i386"
80bea8bf95SDag-Erling SmørgravEXPORT_SYMS=
81bea8bf95SDag-Erling SmørgravEXPORT_SYMS+=	linux_emul_path
82bea8bf95SDag-Erling SmørgravEXPORT_SYMS+=	linux_get_osname
83bea8bf95SDag-Erling SmørgravEXPORT_SYMS+=	linux_get_osrelease
84bea8bf95SDag-Erling SmørgravEXPORT_SYMS+=	linux_ioctl_register_handler
85bea8bf95SDag-Erling SmørgravEXPORT_SYMS+=	linux_ioctl_unregister_handler
8667d39748SDmitry Chagin.endif
87bea8bf95SDag-Erling Smørgrav
887c28c7e8SDmitry ChaginCLEANFILES=	linux${SFX}_assym.h linux${SFX}_genassym.o linux${SFX}_locore.o \
899931033bSDmitry Chagin		genassym.o linux${SFX}_vdso_gtod.o linux${SFX}_vdso.so.o
90785d64c4SPeter Wemm
91adfa0adeSAlexander Leidingerlinux${SFX}_assym.h: linux${SFX}_genassym.o
92528013d5SWarner Losh	sh ${SYSDIR}/kern/genassym.sh linux${SFX}_genassym.o > ${.TARGET}
93785d64c4SPeter Wemm
949931033bSDmitry Chagin.if ${MACHINE_CPUARCH} == "amd64"
95e36d0e86SKonstantin BelousovVDSOFLAGS=-DCOMPAT_FREEBSD32 -DCOMPAT_LINUX32 -m32
96b0fa09a0SDmitry Chagin.else
97b0fa09a0SDmitry ChaginVDSOFLAGS=-mregparm=0
989931033bSDmitry Chagin.endif
999931033bSDmitry Chagin
100fc2a8776SEd Mastelinux${SFX}_locore.o: linux${SFX}_assym.h assym.inc
1019931033bSDmitry Chagin	${CC} -c -x assembler-with-cpp -DLOCORE -fPIC -pipe -O2 -Werror \
102b0fa09a0SDmitry Chagin	-msoft-float \
103de273c83SDmitry Chagin	-fno-common -nostdinc -fasynchronous-unwind-tables \
1049931033bSDmitry Chagin	-fno-omit-frame-pointer -foptimize-sibling-calls ${VDSOFLAGS} \
1059931033bSDmitry Chagin	-fno-stack-protector -I. -I${SYSDIR} -I${SRCTOP}/include \
106c11bd941SBruce Evans	    ${.IMPSRC} -o ${.TARGET}
107785d64c4SPeter Wemm
1089931033bSDmitry Chaginlinux${SFX}_vdso_gtod.o: linux_vdso_gtod.inc ${VDSODEPS}
109b0fa09a0SDmitry Chagin	${CC} -c -fPIC -pipe -O2 -Werror -msoft-float \
110de273c83SDmitry Chagin	-fno-common -nostdinc -fasynchronous-unwind-tables \
1119931033bSDmitry Chagin	-fno-omit-frame-pointer -foptimize-sibling-calls ${VDSOFLAGS} \
1129931033bSDmitry Chagin	-fno-stack-protector -I. -I${SYSDIR} -I${SRCTOP}/include \
1139931033bSDmitry Chagin	    ${.IMPSRC} -o ${.TARGET}
1149931033bSDmitry Chagin
1159931033bSDmitry Chaginlinux${SFX}_vdso.so.o: linux${SFX}_locore.o linux${SFX}_vdso_gtod.o
1169931033bSDmitry Chagin	${LD} -m elf_i386 --shared --eh-frame-hdr -soname=linux-gate.so.1 \
1179931033bSDmitry Chagin	--no-undefined --hash-style=both -warn-common -nostdlib \
1189931033bSDmitry Chagin	--strip-debug -s --build-id=sha1 --Bsymbolic \
1199931033bSDmitry Chagin	-T${SRCTOP}/sys/${MACHINE}/linux${SFX}/linux${SFX}_vdso.lds.s \
1209931033bSDmitry Chagin	-o ${.TARGET} ${.ALLSRC:M*.o}
1219931033bSDmitry Chagin
1229931033bSDmitry Chagin.if ${MACHINE_CPUARCH} == "amd64"
1239931033bSDmitry ChaginOBJCOPY_TARGET=--output-target elf64-x86-64-freebsd --binary-architecture i386
1249931033bSDmitry Chagin.elif ${MACHINE_CPUARCH} == "i386"
1259931033bSDmitry ChaginOBJCOPY_TARGET=--output-target elf32-i386-freebsd --binary-architecture i386
1269931033bSDmitry Chagin.else
1279931033bSDmitry Chagin.error ${MACHINE_CPUARCH} not yet supported by linux
1289931033bSDmitry Chagin.endif
1299931033bSDmitry Chagin
1309931033bSDmitry Chaginlinux${SFX}_vdso.so: linux${SFX}_vdso.so.o
1319931033bSDmitry Chagin	${OBJCOPY} --input-target binary ${OBJCOPY_TARGET} \
1329931033bSDmitry Chagin	    linux${SFX}_vdso.so.o ${.TARGET}
1339931033bSDmitry Chagin	${STRIPBIN} -N _binary_linux${SFX}_vdso_so_o_size ${.TARGET}
1349931033bSDmitry Chagin
1350cde66afSKonstantin Belousov.if ${MACHINE_CPUARCH} == "amd64"
13635548e48SEd Mastelinux${SFX}_support.o: linux${SFX}_support.S linux${SFX}_assym.h assym.inc
1371c182de9SKonstantin Belousov	${CC} -c -x assembler-with-cpp -DLOCORE ${CFLAGS} \
13835548e48SEd Maste	    ${.ALLSRC:M*.S:u} -o ${.TARGET}
139bdc37934SDmitry Chagin.endif
140bdc37934SDmitry Chagin
141ccca101fSBryan Drewerylinux${SFX}_genassym.o: offset.inc
1424db3ef4cSAlex Richardson	${CC} -c ${CFLAGS:N-flto:N-fno-common} -fcommon ${.IMPSRC}
143785d64c4SPeter Wemm
1446e4cf32eSDmitry Chagin.if !defined(KERNBUILDDIR)
1456e4cf32eSDmitry Chagin.warning Building Linuxulator outside of a kernel does not make sense
1466e4cf32eSDmitry Chagin.endif
1476e4cf32eSDmitry Chagin
1485bb3134aSKonstantin BelousovEXPORT_SYMS=	YES
1495bb3134aSKonstantin Belousov
15064db83a8SPeter Wemm.include <bsd.kmod.mk>
151