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.

Makefile 3.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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. MKCONFIG ?= $(PERL) ./util/mkconfig.pl
  72. NRV2B ?= ./util/nrv2b
  73. # Location to place generated files
  74. #
  75. BIN ?= bin
  76. # Library containing all compiled objects
  77. BLIB = $(BIN)/blib.a
  78. # Common flags
  79. #
  80. CFLAGS += -I include -I arch/$(ARCH)/include -I . -DARCH=$(ARCH)
  81. CFLAGS += -Os -ffreestanding
  82. CFLAGS += -Wall -W -Wno-format
  83. CFLAGS += $(EXTRA_CFLAGS)
  84. ASFLAGS += $(EXTRA_ASFLAGS)
  85. LDFLAGS += $(EXTRA_LDFLAGS)
  86. # CFLAGS for specific object types
  87. #
  88. CFLAGS_c +=
  89. CFLAGS_S += -DASSEMBLY
  90. # Base object name of the current target
  91. #
  92. OBJECT = $(firstword $(subst ., ,$(@F)))
  93. # CFLAGS for specific object files. You can define
  94. # e.g. CFLAGS_rtl8139, and have those flags automatically used when
  95. # compiling bin/rtl8139.o.
  96. #
  97. OBJ_CFLAGS = $(CFLAGS_$(OBJECT)) -DOBJECT=$(subst -,_,$(OBJECT))
  98. $(BIN)/%.flags :
  99. @echo $(OBJ_CFLAGS)
  100. # Rules for specific object types.
  101. #
  102. COMPILE_c = $(CC) $(CFLAGS) $(CFLAGS_c) $(OBJ_CFLAGS)
  103. RULE_c = $(COMPILE_c) -c $< -o $@
  104. RULE_c_to_dbg.o = $(COMPILE_c) -Ddebug_$(OBJECT) -c $< -o $@
  105. RULE_c_to_c = $(COMPILE_c) -E -c $< > $@
  106. RULE_c_to_s = $(COMPILE_c) -S -c $< -o $@
  107. PREPROCESS_S = $(CPP) $(CFLAGS) $(CFLAGS_S) $(OBJ_CFLAGS)
  108. ASSEMBLE_S = $(AS) $(ASFLAGS)
  109. RULE_S = $(PREPROCESS_S) $< | $(ASSEMBLE_S) -o $@
  110. RULE_S_to_s = $(PREPROCESS_S) $< > $@
  111. DEBUG_TARGETS += dbg.o c s
  112. # SRCDIRS lists all directories containing source files.
  113. #
  114. SRCDIRS += core drivers/bus drivers/net
  115. # drivers/disk
  116. # NON_AUTO_SRCS lists files that are excluded from the normal
  117. # automatic build system.
  118. #
  119. NON_AUTO_SRCS += core/elf_loader.c
  120. NON_AUTO_SRCS += drivers/net/prism2.c
  121. # Rules for finalising files. TGT_MAKEROM_FLAGS is defined as part of
  122. # the automatic build system and varies by target; it includes the
  123. # "-p 0x1234,0x5678" string to set the PCI IDs.
  124. #
  125. FINALISE_rom = $(MAKEROM) $(MAKEROM_FLAGS) $(TGT_MAKEROM_FLAGS) \
  126. -i$(IDENT) $@
  127. # Some ROMs require specific flags to be passed to makerom.pl
  128. #
  129. MAKEROM_FLAGS_3c503 = -3
  130. # Drag in architecture-specific Makefile
  131. #
  132. MAKEDEPS += arch/$(ARCH)/Makefile
  133. include arch/$(ARCH)/Makefile
  134. # Drag in the automatic build system and other housekeeping functions
  135. MAKEDEPS += Makefile.housekeeping
  136. include Makefile.housekeeping