1
2.PATH: ${SRCTOP}/sys/compat/linux ${SRCTOP}/sys/${MACHINE}/linux
3.if ${MACHINE_CPUARCH} == "amd64"
4.PATH: ${SRCTOP}/sys/x86/linux
5.endif
6
7KMOD=	linux64
8SRCS=	linux_dummy_machdep.c \
9	linux_elf64.c \
10	linux_event.c \
11	linux_file.c \
12	linux_fork.c \
13	linux_futex.c \
14	linux_getcwd.c \
15	linux_ioctl.c \
16	linux_ipc.c \
17	linux_machdep.c \
18	linux_misc.c \
19	linux_ptrace.c \
20	linux_rseq.c \
21	linux_signal.c \
22	linux_socket.c \
23	linux_stats.c \
24	linux_syscalls.c \
25	linux_sysctl.c \
26	linux_sysent.c \
27	linux_sysvec.c \
28	linux_time.c \
29	linux_vdso.c \
30	linux_timer.c \
31	linux_xattr.c \
32	opt_ktrace.h \
33	opt_inet6.h \
34	opt_posix.h \
35	bus_if.h \
36	device_if.h \
37	vnode_if.h \
38	linux_support.S \
39	linux_vdso_inc.S
40.if ${MACHINE_CPUARCH} == "amd64"
41SRCS+=	linux_dummy_x86.c
42.endif
43DPSRCS=	assym.inc linux_genassym.c
44
45# XXX: for assym.inc
46SRCS+=  opt_kstack_pages.h opt_nfs.h opt_hwpmc_hooks.h
47
48CLEANFILES=	linux_assym.h linux_genassym.o linux_locore.o \
49		genassym.o linux_vdso_gtod.o linux_vdso.so.o
50
51
52linux_assym.h: linux_genassym.o
53	sh ${SYSDIR}/kern/genassym.sh linux_genassym.o > ${.TARGET}
54
55.if ${MACHINE_CPUARCH} == "amd64"
56VDSOFLAGS=-mcmodel=small -msoft-float
57VDSODEPS=linux_vdso_gettc_x86.inc
58.elif ${MACHINE_CPUARCH} == "aarch64"
59# The Linux uses tiny memory model, but our ld does not know about
60# some of relocation types which is generated by cc
61VDSOFLAGS=-mgeneral-regs-only -mcmodel=small -ffixed-x18
62.endif
63
64linux_locore.o: linux_assym.h assym.inc
65	${CC} -c -x assembler-with-cpp -DLOCORE \
66	-fPIC -pipe -O2 -Werror ${VDSOFLAGS} \
67	-nostdinc -fasynchronous-unwind-tables \
68	-fno-omit-frame-pointer -foptimize-sibling-calls \
69	-fno-stack-protector -I. -I${SYSDIR} -I${SRCTOP}/include \
70	    ${.IMPSRC} -o ${.TARGET}
71
72linux_vdso_gtod.o: linux_vdso_gtod.inc ${VDSODEPS}
73	${CC} -c -fPIC -pipe -O2 -Werror ${VDSOFLAGS} \
74	-nostdinc -fasynchronous-unwind-tables \
75	-fno-omit-frame-pointer -foptimize-sibling-calls \
76	-fno-stack-protector -I. -I${SYSDIR} -I${SRCTOP}/include \
77	    ${.IMPSRC} -o ${.TARGET}
78
79linux_vdso.so.o: linux_locore.o linux_vdso_gtod.o
80	${LD} --shared --eh-frame-hdr -soname=linux-vdso.so.1 \
81	--no-undefined --hash-style=both -warn-common -nostdlib \
82	--strip-debug -s --build-id=sha1 -Bsymbolic \
83	-T${SRCTOP}/sys/${MACHINE}/linux/linux_vdso.lds.s \
84	-o ${.TARGET} ${.ALLSRC:M*.o}
85
86linux_vdso_inc.o: linux_vdso.so.o
87
88linux_support.o: linux_support.S assym.inc linux_assym.h
89	${CC} -c -x assembler-with-cpp -DLOCORE ${CFLAGS} \
90	    ${.ALLSRC:M*.S:u} -o ${.TARGET}
91
92linux_genassym.o: offset.inc
93	${CC} -c ${CFLAGS:N-flto*:N-fno-common:N-fsanitize*:N-fno-sanitize*} \
94	    -fcommon ${.IMPSRC}
95
96.if !defined(KERNBUILDDIR)
97.warning Building Linuxulator outside of a kernel does not make sense
98.endif
99
100EXPORT_SYMS=	YES
101
102.include <bsd.kmod.mk>
103