1 # $NetBSD: Makefile.usermode,v 1.25 2011/12/20 21:01:39 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= -lc -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 42 .if !empty(OPT_SDL) 43 SDL_CFLAGS!= sdl-config --cflags 44 SDL_LIBS!= sdl-config --libs 45 USERMODE_LIBS+= -Wl,-Bdynamic ${SDL_LIBS} 46 .endif 47 48 CPPFLAGS.thunk.c+= ${USERMODE_CPPFLAGS} 49 CPPFLAGS.thunk_sdl.c+= ${SDL_CFLAGS} ${USERMODE_CPPFLAGS} 50 51 ## 52 ## (3) libkern and compat 53 ## 54 KERN_AS= library 55 COMPAT_AS= library 56 57 ## 58 ## (4) local objects, compile rules, and dependencies 59 ## 60 MD_OBJS= thunk.o 61 MD_CFILES= ${USERMODE}/usermode/thunk.c 62 MD_SFILES= 63 64 .if !empty(OPT_SDL) 65 MD_OBJS+= thunk_sdl.o 66 MD_CFILES+= ${USERMODE}/usermode/thunk_sdl.c 67 .endif 68 69 ## 70 ## (5) link settings 71 ## 72 TEXTADDR?= %TEXTADDR% 73 74 LINKFLAGS_NORMAL= -X 75 KERN_LDSCRIPT?= kern.ldscript 76 #LINKFORMAT= -T ${USERMODE}/conf/${KERN_LDSCRIPT} 77 78 SYSTEM_LD= @${_MKSHMSG} " link ${.CURDIR:T}/${.TARGET}"; \ 79 ${_MKSHECHO}\ 80 ${CC} -static ${COPTS} -Wl,-Map,$@.map -o $@ ${LINKFORMAT} -Ttext ${TEXTADDR} '$${SYSTEM_OBJ}' '$${EXTRA_OBJ}' vers.o ${USERMODE_LIBS}; \ 81 ${CC} -static ${COPTS} -Wl,-Map,$@.map -o $@ ${LINKFORMAT} -Ttext ${TEXTADDR} ${SYSTEM_OBJ} ${EXTRA_OBJ} vers.o ${USERMODE_LIBS} 82 NVFLAGS= -n 83 84 ## 85 ## (6) port specific target dependencies 86 ## 87 88 .if !make(obj) && !make(clean) && !make(cleandir) 89 .BEGIN: 90 @rm -f i386 && \ 91 ln -s $S/arch/i386/include i386 92 .endif 93 94 thunk.d: ${USERMODE}/usermode/thunk.c 95 ${MKDEP} -f ${.TARGET} -- ${MKDEP_CFLAGS} \ 96 ${CPPFLAGS.thunk.c} ${USERMODE}/usermode/thunk.c 97 98 thunk.o: ${USERMODE}/usermode/thunk.c 99 ${CC} ${CPPFLAGS.thunk.c} -c -o $@ ${USERMODE}/usermode/thunk.c 100 101 thunk_sdl.d: ${USERMODE}/usermode/thunk.c 102 ${MKDEP} -f ${.TARGET} -- ${MKDEP_CFLAGS} \ 103 ${CPPFLAGS.thunk_sdl.c} ${USERMODE}/usermode/thunk_sdl.c 104 105 thunk_sdl.o: ${USERMODE}/usermode/thunk_sdl.c 106 ${CC} ${CPPFLAGS.thunk_sdl.c} -c -o $@ ${USERMODE}/usermode/thunk_sdl.c 107 108 ## 109 ## (7) misc settings 110 ## 111 112 ## 113 ## (8) config(8) generated machinery 114 %INCLUDES 115 116 %OBJS 117 118 %CFILES 119 120 %SFILES 121 122 %LOAD 123 124 %RULES 125 126 ## 127 ## (9) port independent kernel machinery 128 ## 129 .include "$S/conf/Makefile.kern.inc" 130 131 ## 132 ## (10) appending make options 133 ## 134 %MAKEOPTIONSAPPEND 135