1 # $NetBSD: Makefile,v 1.4 2023/08/11 15:18:29 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 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${.CURDIR}/../libgnulib/arch/${GDB_MACHINE_ARCH} \ 26 -I${DIST}/bfd \ 27 -I${DIST}/gdb \ 28 -I${DIST}/gdb/config \ 29 -DHAVE_COMMON_FPU \ 30 -I${.CURDIR}/../arch/${GDB_MACHINE_ARCH} \ 31 -I${DIST}/sim/common 32 PSIM_DEFINES= -DHAVE_CONFIG_H \ 33 -DDEFAULT_INLINE=INLINE_LOCALS \ 34 -DWITH_HOST_BYTE_ORDER=BYTE_ORDER \ 35 -DWITH_SMP=5 \ 36 -DSIM_COMMON_BUILD \ 37 -DHAVE_TERMIOS_STRUCTURE \ 38 -DHAVE_DEVZERO \ 39 -DWITH_TRACE=0 \ 40 -DWITH_ASSERT=0 \ 41 -DWITH_STDIO=0 \ 42 -DWITH_ENVIRONMENT=0 \ 43 -DWITH_RESERVED_BITS=0 \ 44 -DREPORT_BUGS_TO=\"gnats (at] NetBSD.org\" \ 45 -DPKGVERSION=\"13.2\" 46 47 # we need the same -I flags for host / target. 48 CPPFLAGS+= ${HOST_CPPFLAGS} ${PSIM_DEFINES} 49 50 # 51 # These portions run several programs to generate more code to compile. 52 # 53 54 # igen portion 55 IGEN_FLAGS= -E -F 32,f,o -CSRI 1024 -N 5 \ 56 -o ${DIST}/sim/ppc/dc-complex \ 57 -I ${DIST}/sim/ppc -i ${DIST}/sim/ppc/powerpc.igen \ 58 -n icache.h -hc tmp-icache.h \ 59 -n icache.c -c tmp-icache.c \ 60 -n semantics.h -hs tmp-semantics.h \ 61 -n semantics.c -s tmp-semantics.c \ 62 -n idecode.h -hd tmp-idecode.h \ 63 -n idecode.c -d tmp-idecode.c \ 64 -n itable.h -ht tmp-itable.h \ 65 -n itable.c -t tmp-itable.c \ 66 -n model.h -hm tmp-model.h \ 67 -n model.c -m tmp-model.c \ 68 -n support.h -hf tmp-support.h \ 69 -n support.c -f tmp-support.c 70 IGENED_FILES= icache.h icache.c idecode.h idecode.c semantics.h semantics.c \ 71 itable.h itable.c model.h model.c support.h support.c 72 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 73 IGENOBJS= ${IGENSRCS:S/.c/.lo/} 74 DPSRCS+= ${IGENED_FILES:M*.h} 75 76 ${IGENED_FILES}: run-igen 77 run-igen: igen powerpc.igen 78 ${_MKMSG_CREATE} ${IGENED_FILES} 79 rm -f ${.TARGET} 80 ./igen ${IGEN_FLAGS} 81 ${MIC} tmp-icache.h icache.h 82 ${MIC} tmp-icache.c icache.c 83 ${MIC} tmp-idecode.h idecode.h 84 ${MIC} tmp-idecode.c idecode.c 85 ${MIC} tmp-semantics.h semantics.h 86 ${MIC} tmp-semantics.c semantics.c 87 ${MIC} tmp-itable.h itable.h 88 ${MIC} tmp-itable.c itable.c 89 ${MIC} tmp-model.h model.h 90 ${MIC} tmp-model.c model.c 91 ${MIC} tmp-support.h support.h 92 ${MIC} tmp-support.c support.c 93 touch ${.TARGET} 94 95 igen: ${IGENOBJS} 96 ${HOST_LINK.c} ${IGENOBJS} -o ${.TARGET} 97 98 # dgen portion 99 DGEN_FLAGS= -r ${DIST}/sim/ppc/ppc-spr-table \ 100 -n spreg.h -hp tmp-spreg.h \ 101 -n spreg.c -p tmp-spreg.c 102 DGENED_FILES= spreg.h spreg.c 103 DGENSRCS= dgen.c table.c lf.c misc.c filter_host.c 104 DGENOBJS= ${DGENSRCS:S/.c/.lo/} 105 DPSRCS+= ${DGENED_FILES:M*.h} 106 107 ${DGENED_FILES}: run-dgen 108 run-dgen: dgen 109 ./dgen ${DGEN_FLAGS} 110 ${MIC} tmp-spreg.h spreg.h 111 ${MIC} tmp-spreg.c spreg.c 112 touch run-dgen 113 114 dgen: ${DGENOBJS} 115 ${HOST_LINK.c} ${DGENOBJS} -o ${.TARGET} 116 117 # hw.c / hw.h portion 118 HWSRCS= hw_cpu.c hw_memory.c hw_nvram.c hw_iobus.c hw_htab.c hw_disk.c \ 119 hw_trace.c hw_register.c hw_vm.c hw_init.c hw_core.c hw_pal.c \ 120 hw_com.c hw_eeprom.c hw_opic.c hw_glue.c hw_phb.c hw_ide.c 121 122 hw.h hw.c: run-hw 123 run-hw: Makefile 124 f=""; \ 125 for i in ${HWSRCS}; do \ 126 case " $$f " in \ 127 *" $$i "*) ;; \ 128 *) f="$$f $$i" ;; \ 129 esac ; \ 130 done ; \ 131 for hw in $$f; do \ 132 echo $$hw; \ 133 done | ${TOOL_SED} -e 's/^.*\(hw_.*\)\.c/\1/' \ 134 -e 's/^/extern const device_descriptor /' \ 135 -e 's/$$/_device_descriptor\[\];/' \ 136 > tmp-hw.h 137 f=""; \ 138 for i in ${HWSRCS}; do \ 139 case " $$f " in \ 140 *" $$i "*) ;; \ 141 *) f="$$f $$i" ;; \ 142 esac ; \ 143 done ; \ 144 for hw in $$f; do \ 145 echo $$hw; \ 146 done | ${TOOL_SED} -e 's/^.*\(hw_.*\)\.c/\1/' \ 147 -e 's/^/ /' \ 148 -e 's/$$/_device_descriptor,/' > tmp-hw.c 149 ${MIC} tmp-hw.h hw.h 150 ${MIC} tmp-hw.c hw.c 151 touch run-hw 152 DPSRCS+= hw.h 153 154 # package portion 155 PACKAGE_SRC = pk_disklabel.c 156 PK_H = pk.h 157 158 ${PK_H}: run-pk 159 run-pk: $(PACKAGE_SRC) 160 f=""; \ 161 for i in $(PACKAGE_SRC) ; do \ 162 case " $$f " in \ 163 *" $$i "*) ;; \ 164 *) f="$$f $$i" ;; \ 165 esac ; \ 166 done ; \ 167 for pk in $$f; do \ 168 echo $$pk; \ 169 done | ${TOOL_SED} -e 's/^.*pk_\(.*\)\.c/\1/' \ 170 -e 's/^/extern package_create_instance_callback pk_/' \ 171 -e 's/$$/_create_instance;/' > tmp-pk.h 172 ${MIC} tmp-pk.h pk.h 173 touch run-pk 174 DPSRCS+= ${PK_H} 175 176 # defines portion 177 DEFINES_H= defines.h 178 ${DEFINES_H}: run-defines 179 run-defines: 180 ${TOOL_SED} -n -e '/^#define HAVE_/s/ 1$$/",/' \ 181 -e '/^#define HAVE_/s//"HAVE_/p' \ 182 < ${.CURDIR}/arch/${GDB_MACHINE_ARCH}/config.h > tmp-defines.h 183 ${MIC} tmp-defines.h defines.h 184 touch run-defines 185 DPSRCS+= ${DEFINES_H} 186 187 # misc. dependancies. 188 filter_host.c: ${DIST}/sim/ppc/filter_filename.c 189 cp -f ${.ALLSRC} ${.TARGET} 190 filter_host.lo: ppc-config.h 191 192 ppc-config.h: ${DIST}/sim/ppc/std-config.h 193 cp -f ${.ALLSRC} ${.TARGET} 194 DPSRCS+= ppc-config.h 195 196 CLEANFILES+= igen dgen gentmap *.lo \ 197 ppc-config.h filter_host.c \ 198 tmp-icache.h icache.h \ 199 tmp-icache.c icache.c \ 200 tmp-idecode.h idecode.h \ 201 tmp-idecode.c idecode.c \ 202 tmp-semantics.h semantics.h \ 203 tmp-semantics.c semantics.c \ 204 tmp-itable.h itable.h \ 205 tmp-itable.c itable.c \ 206 tmp-model.h model.h \ 207 tmp-model.c model.c \ 208 tmp-support.h support.h \ 209 tmp-support.c support.c \ 210 tmp-spreg.h spreg.h \ 211 tmp-spreg.c spreg.c \ 212 tmp-vals.h targ-vals.h \ 213 hw.c hw.h \ 214 defines.h pk.h \ 215 targ-map.c targ-vals.def \ 216 run-defines run-dgen run-hw run-igen run-pk 217 218 .SUFFIXES: .lo 219 .c.lo: 220 ${HOST_COMPILE.c} -o ${.TARGET} $< 221 222 .PATH: ${DIST}/sim/ppc ${DIST}/sim/common 223 224 .include <bsd.lib.mk> 225 .include "../../Makefile.inc" 226