1# $FreeBSD$ 2 3.if ${MACHINE_CPUARCH} == "amd64" 4SFX= 32 5CFLAGS+=-DCOMPAT_FREEBSD32 -DCOMPAT_LINUX32 6.endif 7 8.PATH: ${SRCTOP}/sys/compat/linux ${SRCTOP}/sys/${MACHINE_CPUARCH}/linux${SFX} 9.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" 10.PATH: ${SRCTOP}/sys/x86/linux 11.endif 12 13KMOD= linux 14SRCS= linux${SFX}_dummy_machdep.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 opt_compat.h \ 37 opt_inet6.h \ 38 opt_ktrace.h \ 39 opt_posix.h \ 40 opt_usb.h \ 41 bus_if.h \ 42 device_if.h \ 43 vnode_if.h 44.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64" 45SRCS+= linux_dummy_x86.c 46VDSODEPS=linux_vdso_gettc_x86.inc 47.endif 48.if ${MACHINE_CPUARCH} == "amd64" 49SRCS+= linux${SFX}_support.S 50SRCS+= linux_elf32.c 51.else 52SRCS+= linux_copyout.c 53.endif 54DPSRCS= assym.inc linux${SFX}_genassym.c 55 56# XXX: for assym.inc 57SRCS+= opt_kstack_pages.h opt_nfs.h opt_hwpmc_hooks.h 58.if ${MACHINE_CPUARCH} == "i386" 59SRCS+= opt_apic.h opt_cpu.h 60.endif 61 62OBJS= linux${SFX}_vdso.so 63 64.if ${MACHINE_CPUARCH} == "i386" 65SRCS+= imgact_linux.c \ 66 linux.c \ 67 linux_dummy.c \ 68 linux_emul.c \ 69 linux_errno.c \ 70 linux_mib.c \ 71 linux_mmap.c \ 72 linux_ptrace_machdep.c \ 73 linux_util.c \ 74 linux_vdso_selector_x86.c \ 75 linux_x86.c 76.endif 77 78.if ${MACHINE_CPUARCH} == "i386" 79EXPORT_SYMS= 80EXPORT_SYMS+= linux_emul_path 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} -fcommon ${.IMPSRC} 142 143.if !defined(KERNBUILDDIR) 144.warning Building Linuxulator outside of a kernel does not make sense 145.endif 146 147EXPORT_SYMS= YES 148 149.include <bsd.kmod.mk> 150