Home | History | Annotate | Line # | Download | only in conf
Makefile.sparc64 revision 1.40
      1 # 	$NetBSD: Makefile.sparc64,v 1.40 2001/10/24 18:49:39 thorpej 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/sparc64/conf/``machineid''
      9 # after which you should do
     10 #	config machineid
     11 # Machine generic makefile changes should be made in
     12 #	/sys/arch/sparc64/conf/Makefile.sparc64
     13 # after which config should be rerun for all machines of that type.
     14 
     15 # Always use sparc64 as the MACHINE_ARCH, so we select the correct
     16 # toolchain (i.e. need v9 instruction support in the assembler, etc.)
     17 # 32-bit vs. 64-bit will be selected based on compiler/assember options.
     18 MACHINE_ARCH=sparc64
     19 
     20 .include <bsd.own.mk>
     21 
     22 # DEBUG is set to -g if debugging.
     23 # PROF is set to -pg if profiling.
     24 
     25 AR?=	ar
     26 AS?=	as
     27 CC?=	cc
     28 CPP?=	cpp
     29 LD?=	ld
     30 LORDER?=lorder
     31 MKDEP?=	mkdep
     32 NM?=	nm
     33 RANLIB?=ranlib
     34 SIZE?=	size
     35 STRIP?=	strip
     36 TSORT?=	tsort -q
     37 
     38 COPTS?= 	-O2
     39 
     40 # source tree is located via $S relative to the compilation directory
     41 .ifndef S
     42 S!=	cd ../../../..; pwd
     43 .endif
     44 SPARC64=	$S/arch/sparc64
     45 
     46 INCLUDES=	-I. -I$S/arch -I$S -nostdinc
     47 CPPFLAGS=	${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -D_KERNEL_OPT -Dsparc64
     48 CWARNFLAGS=	-Werror -Wall -Wstrict-prototypes -Wmissing-prototypes \
     49 		-Wpointer-arith
     50 # XXX Delete -Wuninitialized for now, since the compiler doesn't
     51 # XXX always get it right.  --thorpej
     52 CWARNFLAGS+=	-Wno-uninitialized
     53 CWARNFLAGS+=	-Wno-main
     54 
     55 # Select the compiler, assembler, and linker flags based on the
     56 # LP64 variable.
     57 LP64?=	no
     58 .if ${LP64} == "yes"
     59 CC:=		${CC} -m64
     60 AS:=		${AS} -64
     61 LD:=		${LD} -m elf64_sparc
     62 CPPFLAGS+=	-D_LP64
     63 .else
     64 CC:=		${CC} -m32
     65 AS:=		${AS} -32
     66 LD:=		${LD} -m elf32_sparc
     67 .endif
     68 
     69 CFLAGS=		${DEBUG} ${COPTS} ${CWARNFLAGS} -Wa,-Av9a -mno-fpu
     70 .if defined(PROF)
     71 # We need to run the compiler in medlow memory model.
     72 CFLAGS+=	-mcmodel=medlow
     73 .endif
     74 AFLAGS=		-x assembler-with-cpp -traditional-cpp -D_LOCORE -Wa,-Av9a
     75 
     76 #
     77 # Gotta find a way to make kernel base tuneable.
     78 #
     79 
     80 LINKFLAGS=	-Ttext 01000000 -Tdata 01800000 -e start
     81 #LINKFLAGS=	-Ttext f1000000 -Tdata f1400000 -e start
     82 
     83 LINKFLAGS+=	-n -T ${SPARC64}/conf/${KERN_LDSCRIPT}
     84 .if ${LP64} == "yes"
     85 KERN_LDSCRIPT?= kern.ldscript
     86 .else
     87 KERN_LDSCRIPT?= kern32.ldscript
     88 .endif
     89 
     90 STRIPFLAGS=	-g
     91 
     92 %INCLUDES
     93 
     94 ### find out what to use for libkern
     95 # KERN_AS=	obj	# bcopy, bzero, memcpy, memset, etc. are in locore.s
     96 .include "$S/lib/libkern/Makefile.inc"
     97 .ifndef PROF
     98 LIBKERN=	${KERNLIB}
     99 .else
    100 LIBKERN=	${KERNLIB_PROF}
    101 .endif
    102 
    103 ### find out what to use for libcompat
    104 .include "$S/compat/common/Makefile.inc"
    105 .ifndef PROF
    106 LIBCOMPAT=	${COMPATLIB}
    107 .else
    108 LIBCOMPAT=	${COMPATLIB_PROF}
    109 .endif
    110 
    111 # compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or
    112 # HOSTED, and SUFFIX is the file suffix, capitalized (e.g. C for a .c file).
    113 
    114 NORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
    115 NOOPT_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -O0 -c $<
    116 NORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} -c $<
    117 
    118 %OBJS
    119 
    120 %CFILES
    121 
    122 %SFILES
    123 
    124 # load lines for config "xxx" will be emitted as:
    125 # xxx: ${SYSTEM_DEP} swapxxx.o
    126 #	${SYSTEM_LD_HEAD}
    127 #	${SYSTEM_LD} swapxxx.o
    128 #	${SYSTEM_LD_TAIL}
    129 SYSTEM_OBJ=	locore.o \
    130 		param.o ioconf.o ${OBJS} ${LIBCOMPAT} ${LIBKERN}
    131 SYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
    132 SYSTEM_LD_HEAD=	rm -f $@
    133 SYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
    134 		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
    135 SYSTEM_LD_TAIL=	@${SIZE} $@; chmod 755 $@
    136 
    137 DEBUG?=
    138 .if ${DEBUG} == "-g"
    139 LINKFLAGS+=	-X
    140 SYSTEM_LD_TAIL+=; \
    141 		echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \
    142 		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
    143 		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
    144 .else
    145 LINKFLAGS+=	-S
    146 .endif
    147 
    148 %LOAD
    149 
    150 assym.h: $S/kern/genassym.sh ${SPARC64}/sparc64/genassym.cf
    151 	sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
    152 	    < ${SPARC64}/sparc64/genassym.cf > assym.h.tmp && \
    153 	mv -f assym.h.tmp assym.h
    154 
    155 param.c: $S/conf/param.c
    156 	rm -f param.c
    157 	cp $S/conf/param.c .
    158 
    159 param.o: param.c Makefile
    160 	${NORMAL_C}
    161 
    162 ioconf.o: ioconf.c
    163 	${NORMAL_C}
    164 
    165 newvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
    166 	sh $S/conf/newvers.sh
    167 	${CC} ${COPTS} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
    168 
    169 
    170 __CLEANKERNEL: .USE
    171 	@echo "${.TARGET}ing the kernel objects"
    172 	rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \
    173 	    [Ee]rrs linterrs makelinks assym.h.tmp assym.h
    174 
    175 __CLEANDEPEND: .USE
    176 	rm -f .depend
    177 
    178 clean: __CLEANKERNEL
    179 
    180 cleandir distclean: __CLEANKERNEL __CLEANDEPEND
    181 
    182 lint:
    183 	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
    184 	    ${SPARC64}/sparc64/Locore.c ${CFILES} \
    185 	    ioconf.c param.c | \
    186 	    grep -v 'static function .* unused'
    187 
    188 tags:
    189 	@echo "see $S/kern/Makefile for tags"
    190 
    191 links:
    192 	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
    193 	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
    194 	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
    195 	  sort -u | comm -23 - dontlink | \
    196 	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
    197 	sh makelinks && rm -f dontlink
    198 
    199 SRCS=	${SPARC64}/sparc64/locore.s \
    200 	param.c ioconf.c ${CFILES} ${SFILES}
    201 depend: .depend
    202 .depend: ${SRCS} assym.h param.c
    203 	${MKDEP} ${AFLAGS} ${CPPFLAGS} ${SPARC64}/sparc64/locore.s
    204 	${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES}
    205 .if (${SFILES} != "")
    206 	${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${SFILES}
    207 .endif
    208 	sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${COPTS} ${CFLAGS} \
    209 	  ${CPPFLAGS} < ${SPARC64}/sparc64/genassym.cf
    210 	@sed -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >> .depend
    211 	@rm -f assym.dep
    212 
    213 dependall: depend all
    214 
    215 
    216 # depend on root or device configuration
    217 autoconf.o conf.o: Makefile
    218 
    219 # depend on network or filesystem configuration 
    220 uipc_proto.o vfs_conf.o: Makefile 
    221 
    222 # depend on maxusers
    223 machdep.o: Makefile
    224 
    225 # depend on CPU configuration 
    226 bwtwo.o cgsix.o cgthree.o cgtwo.o cons.o dma.o esp.o fb.o if_ie.o: Makefile
    227 ms.c obio.o zs.c autoconf.o clock.o cpu.o disksubr.o locore.o: Makefile
    228 machdep.o mem.o openprom.o pmap.o vm_machdep.o: Makefile
    229 
    230 
    231 locore.o: ${SPARC64}/sparc64/locore.s assym.h
    232 	${NORMAL_S}
    233 
    234 # The install target can be redefined by putting a
    235 # install-kernel-${MACHINE_NAME} target into /etc/mk.conf
    236 MACHINE_NAME!=  uname -n
    237 install: install-kernel-${MACHINE_NAME}
    238 .if !target(install-kernel-${MACHINE_NAME}})
    239 install-kernel-${MACHINE_NAME}:
    240 	rm -f /onetbsd
    241 	ln /netbsd /onetbsd
    242 	cp netbsd /nnetbsd
    243 	mv /nnetbsd /netbsd
    244 .endif
    245 
    246 %RULES
    247