xref: /freebsd/sys/modules/linux64/Makefile (revision 9768746b)
1# $FreeBSD$
2
3.PATH: ${SRCTOP}/sys/compat/linux ${SRCTOP}/sys/${MACHINE}/linux
4.if ${MACHINE_CPUARCH} == "amd64"
5.PATH: ${SRCTOP}/sys/x86/linux
6.endif
7
8KMOD=	linux64
9SRCS=	linux_dummy_machdep.c \
10	linux_elf64.c \
11	linux_event.c \
12	linux_file.c \
13	linux_fork.c \
14	linux_futex.c \
15	linux_getcwd.c \
16	linux_ioctl.c \
17	linux_ipc.c \
18	linux_machdep.c \
19	linux_misc.c \
20	linux_ptrace.c \
21	linux_rseq.c \
22	linux_signal.c \
23	linux_socket.c \
24	linux_stats.c \
25	linux_syscalls.c \
26	linux_sysctl.c \
27	linux_sysent.c \
28	linux_sysvec.c \
29	linux_time.c \
30	linux_vdso.c \
31	linux_timer.c \
32	opt_ktrace.h \
33	opt_inet6.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.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
51OBJS=	linux_vdso.so
52
53linux_assym.h: linux_genassym.o
54	sh ${SYSDIR}/kern/genassym.sh linux_genassym.o > ${.TARGET}
55
56.if ${MACHINE_CPUARCH} == "amd64"
57VDSOFLAGS=-mcmodel=small -msoft-float
58VDSODEPS=linux_vdso_gettc_x86.inc
59.elif ${MACHINE_CPUARCH} == "aarch64"
60# The Linux uses tiny memory model, but our ld does not know about
61# some of relocation types which is generated by cc
62VDSOFLAGS=-mgeneral-regs-only -mcmodel=small -ffixed-x18
63.endif
64
65linux_locore.o: linux_assym.h assym.inc
66	${CC} -c -x assembler-with-cpp -DLOCORE \
67	-fPIC -pipe -O2 -Werror ${VDSOFLAGS} \
68	-nostdinc -fasynchronous-unwind-tables \
69	-fno-omit-frame-pointer -foptimize-sibling-calls \
70	-fno-stack-protector -I. -I${SYSDIR} -I${SRCTOP}/include \
71	    ${.IMPSRC} -o ${.TARGET}
72
73linux_vdso_gtod.o: linux_vdso_gtod.inc ${VDSODEPS}
74	${CC} -c -fPIC -pipe -O2 -Werror ${VDSOFLAGS} \
75	-nostdinc -fasynchronous-unwind-tables \
76	-fno-omit-frame-pointer -foptimize-sibling-calls \
77	-fno-stack-protector -I. -I${SYSDIR} -I${SRCTOP}/include \
78	    ${.IMPSRC} -o ${.TARGET}
79
80linux_vdso.so.o: linux_locore.o linux_vdso_gtod.o
81	${LD} --shared --eh-frame-hdr -soname=linux-vdso.so.1 \
82	--no-undefined --hash-style=both -warn-common -nostdlib \
83	--strip-debug -s --build-id=sha1 -Bsymbolic \
84	-T${SRCTOP}/sys/${MACHINE}/linux/linux_vdso.lds.s \
85	-o ${.TARGET} ${.ALLSRC:M*.o}
86
87.if ${MACHINE_CPUARCH} == "aarch64"
88OBJCOPY_TARGET=--output-target elf64-littleaarch64 --binary-architecture aarch64
89.elif ${MACHINE_CPUARCH} == "amd64"
90OBJCOPY_TARGET=--output-target elf64-x86-64 --binary-architecture i386:x86-64
91.else
92.error ${MACHINE_CPUARCH} not yet supported by linux64
93.endif
94
95linux_vdso.so: linux_vdso.so.o
96	${OBJCOPY} --input-target binary ${OBJCOPY_TARGET} \
97	    linux_vdso.so.o ${.TARGET}
98	${STRIPBIN} -N _binary_linux_vdso_so_o_size ${.TARGET}
99
100linux_support.o: linux_support.S assym.inc linux_assym.h
101	${CC} -c -x assembler-with-cpp -DLOCORE ${CFLAGS} \
102	    ${.ALLSRC:M*.S:u} -o ${.TARGET}
103
104linux_genassym.o: offset.inc
105	${CC} -c ${CFLAGS:N-flto:N-fno-common} -fcommon ${.IMPSRC}
106
107.if !defined(KERNBUILDDIR)
108.warning Building Linuxulator outside of a kernel does not make sense
109.endif
110
111EXPORT_SYMS=	YES
112
113.include <bsd.kmod.mk>
114