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