Index: Makefile.macppc
===================================================================
RCS file: /export/20060122/Repository/src/sys/arch/macppc/conf/Makefile.macppc,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -r1.1.1.1 -r1.2
--- Makefile.macppc	29 Jan 2006 21:59:34 -0000	1.1.1.1
+++ Makefile.macppc	29 Jan 2006 22:40:23 -0000	1.2
@@ -1,107 +1,90 @@
-#	$NetBSD: Makefile.macppc,v 1.24 2005/11/24 12:54:29 dbj Exp $
+#	$Id: Makefile.macppc,v 1.25 2005/12/29 11:08:07 tsubai Exp $
 #
 # Makefile for NetBSD
 #
 # This makefile is constructed from a machine description:
 #	config machineid
 # Most changes should be made in the machine description
-#	/sys/arch/powerpc/conf/``machineid''
+#	/sys/arch/macppc/conf/``machineid''
 # after which you should do
 #	config machineid
 # Machine generic makefile changes should be made in
-#	/sys/arch/powerpc/conf/Makefile.powerpc
+#	/sys/arch/macppc/conf/Makefile.macppc
 # after which config should be rerun for all machines of that type.
-#
-# To specify debugging, add the config line: makeoptions DEBUG="-g"
-# A better way is to specify -g only for a few files.
-#
-#	makeoptions DEBUGLIST="uvm* trap if_*"
-
-MACHINE_ARCH=powerpc
-USETOOLS?=	no
-NEED_OWN_INSTALL_TARGET?=no
-.include <bsd.own.mk>
-
-##
-## (1) port identification
-##
-THISPPC=	$S/arch/${MACHINE}
-POWERPC=	$S/arch/powerpc
-.if exists(${THISPPC}/${MACHINE}/genassym.cf)
-GENASSYM_CONF=	${THISPPC}/${MACHINE}/genassym.cf
-.else
-GENASSYM_CONF=	${POWERPC}/${PPCDIR}/genassym.cf
-.endif
-.-include "${THISPPC}/conf/Makefile.${MACHINE}.inc"
 
-##
-## (2) compile settings
-##
-CPPFLAGS+=	-D${MACHINE}=${MACHINE}
-CWARNFLAGS+=	-Wreturn-type
-.if ${PPCDIR} == "oea"
-CFLAGS+=	-mno-strict-align
-.endif
-CFLAGS+=	-msoft-float ${CCPUOPTS} -Wa,-maltivec
-AFLAGS+=	${AOPTS}
+.SUFFIXES:	.S .c .o
 
-##
-## (3) libkern and compat
-##
-.if !empty(IDENT:M-DLKM)
-KERN_AS=	obj
-.endif
+# DEBUG is set to -g if debugging.
+# PROF is set to -pg if profiling.
 
