xref: /freebsd/sys/modules/linux64/Makefile (revision 16038816)
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
21.endif
22DPSRCS=	assym.inc linux_genassym.c
23
24# XXX: for assym.inc
25SRCS+=  opt_kstack_pages.h opt_nfs.h opt_hwpmc_hooks.h
26
27CLEANFILES=	linux_assym.h linux_genassym.o linux_locore.o \
28		genassym.o
29
30OBJS=	${VDSO}.so
31
32linux_assym.h: linux_genassym.o
33	sh ${SYSDIR}/kern/genassym.sh linux_genassym.o > ${.TARGET}
34
35linux_locore.o: linux_locore.asm linux_assym.h
36	${CC} ${CCLDFLAGS} -x assembler-with-cpp -DLOCORE -shared -mcmodel=small	\
37	-pipe -I. -I${SYSDIR} ${WERROR} -Wall -fno-common -fPIC -nostdinc	\
38	-Wl,-T${SRCTOP}/sys/${MACHINE}/linux/${VDSO}.lds.s	\
39	-Wl,-soname=${VDSO}.so.1,-warn-common -nostdlib			\
40	    ${.IMPSRC} -o ${.TARGET}
41
42.if ${MACHINE_CPUARCH} == "aarch64"
43OBJCOPY_TARGET=--output-target elf64-littleaarch64 --binary-architecture aarch64
44.elif ${MACHINE_CPUARCH} == "amd64"
45OBJCOPY_TARGET=--output-target elf64-x86-64 --binary-architecture i386:x86-64
46.else
47.error ${MACHINE_CPUARCH} not yet supported by linux64
48.endif
49${VDSO}.so: linux_locore.o
50	${OBJCOPY} --input-target binary ${OBJCOPY_TARGET} \
51	    linux_locore.o ${.TARGET}
52	${STRIPBIN} -N _binary_linux_locore_o_size ${.TARGET}
53
54linux_support.o: assym.inc linux_assym.h
55	${CC} -c -x assembler-with-cpp -DLOCORE ${CFLAGS} \
56	    ${.IMPSRC} -o ${.TARGET}
57
58linux_genassym.o: offset.inc
59	${CC} -c ${CFLAGS:N-flto:N-fno-common} -fcommon ${.IMPSRC}
60
61.if !defined(KERNBUILDDIR)
62.warning Building Linuxulator outside of a kernel does not make sense
63.endif
64
65.include <bsd.kmod.mk>
66