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