xref: /freebsd/sys/modules/linux/Makefile (revision f11c79fc0046c1579faf7cdf6505c51846cc5709)
1c09808d0SWarner Losh.if ${MACHINE_CPUARCH} == "amd64"
2adfa0adeSAlexander LeidingerSFX= 32
3841c0c7eSNathan WhitehornCFLAGS+=-DCOMPAT_FREEBSD32 -DCOMPAT_LINUX32
4adfa0adeSAlexander Leidinger.endif
5adfa0adeSAlexander Leidinger
6193d9e76SEnji Cooper.PATH: ${SRCTOP}/sys/compat/linux ${SRCTOP}/sys/${MACHINE_CPUARCH}/linux${SFX}
7e9b13c66SConrad Meyer.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
8e9b13c66SConrad Meyer.PATH: ${SRCTOP}/sys/x86/linux
9e9b13c66SConrad Meyer.endif
10c68159a6SDavid E. O'Brien
11a654d072SPeter WemmKMOD=	linux
1233178488SMitchell HorneSRCS=	linux${SFX}_dummy_machdep.c \
13cc1b0f7dSDmitry Chagin	linux_elf32.c \
1433178488SMitchell Horne	linux_event.c \
1533178488SMitchell Horne	linux_file.c \
1633178488SMitchell Horne	linux_fork.c \
1733178488SMitchell Horne	linux_futex.c \
1833178488SMitchell Horne	linux_getcwd.c \
1933178488SMitchell Horne	linux_ioctl.c \
2033178488SMitchell Horne	linux_ipc.c \
2133178488SMitchell Horne	linux${SFX}_machdep.c \
2233178488SMitchell Horne	linux_misc.c \
2333178488SMitchell Horne	linux_rseq.c \
2433178488SMitchell Horne	linux_signal.c \
2533178488SMitchell Horne	linux_socket.c \
2633178488SMitchell Horne	linux_stats.c \
27f396f9b6SMitchell Horne	linux${SFX}_syscalls.c \
2833178488SMitchell Horne	linux_sysctl.c \
2933178488SMitchell Horne	linux${SFX}_sysent.c \
3033178488SMitchell Horne	linux${SFX}_sysvec.c \
3133178488SMitchell Horne	linux_time.c \
3233178488SMitchell Horne	linux_timer.c \
3333178488SMitchell Horne	linux_uid16.c \
3433178488SMitchell Horne	linux_vdso.c \
3522dca7acSDmitry Chagin	linux_xattr.c \
36*c5f906d3SWarner Losh	opt_inet.h \
3733178488SMitchell Horne	opt_inet6.h \
38010175a7SWarner Losh	opt_ktrace.h \
3933178488SMitchell Horne	opt_posix.h \
40*c5f906d3SWarner Losh	opt_usb.h \
4133178488SMitchell Horne	bus_if.h \
4233178488SMitchell Horne	device_if.h \
4333178488SMitchell Horne	vnode_if.h
44e9b13c66SConrad Meyer.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
452b378d59SDmitry ChaginSRCS+=	linux_dummy_x86.c
469931033bSDmitry ChaginVDSODEPS=linux_vdso_gettc_x86.inc
47e9b13c66SConrad Meyer.endif
480cde66afSKonstantin Belousov.if ${MACHINE_CPUARCH} == "amd64"
49ccd9b49fSElliott MitchellSRCS+=	linux${SFX}_support.S
500cde66afSKonstantin Belousov.endif
51fc2a8776SEd MasteDPSRCS=	assym.inc linux${SFX}_genassym.c
521c182de9SKonstantin Belousov
53fc2a8776SEd Maste# XXX: for assym.inc
546469bdcdSBrooks DavisSRCS+=  opt_kstack_pages.h opt_nfs.h opt_hwpmc_hooks.h
55c09808d0SWarner Losh.if ${MACHINE_CPUARCH} == "i386"
5633178488SMitchell HorneSRCS+=	opt_apic.h opt_cpu.h
57b2cc900aSDag-Erling Smørgrav.endif
581c182de9SKonstantin Belousov
599931033bSDmitry ChaginOBJS=	linux${SFX}_vdso.so
60bdc37934SDmitry Chagin
61c09808d0SWarner Losh.if ${MACHINE_CPUARCH} == "i386"
6233178488SMitchell HorneSRCS+=	imgact_linux.c \
6333178488SMitchell Horne	linux.c \
6433178488SMitchell Horne	linux_dummy.c \
6533178488SMitchell Horne	linux_emul.c \
6633178488SMitchell Horne	linux_errno.c \
6733178488SMitchell Horne	linux_mib.c \
6833178488SMitchell Horne	linux_mmap.c \
6933178488SMitchell Horne	linux_ptrace_machdep.c \
7033178488SMitchell Horne	linux_util.c \
7133178488SMitchell Horne	linux_vdso_selector_x86.c \
72126df352SDmitry Chagin	linux_x86.c \
73126df352SDmitry Chagin	linux_copyout.c \
74ab393e95SKristof Provost	linux_netlink.c
75849baab8SDavid E. O'Brien.endif
76849baab8SDavid E. O'Brien
7767d39748SDmitry Chagin.if ${MACHINE_CPUARCH} == "i386"
78bea8bf95SDag-Erling SmørgravEXPORT_SYMS=
79bea8bf95SDag-Erling SmørgravEXPORT_SYMS+=	linux_get_osname
80bea8bf95SDag-Erling SmørgravEXPORT_SYMS+=	linux_get_osrelease
81bea8bf95SDag-Erling SmørgravEXPORT_SYMS+=	linux_ioctl_register_handler
82bea8bf95SDag-Erling SmørgravEXPORT_SYMS+=	linux_ioctl_unregister_handler
8367d39748SDmitry Chagin.endif
84bea8bf95SDag-Erling Smørgrav
857c28c7e8SDmitry ChaginCLEANFILES=	linux${SFX}_assym.h linux${SFX}_genassym.o linux${SFX}_locore.o \
869931033bSDmitry Chagin		genassym.o linux${SFX}_vdso_gtod.o linux${SFX}_vdso.so.o
87785d64c4SPeter Wemm
88adfa0adeSAlexander Leidingerlinux${SFX}_assym.h: linux${SFX}_genassym.o
89528013d5SWarner Losh	sh ${SYSDIR}/kern/genassym.sh linux${SFX}_genassym.o > ${.TARGET}
90785d64c4SPeter Wemm
919931033bSDmitry Chagin.if ${MACHINE_CPUARCH} == "amd64"
92e36d0e86SKonstantin BelousovVDSOFLAGS=-DCOMPAT_FREEBSD32 -DCOMPAT_LINUX32 -m32
93b0fa09a0SDmitry Chagin.else
94b0fa09a0SDmitry ChaginVDSOFLAGS=-mregparm=0
959931033bSDmitry Chagin.endif
969931033bSDmitry Chagin
97fc2a8776SEd Mastelinux${SFX}_locore.o: linux${SFX}_assym.h assym.inc
989931033bSDmitry Chagin	${CC} -c -x assembler-with-cpp -DLOCORE -fPIC -pipe -O2 -Werror \
99b0fa09a0SDmitry Chagin	-msoft-float \
100de273c83SDmitry Chagin	-fno-common -nostdinc -fasynchronous-unwind-tables \
1019931033bSDmitry Chagin	-fno-omit-frame-pointer -foptimize-sibling-calls ${VDSOFLAGS} \
1029931033bSDmitry Chagin	-fno-stack-protector -I. -I${SYSDIR} -I${SRCTOP}/include \
103c11bd941SBruce Evans	    ${.IMPSRC} -o ${.TARGET}
104785d64c4SPeter Wemm
1059931033bSDmitry Chaginlinux${SFX}_vdso_gtod.o: linux_vdso_gtod.inc ${VDSODEPS}
106b0fa09a0SDmitry Chagin	${CC} -c -fPIC -pipe -O2 -Werror -msoft-float \
107de273c83SDmitry Chagin	-fno-common -nostdinc -fasynchronous-unwind-tables \
1089931033bSDmitry Chagin	-fno-omit-frame-pointer -foptimize-sibling-calls ${VDSOFLAGS} \
1099931033bSDmitry Chagin	-fno-stack-protector -I. -I${SYSDIR} -I${SRCTOP}/include \
1109931033bSDmitry Chagin	    ${.IMPSRC} -o ${.TARGET}
1119931033bSDmitry Chagin
1129931033bSDmitry Chaginlinux${SFX}_vdso.so.o: linux${SFX}_locore.o linux${SFX}_vdso_gtod.o
1139931033bSDmitry Chagin	${LD} -m elf_i386 --shared --eh-frame-hdr -soname=linux-gate.so.1 \
1149931033bSDmitry Chagin	--no-undefined --hash-style=both -warn-common -nostdlib \
1159931033bSDmitry Chagin	--strip-debug -s --build-id=sha1 --Bsymbolic \
1169931033bSDmitry Chagin	-T${SRCTOP}/sys/${MACHINE}/linux${SFX}/linux${SFX}_vdso.lds.s \
1179931033bSDmitry Chagin	-o ${.TARGET} ${.ALLSRC:M*.o}
1189931033bSDmitry Chagin
1199931033bSDmitry Chagin.if ${MACHINE_CPUARCH} == "amd64"
1209931033bSDmitry ChaginOBJCOPY_TARGET=--output-target elf64-x86-64-freebsd --binary-architecture i386
1219931033bSDmitry Chagin.elif ${MACHINE_CPUARCH} == "i386"
1229931033bSDmitry ChaginOBJCOPY_TARGET=--output-target elf32-i386-freebsd --binary-architecture i386
1239931033bSDmitry Chagin.else
1249931033bSDmitry Chagin.error ${MACHINE_CPUARCH} not yet supported by linux
1259931033bSDmitry Chagin.endif
1269931033bSDmitry Chagin
1279931033bSDmitry Chaginlinux${SFX}_vdso.so: linux${SFX}_vdso.so.o
1289931033bSDmitry Chagin	${OBJCOPY} --input-target binary ${OBJCOPY_TARGET} \
1299931033bSDmitry Chagin	    linux${SFX}_vdso.so.o ${.TARGET}
1309931033bSDmitry Chagin	${STRIPBIN} -N _binary_linux${SFX}_vdso_so_o_size ${.TARGET}
1319931033bSDmitry Chagin
1320cde66afSKonstantin Belousov.if ${MACHINE_CPUARCH} == "amd64"
13335548e48SEd Mastelinux${SFX}_support.o: linux${SFX}_support.S linux${SFX}_assym.h assym.inc
1341c182de9SKonstantin Belousov	${CC} -c -x assembler-with-cpp -DLOCORE ${CFLAGS} \
13535548e48SEd Maste	    ${.ALLSRC:M*.S:u} -o ${.TARGET}
136bdc37934SDmitry Chagin.endif
137bdc37934SDmitry Chagin
138ccca101fSBryan Drewerylinux${SFX}_genassym.o: offset.inc
1398e1a7e29SMark Johnston	${CC} -c ${CFLAGS:N-flto*:N-fno-common:N-fsanitize*:N-fno-sanitize*} \
1408e1a7e29SMark Johnston	    -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