1b2f58791SDmitry Chagin# $FreeBSD$ 2b2f58791SDmitry Chagin 348bc159fSEd Maste.PATH: ${SRCTOP}/sys/compat/linux ${SRCTOP}/sys/${MACHINE}/linux 488588c4bSDmitry Chagin.if ${MACHINE_CPUARCH} == "amd64" 5e9b13c66SConrad Meyer.PATH: ${SRCTOP}/sys/x86/linux 6e9b13c66SConrad Meyer.endif 7b2f58791SDmitry Chagin 8b2f58791SDmitry ChaginKMOD= linux64 933178488SMitchell HorneSRCS= linux_dummy_machdep.c \ 1033178488SMitchell Horne linux_elf64.c \ 1133178488SMitchell Horne linux_event.c \ 1233178488SMitchell Horne linux_file.c \ 1333178488SMitchell Horne linux_fork.c \ 1433178488SMitchell Horne linux_futex.c \ 1533178488SMitchell Horne linux_getcwd.c \ 1633178488SMitchell Horne linux_ioctl.c \ 1733178488SMitchell Horne linux_ipc.c \ 1833178488SMitchell Horne linux_machdep.c \ 1933178488SMitchell Horne linux_misc.c \ 2033178488SMitchell Horne linux_ptrace.c \ 2133178488SMitchell Horne linux_rseq.c \ 2233178488SMitchell Horne linux_signal.c \ 2333178488SMitchell Horne linux_socket.c \ 2433178488SMitchell Horne linux_stats.c \ 25f396f9b6SMitchell Horne linux_syscalls.c \ 2633178488SMitchell Horne linux_sysctl.c \ 2733178488SMitchell Horne linux_sysent.c \ 2833178488SMitchell Horne linux_sysvec.c \ 2933178488SMitchell Horne linux_time.c \ 3033178488SMitchell Horne linux_vdso.c \ 3133178488SMitchell Horne linux_timer.c \ 3233178488SMitchell Horne opt_compat.h \ 33010175a7SWarner Losh opt_ktrace.h \ 3433178488SMitchell Horne opt_inet6.h \ 3533178488SMitchell Horne opt_posix.h \ 3633178488SMitchell Horne opt_usb.h \ 3733178488SMitchell Horne bus_if.h \ 3833178488SMitchell Horne device_if.h \ 3933178488SMitchell Horne vnode_if.h \ 40ccd9b49fSElliott Mitchell linux_support.S 4188588c4bSDmitry Chagin.if ${MACHINE_CPUARCH} == "amd64" 422b378d59SDmitry ChaginSRCS+= linux_dummy_x86.c 43e9b13c66SConrad Meyer.endif 44fc2a8776SEd MasteDPSRCS= assym.inc linux_genassym.c 45b2f58791SDmitry Chagin 46fc2a8776SEd Maste# XXX: for assym.inc 47ce859641SBryan DrewerySRCS+= opt_kstack_pages.h opt_nfs.h opt_hwpmc_hooks.h 48b2f58791SDmitry Chagin 497c28c7e8SDmitry ChaginCLEANFILES= linux_assym.h linux_genassym.o linux_locore.o \ 509931033bSDmitry Chagin genassym.o linux_vdso_gtod.o linux_vdso.so.o 51b2f58791SDmitry Chagin 529931033bSDmitry ChaginOBJS= linux_vdso.so 53b2f58791SDmitry Chagin 54b2f58791SDmitry Chaginlinux_assym.h: linux_genassym.o 55b2f58791SDmitry Chagin sh ${SYSDIR}/kern/genassym.sh linux_genassym.o > ${.TARGET} 56b2f58791SDmitry Chagin 579931033bSDmitry Chagin.if ${MACHINE_CPUARCH} == "amd64" 58b0fa09a0SDmitry ChaginVDSOFLAGS=-mcmodel=small -msoft-float 599931033bSDmitry ChaginVDSODEPS=linux_vdso_gettc_x86.inc 609931033bSDmitry Chagin.elif ${MACHINE_CPUARCH} == "aarch64" 619931033bSDmitry Chagin# The Linux uses tiny memory model, but our ld does not know about 629931033bSDmitry Chagin# some of relocation types which is generated by cc 639931033bSDmitry ChaginVDSOFLAGS=-mgeneral-regs-only -mcmodel=small -ffixed-x18 649931033bSDmitry Chagin.endif 659931033bSDmitry Chagin 669931033bSDmitry Chaginlinux_locore.o: linux_assym.h assym.inc 679931033bSDmitry Chagin ${CC} -c -x assembler-with-cpp -DLOCORE \ 689931033bSDmitry Chagin -fPIC -pipe -O2 -Werror ${VDSOFLAGS} \ 699931033bSDmitry Chagin -nostdinc -fasynchronous-unwind-tables \ 709931033bSDmitry Chagin -fno-omit-frame-pointer -foptimize-sibling-calls \ 719931033bSDmitry Chagin -fno-stack-protector -I. -I${SYSDIR} -I${SRCTOP}/include \ 72b2f58791SDmitry Chagin ${.IMPSRC} -o ${.TARGET} 73b2f58791SDmitry Chagin 749931033bSDmitry Chaginlinux_vdso_gtod.o: linux_vdso_gtod.inc ${VDSODEPS} 759931033bSDmitry Chagin ${CC} -c -fPIC -pipe -O2 -Werror ${VDSOFLAGS} \ 769931033bSDmitry Chagin -nostdinc -fasynchronous-unwind-tables \ 779931033bSDmitry Chagin -fno-omit-frame-pointer -foptimize-sibling-calls \ 789931033bSDmitry Chagin -fno-stack-protector -I. -I${SYSDIR} -I${SRCTOP}/include \ 799931033bSDmitry Chagin ${.IMPSRC} -o ${.TARGET} 809931033bSDmitry Chagin 819931033bSDmitry Chaginlinux_vdso.so.o: linux_locore.o linux_vdso_gtod.o 829931033bSDmitry Chagin ${LD} --shared --eh-frame-hdr -soname=linux-vdso.so.1 \ 839931033bSDmitry Chagin --no-undefined --hash-style=both -warn-common -nostdlib \ 849931033bSDmitry Chagin --strip-debug -s --build-id=sha1 -Bsymbolic \ 859931033bSDmitry Chagin -T${SRCTOP}/sys/${MACHINE}/linux/linux_vdso.lds.s \ 869931033bSDmitry Chagin -o ${.TARGET} ${.ALLSRC:M*.o} 879931033bSDmitry Chagin 88d3b03d74SEd Maste.if ${MACHINE_CPUARCH} == "aarch64" 89d3b03d74SEd MasteOBJCOPY_TARGET=--output-target elf64-littleaarch64 --binary-architecture aarch64 90d3b03d74SEd Maste.elif ${MACHINE_CPUARCH} == "amd64" 91d3b03d74SEd MasteOBJCOPY_TARGET=--output-target elf64-x86-64 --binary-architecture i386:x86-64 92d3b03d74SEd Maste.else 93d3b03d74SEd Maste.error ${MACHINE_CPUARCH} not yet supported by linux64 94d3b03d74SEd Maste.endif 959931033bSDmitry Chagin 969931033bSDmitry Chaginlinux_vdso.so: linux_vdso.so.o 97513c5cd8SJessica Clarke ${OBJCOPY} --input-target binary ${OBJCOPY_TARGET} \ 989931033bSDmitry Chagin linux_vdso.so.o ${.TARGET} 999931033bSDmitry Chagin ${STRIPBIN} -N _binary_linux_vdso_so_o_size ${.TARGET} 100b2f58791SDmitry Chagin 101*35548e48SEd Mastelinux_support.o: linux_support.S assym.inc linux_assym.h 102b2f58791SDmitry Chagin ${CC} -c -x assembler-with-cpp -DLOCORE ${CFLAGS} \ 103*35548e48SEd Maste ${.ALLSRC:M*.S:u} -o ${.TARGET} 104b2f58791SDmitry Chagin 105ccca101fSBryan Drewerylinux_genassym.o: offset.inc 1064db3ef4cSAlex Richardson ${CC} -c ${CFLAGS:N-flto:N-fno-common} -fcommon ${.IMPSRC} 107b2f58791SDmitry Chagin 1086e4cf32eSDmitry Chagin.if !defined(KERNBUILDDIR) 1096e4cf32eSDmitry Chagin.warning Building Linuxulator outside of a kernel does not make sense 1106e4cf32eSDmitry Chagin.endif 1116e4cf32eSDmitry Chagin 1125bb3134aSKonstantin BelousovEXPORT_SYMS= YES 1135bb3134aSKonstantin Belousov 114b2f58791SDmitry Chagin.include <bsd.kmod.mk> 115