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 945d99014SEdward Tomasz NapieralaSRCS= linux_elf64.c linux_fork.c linux_dummy_machdep.c linux_file.c \ 1045d99014SEdward Tomasz Napierala linux_event.c linux_futex.c linux_getcwd.c linux_ioctl.c linux_ipc.c \ 11d82de054SEdward Tomasz Napierala linux_machdep.c linux_misc.c linux_ptrace.c linux_signal.c \ 12b2f58791SDmitry Chagin linux_socket.c linux_stats.c linux_sysctl.c linux_sysent.c \ 13b2f58791SDmitry Chagin linux_sysvec.c linux_time.c linux_vdso.c linux_timer.c \ 146469bdcdSBrooks Davis opt_compat.h opt_inet6.h opt_posix.h opt_usb.h \ 1585059bc4SEd Maste vnode_if.h device_if.h bus_if.h \ 16b2f58791SDmitry Chagin linux_support.s 1788588c4bSDmitry Chagin.if ${MACHINE_CPUARCH} == "amd64" 189931033bSDmitry ChaginSRCS+= linux_dummy_x86.c linux_vdso_tsc_selector_x86.c 19e9b13c66SConrad Meyer.endif 20fc2a8776SEd MasteDPSRCS= assym.inc linux_genassym.c 21b2f58791SDmitry Chagin 22fc2a8776SEd Maste# XXX: for assym.inc 23ce859641SBryan DrewerySRCS+= opt_kstack_pages.h opt_nfs.h opt_hwpmc_hooks.h 24b2f58791SDmitry Chagin 257c28c7e8SDmitry ChaginCLEANFILES= linux_assym.h linux_genassym.o linux_locore.o \ 269931033bSDmitry Chagin genassym.o linux_vdso_gtod.o linux_vdso.so.o 27b2f58791SDmitry Chagin 289931033bSDmitry ChaginOBJS= linux_vdso.so 29b2f58791SDmitry Chagin 30b2f58791SDmitry Chaginlinux_assym.h: linux_genassym.o 31b2f58791SDmitry Chagin sh ${SYSDIR}/kern/genassym.sh linux_genassym.o > ${.TARGET} 32b2f58791SDmitry Chagin 339931033bSDmitry Chagin.if ${MACHINE_CPUARCH} == "amd64" 34*b0fa09a0SDmitry ChaginVDSOFLAGS=-mcmodel=small -msoft-float 359931033bSDmitry ChaginVDSODEPS=linux_vdso_gettc_x86.inc 369931033bSDmitry Chagin.elif ${MACHINE_CPUARCH} == "aarch64" 379931033bSDmitry Chagin# The Linux uses tiny memory model, but our ld does not know about 389931033bSDmitry Chagin# some of relocation types which is generated by cc 399931033bSDmitry ChaginVDSOFLAGS=-mgeneral-regs-only -mcmodel=small -ffixed-x18 409931033bSDmitry Chagin.endif 419931033bSDmitry Chagin 429931033bSDmitry Chaginlinux_locore.o: linux_assym.h assym.inc 439931033bSDmitry Chagin ${CC} -c -x assembler-with-cpp -DLOCORE \ 449931033bSDmitry Chagin -fPIC -pipe -O2 -Werror ${VDSOFLAGS} \ 459931033bSDmitry Chagin -nostdinc -fasynchronous-unwind-tables \ 469931033bSDmitry Chagin -fno-omit-frame-pointer -foptimize-sibling-calls \ 479931033bSDmitry Chagin -fno-stack-protector -I. -I${SYSDIR} -I${SRCTOP}/include \ 48b2f58791SDmitry Chagin ${.IMPSRC} -o ${.TARGET} 49b2f58791SDmitry Chagin 509931033bSDmitry Chaginlinux_vdso_gtod.o: linux_vdso_gtod.inc ${VDSODEPS} 519931033bSDmitry Chagin ${CC} -c -fPIC -pipe -O2 -Werror ${VDSOFLAGS} \ 529931033bSDmitry Chagin -nostdinc -fasynchronous-unwind-tables \ 539931033bSDmitry Chagin -fno-omit-frame-pointer -foptimize-sibling-calls \ 549931033bSDmitry Chagin -fno-stack-protector -I. -I${SYSDIR} -I${SRCTOP}/include \ 559931033bSDmitry Chagin ${.IMPSRC} -o ${.TARGET} 569931033bSDmitry Chagin 579931033bSDmitry Chaginlinux_vdso.so.o: linux_locore.o linux_vdso_gtod.o 589931033bSDmitry Chagin ${LD} --shared --eh-frame-hdr -soname=linux-vdso.so.1 \ 599931033bSDmitry Chagin --no-undefined --hash-style=both -warn-common -nostdlib \ 609931033bSDmitry Chagin --strip-debug -s --build-id=sha1 -Bsymbolic \ 619931033bSDmitry Chagin -T${SRCTOP}/sys/${MACHINE}/linux/linux_vdso.lds.s \ 629931033bSDmitry Chagin -o ${.TARGET} ${.ALLSRC:M*.o} 639931033bSDmitry Chagin 64d3b03d74SEd Maste.if ${MACHINE_CPUARCH} == "aarch64" 65d3b03d74SEd MasteOBJCOPY_TARGET=--output-target elf64-littleaarch64 --binary-architecture aarch64 66d3b03d74SEd Maste.elif ${MACHINE_CPUARCH} == "amd64" 67d3b03d74SEd MasteOBJCOPY_TARGET=--output-target elf64-x86-64 --binary-architecture i386:x86-64 68d3b03d74SEd Maste.else 69d3b03d74SEd Maste.error ${MACHINE_CPUARCH} not yet supported by linux64 70d3b03d74SEd Maste.endif 719931033bSDmitry Chagin 729931033bSDmitry Chaginlinux_vdso.so: linux_vdso.so.o 73513c5cd8SJessica Clarke ${OBJCOPY} --input-target binary ${OBJCOPY_TARGET} \ 749931033bSDmitry Chagin linux_vdso.so.o ${.TARGET} 759931033bSDmitry Chagin ${STRIPBIN} -N _binary_linux_vdso_so_o_size ${.TARGET} 76b2f58791SDmitry Chagin 77fc2a8776SEd Mastelinux_support.o: assym.inc linux_assym.h 78b2f58791SDmitry Chagin ${CC} -c -x assembler-with-cpp -DLOCORE ${CFLAGS} \ 79b2f58791SDmitry Chagin ${.IMPSRC} -o ${.TARGET} 80b2f58791SDmitry Chagin 81ccca101fSBryan Drewerylinux_genassym.o: offset.inc 824db3ef4cSAlex Richardson ${CC} -c ${CFLAGS:N-flto:N-fno-common} -fcommon ${.IMPSRC} 83b2f58791SDmitry Chagin 846e4cf32eSDmitry Chagin.if !defined(KERNBUILDDIR) 856e4cf32eSDmitry Chagin.warning Building Linuxulator outside of a kernel does not make sense 866e4cf32eSDmitry Chagin.endif 876e4cf32eSDmitry Chagin 88b2f58791SDmitry Chagin.include <bsd.kmod.mk> 89