Home | History | Annotate | Line # | Download | only in conf
Makefile.usermode revision 1.41
      1 # $NetBSD: Makefile.usermode,v 1.41 2018/01/13 16:20:33 reinoud Exp $
      2 
      3 USETOOLS?=			no
      4 NEED_OWN_INSTALL_TARGET?=	no
      5 .include <bsd.own.mk>
      6 
      7 ##
      8 ## (1) port identification
      9 ##
     10 USERMODE=	$S/arch/usermode
     11 GENASSYM_CONF=	${USERMODE}/usermode/genassym.cf
     12 
     13 ## support for crosscompiling
     14 .if ${MACHINE_ARCH:Uunset} == "unset"
     15 MACHINE_ARCH!=uname -p
     16 .endif
     17 
     18 ##
     19 ## (2) compile settings
     20 ##
     21 USERMODE_HOSTOS!=uname -s
     22 USERMODE_HOSTMACHINE!=uname -m
     23 USERMODE_LIBS= -L${DESTDIR}/usr/lib -lrt
     24 USERMODE_CPPFLAGS=${DEBUG} -U_KERNEL
     25 USERMODE_CPPFLAGS+=-I${DESTDIR}/usr/include
     26 USERMODE_CPPFLAGS+=${CWARNFLAGS} ${NOGCCERROR:D:U-Werror}
     27 
     28 ## XXX hack to make it work under build.sh
     29 .if ${TOOLDIR:Uno} != "no"
     30 USERMODE_LIBS+= crti.o
     31 SYSTEM_LD_FIX= cp ${DESTDIR}/usr/lib/crt0.o ${DESTDIR}/usr/lib/crtbegin.o ${DESTDIR}/usr/lib/crtend.o ${DESTDIR}/usr/lib/crti.o .;
     32 .endif
     33 
     34 .if ${USERMODE_HOSTOS} == "Linux"
     35 USERMODE_LIBS+=	-lpthread
     36 CPPFLAGS+=-Dstrtoul=netbsd_strtoul
     37 CPPFLAGS+=-Dstrtoll=netbsd_strtoll
     38 CPPFLAGS+=-Dstrtoull=netbsd_strtoull
     39 CPPFLAGS+=-D__NetBSD__ -Wno-unused-but-set-variable
     40 .endif
     41 
     42 DEFCOPTS=	-fno-omit-frame-pointer
     43 CPPFLAGS+=	-Dusermode
     44 CPPFLAGS+=	-Dsyscall=kernel_syscall
     45 CPPFLAGS.init_main.c+=	-Dmain=kernmain
     46 
     47 CPPFLAGS.thunk.c+=	${USERMODE_CPPFLAGS}
     48 
     49 ##
     50 ## (3) libkern and compat
     51 ##
     52 KERN_AS=	library
     53 COMPAT_AS=	library
     54 
     55 ##
     56 ## (4) local objects, compile rules, and dependencies
     57 ##
     58 MD_OBJS=	thunk.o
     59 MD_CFILES=	${USERMODE}/usermode/thunk.c
     60 MD_SFILES=
     61 
     62 MD_OBJS+=	cpu_${MACHINE_CPU}.o
     63 MD_CFILES+=	${USERMODE}/target/${MACHINE_CPU}/cpu_${MACHINE_CPU}.c
     64 
     65 ##
     66 ## (5) link settings
     67 ##
     68 TEXTADDR?=	  %TEXTADDR%
     69 
     70 LINKFLAGS_NORMAL=	-X
     71 KERNLDSCRIPT?=	${USERMODE}/conf/kern.ldscript
     72 
     73 SYSTEM_LD=	@do_system_ld() { \
     74 		${_MKSHMSG} "   link  ${.CURDIR:T}/${.TARGET}"; \
     75 		${_MKSHECHO}\
     76 		${CC} -static ${COPTS} -Wl,-Map,$${target}.map -o ${.TARGET} ${LINKFORMAT} -Ttext ${TEXTADDR} '$${SYSTEM_OBJ}' '$${EXTRA_OBJ}' vers.o ${USERMODE_LIBS} $$@; \
     77 		${SYSTEM_LD_FIX} \
     78 		${CC} -static ${COPTS} -Wl,-Map,$${target}.map -o ${.TARGET} ${LINKFORMAT} -Ttext ${TEXTADDR} ${SYSTEM_OBJ} ${EXTRA_OBJ} vers.o ${USERMODE_LIBS} $$@; \
     79 		}; \
     80 		do_system_ld
     81 NVFLAGS=	-n
     82 
     83 ##
     84 ## (6) port specific target dependencies
     85 ##
     86 
     87 .if !make(obj) && !make(clean) && !make(cleandir)
     88 .BEGIN::
     89 	-@rm -f i386 && \
     90 		ln -s $S/arch/i386/include i386
     91 	-@rm -f amd64 && \
     92 		ln -s $S/arch/amd64/include amd64
     93 	-@rm -f arm && \
     94 		ln -s $S/arch/arm/include arm
     95 .endif
     96 
     97 thunk.d: ${USERMODE}/usermode/thunk.c
     98 	${MKDEP} -f ${.TARGET} -- ${MKDEP_CFLAGS} \
     99 	    ${CPPFLAGS.thunk.c} ${USERMODE}/usermode/thunk.c
    100 
    101 thunk.o: ${USERMODE}/usermode/thunk.c
    102 	${CC} ${COPTS} ${CPPFLAGS.thunk.c} -c -o $@ ${USERMODE}/usermode/thunk.c
    103 
    104 cpu_${MACHINE_CPU}.o:	${USERMODE}/target/${MACHINE_CPU}/cpu_${MACHINE_CPU}.c
    105 
    106 ##
    107 ## (7) misc settings
    108 ##
    109 
    110 ##
    111 ## (8) config(8) generated machinery
    112 %INCLUDES
    113 
    114 %OBJS
    115 
    116 %CFILES
    117 
    118 %SFILES
    119 
    120 %LOAD
    121 
    122 %RULES
    123 
    124 ##
    125 ## (9) port independent kernel machinery
    126 ##
    127 .include "$S/conf/Makefile.kern.inc"
    128 
    129 ##
    130 ## (10) appending make options
    131 ##
    132 %MAKEOPTIONSAPPEND
    133