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