1# Makefile for yaze-ag
2
3BUILD = " (build for Solaris Sparcv9 64 Bit (sparcv9))"
4
5# CC must be an ANSI-C compiler
6CC            =	gcc
7
8#where you want the binaries and manual page
9BINDIR	      = /usr/local/bin
10MANDIR	      = /usr/local/man/man1
11LIBDIR	      = /usr/local/lib/yaze
12DSKDIR        = $(LIBDIR)/disks
13DOCDIR        = $(LIBDIR)/doc
14DOCHTMLDIR    = $(LIBDIR)/doc_html
15
16#OPTIMIZE	= -g
17#OPTIMIZE	= -g -save-temps
18# OPTIMIZE	=
19# OPTIMIZE	= -O1
20# OPTIMIZE	= -O2
21# OPTIMIZE	= -O2 -save-temps
22
23# optimizing with gcc 2.x.x
24#OPTIMIZE	= -O3
25
26# optimizing with gcc 3.x.x
27# (please search for your processor in "man gcc")
28# (tip: search first for "sparc")
29#
30# -mcpu=cpu-type  # refer the man page "man gcc" for -mcpu
31#
32OPTIMIZE	= -O3 -mcpu=v9
33#OPTIMIZE	= -O3 -march=corei7
34
35# -DUSE_GNU_READLINE for command recall/editing and filename completion
36# -DBGii_BUG works around a problem in Backgrounder II
37# -DBIOS to build a CP/M bios and monitor program into the emulator
38#  (see also YAZE_OBJS, below)
39#
40# -- The following options are new:
41#
42# -DMMU compiles support for MMU-switched memory and CP/M 3.1 extensions
43# -DMMUTABLES=<val> sets the no of MMU tables (default 16)
44# -DYAZEPAGESIZE=<val> sets the page size for every page pointer (default 4 KB)
45#		(The MMUPAGEPOINTERS are generated automatically)
46# -DSHOWMMU shows at start the MMU tables (will be defined if MMUTEST is def.)
47# -DMMUTEST setup pages for 3000h - BFFFh to pages above 64K
48#	    (-DSHOWMMU will be set and the MMU-Table 7 will be selected)
49#	    (Only used unter CP/M 2.2. See README-1.20 for details)
50#	    (DO NOT USE IT IF YOU WANT TO RUN CP/M 3.1 - THIS IS ONLY FOR TEST!)
51#
52# -DMEMSIZE=<val> sets size of memory in KBytes (default 64KB, with MMU: 512KB)
53#
54# -DBOOTSYS loads yaze-cpm3.boot at 0100H  instead of  yaze.boot (CP/M 2.2).
55#	    yaze-cpm3.boot is idendical with A:CPM3.COM. Inside there is
56#	    the CP/M 3.1 loader BOOTSYS.COM + CPM3.SYS (see BOOTSYS.Z80
57#	    on drive P:). You can generate CPM3.COM with
58#		"pip cpm3.com=bootsys.com,cpm3.sys".
59#	    If BOOTSYS is given you can boot CP/M 2.2 (SUPERDOS) with
60#		"yaze -l -1 -b yaze.boot".
61#
62# -DSHOWDRV shows the entries in @dtbl, the DPHs and the DPBs when CP/M 3.1
63#	    starts or "mount.com" or "sys mount" is running.
64# -DMULTIO  Use Multi-I/O disk transfere
65# -DRWDEBUG Set the debug mode for read/write operations. If MULTIO is defined
66#	    and multi sector count is set by the bdos the multi sector read
67#	    and write will be displayed with "r" and "w". The rest will be
68#	    displayed with ".". Reads/writes without multi sector count will
69#	    be displayed with "R" and "W".
70#
71# -DUCSD    Set mode if you want to use UCSD-pascal version for CP/M.
72#	    It was neccessary because UCSD-Pascal-System does not use the
73#	    register B when it gives Sektor or Track to the BIOS. With this
74#	    Flag only the Register C of BC is used in SETTRK & SETSEC. It
75#	    was neccessary because yaze-ag crashes.
76#
77# --
78# solaris2, freebsd and cygwin needs -D__EXTENSIONS__
79# linux needs -D_BSD_SOURCE
80#
81OPTIONS	= -DBIOS -D__EXTENSIONS__ -DMMU -DBOOTSYS -DMULTIO # -DSHOWDRV
82
83# Link with CP/M BIOS support,
84YAZE_OBJS     = yaze.o mem_mmu.o simz80.o simz80_wts.o ytimer.o ybios.o \
85		monitor.o keytran.o conin.o
86# or link as a naked Z80
87#YAZE_OBJS    = yaze.o simz80.o io.o
88
89# Keyboard translation test program
90KT_OBJS       = keytest.o conin.o keytran.o nulrq.o
91
92# -lreadline -lcurses -liberty if you defined USE_GNU_READLINE
93#  (you don't need -liberty on linux or BSD systems)
94#
95#LIBS	      = -lreadline -lncurses
96LIBS	      = -lrt
97
98# a bsd-like install program (/usr/ucb/install on Solaris2)
99INSTALL	      = install
100
101
102###### you should not need to change anything below this line ######
103# CWARN	      = -ansi -pedantic -Wall -Wshadow \
104#		-Wpointer-arith -Wnested-externs -Winline
105CWARN	      = -ansi -pedantic -Wall -Wshadow \
106		-Wpointer-arith -Wnested-externs -Winline \
107		-Wno-attributes -Wno-char-subscripts -Wno-unused-variable
108# CWARN	      = -ansi -Wall
109CFLAGS        =	$(CWARN) $(OPTIMIZE) $(OPTIONS) -DLIBDIR=\"$(LIBDIR)/\" \
110		-DBUILD=\"$(BUILD)\"
111
112SRCS	      = yaze.c mem_mmu.c simz80.c simz80_wts.c ytimer.c io.c ybios.c \
113		monitor.c cdm.c \
114		conin.c keytest.c keytran.c nulrq.c \
115		chan.h ktt.h mem_mmu.h simz80.h yaze.h ybios.h ytypes.h \
116		ktt.z80 keycodes.z80
117
118DOC	      = COPYING yaze.1 cdm.1 cpm.1 z80.1 ChangeLog \
119		doc docfiles.txt install_doc.sh \
120		doc_html docfiles_html.txt doc_cpmhelp_html.txt \
121		install_doc_html.sh
122
123TEST	      =	test/prelim.z80 test/zexlax.pl test/zexall.z80 test/zexdoc.z80 \
124		test/prelim.com test/zexall.com test/zexdoc.com \
125		test/savage.pas test/savage.com test/sys.azm test/sys.com \
126		test/timex.com \
127		TODO test.c md5 md5_V1.10 di
128
129DISTRIB       =	Makefile_linux_32_i586 \
130		Makefile_linux_64_amd_athlon64 \
131		Makefile_linux_64_intel_corei7 \
132		Makefile_linux_64_intel_nocona \
133		Makefile_solaris_cc-sparcv9 \
134		Makefile_solaris_cc-x86_64 \
135		Makefile_solaris_gcc-sparcv9 \
136		Makefile_solaris_gcc-x86_64 \
137		Makefile_freebsd \
138		Makefile Makefile_first \
139		Makefile_cygwin_32 \
140		Makefile_cygwin_64_core2duo \
141		Makefile_cygwin_64_corei7 \
142		Makefile_cygwin_64_generic \
143		Makefile_Orange_Pi_Plus2_ARMv7 \
144		Makefile_radxa_Rock_RockPro_RockLite \
145		Makefile_Raspberry_Pi_1 \
146		Makefile_Raspberry_Pi_2_Model_B \
147		Makefile_Raspberry_Pi_3_Model_B_ARMv7_32Bit \
148		Makefile_Raspberry_Pi_3_Model_B_ARMv8_64Bit \
149		Makefile_Raspberry_Pi_4_Model_B_ARMv7_32Bit \
150		Makefile_Raspberry_Pi_4_Model_B_ARMv8_64Bit \
151		m2.ktt sample.ktt yaze.ktt \
152		gen_windows yaze.bat .yazerc_winbinaries \
153		.minttyrc md5summer.exe metapad.exe metapad.ini \
154		simz80.pl .yazerc yaze.boot $(SRCS) $(DOC) \
155		yaze-cpm3_80-columns_46-lines.boot \
156		yaze.sh doc_ydskfiles.txt doc_ydskfiles_windows.txt \
157		install_disks.sh \
158		bios3.ydsk yaze-cpm3.boot \
159		BOOT_UTILS.ydsk BOOT_UTILS_windows.ydsk testdsk.ydsk \
160		CPM3_SYS.ydsk kermit_szrz.ydsk \
161		zinc.ydsk spl.ydsk\
162		test-utils-1.10.ydsk TODO \
163		unixlike.ydsk turbo-modula-2.ydsk \
164		hi-c-z280-compiler.ydsk mmu-utils.ydsk \
165		disksort disksort.ydsk # $(TEST)
166
167all:		yaze_bin cdm keytest
168
169yaze_bin:	$(YAZE_OBJS)
170		$(CC) $(CFLAGS) $(YAZE_OBJS) $(LIBS) -o $@
171		ln -f -s yaze.sh yaze
172
173keytest:	$(KT_OBJS)
174		$(CC) $(CFLAGS) $(KT_OBJS) -o $@
175
176simz80.c:	simz80.pl
177		rm -f simz80.c
178		perl -w simz80.pl >simz80.c
179		chmod a-w simz80.c
180
181cdm:		cdm.o
182		$(CC) $(CFLAGS) cdm.o $(LIBS) -o $@
183
184install:	all
185		rm -rf $(LIBDIR)
186		mkdir -p $(LIBDIR)
187		mkdir -p $(MANDIR)
188		$(INSTALL) -s -c -m 755 yaze_bin $(BINDIR)
189		$(INSTALL) -s -c -m 755 cdm $(BINDIR)
190		$(INSTALL) -c -m 755 yaze $(BINDIR)
191		ln -f -s $(BINDIR)/yaze $(BINDIR)/cpm
192		ln -f -s $(BINDIR)/yaze $(BINDIR)/z80
193		$(INSTALL) -c -m 644 yaze-cpm3.boot $(LIBDIR)
194		$(INSTALL) -c -m 644 yaze.boot $(LIBDIR)
195		$(INSTALL) -c -m 644 m2.ktt $(LIBDIR)
196		$(INSTALL) -c -m 644 sample.ktt $(LIBDIR)
197		$(INSTALL) -c -m 644 yaze.ktt $(LIBDIR)
198		$(INSTALL) -c -m 644 yaze.1 $(MANDIR)
199		$(INSTALL) -c -m 644 cdm.1 $(MANDIR)
200		$(INSTALL) -c -m 644 cpm.1 $(MANDIR)
201		$(INSTALL) -c -m 644 z80.1 $(MANDIR)
202		/bin/sh install_disks.sh $(DSKDIR)
203		/bin/sh install_doc.sh $(DOCDIR)
204		/bin/sh install_doc_html.sh $(DOCHTMLDIR)
205		(cd $(LIBDIR); \
206		rm -f md5 /tmp/md5.yaze-ag; \
207		find . -type f -exec md5sum -b {} >>/tmp/md5.yaze-ag \; ; \
208		mv /tmp/md5.yaze-ag md5)
209
210md5:		$(DISTRIB)
211		(P=`pwd`; D=`basename $$P`; \
212			rm -f md5_$$D; \
213			ls md5_y* >md5.list; \
214			ls YAZE-AG-* >yaze-ag.list; \
215			md5sum -b $(DISTRIB) `cat md5.list` \
216						`cat yaze-ag.list` \
217						`cat windows.txt` \
218						`cat docfiles.txt` \
219						`cat docfiles_html.txt` \
220			| grep -v 'md5_$$D' >md5_$$D; )
221		rm -f md5.list
222		rm -f yaze-ag.list
223
224tar:		$(DISTRIB) md5
225		ls md5_y* >md5.list
226		ls YAZE-AG-* >yaze-ag.list
227		(P=`pwd`; D=`basename $$P`; cd ..; \
228			for f in $(DISTRIB) `cat $$D/md5.list` `cat $$D/yaze-ag.list`; \
229				do echo $$D/$$f; done \
230			| tar -T - -cf - | gzip -9 >$$D/$$D.tar.gz)
231		rm -f md5.list
232		rm -f yaze-ag.list
233
234clean:;		rm -f *.o *~ core
235		rm -f *.i *.s
236		rm -f yaze
237
238yaze.o:		yaze.c simz80.h yaze.h mem_mmu.h ytypes.h
239ybios.o:	ybios.c simz80.h yaze.h ybios.h mem_mmu.h ytypes.h ktt.h
240mem_mmu.o:	mem_mmu.c mem_mmu.h simz80.h ytypes.h
241simz80.o:	simz80.c simz80.h mem_mmu.h ytypes.h
242simz80_wts.o:	simz80_wts.c simz80.h mem_mmu.h ytypes.h
243ytimer.o:	ytimer.c ytypes.h
244monitor.o:	monitor.c yaze.h ybios.h chan.h mem_mmu.h ytypes.h
245keytran.o:	keytran.c ktt.h ytypes.h
246conin.o:	conin.c ytypes.h ktt.h chan.h
247
248keytest.o:	keytest.c ytypes.h ktt.h
249nulrq.o:	nulrq.c
250
251