You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. # Initialise variables that get added to throughout the various Makefiles
  2. #
  3. MAKEDEPS := Makefile .toolcheck
  4. SRCDIRS :=
  5. SRCS :=
  6. NON_AUTO_SRCS :=
  7. DRIVERS :=
  8. ROMS :=
  9. MEDIA :=
  10. NON_AUTO_MEDIA :=
  11. # Grab the central Config file.
  12. #
  13. MAKEDEPS += Config
  14. include Config
  15. # If no architecture is specified in Config or on the command-line,
  16. # use that of the build machine.
  17. #
  18. ifndef ARCH
  19. ARCH := $(shell uname -m | sed -e s,i[3456789]86,i386,)
  20. endif
  21. # Drag in architecture-specific Config
  22. #
  23. MAKEDEPS += arch/$(ARCH)/Config
  24. include arch/$(ARCH)/Config
  25. # If invoked with no build target, print out a helpfully suggestive
  26. # message.
  27. #
  28. noargs : blib
  29. @echo '===================================================='
  30. @echo 'No target specified. To specify a target, do: '
  31. @echo
  32. @echo ' $(MAKE) bin/<rom-name>.<output-format> '
  33. @echo
  34. @echo 'where <output-format> is one of [z]{$(MEDIA) }'
  35. @echo
  36. @echo 'or: '
  37. @echo
  38. @echo ' $(MAKE) all<output-format>s'
  39. @echo
  40. @echo 'to generate all possible images of format <output-format>'
  41. @echo
  42. @echo 'For example, '
  43. @echo
  44. @echo ' make allzroms '
  45. @echo
  46. @echo 'will generate all possible .zrom (rom burnable) images, and'
  47. @echo
  48. @echo ' make allzdsks'
  49. @echo
  50. @echo 'will generate all possible .zdsk (bootable floppy) images, or'
  51. @echo
  52. @echo '===================================================='
  53. @exit 1
  54. # Locations of utilities
  55. #
  56. HOST_CC ?= gcc
  57. CPP ?= gcc -E -Wp,-Wall
  58. RM ?= rm -f
  59. TOUCH ?= touch
  60. MKDIR ?= mkdir
  61. PERL ?= /usr/bin/perl
  62. CC ?= $(CROSS_COMPILE)gcc
  63. AS ?= $(CROSS_COMPILE)as
  64. LD ?= $(CROSS_COMPILE)ld
  65. SIZE ?= $(CROSS_COMPILE)size
  66. AR ?= $(CROSS_COMPILE)ar
  67. RANLIB ?= $(CROSS_COMPILE)ranlib
  68. OBJCOPY ?= $(CROSS_COMPILE)objcopy
  69. PARSEROM ?= $(PERL) ./util/parserom.pl
  70. MAKEROM ?= $(PERL) ./util/makerom.pl
  71. NRV2B ?= ./util/nrv2b
  72. # Location to place generated files
  73. #
  74. BIN ?= bin
  75. # Library containing all compiled objects
  76. BLIB = $(BIN)/blib.a
  77. # Common flags
  78. #
  79. CFLAGS += -I include -I arch/$(ARCH)/include -DARCH=$(ARCH)
  80. CFLAGS += -Os -ffreestanding
  81. CFLAGS += -Wall -W -Wno-format
  82. CFLAGS += $(EXTRA_CFLAGS)
  83. ASFLAGS += $(EXTRA_ASFLAGS)
  84. LDFLAGS += $(EXTRA_LDFLAGS)
  85. # CFLAGS for specific object types
  86. #
  87. CFLAGS_c +=
  88. CFLAGS_S += -DASSEMBLY
  89. # CFLAGS for specific object files. You can define
  90. # e.g. CFLAGS_rtl8139, and have those flags automatically used when
  91. # compiling bin/rtl8139.o.
  92. #
  93. OBJ_CFLAGS = $(CFLAGS_$(basename $(@F))) \
  94. -DOBJECT=$(subst -,_,$(basename $(@F)))
  95. $(BIN)/%.flags :
  96. @echo $(OBJ_CFLAGS)
  97. # Rules for specific object types.
  98. #
  99. COMPILE_c = $(CC) $(CFLAGS) $(CFLAGS_c) $(OBJ_CFLAGS)
  100. RULE_c = $(COMPILE_c) -c $< -o $@
  101. RULE_c_to_s = $(COMPILE_c) -S -c $< -o $@
  102. RULE_c_to_c = $(COMPILE_c) -E -c $< > $@
  103. PREPROCESS_S = $(CPP) $(CFLAGS) $(CFLAGS_S) $(OBJ_CFLAGS)
  104. ASSEMBLE_S = $(AS) $(ASFLAGS)
  105. RULE_S = $(PREPROCESS_S) $< | $(ASSEMBLE_S) -o $@
  106. RULE_S_to_s = $(PREPROCESS_S) $< > $@
  107. DEBUG_TARGETS += c s
  108. # SRCDIRS lists all directories containing source files.
  109. #
  110. SRCDIRS += core drivers/net drivers/disk
  111. # NON_AUTO_SRCS lists files that are excluded from the normal
  112. # automatic build system.
  113. #
  114. NON_AUTO_SRCS += core/elf_loader.c
  115. # Rules for finalising files. TGT_MAKEROM_FLAGS is defined as part of
  116. # the automatic build system and varies by target; it includes the
  117. # "-p 0x1234,0x5678" string to set the PCI IDs.
  118. #
  119. FINALISE_rom = $(MAKEROM) $(MAKEROM_FLAGS) $(TGT_MAKEROM_FLAGS) \
  120. -i$(IDENT) $@
  121. # Drag in architecture-specific Makefile
  122. #
  123. MAKEDEPS += arch/$(ARCH)/Makefile
  124. include arch/$(ARCH)/Makefile
  125. # Drag in the automatic build system and other housekeeping functions
  126. MAKEDEPS += Makefile.housekeeping
  127. include Makefile.housekeeping