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 4.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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. # handle x86_64 like i386, but set -m32 option for 32bit code only
  22. ifeq ($(ARCH),x86_64)
  23. ARCH := i386
  24. CFLAGS += -m32
  25. endif
  26. # Drag in architecture-specific Config
  27. #
  28. MAKEDEPS += arch/$(ARCH)/Config
  29. include arch/$(ARCH)/Config
  30. # If invoked with no build target, print out a helpfully suggestive
  31. # message.
  32. #
  33. noargs : blib
  34. @echo '===================================================='
  35. @echo
  36. @echo ' *** WARNING: THE INSTRUCTIONS BELOW DO NOT FULLY WORK YET !!! ***'
  37. @echo ' *** PLEASE STAY TUNED ***'
  38. @echo
  39. @echo 'No target specified. To specify a target, do: '
  40. @echo
  41. @echo ' make bin/<rom-name>.<output-format> '
  42. @echo
  43. @echo 'where <output-format> is one of {$(MEDIA) }'
  44. @echo
  45. @echo 'or: '
  46. @echo
  47. @echo ' make all<output-format>s'
  48. @echo
  49. @echo 'to generate all possible images of format <output-format>'
  50. @echo
  51. @echo 'For example, '
  52. @echo
  53. @echo ' make allroms '
  54. @echo
  55. @echo 'will generate all possible .rom (rom burnable) images, and'
  56. @echo
  57. @echo ' make alldsks'
  58. @echo
  59. @echo 'will generate all possible .dsk (bootable floppy) images, or'
  60. @echo
  61. @echo '===================================================='
  62. @exit 1
  63. # Locations of utilities
  64. #
  65. HOST_CC ?= gcc
  66. CPP ?= gcc -E -Wp,-Wall
  67. RM ?= rm -f
  68. TOUCH ?= touch
  69. MKDIR ?= mkdir
  70. CP ?= cp
  71. PERL ?= /usr/bin/perl
  72. CC ?= $(CROSS_COMPILE)gcc
  73. AS ?= $(CROSS_COMPILE)as
  74. LD ?= $(CROSS_COMPILE)ld
  75. SIZE ?= $(CROSS_COMPILE)size
  76. AR ?= $(CROSS_COMPILE)ar
  77. RANLIB ?= $(CROSS_COMPILE)ranlib
  78. OBJCOPY ?= $(CROSS_COMPILE)objcopy
  79. NM ?= $(CROSS_COMPILE)nm
  80. OBJDUMP ?= $(CROSS_COMPILE)objdump
  81. PARSEROM ?= $(PERL) ./util/parserom.pl
  82. MAKEROM ?= $(PERL) ./util/makerom.pl
  83. MKCONFIG ?= $(PERL) ./util/mkconfig.pl
  84. SYMCHECK ?= $(PERL) ./util/symcheck.pl
  85. SORTOBJDUMP ?= $(PERL) ./util/sortobjdump.pl
  86. NRV2B ?= ./util/nrv2b
  87. ZBIN ?= ./util/zbin
  88. DOXYGEN ?= doxygen
  89. # Location to place generated files
  90. #
  91. BIN ?= bin
  92. # Common flags
  93. #
  94. CFLAGS += -I include -I arch/$(ARCH)/include -I . -DARCH=$(ARCH)
  95. CFLAGS += -Os -ffreestanding
  96. CFLAGS += -Wall -W
  97. CFLAGS += -g
  98. CFLAGS += $(EXTRA_CFLAGS)
  99. ASFLAGS += $(EXTRA_ASFLAGS)
  100. LDFLAGS += $(EXTRA_LDFLAGS)
  101. # CFLAGS for specific object types
  102. #
  103. CFLAGS_c +=
  104. CFLAGS_S += -DASSEMBLY
  105. # Base object name of the current target
  106. #
  107. OBJECT = $(firstword $(subst ., ,$(@F)))
  108. # CFLAGS for specific object files. You can define
  109. # e.g. CFLAGS_rtl8139, and have those flags automatically used when
  110. # compiling bin/rtl8139.o.
  111. #
  112. OBJ_CFLAGS = $(CFLAGS_$(OBJECT)) -DOBJECT=$(subst -,_,$(OBJECT))
  113. $(BIN)/%.flags :
  114. @echo $(OBJ_CFLAGS)
  115. # Rules for specific object types.
  116. #
  117. COMPILE_c = $(CC) $(CFLAGS) $(CFLAGS_c) $(OBJ_CFLAGS)
  118. RULE_c = $(Q)$(COMPILE_c) -c $< -o $@
  119. RULE_c_to_dbg%.o = $(Q)$(COMPILE_c) -Ddebug_$(OBJECT)=$* -c $< -o $@
  120. RULE_c_to_c = $(Q)$(COMPILE_c) -E -c $< > $@
  121. RULE_c_to_s = $(Q)$(COMPILE_c) -S -g0 -c $< -o $@
  122. PREPROCESS_S = $(CPP) $(CFLAGS) $(CFLAGS_S) $(OBJ_CFLAGS)
  123. ASSEMBLE_S = $(AS) $(ASFLAGS)
  124. RULE_S = $(Q)$(PREPROCESS_S) $< | $(ASSEMBLE_S) -o $@
  125. RULE_S_to_s = $(Q)$(PREPROCESS_S) $< > $@
  126. DEBUG_TARGETS += dbg%.o c s
  127. # SRCDIRS lists all directories containing source files.
  128. #
  129. SRCDIRS += core
  130. SRCDIRS += proto
  131. SRCDIRS += net net/tcp net/udp
  132. SRCDIRS += image
  133. SRCDIRS += drivers/bus
  134. SRCDIRS += drivers/net
  135. SRCDIRS += drivers/block
  136. SRCDIRS += drivers/scsi
  137. SRCDIRS += drivers/ata
  138. SRCDIRS += drivers/nvs
  139. SRCDIRS += drivers/bitbash
  140. SRCDIRS += interface/pxe
  141. SRCDIRS += tests
  142. SRCDIRS += crypto crypto/axtls crypto/matrixssl
  143. SRCDIRS += hci hci/commands hci/tui
  144. SRCDIRS += hci/mucurses hci/mucurses/widgets
  145. SRCDIRS += usr
  146. # NON_AUTO_SRCS lists files that are excluded from the normal
  147. # automatic build system.
  148. #
  149. NON_AUTO_SRCS += core/elf_loader.c
  150. NON_AUTO_SRCS += drivers/net/prism2.c
  151. # Rules for finalising files. TGT_MAKEROM_FLAGS is defined as part of
  152. # the automatic build system and varies by target; it includes the
  153. # "-p 0x1234,0x5678" string to set the PCI IDs.
  154. #
  155. FINALISE_rom = $(MAKEROM) $(MAKEROM_FLAGS) $(TGT_MAKEROM_FLAGS) \
  156. -i$(IDENT) -s 0 $@
  157. # Some ROMs require specific flags to be passed to makerom.pl
  158. #
  159. MAKEROM_FLAGS_3c503 = -3
  160. # Drag in architecture-specific Makefile
  161. #
  162. MAKEDEPS += arch/$(ARCH)/Makefile
  163. include arch/$(ARCH)/Makefile
  164. # Drag in the automatic build system and other housekeeping functions
  165. MAKEDEPS += Makefile.housekeeping
  166. include Makefile.housekeeping