1 # $NetBSD: Makefile.usermode,v 1.20 2011/09/08 11:53:18 jmcneill Exp $ 2 3 OPT_CPU_HOST= %CPU_HOST% 4 .if !empty(OPT_CPU_HOST) 5 MACHINE_ARCH= ${OPT_CPU_HOST} 6 .else 7 MACHINE_ARCH= usermode 8 .endif 9 USETOOLS?= no 10 NEED_OWN_INSTALL_TARGET?= no 11 .include <bsd.own.mk> 12 13 ## 14 ## (1) port identification 15 ## 16 USERMODE= $S/arch/usermode 17 GENASSYM_CONF= ${USERMODE}/usermode/genassym.cf 18 19 ## 20 ## (2) compile settings 21 ## 22 USERMODE_HOSTOS!=uname -s 23 USERMODE_HOSTMACHINE!=uname -m 24 USERMODE_LIBS= -lrt 25 USERMODE_CPPFLAGS=${DEBUG} -U_KERNEL -I/usr/include 26 USERMODE_CPPFLAGS+=${CWARNFLAGS} ${NOGCCERROR:D:U-Werror} 27 28 .if ${USERMODE_HOSTOS} == "Linux" 29 USERMODE_LIBS+= -lpthread 30 CPPFLAGS+=-Dstrtoul=netbsd_strtoul 31 CPPFLAGS+=-Dstrtoll=netbsd_strtoll 32 CPPFLAGS+=-Dstrtoull=netbsd_strtoull 33 CPPFLAGS+=-D__NetBSD__ -Wno-unused-but-set-variable 34 .endif 35 36 DEFCOPTS= -fno-omit-frame-pointer 37 CPPFLAGS+= -Dusermode 38 CPPFLAGS.init_main.c+= -Dmain=kernmain 39 40 OPT_SDL= %SDL% 41 OPT_URKELVISOR= %URKELVISOR% 42 43 .if !empty(OPT_SDL) 44 SDL_CFLAGS!= sdl-config --cflags 45 SDL_LIBS!= sdl-config --libs 46 USERMODE_LIBS+= -Wl,-Bdynamic ${SDL_LIBS} 47 .endif 48 49 CPPFLAGS.thunk.c+= ${USERMODE_CPPFLAGS} 50 CPPFLAGS.thunk_sdl.c+= ${SDL_CFLAGS} ${USERMODE_CPPFLAGS} 51 CPPFLAGS.urkelvisor.c+= ${USERMODE_CPPFLAGS} 52 53 ## 54 ## (3) libkern and compat 55 ## 56 KERN_AS= library 57 COMPAT_AS= library 58 59 ## 60 ## (4) local objects, compile rules, and dependencies 61 ## 62 MD_OBJS= thunk.o 63 MD_CFILES= ${USERMODE}/usermode/thunk.c 64 MD_SFILES= 65 66 .if !empty(OPT_URKELVISOR) 67 MD_OBJS+= urkelvisor.o 68 MD_CFILES+= ${USERMODE}/usermode/urkelvisor.c 69 .endif 70 71 .if !empty(OPT_SDL) 72 MD_OBJS+= thunk_sdl.o 73 MD_CFILES+= ${USERMODE}/usermode/thunk_sdl.c 74 .endif 75 76 ## 77 ## (5) link settings 78 ## 79 SYSTEM_LD= @${_MKSHMSG} " link ${.CURDIR:T}/${.TARGET}"; \ 80 ${_MKSHECHO}\ 81 ${CC} -static ${COPTS} -Wl,-Map,$@.map -o $@ '$${SYSTEM_OBJ}' '$${EXTRA_OBJ}' vers.o ${USERMODE_LIBS}; \ 82 ${CC} -static ${COPTS} -Wl,-Map,$@.map -o $@ ${SYSTEM_OBJ} ${EXTRA_OBJ} vers.o ${USERMODE_LIBS} 83 NVFLAGS= -n 84 85 ## 86 ## (6) port specific target dependencies 87 ## 88 89 .if !make(obj) && !make(clean) && !make(cleandir) 90 .BEGIN: 91 @rm -f i386 && \ 92 ln -s $S/arch/i386/include i386 93 .endif 94 95 thunk.d: ${USERMODE}/usermode/thunk.c 96 ${MKDEP} -f ${.TARGET} -- ${MKDEP_CFLAGS} \ 97 ${CPPFLAGS.thunk.c} ${USERMODE}/usermode/thunk.c 98 99 thunk.o: ${USERMODE}/usermode/thunk.c 100 ${CC} ${CPPFLAGS.thunk.c} -c -o $@ ${USERMODE}/usermode/thunk.c 101 102 thunk_sdl.d: ${USERMODE}/usermode/thunk.c 103 ${MKDEP} -f ${.TARGET} -- ${MKDEP_CFLAGS} \ 104 ${CPPFLAGS.thunk_sdl.c} ${USERMODE}/usermode/thunk_sdl.c 105 106 thunk_sdl.o: ${USERMODE}/usermode/thunk_sdl.c 107 ${CC} ${CPPFLAGS.thunk_sdl.c} -c -o $@ ${USERMODE}/usermode/thunk_sdl.c 108 109 urkelvisor.d: ${USERMODE}/usermode/urkelvisor.c 110 ${MKDEP} -f ${.TARGET} -- ${MKDEP_CFLAGS} \ 111 ${CPPFLAGS.urkelvisor.c} ${USERMODE}/usermode/urkelvisor.c 112 113 urkelvisor.o: ${USERMODE}/usermode/urkelvisor.c 114 ${CC} ${CPPFLAGS.urkelvisor.c} -c -o $@ ${USERMODE}/usermode/urkelvisor.c 115 116 ## 117 ## (7) misc settings 118 ## 119 120 ## 121 ## (8) config(8) generated machinery 122 %INCLUDES 123 124 %OBJS 125 126 %CFILES 127 128 %SFILES 129 130 %LOAD 131 132 %RULES 133 134 ## 135 ## (9) port independent kernel machinery 136 ## 137 .include "$S/conf/Makefile.kern.inc" 138 139 ## 140 ## (10) appending make options 141 ## 142 %MAKEOPTIONSAPPEND 143