-##
-## (4) local objects, compile rules, and dependencies
-##
-.if !defined(SYSTEM_FIRST_OBJ)
-SYSTEM_FIRST_OBJ= locore.o
-.endif
-.if !defined(SYSTEM_FIRST_SFILE)
-SYSTEM_FIRST_SFILE= ${THISPPC}/${MACHINE}/locore.S
-.endif
-MD_OBJS=	${SYSTEM_FIRST_OBJ}
-MD_CFILES=
-MD_SFILES=	${SYSTEM_FIRST_SFILE}
+AR?=	ar
+AS?=	as
+CC?=	cc
+CPP?=	cpp
+LD?=	ld
+LORDER?=lorder
+MKDEP?=	mkdep
+NM?=	nm
+RANLIB?=ranlib
+SIZE?=	size
+STRIP?=	strip
+TSORT?=	tsort -q
+
+COPTS?= -O2 -pipe
+
+# source tree is located via $S relative to the compilation directory
+.ifndef	S
+S!=	cd ../../../..; pwd
+.endif
+PPC=	$S/arch/macppc
+
+TEXTADDR?=	100000
+INCLUDES=	-I. -I$S/arch -I$S -nostdinc
+CPPFLAGS=	${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -D_KERNEL_OPT -Dmacppc
+CWARNFLAGS?=	-Werror -Wall -Wpointer-arith -Wstrict-prototypes \
+		-Wmissing-prototypes \
+		-Wno-main -Wno-format-zero-length -Wno-nonnull
+# XXX Delete -Wuninitialized for now, since the compiler doesn't
+# XXX always get it right.  --thorpej
+CWARNFLAGS+=	-Wno-uninitialized
+CFLAGS=		${CPUFLAGS} ${DEBUG} ${COPTS} ${CWARNFLAGS} \
+		-msoft-float -fno-zero-initialized-in-bss -ffreestanding
+#CFLAGS+=	-fno-unit-at-a-time	# for gcc-3.4
+AFLAGS=		${CPUFLAGS} -D_LOCORE ${AOPTS}
+LINKFLAGS=	-N -Ttext ${TEXTADDR} -e __start
+STRIPFLAGS=	--strip-debug
 
-${SYSTEM_FIRST_OBJ}: ${SYSTEM_FIRST_SFILE} assym.h
-	${NORMAL_S}
+%INCLUDES
 
-##
-## (5) link settings
-##
-TEXTADDR?=	0x100000
-LINKFORMAT=	-N
-ENTRYPOINT=	__start
-
-.if defined(NEED_SREC)
-SYSTEM_LD_TAIL_EXTRA+=; \
-		${OBJCOPY} -v -O srec $@ $@.srec
+### find out what to use for libkern
+.include "$S/arch/powerpc/lib/libkern/Makefile.inc"
+.ifndef PROF
+LIBKERN=	${KERNLIB}
+.else
+LIBKERN=	${KERNLIB_PROF}
 .endif
 
-.if defined(NEED_BINARY)
-SYSTEM_LD_TAIL_EXTRA+=; \
-		${OBJCOPY} -v -O binary $@ $@.bin
+### find out what to use for libcompat
+.include "$S/compat/common/Makefile.inc"
+.ifndef PROF
+LIBCOMPAT=	${COMPATLIB}
+.else
+LIBCOMPAT=	${COMPATLIB_PROF}
 .endif
 
-##
-## (6) port specific target dependencies
-##
+# compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or
+# HOSTED}, and SUFFIX is the file suffix, capitalized (e.g. C for a .c file).
 
-# depend on CPU configuration
-locore.o machdep.o: Makefile
+NORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
+NOPROF_C=	${CC} ${CFLAGS} ${CPPFLAGS} -c $<
 
-setfault.o: assym.h
+NORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} -c -traditional-cpp $<
 
-##
-## (7) misc settings
-##
-
-##
-## (8) config(8) generated machinery
-##
-%INCLUDES
+#.c.o:
+#	${NORMAL_C}
+#
+#.S.o:
+#	${NORMAL_S}
 
 %OBJS
 
@@ -109,32 +92,118 @@
 
 %SFILES
 
+# load lines for config "xxx" will be emitted as:
+# xxx: ${SYSTEM_DEP} swapxxx.o
+#	${SYSTEM_LD_HEAD}
+#	${SYSTEM_LD} swapxxx.o
+#	${SYSTEM_LD_TAIL}
+SYSTEM_OBJ=	locore.o \
+		param.o ioconf.o devsw.o ${OBJS} ${LIBCOMPAT} ${LIBKERN}
+SYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
+SYSTEM_LD_HEAD=	rm -f $@
+SYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
+		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
+SYSTEM_LD_TAIL=	@${SIZE} $@; chmod 755 $@
+
+DEBUG?=
+.if ${DEBUG} == "-g"
+LINKFLAGS+=	-X
+SYSTEM_LD_TAIL+=; \
+		echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \
+		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
+		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
+.else
+LINKFLAGS+=	-S
+.endif
+
 %LOAD
 
