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