-
Notifications
You must be signed in to change notification settings - Fork 9
/
Makefile
1551 lines (1270 loc) · 41.3 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#
# Makefile - the EmuTOS overbloated Makefile
#
# Copyright (C) 2001-2017 The EmuTOS development team.
#
# This file is distributed under the GPL, version 2 or at your
# option any later version. See doc/license.txt for details.
#
# The Makefile is suitable for Linux and Cygwin setups.
# only GCC (cross-mint) is supported. GNU-make *is* required.
#
# for a list of main targets do
# make help
#
# C code (C) and assembler (S) source go in directories bios/, bdos/, ...
# To modify the list of source code files, update the variables xxx_csrc
# and xxx_ssrc below; each directories has a different set of build flags
# indicated in variables xxx_copts and xxx_sopts below.
# (xxx being the directory name)
#
# General settings
#
MAKEFLAGS = --no-print-directory
#
# EmuTOS version
#
include version.mk
#
# the country. should be a lowercase two-letter code as found in
# the table in tools/mkheader.c and bios/country.c
#
COUNTRY = us
#
# Unique-country support: if UNIQUE is defined, then
# EmuTOS will be built with only one country.
#
# example: make UNIQUE=fr 256
#
DEF =
UNIQUE =
ifneq (,$(UNIQUE))
COUNTRY = $(UNIQUE)
endif
#
# Choose the features that should be included into EmuTOS
#
# Include the AES and EmuDesk
WITH_AES=1
# Include EmuCON
WITH_CLI=1
#
# crude machine detection (Unix or Cygwin)
#
ifneq (,$(findstring CYGWIN,$(shell uname)))
# CYGWIN-dependent stuff
CORE = *.stackdump
DDOPTS = iflag=binary oflag=binary
else
# ordinary Unix stuff
CORE = core
DDOPTS =
endif
#
# test for localconf.h
#
ifneq (,$(wildcard localconf.h))
LOCALCONF = -DLOCALCONF
else
LOCALCONF =
endif
#
# GEN_SRC will accumulate the all the generated source files.
# Consequences for such files are:
# - they are automatically built before generating makefile.dep
# - they are automatically deleted on make clean
#
GEN_SRC =
#
# TOCLEAN will accumulate over the Makefile the names of files to remove
# when doing make clean; temporary Makefile files are *.tmp
#
TOCLEAN = *~ */*~ $(CORE) *.tmp obj/*.h $(GEN_SRC)
#
# NODEP will accumulate the names of the targets which does not need to include
# makefile.dep, to avoid rebuilding that file when not necessary.
# This includes targets not using $(CC) and targets recursively invoking $(MAKE).
#
NODEP := %.c %.h %.pot
# Emutos requires C90 with some GNU extensions.
CSTANDARD = -std=gnu90
#
# compilation flags
#
ifdef RPI
# Raspberry PI is always ELF
ARCH = arm
MACHINE ?= raspi
ELF = 1
TOOLCHAIN_PREFIX = arm-none-eabi-
TOOLCHAIN_CFLAGS = -fleading-underscore -fno-reorder-functions -DELF_TOOLCHAIN
ifeq (4,$(RPI))
WITH_USB = 0
else
WITH_USB = 1
endif
else # Not Raspberry PI
ifeq (1,$(COLDFIRE))
ARCH += coldfire
endif
ARCH += m68k
MACHINE ?= atari
# Override with 1 to use the ELF toolchain instead of the MiNT one
ELF ?= 0
ifeq (1,$(ELF))
# Standard ELF toolchain
TOOLCHAIN_PREFIX = m68k-elf-
TOOLCHAIN_CFLAGS = -fleading-underscore -Wa,--register-prefix-optional -fno-reorder-functions -DELF_TOOLCHAIN
else
# MiNT toolchain
TOOLCHAIN_PREFIX = m68k-atari-mint-
TOOLCHAIN_CFLAGS =
endif
WITH_USB = 0
endif
# indent flags
INDENT = indent -kr
# Linker with relocation information and binary output (image)
LD = $(CC) $(MULTILIBFLAGS) -nostartfiles -nostdlib
LIBS = -lgcc
LDFLAGS = -Wl,-T,obj/emutospp.ld
PCREL_LDFLAGS = -Wl,--oformat=binary,-Ttext=0,--entry=0
# C compiler
CC = $(TOOLCHAIN_PREFIX)gcc
CPP = $(CC) -E
ifndef RPI
CPUFLAGS = -m68000
MULTILIBFLAGS = $(CPUFLAGS) -mshort
else
ifeq (1,$(RPI))
CPUFLAGS = -march=armv6k -mtune=arm1176jzf-s -marm -mfpu=vfp -mfloat-abi=hard
IMG_RPI = kernel.img
else ifeq (2,$(RPI))
CPUFLAGS = -march=armv7-a -marm -mfpu=neon-vfpv4 -mfloat-abi=hard
IMG_RPI = kernel7.img
else ifeq (3,$(RPI))
CPUFLAGS = -march=armv8-a -mtune=cortex-a53 -marm -mfpu=neon-fp-armv8 -mfloat-abi=hard
IMG_RPI = kernel8-32.img
else ifeq (4,$(RPI))
CPUFLAGS = -march=armv8-a -mtune=cortex-a72 -marm -mfpu=neon-fp-armv8 -mfloat-abi=hard
IMG_RPI = kernel7l.img
else
$(error Unknown Raspberry PI version $(RPI). Use only 1, 2, 3, or 4)
endif
MULTILIBFLAGS = $(CPUFLAGS) -fsigned-char -g
endif
current_dir = $(filter-out .,$(word 1,$(subst /, ,$(dir $<))))
arch_subdirs = $(addprefix machine/,$(MACHINE)) $(addprefix arch/,$(ARCH))
include_dirs = $(addprefix include/,$(arch_subdirs)) include $(if $(current_dir), $(addprefix $(current_dir)/,$(arch_subdirs)) $(current_dir))
INC = $(addprefix -I,$(include_dirs))
OTHERFLAGS = -fomit-frame-pointer -fno-common
# Optimization flags (affects ROM size and execution speed)
STANDARD_OPTFLAGS = -O2
SMALL_OPTFLAGS = -Os
BUILD_TOOLS_OPTFLAGS = -O
OPTFLAGS = $(STANDARD_OPTFLAGS)
WARNFLAGS = -Wall -Wundef -Wmissing-prototypes -Wstrict-prototypes
#-Wshadow
#-Werror
GCCVERSION := $(shell $(CC) -dumpversion 2>/dev/null | cut -d. -f1)
# add warning flags not supported by GCC v2
ifneq (,$(GCCVERSION))
ifneq (2,$(GCCVERSION))
WARNFLAGS += -Wold-style-definition -Wtype-limits
endif
endif
DEFINES = $(LOCALCONF) -DWITH_AES=$(WITH_AES) -DWITH_CLI=$(WITH_CLI) -DWITH_USB=$(WITH_USB) $(DEF)
CFLAGS = $(MULTILIBFLAGS) $(TOOLCHAIN_CFLAGS) $(CSTANDARD) $(OPTFLAGS) $(OTHERFLAGS) $(WARNFLAGS) $(INC) $(DEFINES)
CPPFLAGS = $(CFLAGS)
# The objdump utility (disassembler)
OBJDUMP = $(TOOLCHAIN_PREFIX)objdump
# The objcopy utility
OBJCOPY = $(TOOLCHAIN_PREFIX)objcopy
# the native C compiler, for tools
NATIVECC = gcc -ansi -pedantic $(WARNFLAGS) -W $(BUILD_TOOLS_OPTFLAGS)
#
# source code in bios/
#
# The source below must be the first to be linked
bios_src = startup.S
# These sources will be placed in ST-RAM by the linked script
bios_src += lowstram.c
# Other BIOS sources can be put in any order
bios_src += memory.S processor.S vectors.S bios.c xbios.c acsi.c \
biosmem.c blkdev.c chardev.c clock.c conout.c cookie.c country.c \
disk.c dma.c dmasound.c floppy.c font.c ide.c ikbd.c initinfo.c \
kprint.c lineainit.c machine.c \
mfp.c midi.c mouse.c nvram.c panicasm.S \
parport.c screen.c serport.c sound.c videl.c vt52.c xhdi.c \
delay.c sd.c memory2.c bootparams.c scsi.c
ifdef RPI
bios_src += vectorsasm.S aciaemu.c raspi_uart.c raspi_int.c \
raspi_mbox.c raspi_screen.c raspi_emmc.c
ifneq (1,$(RPI))
bios_src += cache_armv7.c cache_armv7_asm.S
endif
else
bios_src += aciavecs.S kprintasm.S linea.S natfeat.S natfeats.c \
pmmu030.c 68040_pmmu.S \
amiga.c amiga2.S aros.c aros2.S delayasm.S nova.c
endif
ifeq (1,$(COLDFIRE))
bios_src += coldfire.c coldfire2.S spi.c
endif
#
# usb bios extensions - based on USB code in FreeMint and Uboot
#
usb_src = usb.c ucd.c udd.c usb_api.c usb_hub.c udd_mouse.c
ifdef RPI
ifeq (4,$(RPI))
# TODO: USB support for RPI4
else
# RPI 1,2,3 have a DWC2 OTG usb controller
usb_src += ucd_dwc2.c
endif
endif
#
# source code in bdos/
#
bdos_src = bdosmain.c console.c fsbuf.c fsdir.c fsdrive.c fsfat.c fsglob.c \
fshand.c fsio.c fsmain.c fsopnclo.c iumem.c kpgmld.c osmem.c \
proc.c time.c umem.c rwa.S
#
# source code in util/
#
util_src = doprintf.c intmath.c langs.c memmove.c string.c miscasm.S \
nls.c setjmp.S
ifndef RPI
util_src += memset.S nlsasm.S stringasm.S
endif
# The functions in the following modules are used by the AES and EmuDesk
ifeq ($(WITH_AES),1)
util_src += gemdos.c optimize.c rectfunc.c
ifndef RPI
util_src += optimopt.S
endif
endif
#
# source code in vdi/
#
vdi_src = vdi_entry.cS vdi_bezier.c vdi_col.c vdi_control.c vdi_esc.c \
vdi_fill.c vdi_gdp.c vdi_input.c vdi_line.c vdi_main.c \
vdi_marker.c vdi_misc.c vdi_mouse.c vdi_raster.c vdi_text.c \
vdi_textblit.c
ifdef RPI
vdi_src += raspi_mouse.c
endif
vdi_src += vdi_tblit.cS
ifneq (1,$(COLDFIRE))
ifndef RPI
vdi_src += vdi_blit.S
endif
endif
# The source below must be the last VDI one (doesn't contain any asm instructions, so safe for both arm and 68k)
vdi_src += endvdi.S
#
# source code in aes/
#
aes_src =
ifdef RPI
aes_src += gemasm_rpi.S gemstart_rpi.S gemdosif_rpi.S gemdosifc_rpi.c
else
aes_src += gemasm.S gemstart.S gemdosif.S
endif
aes_src += gemaplib.c gemasync.c gemctrl.c \
gemdisp.c gemevlib.c gemflag.c gemfmalt.c gemfmlib.c \
gemfslib.c gemgraf.c gemgrlib.c gemgsxif.c geminit.c geminput.c \
gemmnlib.c gemobed.c gemobjop.c gemoblib.c gempd.c gemqueue.c \
gemrslib.c gemsclib.c gemshlib.c gemsuper.c gemwmlib.c gemwrect.c \
gsx2.c gem_rsc.c mforms.c
#
# source code in desk/
#
desk_src =
ifdef RPI
desk_src += deskstart_rpi.S
else
desk_src += deskstart.S
endif
desk_src += deskmain.c gembind.c deskact.c deskapp.c deskdir.c \
deskfpd.c deskfun.c deskglob.c deskinf.c deskins.c deskobj.c \
deskpro.c deskrez.c deskrsrc.c desksupp.c deskwin.c \
desk_rsc.c icons.c
# The source below must be the last GEM one
desk_src += endgem.S
#
# source code in cli/ for EmuTOS console EmuCON
#
cli_src = cmdasm.S cmdmain.c cmdedit.c cmdexec.c cmdint.c cmdparse.c cmdutil.c
#
# specific CC -c options for specific directories
#
bios_copts =
# The USB code is conceptually part of the bios and needs access to the bios private headers
usb_copts = $(addprefix -Ibios/,$(arch_subdirs)) -Ibios
bdos_copts =
util_copts =
cli_copts =
vdi_copts =
aes_copts =
desk_copts =
#
# Makefile functions
#
# Shell command to get the address of a symbol
FUNCTION_SHELL_GET_SYMBOL_ADDRESS = printf 0x%08x $$(awk '/^ *0x[^ ]* *$(1)( |$$)/{print $$1}' $(2))
# Function to get the address of a symbol into a Makefile variable
# $(1) = symbol name
# $(2) = map file name
MAKE_SYMADDR = $(shell $(call FUNCTION_SHELL_GET_SYMBOL_ADDRESS,$(1),$(2)))
# Function to get the address of a symbol into a shell variable
# This is useful to make an action in the first line of a recipe,
# then to get the result on the second line.
# Makefile variables in recipe can't be used for that, because they are
# evaluated before executing all recipe lines (but after building prerequisites)
# $(1) = symbol name
# $(2) = map file name
SHELL_SYMADDR = $$($(call FUNCTION_SHELL_GET_SYMBOL_ADDRESS,$(1),$(2)))
# The following reference values have been gathered from major TOS versions
MEMBOT_TOS102 = 0x0000ca00
MEMBOT_TOS104 = 0x0000a84e
MEMBOT_TOS162 = 0x0000a832
MEMBOT_TOS206 = 0x0000ccb2
MEMBOT_TOS305 = 0x0000e6fc
MEMBOT_TOS404 = 0x0000f99c
#
# Directory selection depending on the features
#
# Core directories are essential for basic OS operation
core_dirs = bios bdos util
# Optional directories may be disabled for reduced features
optional_dirs = vdi
ifeq ($(WITH_AES),1)
optional_dirs += aes desk
endif
ifeq ($(WITH_CLI),1)
optional_dirs += cli
endif
ifeq ($(WITH_USB),1)
optional_dirs += usb
endif
dirs = $(core_dirs) $(optional_dirs)
arch_dirs = $(foreach A,$(ARCH),$(patsubst %,%/arch/$(A),$(dirs)))
machine_dirs = $(foreach M,$(MACHINE),$(patsubst %,%/machine/$(M),$(dirs)))
vpath %.c $(machine_dirs) $(arch_dirs) $(dirs)
vpath %.S $(machine_dirs) $(arch_dirs) $(dirs)
#
# country-specific settings
#
include country.mk
#
# everything should work fine below.
#
SRC = $(foreach d,$(dirs),$($(d)_src))
CORE_OBJ = $(foreach d,$(core_dirs),$(patsubst %,obj/%.o,$(basename $($(d)_src)))) $(FONTOBJ) obj/version.o
OPTIONAL_OBJ = $(foreach d,$(optional_dirs),$(patsubst %,obj/%.o,$(basename $($(d)_src))))
OBJECTS = $(CORE_OBJ) $(OPTIONAL_OBJ)
#
# production targets
#
.PHONY: all
NODEP += all
all: help
.PHONY: help
NODEP += help
help: UNIQUE = $(COUNTRY)
help:
@echo "pTOS - Portable EmuTOS - Build Options:"
@echo "target meaning"
@echo "------ -------"
@echo "help EmuTOS make options"
@echo "help-atari EmuTOS for Atari build options"
@echo "help-cf EmuTOS for ColdFire build options"
@echo "help-amiga EmuTOS for Amiga build options"
@echo "help-arm EmuTOS for ARM build options"
@echo "version display the EmuTOS version"
@echo "clean"
@echo "expand expand tabs to spaces"
@echo "crlf convert all end of lines to LF"
@echo "charset check the charset of all the source files"
@echo "bugready set up files in preparation for 'bug update'"
@echo "gitready same as $(MAKE) expand crlf"
@echo "depend creates dependancy file (makefile.dep)"
@echo "dsm dsm.txt, an edited disassembly of MG"
@echo "*.dsm disassembly of any .c or almost any .img file"
@echo "release build the release archives into $(RELEASE_DIR)"
.PHONY: help-atari
NODEP += help-atari
help-atari:
@echo "pTOS - Portable EmuTOS - Atari Options:"
@echo "target meaning"
@echo "------ -------"
@echo "help EmuTOS make options"
@echo "help-atari EmuTOS for Atari build options"
@echo "help-cf EmuTOS for ColdFire build options"
@echo "help-amiga EmuTOS for Amiga build options"
@echo "help-arm EmuTOS for ARM build options"
@echo "version display the EmuTOS version"
@echo "clean"
@echo "192 $(ROM_192), EmuTOS ROM padded to size 192 KB"
@echo "256 $(ROM_256), EmuTOS ROM padded to size 256 KB"
@echo "512 $(ROM_512), EmuTOS ROM padded to size 512 KB"
@echo "aranym $(ROM_ARANYM), suitable for ARAnyM"
@echo "prg emutos.prg, a RAM tos"
@echo "flop $(EMUTOS_ST), a bootable floppy with RAM tos"
@echo "all192 build all 192 KB images"
@echo "all256 build all 256 KB images"
@echo "allprg build all emutos*.prg"
@echo "allflop build all emutos*.st"
@echo "cart $(ROM_CARTRIDGE), EmuTOS as a diagnostic cartridge"
.PHONY: help-cf
NODEP += help-cf
help-cf:
@echo "pTOS - Portable EmuTOS - ColdFire Options:"
@echo "target meaning"
@echo "------ -------"
@echo "help EmuTOS make options"
@echo "help-atari EmuTOS for Atari build options"
@echo "help-cf EmuTOS for ColdFire build options"
@echo "help-amiga EmuTOS for Amiga build options"
@echo "help-arm EmuTOS for ARM build options"
@echo "version display the EmuTOS version"
@echo "clean"
@echo "firebee $(SREC_FIREBEE), to be flashed on the FireBee"
@echo "firebee-prg emutos.prg, a RAM tos for the FireBee"
@echo "m548x-dbug $(SREC_M548X_DBUG), EmuTOS-RAM for dBUG on ColdFire Evaluation Boards"
@echo "m548x-bas $(SREC_M548X_BAS), EmuTOS for BaS_gcc on ColdFire Evaluation Boards"
@echo "m548x-prg emutos.prg, a RAM tos for ColdFire Evaluation Boards with BaS_gcc"
.PHONY: help-amiga
NODEP += help-amiga
help-amiga:
@echo "pTOS - Portable EmuTOS - Amiga Options:"
@echo "target meaning"
@echo "------ -------"
@echo "help EmuTOS make options"
@echo "help-atari EmuTOS for Atari build options"
@echo "help-cf EmuTOS for ColdFire build options"
@echo "help-amiga EmuTOS for Amiga build options"
@echo "help-arm EmuTOS for ARM build options"
@echo "version display the EmuTOS version"
@echo "clean"
@echo "amiga $(ROM_AMIGA), EmuTOS ROM for Amiga hardware"
@echo "amigavampire $(VAMPIRE_ROM_AMIGA), EmuTOS ROM for Amiga optimized for Vampire V2"
@echo "amigakd $(AMIGA_KICKDISK), EmuTOS as Amiga 1000 Kickstart disk"
@echo "amigaflop $(EMUTOS_ADF), EmuTOS RAM as Amiga boot floppy"
@echo "amigaflopvampire $(EMUTOS_VAMPIRE_ADF), EmuTOS RAM as Amiga boot floppy optimized for Vampire V2"
@echo "aros read and edit Makefile, search for AROS"
.PHONY: help-arm
NODEP += help-arm
help-arm:
@echo "pTOS - Portable EmuTOS - ARM Options:"
@echo "target meaning"
@echo "------ -------"
@echo "help EmuTOS make options"
@echo "help-atari EmuTOS for Atari build options"
@echo "help-cf EmuTOS for ColdFire build options"
@echo "help-amiga EmuTOS for Amiga build options"
@echo "help-arm EmuTOS for ARM build options"
@echo "version display the EmuTOS version"
@echo "clean"
@echo "rpi1 kernel.img, for RPi 0/A/A+/B/B+/CM0"
@echo "rpi2 kernel7.img, for RPi 2B+"
@echo "rpi3 kernel8-32.img, for RPi 3/3+/CM3"
@echo "rpi4 kernel7l.img, for RPi 4/400"
# Display the EmuTOS version
.PHONY: version
NODEP += version
version:
@echo '$(VERSION)'
#
# Preprocess the linker script, to allow #include, #define, #if, etc.
#
TOCLEAN += obj/*.ld
obj/emutospp.ld: emutos.ld include/config.h tosvars.ld
$(CPP) $(CPPFLAGS) -P -x c $< -o $@
#
# the maps must be built at the same time as the images, to enable
# one generic target to deal with all edited disassembly.
#
TOCLEAN += *.img *.map *.elf
ifdef RPI
EMUTOS_IMG = emutos.elf
LDFLAGS += -Wl,-build-id=none
else
EMUTOS_IMG = emutos.img
endif
$(EMUTOS_IMG): $(OBJECTS) obj/emutospp.ld Makefile
$(LD) $(CORE_OBJ) $(LIBS) $(OPTIONAL_OBJ) $(LIBS) $(LDFLAGS) -Wl,-Map=emutos.map -o $(EMUTOS_IMG)
@if [ $$(($$(awk '/^\.data /{print $$3}' emutos.map))) -gt 0 ]; then \
echo "### Warning: The DATA segment is not empty."; \
echo "### Please examine emutos.map and use \"const\" where appropriate."; \
fi
@echo "# TEXT=$(call SHELL_SYMADDR,__text,emutos.map)"\
" STKBOT=$(call SHELL_SYMADDR,_stkbot,emutos.map)"\
" LOWSTRAM=$(call SHELL_SYMADDR,__low_stram_start,emutos.map)"\
" BSS=$(call SHELL_SYMADDR,__bss,emutos.map)"\
" MEMBOT=$(call SHELL_SYMADDR,__end_os_stram,emutos.map)"
#
# 128kB Image
#
ROM_128 = etos128k.img
$(ROM_128): ROMSIZE = 128
$(ROM_128): $(EMUTOS_IMG) mkrom
./mkrom pad $(ROMSIZE)k $< $(ROM_128)
#
# 192kB Image
#
ROM_192 = etos192$(UNIQUE).img
.PHONY: 192
NODEP += 192
192: UNIQUE = $(COUNTRY)
192: OPTFLAGS = $(SMALL_OPTFLAGS)
192: override DEF += -DTARGET_192
192: WITH_CLI = 0
192:
$(MAKE) DEF='$(DEF)' OPTFLAGS=$(OPTFLAGS) WITH_CLI=$(WITH_CLI) UNIQUE=$(UNIQUE) ROM_192=$(ROM_192) $(ROM_192)
@MEMBOT=$(call SHELL_SYMADDR,__end_os_stram,emutos.map);\
echo "# RAM used: $$(($$MEMBOT)) bytes ($$(($$MEMBOT - $(MEMBOT_TOS102))) bytes more than TOS 1.02)"
$(ROM_192): ROMSIZE = 192
$(ROM_192): $(EMUTOS_IMG) mkrom
./mkrom pad $(ROMSIZE)k $< $(ROM_192)
#
# 256kB Image
#
ROM_256 = etos256$(UNIQUE).img
.PHONY: 256
NODEP += 256
256: UNIQUE = $(COUNTRY)
256: OPTFLAGS = $(SMALL_OPTFLAGS)
256: override DEF += -DTARGET_256
256:
$(MAKE) DEF='$(DEF)' OPTFLAGS=$(OPTFLAGS) UNIQUE=$(UNIQUE) ROM_256=$(ROM_256) $(ROM_256)
@MEMBOT=$(call SHELL_SYMADDR,__end_os_stram,emutos.map);\
echo "# RAM used: $$(($$MEMBOT)) bytes ($$(($$MEMBOT - $(MEMBOT_TOS162))) bytes more than TOS 1.62)"
$(ROM_256): ROMSIZE = 256
$(ROM_256): $(EMUTOS_IMG) mkrom
./mkrom pad $(ROMSIZE)k $< $(ROM_256)
#
# 512kB Image (for Falcon)
#
ROM_512 = etos512k.img
SYMFILE = $(addsuffix .sym,$(basename $(ROM_512)))
.PHONY: 512
512: override DEF += -DTARGET_512
512: $(ROM_512) $(SYMFILE)
@MEMBOT=$(call SHELL_SYMADDR,__end_os_stram,emutos.map);\
echo "# RAM used: $$(($$MEMBOT)) bytes ($$(($$MEMBOT - $(MEMBOT_TOS404))) bytes more than TOS 4.04)"
$(ROM_512): ROMSIZE = 512
$(ROM_512): $(EMUTOS_IMG) mkrom
./mkrom pad $(ROMSIZE)k $< $(ROM_512)
.PHONY: falcon
NODEP += falcon
falcon: help-atari
#
# ARAnyM Image
#
ROM_ARANYM = emutos-aranym.img
.PHONY: aranym
NODEP += aranym
aranym: override DEF += -DMACHINE_ARANYM
aranym: CPUFLAGS = -m68040
aranym:
@echo "# Building ARAnyM EmuTOS into $(ROM_ARANYM)"
$(MAKE) CPUFLAGS=$(CPUFLAGS) DEF='$(DEF)' ROM_512=$(ROM_ARANYM) $(ROM_ARANYM)
@MEMBOT=$(call SHELL_SYMADDR,__end_os_stram,emutos.map);\
echo "# RAM used: $$(($$MEMBOT)) bytes ($$(($$MEMBOT - $(MEMBOT_TOS404))) bytes more than TOS 4.04)"
#
# Diagnostic Cartridge Image
#
TOCLEAN += *.stc
ROM_CARTRIDGE = etoscart.img
.PHONY: cart
NODEP += cart
cart: OPTFLAGS = $(SMALL_OPTFLAGS)
cart: override DEF += -DTARGET_CART
cart: WITH_AES = 0
cart:
@echo "# Building Diagnostic Cartridge EmuTOS into $(ROM_CARTRIDGE)"
$(MAKE) OPTFLAGS=$(OPTFLAGS) DEF='$(DEF)' UNIQUE=$(COUNTRY) WITH_AES=$(WITH_AES) ROM_128=$(ROM_CARTRIDGE) $(ROM_CARTRIDGE)
./mkrom stc $(EMUTOS_IMG) emutos.stc
@MEMBOT=$(call SHELL_SYMADDR,__end_os_stram,emutos.map);\
echo "# RAM used: $$(($$MEMBOT)) bytes ($$(($$MEMBOT - $(MEMBOT_TOS102))) bytes more than TOS 1.02)"
#
# Amiga Image
#
TOCLEAN += *.rom
ROM_AMIGA = emutos-amiga.rom
AMIGA_DEFS =
.PHONY: aros
NODEP += aros
aros: help-amiga
# AROS support is disabled by default due to license issues
AROS = 0
ifeq (1,$(AROS))
AMIGA_DEFS += -DCONF_WITH_AROS=1
endif
.PHONY: amiga
NODEP += amiga
amiga: UNIQUE = $(COUNTRY)
amiga: OPTFLAGS = $(SMALL_OPTFLAGS)
amiga: MACHINE = amiga
amiga: override DEF += -DTARGET_AMIGA_ROM $(AMIGA_DEFS)
amiga:
@echo "# Building Amiga EmuTOS into $(ROM_AMIGA)"
$(MAKE) CPUFLAGS=$(CPUFLAGS) DEF='$(DEF)' OPTFLAGS=$(OPTFLAGS) UNIQUE=$(UNIQUE) ROM_AMIGA=$(ROM_AMIGA) MACHINE=$(MACHINE) $(ROM_AMIGA)
@MEMBOT=$(call SHELL_SYMADDR,__end_os_stram,emutos.map);\
echo "# RAM used: $$(($$MEMBOT)) bytes ($$(($$MEMBOT - $(MEMBOT_TOS162))) bytes more than TOS 1.62)"
$(ROM_AMIGA): $(EMUTOS_IMG) mkrom
./mkrom amiga $< $(ROM_AMIGA)
# Special Amiga ROM optimized for Vampire V2
VAMPIRE_CPUFLAGS = -m68040
VAMPIRE_DEF = -DSTATIC_ALT_RAM_ADDRESS=0x08000000 -DSTATIC_ALT_RAM_SIZE=126UL*1024*1024
VAMPIRE_ROM_AMIGA = emutos-vampire.rom
.PHONY: amigavampire
NODEP += amigavampire
amigavampire: CPUFLAGS = $(VAMPIRE_CPUFLAGS)
amigavampire: override DEF += $(VAMPIRE_DEF)
amigavampire: ROM_AMIGA = $(VAMPIRE_ROM_AMIGA)
amigavampire: MACHINE = amiga
amigavampire: amiga
#
# Amiga Kickstart disk image for Amiga 1000
#
TOCLEAN += *.adf
AMIGA_KICKDISK = emutos-kickdisk.adf
.PHONY: amigakd
NODEP += amigakd
amigakd: amiga
./mkrom amiga-kickdisk $(ROM_AMIGA) $(AMIGA_KICKDISK)
#
# Raspberry PI kernel images
#
RPI_DEFS =
.PHONY: rpi1
NODEP += rpi1
rpi1: UNIQUE = $(COUNTRY)
rpi1: IMG_RPI = kernel.img
rpi1: OPTFLAGS = -O2
rpi1: override DEF += -DTARGET_RPI1 $(RPI_DEFS)
rpi1:
@echo "# Building Raspberry Pi 1 (and zero) EmuTOS into $(IMG_RPI)"
$(MAKE) RPI=1 WITH_CLI=0 DEF='$(DEF)' OPTFLAGS=$(OPTFLAGS) UNIQUE=$(UNIQUE) IMG_RPI=$(IMG_RPI) $(IMG_RPI)
@MEMBOT=$(call SHELL_SYMADDR,__end_os_stram,emutos.map);\
echo "# RAM used: $$(($$MEMBOT)) bytes ($$(($$MEMBOT - $(MEMBOT_TOS162))) bytes more than TOS 1.62)"
.PHONY: rpi2
NODEP += rpi2
rpi2: UNIQUE = $(COUNTRY)
rpi2: IMG_RPI = kernel7.img
rpi2: OPTFLAGS = -O2
rpi2: override DEF += -DTARGET_RPI2 $(RPI_DEFS)
rpi2:
@echo "# Building Raspberry Pi 2 EmuTOS into $(IMG_RPI)"
$(MAKE) RPI=2 WITH_CLI=0 DEF='$(DEF)' OPTFLAGS=$(OPTFLAGS) UNIQUE=$(UNIQUE) IMG_RPI=$(IMG_RPI) $(IMG_RPI)
@MEMBOT=$(call SHELL_SYMADDR,__end_os_stram,emutos.map);\
echo "# RAM used: $$(($$MEMBOT)) bytes ($$(($$MEMBOT - $(MEMBOT_TOS162))) bytes more than TOS 1.62)"
.PHONY: rpi3
NODEP += rpi3
rpi3: UNIQUE = $(COUNTRY)
rpi3: IMG_RPI = kernel8-32.img
rpi3: OPTFLAGS = -O2
rpi3: override DEF += -DTARGET_RPI3 $(RPI_DEFS)
rpi3:
@echo "# Building Raspberry Pi 3 EmuTOS into $(IMG_RPI)"
$(MAKE) RPI=3 WITH_CLI=0 DEF='$(DEF)' OPTFLAGS=$(OPTFLAGS) UNIQUE=$(UNIQUE) IMG_RPI=$(IMG_RPI) $(IMG_RPI)
@MEMBOT=$(call SHELL_SYMADDR,__end_os_stram,emutos.map);\
echo "# RAM used: $$(($$MEMBOT)) bytes ($$(($$MEMBOT - $(MEMBOT_TOS162))) bytes more than TOS 1.62)"
.PHONY: rpi4
NODEP += rpi4
rpi4: UNIQUE = $(COUNTRY)
rpi4: IMG_RPI = kernel7l.img
rpi4: OPTFLAGS = -O2
rpi4: override DEF += -DTARGET_RPI4 $(RPI_DEFS)
rpi4:
@echo "# Building Raspberry Pi 4 EmuTOS into $(IMG_RPI)"
$(MAKE) RPI=4 WITH_CLI=0 DEF='$(DEF)' OPTFLAGS=$(OPTFLAGS) UNIQUE=$(UNIQUE) IMG_RPI=$(IMG_RPI) $(IMG_RPI)
@MEMBOT=$(call SHELL_SYMADDR,__end_os_stram,emutos.map);\
echo "# RAM used: $$(($$MEMBOT)) bytes ($$(($$MEMBOT - $(MEMBOT_TOS162))) bytes more than TOS 1.62)"
$(IMG_RPI): $(EMUTOS_IMG)
$(OBJCOPY) $< -O binary $(IMG_RPI)
#
# ColdFire images
#
TOCLEAN += *.s19
SRECFILE = emutos.s19
LMA = $(error LMA must be set)
$(SRECFILE): $(EMUTOS_IMG)
$(OBJCOPY) -I binary -O srec --change-addresses $(LMA) $< $(SRECFILE)
CPUFLAGS_FIREBEE = -mcpu=5474
SREC_FIREBEE = emutosfb.s19
.PHONY: firebee
NODEP += firebee
firebee: override DEF += -DMACHINE_FIREBEE
firebee: CPUFLAGS = $(CPUFLAGS_FIREBEE)
firebee:
@echo "# Building FireBee EmuTOS into $(SREC_FIREBEE)"
$(MAKE) COLDFIRE=1 CPUFLAGS=$(CPUFLAGS) DEF='$(DEF)' LMA=0xe0600000 SRECFILE=$(SREC_FIREBEE) $(SREC_FIREBEE)
@MEMBOT=$(call SHELL_SYMADDR,__end_os_stram,emutos.map);\
echo "# RAM used: $$(($$MEMBOT)) bytes ($$(($$MEMBOT - $(MEMBOT_TOS404))) bytes more than TOS 4.04)"
.PHONY: firebee-prg
NODEP += firebee-prg
firebee-prg: OPTFLAGS = $(STANDARD_OPTFLAGS)
firebee-prg: override DEF += -DMACHINE_FIREBEE
firebee-prg: CPUFLAGS = $(CPUFLAGS_FIREBEE)
firebee-prg:
@echo "# Building FireBee $(EMUTOS_PRG)"
$(MAKE) COLDFIRE=1 CPUFLAGS=$(CPUFLAGS) DEF='$(DEF)' OPTFLAGS=$(OPTFLAGS) prg
CPUFLAGS_M548X = -mcpu=5475
.PHONY: m548x-prg
NODEP += m548x-prg
m548x-prg: OPTFLAGS = $(STANDARD_OPTFLAGS)
m548x-prg: override DEF += -DMACHINE_M548X -DCONF_WITH_BAS_MEMORY_MAP=1
m548x-prg: CPUFLAGS = $(CPUFLAGS_M548X)
m548x-prg:
@echo "# Building m548x $(EMUTOS_PRG)"
$(MAKE) COLDFIRE=1 CPUFLAGS=$(CPUFLAGS) DEF='$(DEF)' OPTFLAGS=$(OPTFLAGS) prg
SREC_M548X_DBUG = emutos-m548x-dbug.s19
.PHONY: m548x-dbug
NODEP += m548x-dbug
m548x-dbug: UNIQUE = $(COUNTRY)
m548x-dbug: override DEF += -DMACHINE_M548X
m548x-dbug: CPUFLAGS = $(CPUFLAGS_M548X)
m548x-dbug:
@echo "# Building M548x dBUG EmuTOS in $(SREC_M548X_DBUG)"
$(MAKE) COLDFIRE=1 CPUFLAGS=$(CPUFLAGS) DEF='$(DEF)' UNIQUE=$(UNIQUE) LMA=0x00e00000 SRECFILE=$(SREC_M548X_DBUG) $(SREC_M548X_DBUG)
@MEMBOT=$(call SHELL_SYMADDR,__end_os_stram,emutos.map);\
echo "# RAM used: $$(($$MEMBOT)) bytes ($$(($$MEMBOT - $(MEMBOT_TOS404))) bytes more than TOS 4.04)"
SREC_M548X_BAS = emutos-m548x-bas.s19
.PHONY: m548x-bas
NODEP += m548x-bas
m548x-bas: UNIQUE = $(COUNTRY)
m548x-bas: override DEF += -DMACHINE_M548X -DCONF_WITH_BAS_MEMORY_MAP=1
m548x-bas: CPUFLAGS = $(CPUFLAGS_M548X)
m548x-bas:
@echo "# Building M548x BaS_gcc EmuTOS in $(SREC_M548X_BAS)"
$(MAKE) COLDFIRE=1 CPUFLAGS=$(CPUFLAGS) DEF='$(DEF)' UNIQUE=$(UNIQUE) LMA=0xe0100000 SRECFILE=$(SREC_M548X_BAS) $(SREC_M548X_BAS)
@MEMBOT=$(call SHELL_SYMADDR,__end_os_stram,emutos.map);\
echo "# RAM used: $$(($$MEMBOT)) bytes ($$(($$MEMBOT - $(MEMBOT_TOS404))) bytes more than TOS 4.04)"
#
# Special variants of EmuTOS running in RAM instead of ROM.
# In this case, $(EMUTOS_IMG) needs to be loaded into RAM by some loader.
#
obj/ramtos.h: $(EMUTOS_IMG)
@echo '# Generating $@'
@printf \
'/* Generated from emutos.map */\n'\
'#define ADR_TEXT $(call MAKE_SYMADDR,__text,emutos.map)\n'\
'#define ADR_ALTRAM_REGIONS $(call MAKE_SYMADDR,_altram_regions,emutos.map)\n'\
>$@
#
# emutos.prg
#
EMUTOS_PRG = emutos$(UNIQUE).prg
TOCLEAN += emutos*.prg
.PHONY: prg
prg: $(EMUTOS_PRG)
@MEMBOT=$(call SHELL_SYMADDR,__end_os_stram,emutos.map);\
echo "# RAM used: $$(($$MEMBOT)) bytes"
obj/boot.o: obj/ramtos.h
# incbin dependencies are not automatically detected
obj/ramtos.o: $(EMUTOS_IMG)
$(EMUTOS_PRG): override DEF += -DTARGET_PRG
$(EMUTOS_PRG): OPTFLAGS = $(SMALL_OPTFLAGS)
$(EMUTOS_PRG): obj/minicrt.o obj/boot.o obj/bootram.o obj/ramtos.o
$(LD) $+ -lgcc -o $@ -s
#
# flop
#
EMUTOS_ST = emutos$(UNIQUE).st
TOCLEAN += emutos*.st mkflop
.PHONY: flop
NODEP += flop
flop: UNIQUE = $(COUNTRY)
flop:
$(MAKE) UNIQUE=$(UNIQUE) $(EMUTOS_ST)
@MEMBOT=$(call SHELL_SYMADDR,__end_os_stram,emutos.map);\
echo "# RAM used: $$(($$MEMBOT)) bytes"
$(EMUTOS_ST): override DEF += -DTARGET_FLOPPY
$(EMUTOS_ST): OPTFLAGS = $(SMALL_OPTFLAGS)
$(EMUTOS_ST): mkflop bootsect.img $(EMUTOS_IMG)
./mkflop bootsect.img $(EMUTOS_IMG) $@
bootsect.img : obj/bootsect.o obj/bootram.o
$(LD) $+ $(PCREL_LDFLAGS) -o $@
obj/bootsect.o: obj/ramtos.h
NODEP += mkflop
mkflop : tools/mkflop.c
$(NATIVECC) $< -o $@
#
# amigaflop
#
EMUTOS_ADF = emutos.adf
.PHONY: amigaflop
NODEP += amigaflop
amigaflop: UNIQUE = $(COUNTRY)
amigaflop: OPTFLAGS = $(SMALL_OPTFLAGS)
amigaflop: override DEF += -DTARGET_AMIGA_FLOPPY $(AMIGA_DEFS)
amigaflop:
$(MAKE) CPUFLAGS=$(CPUFLAGS) DEF='$(DEF)' OPTFLAGS=$(OPTFLAGS) UNIQUE=$(UNIQUE) EMUTOS_ADF=$(EMUTOS_ADF) $(EMUTOS_ADF)
@MEMBOT=$(call SHELL_SYMADDR,__end_os_stram,emutos.map);\
echo "# RAM used: $$(($$MEMBOT)) bytes"
EMUTOS_VAMPIRE_ADF = emutos-vampire.adf
.PHONY: amigaflopvampire
NODEP += amigaflopvampire
amigaflopvampire: override DEF += -DSTATIC_ALT_RAM_ADDRESS=0x08000000 $(AMIGA_DEFS)
amigaflopvampire: CPUFLAGS = -m68040
amigaflopvampire: EMUTOS_ADF = $(EMUTOS_VAMPIRE_ADF)
amigaflopvampire: amigaflop
# Convenient target to test amigaflopvampire on WinUAE
.PHONY: amigaflopwinuae
NODEP += amigaflopwinuae
amigaflopwinuae: override DEF += -DSTATIC_ALT_RAM_ADDRESS=0x40000000 $(AMIGA_DEFS)
amigaflopwinuae: CPUFLAGS = -m68040
amigaflopwinuae: amigaflop
$(EMUTOS_ADF): amigaboot.img $(EMUTOS_IMG) mkrom