-%RULES
+assym.h: ${PPC}/macppc/genassym.cf
+	genassym ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
+	    < ${PPC}/macppc/genassym.cf > assym.h.tmp && \
+	mv -f assym.h.tmp assym.h
+
+param.c: $S/conf/param.c
+	rm -f param.c
+	cp $S/conf/param.c .
+
+param.o: param.c Makefile
+	${NORMAL_C}
+
+ioconf.o: ioconf.c
+	${NORMAL_C}
+
+devsw.o: devsw.c
+	${NORMAL_C}
+
+vers.o: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
+	sh $S/conf/newvers.sh
+	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
+
+newvers: vers.o
+
+__CLEANKERNEL: .USE
+	@echo "${.TARGET}ing the kernel objects"
+	rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \
+	    [Ee]rrs linterrs makelinks assym.h.tmp assym.h
+
+__CLEANDEPEND: .USE
+	rm -f .depend
+
+clean: __CLEANKERNEL
+
+cleandir distclean: __CLEANKERNEL __CLEANDEPEND
+
+lint:
+	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
+		${PPC}/macppc/Locore.c ${CFILES} \
+		ioconf.c param.c | \
+		grep -v 'static function .* unused'
+
+tags:
+	@echo "see $S/kern/Makefile for tags"
+
+links:
+	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
+	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
+	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
+	  sort -u | comm -23 - dontlink | \
+	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
+	sh makelinks && rm -f dontlink
+
+SRCS=	${PPC}/macppc/locore.S \
+	param.c ioconf.c ${CFILES} ${SFILES}
+depend: .depend
+.depend: ${SRCS} assym.h param.c
+	${MKDEP} -- ${AFLAGS} ${CPPFLAGS} ${PPC}/macppc/locore.S
+	${MKDEP} -a -- ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES}
+.if ${SFILES} != ""
+	${MKDEP} -a -- ${AFLAGS} ${CPPFLAGS} ${SFILES}
+.endif
+	genassym ${MKDEP} -f assym.dep -- ${CFLAGS} \
+	  ${CPPFLAGS} < ${PPC}/macppc/genassym.cf
+	@sed -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >> .depend
+	@rm -f assym.dep
+
+dependall: depend all
 
-# XXX - Ugly, but make doesn't easily handle .o.uue (assumes it's a suffix)
-# XXX - Also, config has no simple was to just add foo.o to the Makefile. 
-#       It needs a pathname of some sort for "object"        
-.if !empty(OBJS:M\/athhal-powerpc-be-eabi.hal.o)
-OBJS:=${OBJS:C/\/athhal-powerpc-be-eabi.hal.o/athhal-powerpc-be-eabi.hal.o/}
- 
-.PATH: $S/contrib/arch/powerpc/dev
-ATH_UUDEC?=	@${_MKSHMSG} "uudecode ${.CURDIR:T}/${.TARGET}"; \
-		${_MKSHECHO}\
-		${UUDECODE} -p $> \> ${.TARGET}; \
-		rm -f ${.TARGET}; \
-		${UUDECODE} -p $> > ${.TARGET}
-athhal-powerpc-be-eabi.hal.o: athhal-powerpc-be-eabi.hal.o.uue
-	${ATH_UUDEC}
-.endif
+# depend on root or device configuration
+autoconf.o conf.o: Makefile
+
+# depend on network or filesystem configuration
+uipc_proto.o vfs_conf.o: Makefile
+
+# depend on maxusers
+machdep.o: Makefile
+
+# depend on CPU configuration
+locore.o machdep.o: Makefile
+
+locore.o: ${PPC}/macppc/locore.S assym.h
+	${NORMAL_S}
+
+locore_subr.o: assym.h
+
+%RULES
 
-##
-## (9) port independent kernel machinery
-##
-.include "$S/conf/Makefile.kern.inc"
-
-##
-## (10) Appending make options.
-##
 %MAKEOPTIONSAPPEND
