Makefile.zaurus 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. # $OpenBSD: Makefile.zaurus,v 1.54 2015/01/13 01:12:50 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 -D__${_mach}__ -MD -MP
  20. CWARNFLAGS= -Werror -Wall -Wimplicit-function-declaration \
  21. -Wno-main -Wno-uninitialized \
  22. -Wframe-larger-than=2047
  23. CMACHFLAGS= -ffreestanding -msoft-float # -march=armv4 -mtune=strongarm
  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= -T ldscript --warn-common -nopie
  34. .if ${IDENT:M-DDDB_STRUCT}
  35. DB_STRUCTINFO= db_structinfo.h
  36. .else
  37. DB_STRUCTINFO=
  38. .endif
  39. HOSTCC?= ${CC}
  40. HOSTED_CPPFLAGS=${CPPFLAGS:S/^-nostdinc$//}
  41. HOSTED_CFLAGS= ${CFLAGS}
  42. HOSTED_C= ${HOSTCC} ${HOSTED_CFLAGS} ${HOSTED_CPPFLAGS} -c $<
  43. NORMAL_C_NOP= ${CC} ${CFLAGS} ${CPPFLAGS} -c $<
  44. NORMAL_C= ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
  45. NORMAL_S= ${CC} ${AFLAGS} ${CPPFLAGS} -c $<
  46. %OBJS
  47. %CFILES
  48. %SFILES
  49. # load lines for config "xxx" will be emitted as:
  50. # xxx: ${SYSTEM_DEP} swapxxx.o
  51. # ${SYSTEM_LD_HEAD}
  52. # ${SYSTEM_LD} swapxxx.o
  53. # ${SYSTEM_LD_TAIL}
  54. SYSTEM_HEAD= ${_mach}_start.o locore.o param.o ioconf.o
  55. SYSTEM_OBJ= ${SYSTEM_HEAD} ${OBJS}
  56. SYSTEM_DEP= Makefile ${SYSTEM_OBJ}
  57. SYSTEM_LD_HEAD= @rm -f $@
  58. SYSTEM_LD_HEAD+=; \
  59. cat ${_archdir}/conf/ldscript.head ${_archdir}/conf/ldscript.tail | \
  60. sed -e 's/@KERNEL_BASE_PHYS@/${KERNEL_BASE_PHYS}/' \
  61. -e 's/@KERNEL_BASE_VIRT@/${KERNEL_BASE_VIRT}/' > ldscript
  62. SYSTEM_LD= @echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_HEAD} vers.o $${OBJS}'; \
  63. ${LD} ${LINKFLAGS} -o $@ ${SYSTEM_HEAD} vers.o ${OBJS}
  64. SYSTEM_LD_TAIL= @${SIZE} $@; chmod 755 $@
  65. DEBUG?=
  66. .if ${DEBUG} == "-g"
  67. LINKFLAGS+= -X
  68. STRIPFLAGS= -g -x
  69. SYSTEM_LD_TAIL+=; \
  70. echo mv $@ $@.gdb; rm -f $@.gdb; mv $@ $@.gdb; \
  71. echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
  72. ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
  73. .else
  74. LINKFLAGS+= -x
  75. .endif
  76. %LOAD
  77. # cc's -MD puts the source and output paths in the dependency file;
  78. # since those are temp files here we need to fix it up. It also
  79. # puts the file in /tmp, so we use -MF to put it in the current
  80. # directory as assym.P and then generate assym.d from it with a
  81. # good target name
  82. assym.h: $S/kern/genassym.sh Makefile \
  83. ${_archdir}/${_arch}/genassym.cf ${_machdir}/${_mach}/genassym.cf
  84. cat ${_archdir}/${_arch}/genassym.cf ${_machdir}/${_mach}/genassym.cf | \
  85. sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} -MF assym.P > assym.h.tmp
  86. sed '1s/.*/assym.h: \\/' assym.P > assym.d
  87. sort -u assym.h.tmp > assym.h
  88. param.c: $S/conf/param.c
  89. rm -f param.c
  90. cp $S/conf/param.c .
  91. param.o: param.c Makefile
  92. ${NORMAL_C}
  93. mcount.o: $S/lib/libkern/mcount.c Makefile
  94. ${NORMAL_C_NOP}
  95. ioconf.o: ioconf.c
  96. ${NORMAL_C}
  97. vers.o: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
  98. sh $S/conf/newvers.sh
  99. ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
  100. clean::
  101. rm -f eddep *bsd *bsd.gdb tags *.[dio] [a-z]*.s \
  102. [Ee]rrs linterrs assym.h ${DB_STRUCTINFO}
  103. lint:
  104. @lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
  105. ${CFILES} ioconf.c param.c | \
  106. grep -v 'static function .* unused'
  107. depend:
  108. @touch $@
  109. tags:
  110. @echo "see $S/kern/Makefile for tags"
  111. db_structinfo.h: $S/ddb/db_structinfo.c $S/ddb/parse_structinfo.pl
  112. ${CC} ${CFLAGS} ${CPPFLAGS} -MT $@ -gstabs -c $S/ddb/db_structinfo.c
  113. objdump -g db_structinfo.o | perl $S/ddb/parse_structinfo.pl > $@
  114. rm -f db_structinfo.o
  115. ${_mach}_start.o: ${_machdir}/${_mach}/${_mach}_start.S
  116. locore.o: ${_archdir}/${_arch}/locore.S assym.h
  117. in_cksum_arm.o fiq_subr.o bcopyinout.o copystr.o sigcode.o: assym.h
  118. vectors.o cpuswitch.o exception.o bcopy_page.o irq_dispatch.o: assym.h
  119. zaurus_start.o: assym.h
  120. # The install target can be redefined by putting a
  121. # install-kernel-${MACHINE_NAME} target into /etc/mk.conf
  122. MACHINE_NAME!= uname -n
  123. install: install-kernel-${MACHINE_NAME}
  124. .if !target(install-kernel-${MACHINE_NAME}})
  125. install-kernel-${MACHINE_NAME}:
  126. cmp -s bsd /bsd || ln -f /bsd /obsd
  127. cp bsd /nbsd
  128. mv /nbsd /bsd
  129. .endif
  130. # pull in the dependency information
  131. .if !empty(DB_STRUCTINFO) && !exists(${DB_STRUCTINFO})
  132. ${SYSTEM_OBJ}: ${DB_STRUCTINFO}
  133. .endif
  134. .ifnmake clean
  135. . for o in ${SYSTEM_OBJ} assym.h ${DB_STRUCTINFO}
  136. . if exists(${o:R}.d)
  137. . include "${o:R}.d"
  138. . elif exists($o)
  139. .PHONY: $o
  140. . endif
  141. . endfor
  142. .endif
  143. %RULES