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