1.if ${MACHINE_CPUARCH} == "amd64" 2SFX= 32 3CFLAGS+=-DCOMPAT_FREEBSD32 -DCOMPAT_LINUX32 4.endif 5 6.PATH: ${SRCTOP}/sys/compat/linux ${SRCTOP}/sys/${MACHINE_CPUARCH}/linux${SFX} 7.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" 8.PATH: ${SRCTOP}/sys/x86/linux 9.endif 10 11KMOD= linux 12SRCS= linux${SFX}_dummy_machdep.c \ 13 linux_elf32.c \ 14 linux_event.c \ 15 linux_file.c \ 16 linux_fork.c \ 17 linux_futex.c \ 18 linux_getcwd.c \ 19 linux_ioctl.c \ 20 linux_ipc.c \ 21 linux${SFX}_machdep.c \ 22 linux_misc.c \ 23 linux_rseq.c \ 24 linux_signal.c \ 25 linux_socket.c \ 26 linux_stats.c \ 27 linux${SFX}_syscalls.c \ 28 linux_sysctl.c \ 29 linux${SFX}_sysent.c \ 30 linux${SFX}_sysvec.c \ 31 linux_time.c \ 32 linux_timer.c \ 33 linux_uid16.c \ 34 linux_vdso.c \ 35 linux_xattr.c \ 36 opt_compat.h \ 37 opt_inet.h \ 38 opt_inet6.h \ 39 opt_ktrace.h \ 40 opt_posix.h \ 41 opt_usb.h \ 42 bus_if.h \ 43 device_if.h \ 44 vnode_if.h 45 46.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" 47SRCS+= linux_dummy_x86.c 48VDSODEPS=linux_vdso_gettc_x86.inc 49.endif 50.if ${MACHINE_CPUARCH} == "amd64" 51SRCS+= linux${SFX}_support.S 52.endif 53DPSRCS= assym.inc linux${SFX}_genassym.c 54 55# XXX: for assym.inc 56SRCS+= opt_kstack_pages.h opt_nfs.h opt_hwpmc_hooks.h 57.if ${MACHINE_CPUARCH} == "i386" 58SRCS+= opt_apic.h opt_cpu.h 59.endif 60 61OBJS= linux${SFX}_vdso.so 62 63.if ${MACHINE_CPUARCH} == "i386" 64SRCS+= imgact_linux.c \ 65 linux.c \ 66 linux_dummy.c \ 67 linux_emul.c \ 68 linux_errno.c \ 69 linux_mib.c \ 70 linux_mmap.c \ 71 linux_ptrace_machdep.c \ 72 linux_util.c \ 73 linux_vdso_selector_x86.c \ 74 linux_x86.c \ 75 linux_copyout.c \ 76 linux_netlink.c 77.endif 78 79.if ${MACHINE_CPUARCH} == "i386" 80EXPORT_SYMS= 81EXPORT_SYMS+= linux_get_osname 82EXPORT_SYMS+= linux_get_osrelease 83EXPORT_SYMS+= linux_ioctl_register_handler 84EXPORT_SYMS+= linux_ioctl_unregister_handler 85.endif 86 87CLEANFILES= linux${SFX}_assym.h linux${SFX}_genassym.o linux${SFX}_locore.o \ 88 genassym.o linux${SFX}_vdso_gtod.o linux${SFX}_vdso.so.o 89 90linux${SFX}_assym.h: linux${SFX}_genassym.o 91 sh ${SYSDIR}/kern/genassym.sh linux${SFX}_genassym.o > ${.TARGET} 92 93.if ${MACHINE_CPUARCH} == "amd64" 94VDSOFLAGS=-DCOMPAT_FREEBSD32 -DCOMPAT_LINUX32 -m32 95.else 96VDSOFLAGS=-mregparm=0 97.endif 98 99linux${SFX}_locore.o: linux${SFX}_assym.h assym.inc 100 ${CC} -c -x assembler-with-cpp -DLOCORE -fPIC -pipe -O2 -Werror \ 101 -msoft-float \ 102 -fno-common -nostdinc -fasynchronous-unwind-tables \ 103 -fno-omit-frame-pointer -foptimize-sibling-calls ${VDSOFLAGS} \ 104 -fno-stack-protector -I. -I${SYSDIR} -I${SRCTOP}/include \ 105 ${.IMPSRC} -o ${.TARGET} 106 107linux${SFX}_vdso_gtod.o: linux_vdso_gtod.inc ${VDSODEPS} 108 ${CC} -c -fPIC -pipe -O2 -Werror -msoft-float \ 109 -fno-common -nostdinc -fasynchronous-unwind-tables \ 110 -fno-omit-frame-pointer -foptimize-sibling-calls ${VDSOFLAGS} \ 111 -fno-stack-protector -I. -I${SYSDIR} -I${SRCTOP}/include \ 112 ${.IMPSRC} -o ${.TARGET} 113 114linux${SFX}_vdso.so.o: linux${SFX}_locore.o linux${SFX}_vdso_gtod.o 115 ${LD} -m elf_i386 --shared --eh-frame-hdr -soname=linux-gate.so.1 \ 116 --no-undefined --hash-style=both -warn-common -nostdlib \ 117 --strip-debug -s --build-id=sha1 --Bsymbolic \ 118 -T${SRCTOP}/sys/${MACHINE}/linux${SFX}/linux${SFX}_vdso.lds.s \ 119 -o ${.TARGET} ${.ALLSRC:M*.o} 120 121.if ${MACHINE_CPUARCH} == "amd64" 122OBJCOPY_TARGET=--output-target elf64-x86-64-freebsd --binary-architecture i386 123.elif ${MACHINE_CPUARCH} == "i386" 124OBJCOPY_TARGET=--output-target elf32-i386-freebsd --binary-architecture i386 125.else 126.error ${MACHINE_CPUARCH} not yet supported by linux 127.endif 128 129linux${SFX}_vdso.so: linux${SFX}_vdso.so.o 130 ${OBJCOPY} --input-target binary ${OBJCOPY_TARGET} \ 131 linux${SFX}_vdso.so.o ${.TARGET} 132 ${STRIPBIN} -N _binary_linux${SFX}_vdso_so_o_size ${.TARGET} 133 134.if ${MACHINE_CPUARCH} == "amd64" 135linux${SFX}_support.o: linux${SFX}_support.S linux${SFX}_assym.h assym.inc 136 ${CC} -c -x assembler-with-cpp -DLOCORE ${CFLAGS} \ 137 ${.ALLSRC:M*.S:u} -o ${.TARGET} 138.endif 139 140linux${SFX}_genassym.o: offset.inc 141 ${CC} -c ${CFLAGS:N-flto*:N-fno-common:N-fsanitize*:N-fno-sanitize*} \ 142 -fcommon ${.IMPSRC} 143 144.if !defined(KERNBUILDDIR) 145.warning Building Linuxulator outside of a kernel does not make sense 146.endif 147 148EXPORT_SYMS= YES 149 150.include <bsd.kmod.mk> 151