Makefile.i386 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. # $OpenBSD: Makefile.i386,v 1.92 2015/01/13 01:12:49 deraadt Exp $
  2. # For instructions on building kernels consult the config(8) and options(4)
  3. # manual pages.
  4. #
  5. # N.B.: NO DEPENDENCIES ON FOLLOWING FLAGS ARE VISIBLE TO MAKEFILE
  6. # IF YOU CHANGE THE DEFINITION OF ANY OF THESE RECOMPILE EVERYTHING
  7. # DEBUG is set to -g by config if debugging is requested (config -g).
  8. # PROF is set to -pg by config if profiling is requested (config -p).
  9. .include <bsd.own.mk>
  10. SIZE?= size
  11. STRIP?= strip
  12. # source tree is located via $S relative to the compilation directory
  13. .ifndef S
  14. S!= cd ../../../..; pwd
  15. .endif
  16. _machdir?= $S/arch/${_mach}
  17. _archdir?= $S/arch/${_arch}
  18. INCLUDES= -nostdinc -I$S -I. -I$S/arch
  19. CPPFLAGS= ${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -MD -MP
  20. CWARNFLAGS= -Werror -Wall -Wimplicit-function-declaration \
  21. -Wno-main -Wno-uninitialized \
  22. -Wframe-larger-than=2047
  23. CMACHFLAGS=
  24. CMACHFLAGS+= -fno-builtin-printf -fno-builtin-snprintf \
  25. -fno-builtin-vsnprintf -fno-builtin-log \
  26. -fno-builtin-log2 -fno-builtin-malloc ${NOPIE_FLAGS}
  27. .if ${IDENT:M-DNO_PROPOLICE}
  28. CMACHFLAGS+= -fno-stack-protector
  29. .endif
  30. COPTS?= -O2
  31. CFLAGS= ${DEBUG} ${CWARNFLAGS} ${CMACHFLAGS} ${COPTS} ${PIPE}
  32. AFLAGS= -D_LOCORE -x assembler-with-cpp ${CWARNFLAGS} ${CMACHFLAGS}
  33. LINKFLAGS= -Ttext 0xD0200120 -e start -N --warn-common -nopie
  34. .if ${MACHINE} == "amd64"
  35. CFLAGS+= -m32
  36. AFLAGS+= -m32
  37. LINKFLAGS+= -melf_i386_obsd
  38. .endif
  39. .if ${IDENT:M-DDDB_STRUCT}
  40. DB_STRUCTINFO= db_structinfo.h
  41. .else
  42. DB_STRUCTINFO=
  43. .endif
  44. HOSTCC?= ${CC}
  45. HOSTED_CPPFLAGS=${CPPFLAGS:S/^-nostdinc$//}
  46. HOSTED_CFLAGS= ${CFLAGS}
  47. HOSTED_C= ${HOSTCC} ${HOSTED_CFLAGS} ${HOSTED_CPPFLAGS} -c $<
  48. NORMAL_C_NOP= ${CC} ${CFLAGS} ${CPPFLAGS} -c $<
  49. NORMAL_C= ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
  50. NORMAL_S= ${CC} ${AFLAGS} ${CPPFLAGS} -c $<
  51. %OBJS
  52. %CFILES
  53. %SFILES
  54. # load lines for config "xxx" will be emitted as:
  55. # xxx: ${SYSTEM_DEP} swapxxx.o
  56. # ${SYSTEM_LD_HEAD}
  57. # ${SYSTEM_LD} swapxxx.o
  58. # ${SYSTEM_LD_TAIL}
  59. SYSTEM_HEAD= locore.o param.o ioconf.o
  60. SYSTEM_OBJ= ${SYSTEM_HEAD} ${OBJS}
  61. SYSTEM_DEP= Makefile ${SYSTEM_OBJ}
  62. SYSTEM_LD_HEAD= @rm -f $@
  63. SYSTEM_LD= @echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_HEAD} vers.o $${OBJS}'; \
  64. ${LD} ${LINKFLAGS} -o $@ ${SYSTEM_HEAD} vers.o ${OBJS}
  65. SYSTEM_LD_TAIL= @${SIZE} $@; chmod 755 $@
  66. DEBUG?=
  67. .if ${DEBUG} == "-g"
  68. LINKFLAGS+= -X
  69. STRIPFLAGS= -g -x
  70. SYSTEM_LD_TAIL+=; \
  71. echo mv $@ $@.gdb; rm -f $@.gdb; mv $@ $@.gdb; \
  72. echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
  73. ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
  74. .else
  75. LINKFLAGS+= -S -x
  76. .endif
  77. %LOAD
  78. # cc's -MD puts the source and output paths in the dependency file;
  79. # since those are temp files here we need to fix it up. It also
  80. # puts the file in /tmp, so we use -MF to put it in the current
  81. # directory as assym.P and then generate assym.d from it with a
  82. # good target name
  83. assym.h: $S/kern/genassym.sh Makefile \
  84. ${_archdir}/${_arch}/genassym.cf ${_machdir}/${_mach}/genassym.cf
  85. cat ${_archdir}/${_arch}/genassym.cf ${_machdir}/${_mach}/genassym.cf | \
  86. sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} -MF assym.P > assym.h.tmp
  87. sed '1s/.*/assym.h: \\/' assym.P > assym.d
  88. sort -u assym.h.tmp > assym.h
  89. param.c: $S/conf/param.c
  90. rm -f param.c
  91. cp $S/conf/param.c .
  92. param.o: param.c Makefile
  93. ${NORMAL_C}
  94. mcount.o: $S/lib/libkern/mcount.c Makefile
  95. ${NORMAL_C_NOP}
  96. ioconf.o: ioconf.c
  97. ${NORMAL_C}
  98. vers.o: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
  99. sh $S/conf/newvers.sh
  100. ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
  101. clean::
  102. rm -f eddep *bsd *bsd.gdb tags *.[dio] [a-z]*.s \
  103. [Ee]rrs linterrs assym.h ${DB_STRUCTINFO}
  104. lint:
  105. @lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
  106. ${CFILES} ioconf.c param.c | \
  107. grep -v 'static function .* unused'
  108. depend:
  109. @touch $@
  110. tags:
  111. @echo "see $S/kern/Makefile for tags"
  112. db_structinfo.h: $S/ddb/db_structinfo.c $S/ddb/parse_structinfo.pl
  113. ${CC} ${CFLAGS} ${CPPFLAGS} -MT $@ -gstabs -c $S/ddb/db_structinfo.c
  114. objdump -g db_structinfo.o | perl $S/ddb/parse_structinfo.pl > $@
  115. rm -f db_structinfo.o
  116. locore.o: ${_machdir}/${_mach}/locore.s assym.h
  117. in_cksum.o mptramp.o kvm86call.o acpi_wakecode.o: assym.h
  118. # The install target can be redefined by putting a
  119. # install-kernel-${MACHINE_NAME} target into /etc/mk.conf
  120. MACHINE_NAME!= uname -n
  121. install: install-kernel-${MACHINE_NAME}
  122. .if !target(install-kernel-${MACHINE_NAME}})
  123. install-kernel-${MACHINE_NAME}:
  124. cmp -s bsd /bsd || ln -f /bsd /obsd
  125. cp bsd /nbsd
  126. mv /nbsd /bsd
  127. .endif
  128. # pull in the dependency information
  129. .if !empty(DB_STRUCTINFO) && !exists(${DB_STRUCTINFO})
  130. ${SYSTEM_OBJ}: ${DB_STRUCTINFO}
  131. .endif
  132. .ifnmake clean
  133. . for o in ${SYSTEM_OBJ} assym.h ${DB_STRUCTINFO}
  134. . if exists(${o:R}.d)
  135. . include "${o:R}.d"
  136. . elif exists($o)
  137. .PHONY: $o
  138. . endif
  139. . endfor
  140. .endif
  141. %RULES