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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  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 :
  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 allzroms '
  54. @echo
  55. @echo 'will generate all possible .zrom (rom burnable) images, and'
  56. @echo
  57. @echo ' make allzdsks'
  58. @echo
  59. @echo 'will generate all possible .zdsk (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. PERL ?= /usr/bin/perl
  71. CC ?= $(CROSS_COMPILE)gcc
  72. AS ?= $(CROSS_COMPILE)as
  73. LD ?= $(CROSS_COMPILE)ld
  74. SIZE ?= $(CROSS_COMPILE)size
  75. AR ?= $(CROSS_COMPILE)ar
  76. RANLIB ?= $(CROSS_COMPILE)ranlib
  77. OBJCOPY ?= $(CROSS_COMPILE)objcopy
  78. NM ?= $(CROSS_COMPILE)nm
  79. OBJDUMP ?= $(CROSS_COMPILE)objdump
  80. PARSEROM ?= $(PERL) ./util/parserom.pl
  81. MAKEROM ?= $(PERL) ./util/makerom.pl
  82. MKCONFIG ?= $(PERL) ./util/mkconfig.pl
  83. SYMCHECK ?= $(PERL) ./util/symcheck.pl
  84. SORTOBJDUMP ?= $(PERL) ./util/sortobjdump.pl
  85. NRV2B ?= ./util/nrv2b
  86. DOXYGEN ?= doxygen
  87. # Location to place generated files
  88. #
  89. BIN ?= bin
  90. # Common flags
  91. #
  92. CFLAGS += -I include -I arch/$(ARCH)/include -I . -DARCH=$(ARCH)
  93. CFLAGS += -Os -ffreestanding
  94. CFLAGS += -Wall -W
  95. CFLAGS += -g
  96. CFLAGS += $(EXTRA_CFLAGS)
  97. ASFLAGS += $(EXTRA_ASFLAGS)
  98. LDFLAGS += $(EXTRA_LDFLAGS)
  99. # CFLAGS for specific object types
  100. #
  101. CFLAGS_c +=
  102. CFLAGS_S += -DASSEMBLY
  103. # Base object name of the current target
  104. #
  105. OBJECT = $(firstword $(subst ., ,$(@F)))
  106. # CFLAGS for specific object files. You can define
  107. # e.g. CFLAGS_rtl8139, and have those flags automatically used when
  108. # compiling bin/rtl8139.o.
  109. #
  110. OBJ_CFLAGS = $(CFLAGS_$(OBJECT)) -DOBJECT=$(subst -,_,$(OBJECT))
  111. $(BIN)/%.flags :
  112. @echo $(OBJ_CFLAGS)
  113. # Rules for specific object types.
  114. #
  115. COMPILE_c = $(CC) $(CFLAGS) $(CFLAGS_c) $(OBJ_CFLAGS)
  116. RULE_c = $(Q)$(COMPILE_c) -c $< -o $@
  117. RULE_c_to_dbg%.o = $(Q)$(COMPILE_c) -Ddebug_$(OBJECT)=$* -c $< -o $@
  118. RULE_c_to_c = $(Q)$(COMPILE_c) -E -c $< > $@
  119. RULE_c_to_s = $(Q)$(COMPILE_c) -S -g0 -c $< -o $@
  120. PREPROCESS_S = $(CPP) $(CFLAGS) $(CFLAGS_S) $(OBJ_CFLAGS)
  121. ASSEMBLE_S = $(AS) $(ASFLAGS)
  122. RULE_S = $(Q)$(PREPROCESS_S) $< | $(ASSEMBLE_S) -o $@
  123. RULE_S_to_s = $(Q)$(PREPROCESS_S) $< > $@
  124. DEBUG_TARGETS += dbg%.o c s
  125. # SRCDIRS lists all directories containing source files.
  126. #
  127. SRCDIRS += core
  128. SRCDIRS += proto
  129. SRCDIRS += net net/tcp net/udp
  130. SRCDIRS += image
  131. SRCDIRS += drivers/bus
  132. SRCDIRS += drivers/net
  133. SRCDIRS += drivers/block
  134. SRCDIRS += drivers/scsi
  135. SRCDIRS += drivers/ata
  136. SRCDIRS += drivers/nvs
  137. SRCDIRS += drivers/bitbash
  138. SRCDIRS += interface/pxe
  139. SRCDIRS += tests
  140. SRCDIRS += crypto crypto/axtls crypto/matrixssl
  141. SRCDIRS += hci hci/commands hci/tui
  142. SRCDIRS += hci/mucurses hci/mucurses/widgets
  143. SRCDIRS += usr
  144. # NON_AUTO_SRCS lists files that are excluded from the normal
  145. # automatic build system.
  146. #
  147. NON_AUTO_SRCS += core/elf_loader.c
  148. NON_AUTO_SRCS += drivers/net/prism2.c
  149. # Rules for finalising files. TGT_MAKEROM_FLAGS is defined as part of
  150. # the automatic build system and varies by target; it includes the
  151. # "-p 0x1234,0x5678" string to set the PCI IDs.
  152. #
  153. FINALISE_rom = $(MAKEROM) $(MAKEROM_FLAGS) $(TGT_MAKEROM_FLAGS) \
  154. -i$(IDENT) -s 0 $@
  155. # Some ROMs require specific flags to be passed to makerom.pl
  156. #
  157. MAKEROM_FLAGS_3c503 = -3
  158. # Drag in architecture-specific Makefile
  159. #
  160. MAKEDEPS += arch/$(ARCH)/Makefile
  161. include arch/$(ARCH)/Makefile
  162. # Drag in the automatic build system and other housekeeping functions
  163. MAKEDEPS += Makefile.housekeeping
  164. include Makefile.housekeeping