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