Home | History | Annotate | Line # | Download | only in libsim
Makefile revision 1.6.4.1
      1 #	$NetBSD: Makefile,v 1.6.4.1 2019/06/10 22:02:22 christos Exp $
      2 
      3 LIBISPRIVATE=	yes
      4 NOGCCERROR=
      5 
      6 .include <bsd.own.mk>
      7 .include "../Makefile.inc"
      8 
      9 LIB=	sim
     10 SRCS=	debug.c filter_filename.c bits.c sim-endian.c os_emul.c emul_generic.c \
     11 	emul_bugapi.c emul_chirp.c emul_netbsd.c emul_unix.c registers.c vm.c \
     12 	corefile.c model.c spreg.c cpu.c interrupts.c events.c cap.c device.c \
     13 	tree.c device_table.c itable.c mon.c icache.c semantics.c idecode.c \
     14 	support.c psim.c pk_disklabel.c hw_cpu.c hw_memory.c hw_nvram.c \
     15 	hw_iobus.c hw_htab.c hw_disk.c hw_trace.c hw_register.c hw_vm.c \
     16 	hw_init.c hw_core.c hw_pal.c hw_com.c hw_eeprom.c hw_opic.c hw_glue.c \
     17 	hw_phb.c hw_ide.c options.c sim_calls.c callback.c targ-map.c gdb-sim.c
     18 
     19 MIC=	${HOST_SH} ${DIST}/move-if-change
     20 
     21 HOST_CPPFLAGS+=	-I. \
     22 		-I${DIST}/sim/ppc -I${DIST}/include \
     23 		-I${.CURDIR}/arch/${GDB_MACHINE_ARCH} \
     24 		-I${.CURDIR}/../libbfd/arch/${GDB_MACHINE_ARCH} \
     25 		-I${DIST}/bfd \
     26 		-I${DIST}/gdb \
     27 		-I${DIST}/gdb/config \
     28 		-DHAVE_COMMON_FPU \
     29 		-I${.CURDIR}/../arch/${GDB_MACHINE_ARCH} \
     30 		-I${DIST}/sim/common
     31 PSIM_DEFINES=	-DHAVE_CONFIG_H \
     32 		-DDEFAULT_INLINE=PSIM_INLINE_LOCALS \
     33 		-DWITH_HOST_BYTE_ORDER=BYTE_ORDER \
     34 		-DWITH_SMP=5 \
     35 		-DHAVE_TERMIOS_STRUCTURE \
     36 		-DHAVE_DEVZERO
     37 
     38 # we need the same -I flags for host / target.
     39 CPPFLAGS+=	${HOST_CPPFLAGS} ${PSIM_DEFINES}
     40 
     41 #
     42 # These portions run several programs to generate more code to compile.
     43 #
     44 
     45 # igen portion
     46 IGEN_FLAGS=	-E    -F 32,f,o  -CSRI 1024  -N 5 \
     47 	-o ${DIST}/sim/ppc/dc-complex \
     48 	-I ${DIST}/sim/ppc -i ${DIST}/sim/ppc/ppc-instructions \
     49 	-n icache.h    -hc tmp-icache.h \
     50 	-n icache.c    -c  tmp-icache.c \
     51 	-n semantics.h -hs tmp-semantics.h \
     52 	-n semantics.c -s  tmp-semantics.c \
     53 	-n idecode.h   -hd tmp-idecode.h \
     54 	-n idecode.c   -d  tmp-idecode.c \
     55 	-n itable.h    -ht tmp-itable.h \
     56 	-n itable.c    -t  tmp-itable.c \
     57 	-n model.h     -hm tmp-model.h \
     58 	-n model.c     -m  tmp-model.c \
     59 	-n support.h   -hf tmp-support.h \
     60 	-n support.c   -f  tmp-support.c
     61 IGENED_FILES=	icache.h icache.c idecode.h idecode.c semantics.h semantics.c \
     62 		itable.h itable.c model.h model.c support.h support.c
     63 IGENSRCS= igen.c table.c lf.c misc.c filter_host.c ld-decode.c ld-cache.c filter.c ld-insn.c gen-model.c gen-itable.c gen-icache.c gen-semantics.c gen-idecode.c gen-support.c
     64 IGENOBJS= ${IGENSRCS:S/.c/.lo/}
     65 DPSRCS+= ${IGENED_FILES:M*.h}
     66 
     67 ${IGENED_FILES}: run-igen
     68 run-igen: igen ppc-instructions
     69 	${_MKMSG_CREATE} ${IGENED_FILES}
     70 	rm -f ${.TARGET}
     71 	./igen ${IGEN_FLAGS}
     72 	${MIC} tmp-icache.h icache.h
     73 	${MIC} tmp-icache.c icache.c
     74 	${MIC} tmp-idecode.h idecode.h
     75 	${MIC} tmp-idecode.c idecode.c
     76 	${MIC} tmp-semantics.h semantics.h
     77 	${MIC} tmp-semantics.c semantics.c
     78 	${MIC} tmp-itable.h itable.h
     79 	${MIC} tmp-itable.c itable.c
     80 	${MIC} tmp-model.h model.h
     81 	${MIC} tmp-model.c model.c
     82 	${MIC} tmp-support.h support.h
     83 	${MIC} tmp-support.c support.c
     84 	touch ${.TARGET}
     85 
     86 igen: ${IGENOBJS}
     87 	${HOST_LINK.c} ${IGENOBJS} -o ${.TARGET}
     88 
     89 # dgen portion
     90 DGEN_FLAGS=	-r ${DIST}/sim/ppc/ppc-spr-table \
     91 	-n spreg.h     -hp tmp-spreg.h \
     92 	-n spreg.c     -p  tmp-spreg.c
     93 DGENED_FILES=	spreg.h spreg.c
     94 DGENSRCS= dgen.c table.c lf.c misc.c filter_host.c
     95 DGENOBJS= ${DGENSRCS:S/.c/.lo/}
     96 DPSRCS+= ${DGENED_FILES:M*.h}
     97 
     98 ${DGENED_FILES}: run-dgen
     99 run-dgen: dgen
    100 	./dgen ${DGEN_FLAGS}
    101 	${MIC} tmp-spreg.h spreg.h
    102 	${MIC} tmp-spreg.c spreg.c
    103 	touch run-dgen
    104 
    105 dgen: ${DGENOBJS}
    106 	${HOST_LINK.c} ${DGENOBJS} -o ${.TARGET}
    107 
    108 # gentmap portion
    109 GENTMAPSRCS= gentmap.c
    110 GENTMAPOBJS= ${GENTMAPSRCS:S/.c/.lo/}
    111 
    112 gentmap: ${GENTMAPOBJS}
    113 	${HOST_LINK.c} ${GENTMAPOBJS} -o ${.TARGET}
    114 
    115 gentmap.c: targ-vals.def
    116 
    117 targ-vals.def: ${DIST}/sim/ppc/../common/nltvals.def
    118 	rm -f targ-vals.def tmp-def
    119 	cat ${DIST}/sim/ppc/../common/nltvals.def > tmp-vals.def
    120 	${MIC} tmp-vals.def targ-vals.def
    121 
    122 targ-vals.h: gentmap targ-vals.def
    123 	rm -f tmp-vals.h
    124 	./gentmap -h > tmp-vals.h
    125 	${MIC} tmp-vals.h targ-vals.h
    126 DPSRCS+= targ-vals.h
    127 
    128 targ-map.c: gentmap targ-vals.def
    129 	rm -f tmp-map.c
    130 	./gentmap -c > tmp-map.c
    131 	${MIC} tmp-map.c targ-map.c
    132 
    133 # hw.c / hw.h portion
    134 HWSRCS=	hw_cpu.c hw_memory.c hw_nvram.c hw_iobus.c hw_htab.c hw_disk.c \
    135 	hw_trace.c hw_register.c hw_vm.c hw_init.c hw_core.c hw_pal.c \
    136 	hw_com.c hw_eeprom.c hw_opic.c hw_glue.c hw_phb.c hw_ide.c
    137 
    138 hw.h hw.c: run-hw
    139 run-hw: Makefile
    140 	f=""; \
    141 	for i in ${HWSRCS}; do \
    142 		case " $$f " in \
    143 			*" $$i "*) ;; \
    144 			*) f="$$f $$i" ;; \
    145 		esac ; \
    146 	done ; \
    147 	for hw in $$f; do \
    148 		echo $$hw; \
    149 	done | ${TOOL_SED} -e 's/^.*\(hw_.*\)\.c/\1/' \
    150 		   -e 's/^/extern const device_descriptor /' \
    151 		   -e 's/$$/_device_descriptor\[\];/' \
    152 			> tmp-hw.h
    153 	f=""; \
    154 	for i in ${HWSRCS}; do \
    155 		case " $$f " in \
    156 			*" $$i "*) ;; \
    157 			*) f="$$f $$i" ;; \
    158 		esac ; \
    159 	done ; \
    160 	for hw in $$f; do \
    161 		echo $$hw; \
    162 	done | ${TOOL_SED} -e 's/^.*\(hw_.*\)\.c/\1/' \
    163 		   -e 's/^/    /' \
    164 		   -e 's/$$/_device_descriptor,/' > tmp-hw.c
    165 	${MIC} tmp-hw.h hw.h
    166 	${MIC} tmp-hw.c hw.c
    167 	touch run-hw
    168 DPSRCS+= hw.h
    169 
    170 # package portion
    171 PACKAGE_SRC =	pk_disklabel.c
    172 PK_H = 		pk.h
    173 
    174 ${PK_H}: run-pk
    175 run-pk: $(PACKAGE_SRC)
    176 	f=""; \
    177 	for i in $(PACKAGE_SRC) ; do \
    178 		case " $$f " in \
    179 			*" $$i "*) ;; \
    180 			*) f="$$f $$i" ;; \
    181 		esac ; \
    182 	done ; \
    183 	for pk in $$f; do \
    184 		echo $$pk; \
    185 	done | ${TOOL_SED} -e 's/^.*pk_\(.*\)\.c/\1/' \
    186 		   -e 's/^/extern package_create_instance_callback pk_/' \
    187 		   -e 's/$$/_create_instance;/' > tmp-pk.h
    188 	${MIC} tmp-pk.h pk.h
    189 	touch run-pk
    190 DPSRCS+= ${PK_H}
    191 
    192 # defines portion
    193 DEFINES_H=	defines.h
    194 ${DEFINES_H}: run-defines
    195 run-defines:
    196 	${TOOL_SED} -n -e '/^#define HAVE_/s/ 1$$/",/' \
    197 	       -e '/^#define HAVE_/s//"HAVE_/p' \
    198 	       < ${.CURDIR}/arch/${GDB_MACHINE_ARCH}/config.h > tmp-defines.h
    199 	${MIC} tmp-defines.h defines.h
    200 	touch run-defines
    201 DPSRCS+= ${DEFINES_H}
    202 
    203 # misc. dependancies.
    204 filter_host.c: ${DIST}/sim/ppc/filter_filename.c
    205 	cp -f ${.ALLSRC} ${.TARGET}
    206 filter_host.lo: ppc-config.h
    207 
    208 ppc-config.h: ${DIST}/sim/ppc/std-config.h
    209 	cp -f ${.ALLSRC} ${.TARGET}
    210 DPSRCS+= ppc-config.h
    211 
    212 CLEANFILES+=	igen dgen gentmap *.lo \
    213 		ppc-config.h filter_host.c \
    214 		tmp-icache.h icache.h \
    215 		tmp-icache.c icache.c \
    216 		tmp-idecode.h idecode.h \
    217 		tmp-idecode.c idecode.c \
    218 		tmp-semantics.h semantics.h \
    219 		tmp-semantics.c semantics.c \
    220 		tmp-itable.h itable.h \
    221 		tmp-itable.c itable.c \
    222 		tmp-model.h model.h \
    223 		tmp-model.c model.c \
    224 		tmp-support.h support.h \
    225 		tmp-support.c support.c \
    226 		tmp-spreg.h spreg.h \
    227 		tmp-spreg.c spreg.c \
    228 		tmp-vals.h targ-vals.h \
    229 		hw.c hw.h \
    230 		defines.h pk.h \
    231 		targ-map.c targ-vals.def \
    232 		run-defines run-dgen run-hw run-igen run-pk
    233 
    234 .SUFFIXES: .lo
    235 .c.lo:
    236 	${HOST_COMPILE.c} -o ${.TARGET} $<
    237 
    238 .PATH: ${DIST}/sim/ppc ${DIST}/sim/common
    239 
    240 .include <bsd.lib.mk>
    241 .include "../../Makefile.inc"
    242