forked from emutos/emutos
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
1488 lines (1218 loc) · 41 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-2022 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_src below.
#
# General settings
#
MAKEFLAGS = --no-print-directory
#
# 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 =
# "all" must be the *first* rule of this Makefile. Don't move!
# Variable assignments are allowed before this, but *not* rules.
# Note: The first rule is used when make is invoked without argument.
# So "make" is actually a synonym of "make all", actually "make help".
.PHONY: all
NODEP += all
all: help
.PHONY: help
NODEP += help
help: UNIQUE = $(COUNTRY)
help:
@echo "target meaning"
@echo "------ -------"
@echo "help this help message"
@echo "version display the EmuTOS version"
@echo "192 etos192$(UNIQUE).img, EmuTOS ROM padded to size 192 KB"
@echo "256 etos256$(UNIQUE).img, EmuTOS ROM padded to size 256 KB"
@echo "512 etos512$(UNIQUE).img, EmuTOS ROM padded to size 512 KB"
@echo "1024 etos1024$(UNIQUE).img, EmuTOS ROM padded to size 1024 KB"
@echo "aranym $(ROM_ARANYM), optimized for ARAnyM"
@echo "firebee $(SREC_FIREBEE), to be flashed on the FireBee"
@echo "firebee-prg emutos.prg, a RAM tos for the FireBee"
@echo "amiga $(ROM_AMIGA), EmuTOS ROM for Amiga hardware"
@echo "amigavampire $(VAMPIRE_ROM_AMIGA), EmuTOS ROM for Amiga optimized for Vampire V2"
@echo "v4sa $(V4_ROM_AMIGA), EmuTOS ROM for Amiga Vampire V4 Standalone"
@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 "lisaflop $(EMUTOS_DC42), EmuTOS RAM as Apple Lisa boot floppy"
@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"
@echo "prg emutos.prg, a RAM tos"
@echo "prg256 $(EMU256_PRG), a RAM tos for ST/STe systems"
@echo "flop $(EMUTOS_ST), a bootable floppy with RAM tos"
@echo "pak3 $(ROM_PAK3), suitable for PAK/3 systems"
@echo "cart $(ROM_CARTRIDGE), EmuTOS as a diagnostic cartridge"
@echo "clean remove temporary files"
@echo "Use '$(MAKE) help-develop' for development-oriented targets"
@echo "Use '$(MAKE) help-multi' for multi-image targets"
.PHONY: help-develop
NODEP += help-develop
help-develop:
@echo "target meaning"
@echo "------ -------"
@echo "help-develop this help message"
@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 "dsm dsm.txt, an edited disassembly of emutos.img"
@echo "release build the release archives into $(RELEASE_DIR)"
@echo "release-clean remove the release archives"
.PHONY: help-multi
NODEP += help-multi
help-multi:
@echo "target meaning"
@echo "------ -------"
@echo "help-multi this help message"
@echo "all192 all 192 KB images"
@echo "all256 all 256 KB images"
@echo "all512 all 512 KB images"
@echo "allpak3 all PAK/3 images"
@echo "allprg all emutos*.prg"
@echo "allprg256 all emu256*.prg"
@echo "allflop all emutos*.st"
@echo "allfirebee all FireBee srec files"
#
# EmuTOS version
#
include version.mk
# Display the EmuTOS version
.PHONY: version
NODEP += version
version:
@echo '$(VERSION)'
#
# 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 =
UNIQUEARG =
ifneq (,$(UNIQUE))
COUNTRY = $(UNIQUE)
UNIQUEARG = -u$(UNIQUE)
endif
#
# Choose the features that should be included into EmuTOS
#
# Include the AES and EmuDesk
WITH_AES=0
# 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
LOCALCONFINFO = \n\#\#\# NOTE: Configuration settings from localconf.h were used.\n
else
LOCALCONF =
LOCALCONFINFO =
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)
#
# Don't update makefile.dep when the user asks to generate source files
# from the command line. Does this really happen?
#
NODEP += %.c %.h %.pot
#
# compilation flags
#
# 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 --param=min-pagesize=0 -DELF_TOOLCHAIN
else
# MiNT toolchain
TOOLCHAIN_PREFIX = m68k-atari-mint-
TOOLCHAIN_CFLAGS =
endif
# indent flags
INDENT = indent -kr
# Archiver
AR = $(TOOLCHAIN_PREFIX)ar
ARFLAGS = rc
# 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
CPUFLAGS = -m68000
MULTILIBFLAGS = $(CPUFLAGS) -mshort
INC = -Iinclude
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 =
WARNFLAGS += -Wall
WARNFLAGS += -Werror=undef
WARNFLAGS += -Werror=missing-prototypes
WARNFLAGS += -Werror=strict-prototypes
WARNFLAGS += -Werror=implicit-function-declaration
WARNFLAGS += -Werror=format
WARNFLAGS += -Werror=redundant-decls
WARNFLAGS += -Werror=format-extra-args
#WARNFLAGS += -Werror=unused-function
#WARNFLAGS += -Wshadow
#WARNFLAGS += -Werror
GCCVERSION := $(shell $(CC) -dumpversion | cut -d. -f1)
# add warning flags not supported by GCC v2
ifneq (,$(GCCVERSION))
ifneq (2,$(GCCVERSION))
WARNFLAGS += -Werror=old-style-definition
WARNFLAGS += -Werror=type-limits
endif
endif
DEFINES = $(LOCALCONF) -DWITH_AES=$(WITH_AES) -DWITH_CLI=$(WITH_CLI) $(DEF)
CFLAGS_COMPILE = $(TOOLCHAIN_CFLAGS) $(OPTFLAGS) $(OTHERFLAGS) $(WARNFLAGS)
CFLAGS = $(MULTILIBFLAGS) $(CFLAGS_COMPILE) $(INC) $(DEFINES)
CPPFLAGS = $(CFLAGS)
ifeq (1,$(LTO))
# Link Time Optimization
LTOFLAGS = -flto=auto
CFLAGS += $(LTOFLAGS)
LDFLAGS += $(LTOFLAGS) $(CFLAGS_COMPILE)
AR = $(TOOLCHAIN_PREFIX)gcc-ar
endif
# 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) -Wextra $(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 aciavecs.S bios.c xbios.c acsi.c \
biosmem.c blkdev.c chardev.c clock.c conout.c country.c \
disk.c dma.c dmasound.c floppy.c font.c ide.c ikbd.c initinfo.c \
kprint.c kprintasm.S linea.S lineainit.c lineavars.S machine.c \
mfp.c midi.c mouse.c natfeat.S natfeats.c nvram.c panicasm.S \
parport.c screen.c serport.c sound.c videl.c vt52.c xhdi.c \
pmmu030.c 68040_pmmu.S \
amiga.c amiga2.S spi_vamp.c spi_duart.S \
lisa.c lisa2.S \
delay.c delayasm.S sd.c memory2.c bootparams.c scsi.c nova.c \
dsp.c dsp2.S \
scsidriv.c
ifeq (1,$(COLDFIRE))
bios_src += coldfire.c coldfire2.S spi_cf.c
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 rwa.S time.c umem.c
#
# source code in util/
#
util_src = cookie.c doprintf.c intmath.c langs.c memmove.S memset.S miscasm.S \
nls.c nlsasm.S setjmp.S string.c lisautil.S miscutil.c
# The functions in the following modules are used by the AES and EmuDesk
ifeq ($(WITH_AES),1)
util_src += gemdos.c optimize.c optimopt.S rectfunc.c stringasm.S
endif
#
# source code in vdi/
#
vdi_src = vdi_asm.S 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
ifeq (1,$(COLDFIRE))
vdi_src += vdi_tblit_cf.S
else
vdi_src += vdi_blit.S vdi_tblit.S
endif
# The source below must be the last VDI one
vdi_src += endvdi.S
#
# source code in aes/
#
aes_src = gemasm.S gemstart.S gemdosif.S 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 \
gemmnext.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 = deskstart.S 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
#
# source code in cli/ for EmuTOS console EmuCON
#
cli_src = cmdasm.S cmdmain.c cmdedit.c cmdexec.c cmdint.c cmdparse.c cmdutil.c
#
# source code to put at the end of the ROM
#
end_src = bios/endrom.c
#
# 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)))
# VMA: Virtual Memory Address
# This is the address where the ROM is mapped at run time.
VMA = $(call MAKE_SYMADDR,__text,emutos.map)
# LMA: Load Memory Address
# This is the physical address where the ROM is stored.
# On some machines (i.e. FireBee), the ROM is stored at some address (LMA),
# then mapped to another address (VMA) at run time.
# On most machines, LMA and VMA are equal.
# LMA is important on systems where the ROM can be dynamically updated.
LMA = $(VMA)
# Entry point address to boot the ROM.
# This is used when the pseudo-ROM is loaded into RAM by some kind of debugger,
# i.e. dBUG on ColdFire Evaluation Boards.
# Specifying the entry point is generally useless, as such debugger uses
# the start of the ROM as default entry point, and TOS-like ROMs already have
# a branch to _main there.
ENTRY = $(call MAKE_SYMADDR,_main,emutos.map)
# The following reference values have been gathered from major TOS versions
MEMBOT_TOS100 = 0x0000a100
MEMBOT_TOS102 = 0x0000ca00
MEMBOT_TOS104 = 0x0000a84e
MEMBOT_TOS162 = 0x0000a892
MEMBOT_TOS206 = 0x0000ccb2
MEMBOT_TOS306 = 0x0000e6fc
MEMBOT_TOS404 = 0x0000f99c
# If set, compare performance to one of the TOS versions above.
REF_OS=
#
# 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
dirs = $(core_dirs) $(optional_dirs)
vpath %.c $(dirs)
vpath %.S $(dirs)
#
# country-specific settings
#
include country.mk
#
# everything should work fine below.
#
SRC = $(foreach d,$(dirs),$(addprefix $(d)/,$($(d)_src))) $(end_src)
CORE_OBJ = $(foreach d,$(core_dirs),$(patsubst %.c,obj/%.o,$(patsubst %.S,obj/%.o,$($(d)_src)))) $(FONTOBJ_COMMON) obj/libfont.a obj/version.o
OPTIONAL_OBJ = $(foreach d,$(optional_dirs),$(patsubst %.c,obj/%.o,$(patsubst %.S,obj/%.o,$($(d)_src))))
END_OBJ = $(patsubst %,obj/%.o,$(basename $(notdir $(end_src))))
OBJECTS = $(CORE_OBJ) $(OPTIONAL_OBJ) $(END_OBJ)
#
# 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
emutos.img: $(OBJECTS) obj/emutospp.ld
$(LD) $(CORE_OBJ) $(LIBS) $(OPTIONAL_OBJ) $(LIBS) $(END_OBJ) $(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)"
ifneq (,$(REF_OS))
@MEMBOT=$(call SHELL_SYMADDR,__end_os_stram,emutos.map);\
echo "# RAM used: $$(($$MEMBOT)) bytes ($$(($$MEMBOT - $(MEMBOT_$(REF_OS)))) bytes more than $(REF_OS))"
else
@MEMBOT=$(call SHELL_SYMADDR,__end_os_stram,emutos.map);\
echo "# RAM used: $$(($$MEMBOT)) bytes"
endif
#
# Padded Image
#
ROM_PADDED = $(if $(UNIQUE),etos$(ROMSIZE)$(UNIQUE).img,etos$(ROMSIZE)k.img)
$(ROM_PADDED): emutos.img mkrom
./mkrom pad $(ROMSIZE)k $< $@
#
# 192kB Image
#
.PHONY: 192
NODEP += 192
192: UNIQUE = $(COUNTRY)
192: OPTFLAGS = $(SMALL_OPTFLAGS)
192: override DEF += -DTARGET_192
192: WITH_CLI = 0
192: ROMSIZE = 192
192:
$(MAKE) DEF='$(DEF)' OPTFLAGS='$(OPTFLAGS)' WITH_CLI=$(WITH_CLI) UNIQUE=$(UNIQUE) ROMSIZE=$(ROMSIZE) ROM_PADDED=$(ROM_PADDED) $(ROM_PADDED) REF_OS=TOS104
@printf "$(LOCALCONFINFO)"
#
# 256kB Image
#
.PHONY: 256
NODEP += 256
256: UNIQUE = $(COUNTRY)
256: OPTFLAGS = $(SMALL_OPTFLAGS)
256: override DEF += -DTARGET_256
256: ROMSIZE = 256
256:
$(MAKE) DEF='$(DEF)' OPTFLAGS='$(OPTFLAGS)' UNIQUE=$(UNIQUE) ROMSIZE=$(ROMSIZE) ROM_PADDED=$(ROM_PADDED) $(ROM_PADDED) REF_OS=TOS206
@printf "$(LOCALCONFINFO)"
#
# 512kB Image (for TT or Falcon; also usable for ST/STe under Hatari)
#
.PHONY: 512
NODEP += 512
512: UNIQUE = $(COUNTRY)
512: override DEF += -DTARGET_512
512: ROMSIZE = 512
512:
$(MAKE) DEF='$(DEF)' OPTFLAGS='$(OPTFLAGS)' UNIQUE=$(UNIQUE) MULTIKEYBD='-k' ROMSIZE=$(ROMSIZE) ROM_PADDED=$(ROM_PADDED) $(ROM_PADDED) REF_OS=TOS404
@printf "$(LOCALCONFINFO)"
#
# 512kB PAK/3 Image (based on 256kB Image)
#
ROM_PAK3 = etospak3$(UNIQUE).img
.PHONY: pak3
NODEP += pak3
pak3: UNIQUE = $(COUNTRY)
pak3: OPTFLAGS = $(SMALL_OPTFLAGS)
pak3: override DEF += -DTARGET_256
pak3:
$(MAKE) DEF='$(DEF)' OPTFLAGS='$(OPTFLAGS)' UNIQUE=$(UNIQUE) ROM_PAK3=$(ROM_PAK3) $(ROM_PAK3) REF_OS=TOS206
@printf "$(LOCALCONFINFO)"
$(ROM_PAK3): ROMSIZE = 256
$(ROM_PAK3): emutos.img mkrom
./mkrom pak3 $< $(ROM_PAK3)
#
# 1024kB Image (for Hatari (and potentially other emulators))
#
.PHONY: 1024
NODEP += 1024
1024: override DEF += -DTARGET_1024
1024: ROMSIZE = 1024
1024: SYMFILE = $(addsuffix .sym,$(basename $(ROM_PADDED)))
1024:
$(MAKE) DEF='$(DEF)' OPTFLAGS='$(OPTFLAGS)' UNIQUE=$(UNIQUE) MULTIKEYBD='-k' ROMSIZE=$(ROMSIZE) ROM_PADDED=$(ROM_PADDED) $(ROM_PADDED) REF_OS=TOS404 SYMFILE=$(SYMFILE) $(SYMFILE)
@printf "$(LOCALCONFINFO)"
#
# ARAnyM Image
#
ROM_ARANYM = emutos-aranym.img
.PHONY: aranym
NODEP += aranym
aranym: override DEF += -DMACHINE_ARANYM
aranym: OPTFLAGS = $(SMALL_OPTFLAGS)
aranym: CPUFLAGS = -m68040
aranym: ROMSIZE = 512
aranym: ROM_PADDED = $(ROM_ARANYM)
aranym:
@echo "# Building ARAnyM EmuTOS into $(ROM_PADDED)"
$(MAKE) CPUFLAGS='$(CPUFLAGS)' OPTFLAGS='$(OPTFLAGS)' DEF='$(DEF)' ROMSIZE=$(ROMSIZE) ROM_PADDED=$(ROM_PADDED) $(ROM_PADDED) REF_OS=TOS404
@printf "$(LOCALCONFINFO)"
#
# 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: ROMSIZE = 128
cart: ROM_PADDED = $(ROM_CARTRIDGE)
cart:
@echo "# Building Diagnostic Cartridge EmuTOS into $(ROM_PADDED)"
$(MAKE) OPTFLAGS='$(OPTFLAGS)' DEF='$(DEF)' UNIQUE=$(COUNTRY) WITH_AES=$(WITH_AES) ROMSIZE=$(ROMSIZE) ROM_PADDED=$(ROM_PADDED) $(ROM_PADDED) REF_OS=TOS104
./mkrom stc emutos.img emutos.stc
@printf "$(LOCALCONFINFO)"
#
# Amiga Image
#
TOCLEAN += *.rom
ROM_AMIGA = emutos-amiga.rom
AMIGA_DEFS =
.PHONY: amiga
NODEP += amiga
amiga: UNIQUE = $(COUNTRY)
amiga: OPTFLAGS = $(SMALL_OPTFLAGS)
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) $(ROM_AMIGA) REF_OS=TOS206
@printf "$(LOCALCONFINFO)"
$(ROM_AMIGA): emutos.img mkrom
./mkrom amiga $< $(ROM_AMIGA)
# Special Amiga ROM optimized for Vampire V2
VAMPIRE_CPUFLAGS = -m68040
VAMPIRE_COMMON_DEF = -DCONF_WITH_VAMPIRE_SPI=1 -DCONF_WITH_SDMMC=1
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_COMMON_DEF) $(VAMPIRE_DEF)
amigavampire: ROM_AMIGA = $(VAMPIRE_ROM_AMIGA)
amigavampire: amiga
# Special Amiga ROM optimized for Vampire V4 Standalone
V4_DEF = -DSTATIC_ALT_RAM_ADDRESS=0x01000000 -DSTATIC_ALT_RAM_SIZE=496UL*1024*1024
V4_ROM_AMIGA = emutos-vampire-v4sa.rom
.PHONY: v4sa
NODEP += v4sa
v4sa: CPUFLAGS = $(VAMPIRE_CPUFLAGS)
v4sa: override DEF += $(VAMPIRE_COMMON_DEF) $(V4_DEF)
v4sa: ROM_AMIGA = $(V4_ROM_AMIGA)
v4sa: 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)
#
# ColdFire images
#
TOCLEAN += *.s19
SRECFILE = emutos.s19
# Length of an S-Record data field on a single line, in bytes (optional).
# Increasing the default value may speed up the transfer,
# specially through a slow serial port when data is displayed on the screen.
SREC_LEN =
SREC_LEN_OPTION = $(if $(SREC_LEN),--srec-len=$(SREC_LEN))
$(SRECFILE): emutos.img
$(OBJCOPY) -I binary -O srec $(SREC_LEN_OPTION) --change-addresses $(LMA) --change-start $(ENTRY) $< $(SRECFILE)
CPUFLAGS_FIREBEE = -mcpu=5474
SREC_FIREBEE = etosfb$(UNIQUE).s19
.PHONY: firebee
NODEP += firebee
firebee: UNIQUE = $(COUNTRY)
firebee: OPTFLAGS = $(STANDARD_OPTFLAGS)
firebee: override DEF += -DMACHINE_FIREBEE
firebee: CPUFLAGS = $(CPUFLAGS_FIREBEE)
firebee:
@echo "# Building FireBee EmuTOS into $(SREC_FIREBEE)"
$(MAKE) COLDFIRE=1 CPUFLAGS='$(CPUFLAGS)' DEF='$(DEF)' OPTFLAGS='$(OPTFLAGS)' UNIQUE=$(UNIQUE) LMA=0xe0600000 SRECFILE=$(SREC_FIREBEE) $(SREC_FIREBEE) REF_OS=TOS404
@printf "$(LOCALCONFINFO)"
.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) SRECFILE=$(SREC_M548X_DBUG) $(SREC_M548X_DBUG) REF_OS=TOS404
@printf "$(LOCALCONFINFO)"
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) REF_OS=TOS404
@printf "$(LOCALCONFINFO)"
include Makefile_sbc.mk
#
# 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)
@printf "$(LOCALCONFINFO)"
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
#
# emu256.prg
#
EMU256_PRG = emu256$(UNIQUE).prg
TOCLEAN += emu256*.prg
.PHONY: prg256
NODEP += prg256
prg256: override DEF += -DTARGET_256
prg256: UNIQUE = $(COUNTRY)
prg256: EMUTOS_PRG = $(EMU256_PRG)
prg256:
@echo "# Building $(EMUTOS_PRG)"
$(MAKE) DEF='$(DEF)' UNIQUE=$(UNIQUE) EMUTOS_PRG=$(EMUTOS_PRG) prg
obj/boot.o: obj/ramtos.h
# incbin dependencies are not automatically detected
obj/ramtos.o: emutos.img
#
# flop
#
EMUTOS_ST = emutos$(UNIQUE).st
TOCLEAN += emutos*.st mkflop
.PHONY: flop
NODEP += flop
flop: UNIQUE = $(COUNTRY)
flop:
$(MAKE) UNIQUE=$(UNIQUE) $(EMUTOS_ST)
@printf "$(LOCALCONFINFO)"
$(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)
@printf "$(LOCALCONFINFO)"
EMUTOS_VAMPIRE_ADF = emutos-vampire.adf
.PHONY: amigaflopvampire
NODEP += amigaflopvampire
amigaflopvampire: override DEF += $(VAMPIRE_COMMON_DEF) -DSTATIC_ALT_RAM_ADDRESS=0x08000000 $(AMIGA_DEFS)
amigaflopvampire: CPUFLAGS = $(VAMPIRE_CPUFLAGS)
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 = $(VAMPIRE_CPUFLAGS)
amigaflopwinuae: amigaflop
$(EMUTOS_ADF): amigaboot.img emutos.img mkrom
./mkrom amiga-floppy amigaboot.img emutos.img $@
amigaboot.img: obj/amigaboot.o obj/bootram.o
$(LD) $+ $(PCREL_LDFLAGS) -o $@
obj/amigaboot.o: obj/ramtos.h
#
# lisaflop
#
TOCLEAN += *.dc42
EMUTOS_DC42 = emutos.dc42
LISA_DEFS =
.PHONY: lisaflop
NODEP += lisaflop
lisaflop: UNIQUE = $(COUNTRY)
lisaflop: OPTFLAGS = $(SMALL_OPTFLAGS)
lisaflop: override DEF += -DTARGET_LISA_FLOPPY $(LISA_DEFS)
lisaflop:
$(MAKE) CPUFLAGS='$(CPUFLAGS)' DEF='$(DEF)' OPTFLAGS='$(OPTFLAGS)' UNIQUE=$(UNIQUE) EMUTOS_DC42=$(EMUTOS_DC42) $(EMUTOS_DC42)
@printf "$(LOCALCONFINFO)"
$(EMUTOS_DC42): lisaboot.img emutos.img mkrom
./mkrom lisa-boot-floppy lisaboot.img emutos.img $@
lisaboot.img: obj/lisaboot.o obj/lisautil.o obj/bootram.o
$(LD) $+ $(PCREL_LDFLAGS) -o $@
obj/lisaboot.o: obj/ramtos.h
#
# localisation support: create bios/ctables.h include/i18nconf.h
#
# we would like to group targets, since localise generates both targets
# at the same time. however, this is not supported until gcc make 4.2.
# so that we can use old versions of make, we just run localise twice
# instead, creating a .tmp file each time as a byproduct.
#
GEN_SRC += bios/ctables.h include/i18nconf.h
TOCLEAN += localise include/i18nconf.h bios/ctables.h
NODEP += localise
localise: tools/localise.c
$(NATIVECC) $< -o $@
bios/ctables.h: obj/country localise.ctl localise
./localise $(UNIQUEARG) $(MULTIKEYBD) localise.ctl bios/ctables.h localise1.tmp
include/i18nconf.h: obj/country localise.ctl localise
./localise $(UNIQUEARG) $(MULTIKEYBD) localise.ctl localise2.tmp include/i18nconf.h
#
# NLS support
#
POFILES = $(wildcard po/*.po)
GEN_SRC += util/langs.c
TOCLEAN += bug po/messages.pot
NODEP += bug
bug: tools/bug.c
$(NATIVECC) $< -o $@
# even if UNIQUE is specified, we ensure langs.c exists to avoid dependency problems
util/langs.c: $(POFILES) po/LINGUAS bug po/messages.pot
./bug make
po/messages.pot: bug po/POTFILES.in $(shell grep -v '^#' po/POTFILES.in)
./bug xgettext
#
# Resource support
#
TOCLEAN += erd grd ird mrd draft temp.rsc temp.def
NODEP += erd grd ird mrd draft
erd: tools/erd.c
$(NATIVECC) $< -o $@
grd: tools/erd.c
$(NATIVECC) -DGEM_RSC $< -o grd
ird: tools/erd.c
$(NATIVECC) -DICON_RSC $< -o ird
mrd: tools/erd.c
$(NATIVECC) -DMFORM_RSC $< -o mrd
draft: tools/draft.c tools/draftexc.c
$(NATIVECC) $(DEFINES) $^ -o $@
DESKRSC_BASE = desk/desktop
DESKRSCGEN_BASE = desk/desk_rsc
GEMRSC_BASE = aes/gem
GEMRSCGEN_BASE = aes/gem_rsc
ICONRSC_BASE = desk/icon
ICONRSCGEN_BASE = desk/icons
MFORMRSC_BASE = aes/mform
MFORMRSCGEN_BASE = aes/mforms
GEN_SRC += $(DESKRSCGEN_BASE).c $(DESKRSCGEN_BASE).h $(GEMRSCGEN_BASE).c $(GEMRSCGEN_BASE).h
GEN_SRC += $(ICONRSCGEN_BASE).c $(ICONRSCGEN_BASE).h $(MFORMRSCGEN_BASE).c $(MFORMRSCGEN_BASE).h
# Hack below! '%' is used instead of '.' to support tools with multiple outputs.
# For example, the erd tool produces 2 files: a .c and a .h
# Without special care, when using parallel execution (make -j), the recipe
# may run twice (or more) in parallel. This is useless and could be harmful.
# Problem is that _standard rules_ with several targets just specify that the
# same recipe must be applied for all targets. This *doesn't* mean that recipe
# will generate all the targets at the same time.
# This issue is hidden when parallel execution is not used.
# On the other hand, _pattern rules_ (the ones with %) explicitly specify
# that all the targets will be built at the same time by the recipe.
# In order to work, all the targets must share a common substring replaced
# by the % wildcard. A simple trick is to use the '%' wilcard to replace the '.'
# character. This is enough to match actual filenames and enable the special
# behaviour of pattern rules.
# Trick source: https://stackoverflow.com/a/3077254