Home | History | Annotate | Line # | Download | only in conf
Makefile.powerpc revision 1.19
      1 #	$NetBSD: Makefile.powerpc,v 1.19 2001/10/26 06:45:39 jmc Exp $
      2 #
      3 # Makefile for NetBSD
      4 #
      5 # This makefile is constructed from a machine description:
      6 #	config machineid
      7 # Most changes should be made in the machine description
      8 #	/sys/arch/powerpc/conf/``machineid''
      9 # after which you should do
     10 #	config machineid
     11 # Machine generic makefile changes should be made in
     12 #	/sys/arch/powerpc/conf/Makefile.powerpc
     13 # after which config should be rerun for all machines of that type.
     14 #
     15 # N.B.: NO DEPENDENCIES ON FOLLOWING FLAGS ARE VISIBLE TO MAKEFILE
     16 #	IF YOU CHANGE THE DEFINITION OF ANY OF THESE RECOMPILE EVERYTHING
     17 #
     18 # -DTRACE	compile in kernel tracing hooks
     19 # -DQUOTA	compile in file system quotas
     20 
     21 MACHINE_ARCH=powerpc
     22 USETOOLS?=	no
     23 
     24 .include <bsd.own.mk>
     25 
     26 # DEBUG is set to -g if debugging.
     27 # PROF is set to -pg if profiling.
     28 
     29 AR?=		ar
     30 AS?=		as
     31 CC?=		cc
     32 CPP?=		cpp
     33 LD?=		ld
     34 LORDER?=	lorder
     35 MKDEP?=		mkdep
     36 NM?=		nm
     37 OBJCOPY?=	objcopy
     38 OBJDUMP?=	objdump
     39 RANLIB?=	ranlib
     40 SIZE?=		size
     41 STRIP?=		strip
     42 TSORT?=		tsort -q
     43 
     44 COPTS?=		-O2
     45 TEXTADDR?=	0x100000
     46 
     47 # source tree is located via $S relative to the compilation directory
     48 .ifndef S
     49 S!=		cd ../../../..; pwd
     50 .endif
     51 THISPPC=	$S/arch/${MACHINE}
     52 POWERPC=	$S/arch/powerpc
     53 
     54 INCLUDES=	-I. -I$S/arch -I$S -nostdinc
     55 CPPFLAGS=	${INCLUDES} ${IDENT} ${PARAM} \
     56 		-D_KERNEL -D_KERNEL_OPT -D${MACHINE}
     57 CWARNFLAGS?=	-Werror -Wall -Wreturn-type -Wpointer-arith -Wno-main \
     58 		-Wmissing-prototypes -Wstrict-prototypes
     59 # XXX Delete -Wuninitialized for now, since the compiler doesn't
     60 # XXX always get it right.  --thorpej
     61 CWARNFLAGS+=	-Wno-uninitialized
     62 CFLAGS=		${DEBUG} ${COPTS} ${CWARNFLAGS} -msoft-float ${CCPUOPTS}
     63 AFLAGS=		-D_LOCORE ${AOPTS}
     64 LINKFLAGS=	-N -Ttext ${TEXTADDR} -e __start
     65 STRIPFLAGS=	--strip-debug
     66 
     67 .if exists(${THISPPC}/conf/Makefile.${MACHINE}.inc)
     68 .include "${THISPPC}/conf/Makefile.${MACHINE}.inc"
     69 .endif
     70 
     71 %INCLUDES
     72 
     73 ### find out what to use for libkern
     74 .include "$S/lib/libkern/Makefile.inc"
     75 .ifndef PROF
     76 LIBKERN=	${KERNLIB}
     77 .else
     78 LIBKERN=	${KERNLIB_PROF}
     79 .endif
     80 
     81 ### find out what to use for libcompat
     82 .include "$S/compat/common/Makefile.inc"
     83 .ifndef PROF
     84 LIBCOMPAT=	${COMPATLIB}
     85 .else
     86 LIBCOMPAT=	${COMPATLIB_PROF}
     87 .endif
     88 
     89 # compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or
     90 # HOSTED}, and SUFFIX is the file suffix, capitalized (e.g. C for a .c file).
     91 
     92 NORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
     93 NOPROF_C=	${CC} ${CFLAGS} ${CPPFLAGS} -c $<
     94 NORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} -c $<
     95 
     96 %OBJS
     97 
     98 %CFILES
     99 
    100 %SFILES
    101 
    102 # load lines for config "xxx" will be emitted as:
    103 # xxx: ${SYSTEM_DEP} swapxxx.o
    104 #	${SYSTEM_LD_HEAD}
    105 #	${SYSTEM_LD} swapxxx.o
    106 #	${SYSTEM_LD_TAIL}
    107 SYSTEM_OBJ=	locore.o \
    108 		param.o ioconf.o ${OBJS} ${LIBCOMPAT} ${LIBKERN}
    109 SYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
    110 SYSTEM_LD_HEAD=	rm -f $@
    111 SYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
    112 		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
    113 SYSTEM_LD_TAIL=	@${SIZE} $@; chmod 755 $@
    114 
    115 DEBUG?=
    116 .if ${DEBUG} == "-g"
    117 LINKFLAGS+=	-X
    118 SYSTEM_LD_TAIL+=; \
    119 		echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \
    120 		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
    121 		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
    122 .else
    123 LINKFLAGS+=	-S
    124 .endif
    125 .if defined(NEED_SREC)
    126 SYSTEM_LD_TAIL+=; \
    127 		${OBJCOPY} -v -O srec $@ $@.srec
    128 .endif
    129 
    130 %LOAD
    131 
    132 assym.h: $S/kern/genassym.sh ${THISPPC}/${MACHINE}/genassym.cf
    133 	sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
    134 	    < ${THISPPC}/${MACHINE}/genassym.cf > assym.h.tmp && \
    135 	mv -f assym.h.tmp assym.h
    136 
    137 param.c: $S/conf/param.c
    138 	rm -f param.c
    139 	cp $S/conf/param.c .
    140 
    141 param.o: param.c Makefile
    142 	${NORMAL_C}
    143 
    144 ioconf.o: ioconf.c
    145 	${NORMAL_C}
    146 
    147 newvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
    148 	sh $S/conf/newvers.sh
    149 	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
    150 
    151 __CLEANKERNEL: .USE
    152 	@echo "${.TARGET}ing the kernel objects"
    153 	rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \
    154 	    [Ee]rrs linterrs makelinks assym.h.tmp assym.h
    155 
    156 __CLEANDEPEND: .USE
    157 	rm -f .depend
    158 
    159 clean: __CLEANKERNEL
    160 
    161 cleandir distclean: __CLEANKERNEL __CLEANDEPEND
    162 
    163 lint:
    164 	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
    165 	    ${THISPPC}/${MACHINE}/Locore.c ${CFILES} \
    166 	    ioconf.c param.c | \
    167 	    grep -v 'static function .* unused'
    168 
    169 tags:
    170 	@echo "see $S/kern/Makefile for tags"
    171 
    172 links:
    173 	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
    174 	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
    175 	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
    176 	  sort -u | comm -23 - dontlink | \
    177 	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
    178 	sh makelinks && rm -f dontlink
    179 
    180 SRCS=	${THISPPC}/${MACHINE}/locore.S \
    181 	param.c ioconf.c ${CFILES} ${SFILES}
    182 depend: .depend
    183 .depend: ${SRCS} assym.h param.c
    184 	${MKDEP} ${AFLAGS} ${CPPFLAGS} ${THISPPC}/${MACHINE}/locore.S
    185 	${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES}
    186 .if ${SFILES} != ""
    187 	${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${SFILES}
    188 .endif
    189 	sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${CFLAGS} \
    190 	  ${CPPFLAGS} < ${THISPPC}/${MACHINE}/genassym.cf
    191 	@sed -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >> .depend
    192 	@rm -f assym.dep
    193 
    194 dependall: depend all
    195 
    196 # depend on root or device configuration
    197 autoconf.o conf.o: Makefile
    198 
    199 # depend on network or filesystem configuration
    200 uipc_proto.o vfs_conf.o: Makefile
    201 
    202 # depend on maxusers
    203 machdep.o: Makefile
    204 
    205 # depend on CPU configuration
    206 locore.o machdep.o: Makefile
    207 
    208 locore.o: ${THISPPC}/${MACHINE}/locore.S assym.h
    209 	${NORMAL_S}
    210 
    211 # The install target can be redefined by putting a
    212 # install-kernel-${MACHINE_NAME} target into /etc/mk.conf
    213 MACHINE_NAME!=  uname -n
    214 install: install-kernel-${MACHINE_NAME}
    215 .if !target(install-kernel-${MACHINE_NAME}})
    216 install-kernel-${MACHINE_NAME}:
    217 	rm -f /onetbsd
    218 	ln /netbsd /onetbsd
    219 	cp netbsd /nnetbsd
    220 	mv /nnetbsd /netbsd
    221 .endif
    222 
    223 %RULES
    224