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