1# Makefile for yaze-ag
2
3# TODO:
4# SFX von 2.40.4 mit aufnehmen
5# gen_windows mit aufnehmen
6
7BUILD = " (build for INTEL x86_64Bit (corei7))"
8
9# CC must be an ANSI-C compiler
10CC            =	gcc
11
12#where you want the binaries and manual page
13BINDIR	      = /usr/local/bin
14MANDIR	      = /usr/local/man/man1
15LIBDIR	      = /usr/local/lib/yaze
16DSKDIR        = $(LIBDIR)/disks
17DOCDIR        = $(LIBDIR)/doc
18DOCHTMLDIR    = $(LIBDIR)/doc_html
19
20#OPTIMIZE	= -g -m486
21#OPTIMIZE	= -g -save-temps -m486
22# OPTIMIZE	=
23# OPTIMIZE	= -O1
24# OPTIMIZE	= -O2
25# OPTIMIZE	= -O2 -save-temps
26# OPTIMIZE	= -O2 -save-temps -m486
27
28# optimizing with gcc 2.x.x
29#OPTIMIZE	= -O3 -m486
30
31# optimizing with gcc 3.x.x
32# (please search for your processor in "man gcc")
33# (tip: search first for "pentium3")
34#
35# -march=cpu-type
36#	Tune to cpu-type everything applicable about the gen-
37#	erated code, except for the ABI and the set of avail-
38#	able instructions.  The choices for cpu-type are i386,
39#	i486, i586, i686, pentium, pentium-mmx, pentiumpro,
40#	pentium2, pentium3, pentium4, k6, k6-2, k6-3, athlon,
41#	athlon-tbird, athlon-4, athlon-xp, athlon-mp,
42#	winchip-c6, winchip2 and c3.
43#
44#OPTIMIZE	= -O3 -march=i386
45#OPTIMIZE	= -O3 -march=i486
46#OPTIMIZE	= -O3 -march=i586
47#OPTIMIZE	= -O3 -march=i686
48#OPTIMIZE	= -O3 -march=pentium
49#OPTIMIZE	= -O3 -march=pentium-mmx
50#OPTIMIZE	= -O3 -march=pentiumpro
51#OPTIMIZE	= -O3 -march=pentium2
52#OPTIMIZE	= -O3 -march=pentium3
53#OPTIMIZE	= -O3 -march=pentium4m -mtune=pentium4m
54#OPTIMIZE	= -O3 -mtune=generic
55#OPTIMIZE	= -O3 -march=nocona	# 64 Bit Intel
56OPTIMIZE	= -O3 -m64 -march=native -mtune=native	# 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
114#
115#OPTIONS	= -DUCSD -DCYGWIN -DBIOS -D__EXTENSIONS__ # -DMMU -DBOOTSYS -DMULTIO # -DSHOWDRV
116OPTIONS	= -DCYGWIN -DBIOS -D_BSD_SOURCE -D__EXTENSIONS__ -DMMU -DBOOTSYS -DMULTIO # -DSHOWDRV
117
118# Link with CP/M BIOS support,
119YAZE_OBJS     = yaze.o mem_mmu.o simz80.o simz80_wts.o ytimer.o ybios.o \
120		monitor.o keytran.o conin.o
121# or link as a naked Z80
122#YAZE_OBJS    = yaze.o simz80.o io.o
123
124# Keyboard translation test program
125KT_OBJS       = keytest.o conin.o keytran.o nulrq.o
126
127# -lreadline -lcurses -liberty if you defined USE_GNU_READLINE
128#  (you don't need -liberty on linux or BSD systems)
129#
130#LIBS	      = -lreadline -lncurses
131LIBS	      =
132
133# a bsd-like install program (/usr/ucb/install on Solaris2)
134INSTALL	      = install
135
136
137###### you should not need to change anything below this line ######
138# CWARN	      = -ansi -pedantic -Wall -Wshadow \
139#		-Wpointer-arith -Wnested-externs -Winline
140CWARN	      = -pedantic -Wall -Wshadow \
141		-Wpointer-arith -Wnested-externs -Winline \
142		-Wno-attributes -Wno-char-subscripts -Wno-unused-variable
143# CWARN	      = -ansi -Wall
144CFLAGS        =	$(CWARN) $(OPTIMIZE) $(OPTIONS) -DLIBDIR=\"$(LIBDIR)/\" \
145		-DBUILD=\"$(BUILD)\"
146
147SRCS	      = yaze.c mem_mmu.c simz80.c simz80_wts.c ytimer.c io.c ybios.c \
148		monitor.c cdm.c \
149		conin.c keytest.c keytran.c nulrq.c \
150		chan.h ktt.h mem_mmu.h simz80.h yaze.h ybios.h ytypes.h \
151		ktt.z80 keycodes.z80
152
153DOC	      = COPYING yaze.1 cdm.1 cpm.1 z80.1 ChangeLog \
154		doc docfiles.txt install_doc.sh \
155		doc_html docfiles_html.txt doc_cpmhelp_html.txt \
156		install_doc_html.sh
157
158TEST	      =	test/prelim.z80 test/zexlax.pl test/zexall.z80 test/zexdoc.z80 \
159		test/prelim.com test/zexall.com test/zexdoc.com \
160		test/savage.pas test/savage.com test/sys.azm test/sys.com \
161		test/timex.com \
162		TODO test.c md5 md5_V1.10 di
163
164DISTRIB       =	Makefile_linux_32_i586 \
165		Makefile_linux_64_amd_athlon64 \
166		Makefile_linux_64_intel_corei7 \
167		Makefile_linux_64_intel_nocona \
168		Makefile_solaris_cc-sparcv9 \
169		Makefile_solaris_cc-x86_64 \
170		Makefile_solaris_gcc-sparcv9 \
171		Makefile_solaris_gcc-x86_64 \
172		Makefile_freebsd \
173		Makefile Makefile_first \
174		Makefile_cygwin_32 \
175		Makefile_cygwin_64_core2duo \
176		Makefile_cygwin_64_corei7 \
177		Makefile_cygwin_64_generic \
178		Makefile_Orange_Pi_Plus2_ARMv7 \
179		Makefile_radxa_Rock_RockPro_RockLite \
180		Makefile_Raspberry_Pi_1 \
181		Makefile_Raspberry_Pi_2_Model_B \
182		Makefile_Raspberry_Pi_3_Model_B_ARMv7_32Bit \
183		Makefile_Raspberry_Pi_3_Model_B_ARMv8_64Bit \
184		Makefile_Raspberry_Pi_4_Model_B_ARMv7_32Bit \
185		Makefile_Raspberry_Pi_4_Model_B_ARMv8_64Bit \
186		m2.ktt sample.ktt yaze.ktt \
187		gen_windows yaze.bat .yazerc_winbinaries \
188		.minttyrc md5summer.exe metapad.exe metapad.ini \
189		simz80.pl .yazerc yaze.boot $(SRCS) $(DOC) \
190		yaze-cpm3_80-columns_46-lines.boot \
191		yaze.sh doc_ydskfiles.txt doc_ydskfiles_windows.txt \
192		install_disks.sh \
193		bios3.ydsk yaze-cpm3.boot \
194		BOOT_UTILS.ydsk BOOT_UTILS_windows.ydsk testdsk.ydsk \
195		CPM3_SYS.ydsk kermit_szrz.ydsk \
196		zinc.ydsk spl.ydsk\
197		test-utils-1.10.ydsk TODO \
198		unixlike.ydsk turbo-modula-2.ydsk \
199		hi-c-z280-compiler.ydsk mmu-utils.ydsk \
200		disksort disksort.ydsk # $(TEST)
201
202all:		yaze_bin cdm keytest
203
204yaze_bin:	$(YAZE_OBJS)
205		$(CC) $(CFLAGS) $(YAZE_OBJS) $(LIBS) -o $@
206		ln -f -s yaze.sh yaze
207
208keytest:	$(KT_OBJS)
209		$(CC) $(CFLAGS) $(KT_OBJS) -o $@
210
211simz80.c:	simz80.pl
212		rm -f simz80.c
213		perl -w simz80.pl >simz80.c
214		chmod a-w simz80.c
215
216cdm:		cdm.o
217		$(CC) $(CFLAGS) cdm.o $(LIBS) -o $@
218
219install:	all
220		rm -rf $(LIBDIR)
221		mkdir -p $(LIBDIR)
222		mkdir -p $(MANDIR)
223		$(INSTALL) -s -c -m 755 yaze_bin $(BINDIR)
224		$(INSTALL) -s -c -m 755 cdm $(BINDIR)
225		$(INSTALL) -c -m 755 yaze $(BINDIR)
226		ln -f -s $(BINDIR)/yaze $(BINDIR)/cpm
227		ln -f -s $(BINDIR)/yaze $(BINDIR)/z80
228		$(INSTALL) -c -m 644 yaze-cpm3.boot $(LIBDIR)
229		$(INSTALL) -c -m 644 yaze.boot $(LIBDIR)
230		$(INSTALL) -c -m 644 m2.ktt $(LIBDIR)
231		$(INSTALL) -c -m 644 sample.ktt $(LIBDIR)
232		$(INSTALL) -c -m 644 yaze.ktt $(LIBDIR)
233		$(INSTALL) -c -m 644 yaze.1 $(MANDIR)
234		$(INSTALL) -c -m 644 cdm.1 $(MANDIR)
235		$(INSTALL) -c -m 644 cpm.1 $(MANDIR)
236		$(INSTALL) -c -m 644 z80.1 $(MANDIR)
237		/bin/sh install_disks.sh $(DSKDIR)
238		/bin/sh install_doc.sh $(DOCDIR)
239		/bin/sh install_doc_html.sh $(DOCHTMLDIR)
240		(cd $(LIBDIR); \
241		rm -f md5 /tmp/md5.yaze-ag; \
242		find . -type f -exec md5sum -b {} >>/tmp/md5.yaze-ag \; ; \
243		mv /tmp/md5.yaze-ag md5)
244
245md5:		$(DISTRIB)
246		(P=`pwd`; D=`basename $$P`; \
247			rm -f md5_$$D; \
248			ls md5_y* >md5.list; \
249			ls YAZE-AG-* >yaze-ag.list; \
250			md5sum -b $(DISTRIB) `cat md5.list` \
251						`cat yaze-ag.list` \
252						`cat windows.txt` \
253						`cat docfiles.txt` \
254						`cat docfiles_html.txt` \
255			| grep -v 'md5_$$D' >md5_$$D; )
256		rm -f md5.list
257		rm -f yaze-ag.list
258
259tar:		$(DISTRIB) md5
260		ls md5_y* >md5.list
261		ls YAZE-AG-* >yaze-ag.list
262		(P=`pwd`; D=`basename $$P`; cd ..; \
263			for f in $(DISTRIB) `cat $$D/md5.list` `cat $$D/yaze-ag.list`; \
264				do echo $$D/$$f; done \
265			| tar -T - -cf - | gzip -9 >$$D/$$D.tar.gz)
266		rm -f md5.list
267		rm -f yaze-ag.list
268
269clean:;		rm -f *.o *~ core
270		rm -f *.i *.s
271		rm -f yaze
272
273yaze.o:		yaze.c simz80.h yaze.h mem_mmu.h ytypes.h
274ybios.o:	ybios.c simz80.h yaze.h ybios.h mem_mmu.h ytypes.h ktt.h
275mem_mmu.o:	mem_mmu.c mem_mmu.h simz80.h ytypes.h
276simz80.o:	simz80.c simz80.h mem_mmu.h ytypes.h
277simz80_wts.o:	simz80_wts.c simz80.h mem_mmu.h ytypes.h
278ytimer.o:	ytimer.c ytypes.h
279monitor.o:	monitor.c yaze.h ybios.h chan.h mem_mmu.h ytypes.h
280keytran.o:	keytran.c ktt.h ytypes.h
281conin.o:	conin.c ytypes.h ktt.h chan.h
282
283keytest.o:	keytest.c ytypes.h ktt.h
284nulrq.o:	nulrq.c
285
286