1# $MirOS: src/sys/conf/Makefile.inc,v 1.42 2014/02/09 22:49:30 tg Exp $ 2#- 3# Copyright (c) 2005, 2006, 2007, 2008 4# Thorsten "mirabilos" Glaser <tg@mirbsd.de> 5# 6# Provided that these terms and disclaimer and all copyright notices 7# are retained or reproduced in an accompanying document, permission 8# is granted to deal in this work without restriction, including un- 9# limited rights to use, publicly perform, distribute, sell, modify, 10# merge, give away, or sublicence. 11# 12# This work is provided "AS IS" and WITHOUT WARRANTY of any kind, to 13# the utmost extent permitted by applicable law, neither express nor 14# implied; without malicious intent or gross negligence. In no event 15# may a licensor, author or contributor be held liable for indirect, 16# direct, other damage, loss, or other issues arising in any way out 17# of dealing in the work, even if advised of the possibility of such 18# damage or existence of a defect, except proven that it results out 19# of said person's immediate fault when using the work as intended. 20#- 21# This file includes most kernel compile rules commonly used, by all 22# architectures' kernel Makefiles. 23 24MKDEP?= mkdep 25SIZE?= size 26STRIP?= strip 27 28KERNBASE?= $S/../kern 29 30depend:: beforedepend .WAIT 31 32INCLUDES= -nostdinc -I. -I$S/arch -I$S -I${KERNBASE}/include 33CDIAGFLAGS= -Werror -Wall -Wstrict-prototypes -Wmissing-prototypes \ 34 -Wno-uninitialized -Wno-main -ffreestanding 35.if ${IDENT:M-DNO_PROPOLICE} 36CDIAGFLAGS+= -fno-stack-protector 37.endif 38COPTS?= -Os 39.if ${COPTS:M-O*:N-Os} 40COPTS+= -Os 41.endif 42.if !${COPTS:M-Os} 43COPTS+= -Os 44.endif 45CFLAGS= ${DEBUG} ${CDIAGFLAGS} ${CMACHFLAGS} \ 46 ${COPTS:C/-g[0-9]//:S/-g//} ${PIPE} ${CSYS} 47AFLAGS= -x assembler-with-cpp -traditional-cpp -D_LOCORE 48STRIPFLAGS= -g -X -x -R .comment 49 50.include "${KERNBASE}/z/Makefile.inc" 51 52# load lines for config "xxx" will be emitted as: 53# xxx: ${SYSTEM_DEP} swapxxx.o 54# ${SYSTEM_LD_HEAD} 55# ${SYSTEM_LD} swapxxx.o 56# ${SYSTEM_LD_TAIL} 57SYSTEM_OBJ?= locore.o init_ssp.o config_gz.o mirtime_getleaps.o \ 58 param.o ioconf.o ${OBJS} ${LIBKERN} ${LIBCOMPAT} 59SYSTEM_DEP?= Makefile ${SYSTEM_OBJ} 60SYSTEM_LD_HEAD?=rm -f $@ 61SYSTEM_LD?= @echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \ 62 ${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o 63SYSTEM_LD_TAIL?=@${SIZE} $@; chmod 755 $@ 64DEBUG?= 65SYSTEM_LD_TAIL+=; \ 66 echo cp $@ $@.unstripped; \ 67 rm -f $@.unstripped; cp $@ $@.unstripped; \ 68 echo Running kvm_mkdb...; kvm_mkdb -o . ./$@ 69.if ${DEBUG} == "-g" 70LINKFLAGS+= -X 71SYSTEM_LD_TAIL+=; \ 72 echo ${STRIP} ${STRIPFLAGS} $@; ${STRIP} ${STRIPFLAGS} $@ 73.else 74LINKFLAGS+= -x 75SYSTEM_LD_TAIL+=; \ 76 objcopy -R .comment $@ 77.endif 78.ifndef NO_GZIP 79SYSTEM_LD_GZIP= echo gzip -n9 $@; rm -f $@.gz; gzip -n9 $@; mv $@.gz $@ 80.else 81SYSTEM_LD_GZIP= : 82.endif 83 84#.if ${MKC_USAP:L} == "yes" 85CPPFLAGS+= -DMSDOSFS_NO_LFN 86#.endif 87 88HOSTCC= ${CC} 89HOSTCPPFLAGS= ${CPPFLAGS:N-nostdinc:N-D_KERNEL} 90HOSTCFLAGS?= ${CFLAGS} 91 92### find out what to use for libkern 93.include "$S/lib/libkern/Makefile.inc" 94LIBKERN= ${KERNLIB} 95 96### find out what to use for libcompat 97.include "$S/compat/common/Makefile.inc" 98LIBCOMPAT= ${COMPATLIB} 99 100# compile rules: rules are named ${TYPE}_${SUFFIX}${CONFIG_DEP} 101# where TYPE is NORMAL or DRIVER; SUFFIX is the file suffix, 102# capitalized (e.g. C for a .c file), and CONFIG_DEP is _C if the file 103# is marked as config-dependent. 104 105NORMAL_C= ${CC} ${CFLAGS} ${CPPFLAGS} -c $< 106NORMAL_C_C= ${CC} ${CFLAGS} ${CPPFLAGS} ${PARAM} -c $< 107 108DRIVER_C= ${CC} ${CFLAGS} ${CPPFLAGS} -c $< 109DRIVER_C_C= ${CC} ${CFLAGS} ${CPPFLAGS} ${PARAM} -c $< 110 111NORMAL_S= ${CC} -D_ASM_SOURCE ${AFLAGS} ${CPPFLAGS} -c $< 112NORMAL_S_C= ${CC} -D_ASM_SOURCE ${AFLAGS} ${CPPFLAGS} ${PARAM} -c $< 113 114HOSTED_C= ${HOSTCC} ${HOSTCFLAGS} ${HOSTCPPFLAGS} -c $< 115 116.MAIN: all 117 118# these are 'make depend'ed 119_COMMON_SRCS= param.c ioconf.c 120SRCS?= ${_MDINC}/locore.s ${_COMMON_SRCS} ${CFILES} ${SFILES} 121 122# Propolice init 123init_ssp.o: $S/kern/init_ssp.c 124 ${NORMAL_C} -fno-stack-protector 125 126assym.h: $S/kern/genassym.sh ${_MDINC}/genassym.cf Makefile 127 ${SHELL} $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} \ 128 ${PARAM} <${_MDINC}/genassym.cf >assym.h.tmp && \ 129 mv -f assym.h.tmp assym.h 130 131ioconf.o: ioconf.c 132 ${NORMAL_C} 133 134locore.o: ${_MDINC}/locore.s assym.h 135 ${NORMAL_S} 136 137param.c: $S/conf/param.c 138 rm -f param.c 139 cp $S/conf/param.c . 140 141param.o: param.c Makefile 142 ${NORMAL_C_C} 143 144# depend on root or device configuration 145autoconf.o conf.o: Makefile 146 147# depend on maxusers 148machdep.o: Makefile 149 150config_gz.o: $S/conf/config_gz.S config.gz 151 ${NORMAL_S} 152 153mirtime_getleaps.c: $S/conf/make_leaps.c 154 ${HOSTCC} ${HOSTCFLAGS} ${HOSTCPPFLAGS} -o make_leaps $> 155 ./make_leaps >$@ || (rm -f $@; false) 156 157config.gz: config.txt 158 -@rm -f $@ 159 gzip -n9 <$> >$@ 160 161clean:: 162 rm -f eddep *bsd *.unstripped tags *.[io] [a-z]*.s config.gz \ 163 [Ee]rrs linterrs makelinks genassym genassym.o assym.h \ 164 make_leaps mirtime_getleaps.c ${ZLIB_CLEANFLS} 165 166depend:: .depend 167beforedepend: 168 rm -f syskern 169 ln -s ${KERNBASE:Q}/include syskern 170.depend: ${SRCS} assym.h param.c ${APMINC} ${ZLIB_GENHDRS} mirtime_getleaps.c 171 CC=${CC:Q} ${MKDEP} -D_ASM_SOURCE ${AFLAGS} ${CPPFLAGS} \ 172 ${_MDINC}/locore.s 173 CC=${CC:Q} ${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES} 174.if defined(SFILES) && !empty(SFILES) 175 CC=${CC:Q} ${MKDEP} -a -D_ASM_SOURCE ${AFLAGS} ${CPPFLAGS} ${SFILES} 176.endif 177 CC=${CC:Q} ${SHELL} $S/kern/genassym.sh ${MKDEP} -f assym.dep \ 178 ${CFLAGS} ${CPPFLAGS} <${_MDINC}/genassym.cf 179 @sed -e 's/.*\.o:.* /assym.h: /' <assym.dep >>.depend 180 @rm -f assym.dep 181 182INSTALL_KERNEL= bsd 183install-unstripped: 184 @cd ${.CURDIR} && exec ${MAKE} install INSTALL_KERNEL=bsd.unstripped 185install: 186 @if [[ -e /bsd ]]; then \ 187 echo Move /bsd out of the way!; \ 188 exit 1; \ 189 elif [[ ! -e /bsd.old ]]; then \ 190 echo Back up your old kernel to /bsd.old!; \ 191 exit 1; \ 192 else \ 193 set -x; \ 194 install -c -o root -g daemon -m 400 ${INSTALL_KERNEL} /bsd; \ 195 install -c -o root -g wheel -m 644 \ 196 kvm_bsd.db /var/db/kvm_bsd.new; \ 197 fi 198 199links: 200 egrep '#if' ${CFILES} | sed -f $S/conf/defines | \ 201 sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u >dontlink 202 echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \ 203 sort -u | comm -23 - dontlink | \ 204 sed 's,.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' >makelinks 205 ${SHELL} makelinks && rm -f dontlink makelinks 206 207lint: 208 @lint -hbxncez -DGENERIC -Dvolatile= ${CPPFLAGS} ${PARAM} -UKGDB \ 209 ${CFILES} ioconf.c param.c | \ 210 grep -v 'static function .* unused' 211 212newvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP} 213 ${SHELL} $S/conf/newvers.sh "${OSrev}" "${OSrpl}" "${OScompat}" 214 ${CC} ${CFLAGS} ${CPPFLAGS} -c vers.c 215 216tags: 217 @echo "see $S/kern/Makefile for tags" 218