129 lines
2.8 KiB
Makefile
129 lines
2.8 KiB
Makefile
# $NetBSD: Makefile.usermode,v 1.33 2013/03/06 11:36:21 yamt Exp $
|
|
|
|
USETOOLS?= no
|
|
NEED_OWN_INSTALL_TARGET?= no
|
|
.include <bsd.own.mk>
|
|
|
|
##
|
|
## (1) port identification
|
|
##
|
|
USERMODE= $S/arch/usermode
|
|
GENASSYM_CONF= ${USERMODE}/usermode/genassym.cf
|
|
|
|
## support for crosscompiling
|
|
.if ${MACHINE_ARCH:Uunset} == "unset"
|
|
MACHINE_ARCH!=uname -p
|
|
.endif
|
|
|
|
##
|
|
## (2) compile settings
|
|
##
|
|
USERMODE_HOSTOS!=uname -s
|
|
USERMODE_HOSTMACHINE!=uname -m
|
|
USERMODE_LIBS= -L${DESTDIR}/usr/lib -lrt
|
|
USERMODE_CPPFLAGS=${DEBUG} -U_KERNEL
|
|
USERMODE_CPPFLAGS+=-I${DESTDIR}/usr/include
|
|
USERMODE_CPPFLAGS+=${CWARNFLAGS} ${NOGCCERROR:D:U-Werror}
|
|
|
|
## XXX hack to make it work under build.sh
|
|
.if ${TOOLDIR:Uno} != "no"
|
|
USERMODE_LIBS+= crti.o
|
|
SYSTEM_LD_FIX= cp ${DESTDIR}/usr/lib/crt0.o ${DESTDIR}/usr/lib/crtbegin.o ${DESTDIR}/usr/lib/crtend.o ${DESTDIR}/usr/lib/crti.o .;
|
|
.endif
|
|
|
|
.if ${USERMODE_HOSTOS} == "Linux"
|
|
USERMODE_LIBS+= -lpthread
|
|
CPPFLAGS+=-Dstrtoul=netbsd_strtoul
|
|
CPPFLAGS+=-Dstrtoll=netbsd_strtoll
|
|
CPPFLAGS+=-Dstrtoull=netbsd_strtoull
|
|
CPPFLAGS+=-D__NetBSD__ -Wno-unused-but-set-variable
|
|
.endif
|
|
|
|
DEFCOPTS= -fno-omit-frame-pointer
|
|
CPPFLAGS+= -Dusermode
|
|
CPPFLAGS+= -Dsyscall=kernel_syscall
|
|
CPPFLAGS.init_main.c+= -Dmain=kernmain
|
|
|
|
CPPFLAGS.thunk.c+= ${USERMODE_CPPFLAGS}
|
|
|
|
##
|
|
## (3) libkern and compat
|
|
##
|
|
KERN_AS= library
|
|
COMPAT_AS= library
|
|
|
|
##
|
|
## (4) local objects, compile rules, and dependencies
|
|
##
|
|
MD_OBJS= thunk.o
|
|
MD_CFILES= ${USERMODE}/usermode/thunk.c
|
|
MD_SFILES=
|
|
|
|
MD_OBJS+= cpu_${MACHINE_ARCH}.o
|
|
MD_CFILES+= ${USERMODE}/target/${MACHINE_ARCH}/cpu_${MACHINE_ARCH}.c
|
|
|
|
##
|
|
## (5) link settings
|
|
##
|
|
TEXTADDR?= %TEXTADDR%
|
|
|
|
LINKFLAGS_NORMAL= -X
|
|
KERN_LDSCRIPT?= kern.ldscript
|
|
#LINKFORMAT= -T ${USERMODE}/conf/${KERN_LDSCRIPT}
|
|
|
|
SYSTEM_LD= @${_MKSHMSG} " link ${.CURDIR:T}/${.TARGET}"; \
|
|
${_MKSHECHO}\
|
|
${CC} -static ${COPTS} -Wl,-Map,$@.map -o $@ ${LINKFORMAT} -Ttext ${TEXTADDR} '$${SYSTEM_OBJ}' '$${EXTRA_OBJ}' vers.o ${USERMODE_LIBS}; \
|
|
${SYSTEM_LD_FIX} \
|
|
${CC} -static ${COPTS} -Wl,-Map,$@.map -o $@ ${LINKFORMAT} -Ttext ${TEXTADDR} ${SYSTEM_OBJ} ${EXTRA_OBJ} vers.o ${USERMODE_LIBS}
|
|
NVFLAGS= -n
|
|
|
|
##
|
|
## (6) port specific target dependencies
|
|
##
|
|
|
|
.if !make(obj) && !make(clean) && !make(cleandir)
|
|
.BEGIN:
|
|
@rm -f i386 && \
|
|
ln -s $S/arch/i386/include i386
|
|
@rm -f amd64 && \
|
|
ln -s $S/arch/amd64/include amd64
|
|
.endif
|
|
|
|
thunk.d: ${USERMODE}/usermode/thunk.c
|
|
${MKDEP} -f ${.TARGET} -- ${MKDEP_CFLAGS} \
|
|
${CPPFLAGS.thunk.c} ${USERMODE}/usermode/thunk.c
|
|
|
|
thunk.o: ${USERMODE}/usermode/thunk.c
|
|
${CC} ${COPTS} ${CPPFLAGS.thunk.c} -c -o $@ ${USERMODE}/usermode/thunk.c
|
|
|
|
cpu_${MACHINE_ARCH}.o: ${USERMODE}/target/${MACHINE_ARCH}/cpu_${MACHINE_ARCH}.c
|
|
|
|
##
|
|
## (7) misc settings
|
|
##
|
|
|
|
##
|
|
## (8) config(8) generated machinery
|
|
%INCLUDES
|
|
|
|
%OBJS
|
|
|
|
%CFILES
|
|
|
|
%SFILES
|
|
|
|
%LOAD
|
|
|
|
%RULES
|
|
|
|
##
|
|
## (9) port independent kernel machinery
|
|
##
|
|
.include "$S/conf/Makefile.kern.inc"
|
|
|
|
##
|
|
## (10) appending make options
|
|
##
|
|
%MAKEOPTIONSAPPEND
|