xref: /freebsd/sys/modules/linux64/Makefile (revision 5def4c47d4bd90b209b9b4a4ba9faec15846d8fd)
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
8VDSO=	linux_vdso
9
10KMOD=	linux64
11SRCS=	linux_fork.c linux_dummy_machdep.c linux_file.c linux_event.c \
12	linux_futex.c linux_getcwd.c linux_ioctl.c linux_ipc.c \
13	linux_machdep.c linux_misc.c linux_ptrace.c linux_signal.c \
14	linux_socket.c linux_stats.c linux_sysctl.c linux_sysent.c \
15	linux_sysvec.c linux_time.c linux_vdso.c linux_timer.c \
16	opt_compat.h opt_inet6.h opt_posix.h opt_usb.h \
17	vnode_if.h device_if.h bus_if.h \
18	linux_support.s
19.if ${MACHINE_CPUARCH} == "amd64"
20SRCS+=	linux_dummy_x86.c
21SRCS+=	linux_elf64.c
22.endif
23DPSRCS=	assym.inc linux_genassym.c
24
25# XXX: for assym.inc
26SRCS+=  opt_kstack_pages.h opt_nfs.h opt_hwpmc_hooks.h
27
28CLEANFILES=	linux_assym.h linux_genassym.o linux_locore.o \
29		genassym.o
30
31OBJS=	${VDSO}.so
32
33linux_assym.h: linux_genassym.o
34	sh ${SYSDIR}/kern/genassym.sh linux_genassym.o > ${.TARGET}
35
36linux_locore.o: linux_locore.asm linux_assym.h
37	${CC} ${CCLDFLAGS} -x assembler-with-cpp -DLOCORE -shared -mcmodel=small	\
38	-pipe -I. -I${SYSDIR} ${WERROR} -Wall -fno-common -fPIC -nostdinc	\
39	-Wl,-T${SRCTOP}/sys/${MACHINE}/linux/${VDSO}.lds.s	\
40	-Wl,-soname=${VDSO}.so.1,-warn-common -nostdlib			\
41	    ${.IMPSRC} -o ${.TARGET}
42
43.if ${MACHINE_CPUARCH} == "aarch64"
44OBJCOPY_TARGET=--output-target elf64-littleaarch64 --binary-architecture aarch64
45.elif ${MACHINE_CPUARCH} == "amd64"
46OBJCOPY_TARGET=--output-target elf64-x86-64 --binary-architecture i386:x86-64
47.else
48.error ${MACHINE_CPUARCH} not yet supported by linux64
49.endif
50${VDSO}.so: linux_locore.o
51	${OBJCOPY} --input-target binary ${OBJCOPY_TARGET} \
52	    linux_locore.o ${.TARGET}
53	${STRIPBIN} -N _binary_linux_locore_o_size ${.TARGET}
54
55linux_support.o: assym.inc linux_assym.h
56	${CC} -c -x assembler-with-cpp -DLOCORE ${CFLAGS} \
57	    ${.IMPSRC} -o ${.TARGET}
58
59linux_genassym.o: offset.inc
60	${CC} -c ${CFLAGS:N-flto:N-fno-common} -fcommon ${.IMPSRC}
61
62.if !defined(KERNBUILDDIR)
63.warning Building Linuxulator outside of a kernel does not make sense
64.endif
65
66.include <bsd.kmod.mk>
67