您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

Makefile 5.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  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. # Find a usable "echo -e".
  12. #
  13. ifeq ($(shell echo '\0101'),A)
  14. ECHO := echo
  15. else ifeq ($(shell echo -e '\0101'),A)
  16. ECHO := echo -e
  17. else ifeq ($(shell /bin/echo '\0101'),A)
  18. ECHO := /bin/echo
  19. else ifeq ($(shell /bin/echo -e '\0101'),A)
  20. ECHO := /bin/echo -e
  21. endif
  22. # Grab the central Config file.
  23. #
  24. MAKEDEPS += Config
  25. include Config
  26. # Location to place generated files
  27. #
  28. BIN := bin
  29. # If no architecture is specified in Config or on the command-line,
  30. # use that of the build machine.
  31. #
  32. ifndef ARCH
  33. ARCH := $(shell uname -m | sed -e s,i[3456789]86,i386,)
  34. endif
  35. # handle x86_64 like i386, but set -m32 option for 32bit code only
  36. ifeq ($(ARCH),x86_64)
  37. ARCH := i386
  38. CFLAGS += -m32
  39. ASFLAGS += --32
  40. LDFLAGS += -m elf_i386
  41. endif
  42. # Drag in architecture-specific Config
  43. #
  44. MAKEDEPS += arch/$(ARCH)/Config
  45. include arch/$(ARCH)/Config
  46. # If invoked with no build target, print out a helpfully suggestive
  47. # message.
  48. #
  49. noargs : blib $(BIN)/NIC $(BIN)/gpxe.dsk $(BIN)/gpxe.iso $(BIN)/gpxe.usb
  50. @$(ECHO) '==========================================================='
  51. @$(ECHO)
  52. @$(ECHO) 'To create a bootable floppy, type'
  53. @$(ECHO) ' cat $(BIN)/gpxe.dsk > /dev/fd0'
  54. @$(ECHO) 'where /dev/fd0 is your floppy drive. This will erase any'
  55. @$(ECHO) 'data already on the disk.'
  56. @$(ECHO)
  57. @$(ECHO) 'To create a bootable USB key, type'
  58. @$(ECHO) ' cat $(BIN)/gpxe.usb > /dev/sdX'
  59. @$(ECHO) 'where /dev/sdX is your USB key, and is *not* a real hard'
  60. @$(ECHO) 'disk on your system. This will erase any data already on'
  61. @$(ECHO) 'the USB key.'
  62. @$(ECHO)
  63. @$(ECHO) 'To create a bootable CD-ROM, burn the ISO image '
  64. @$(ECHO) '$(BIN)/gpxe.iso to a blank CD-ROM.'
  65. @$(ECHO)
  66. @$(ECHO) 'These images contain drivers for all supported cards. You'
  67. @$(ECHO) 'can build more customised images, and ROM images, using'
  68. @$(ECHO) ' make bin/<rom-name>.<output-format>'
  69. @$(ECHO)
  70. @$(ECHO) '==========================================================='
  71. # Locations of utilities
  72. #
  73. HOST_CC ?= gcc
  74. CPP ?= gcc -E -Wp,-Wall
  75. RM ?= rm -f
  76. TOUCH ?= touch
  77. MKDIR ?= mkdir
  78. CP ?= cp
  79. PERL ?= /usr/bin/perl
  80. CC ?= $(CROSS_COMPILE)gcc
  81. AS ?= $(CROSS_COMPILE)as
  82. LD ?= $(CROSS_COMPILE)ld
  83. SIZE ?= $(CROSS_COMPILE)size
  84. AR ?= $(CROSS_COMPILE)ar
  85. RANLIB ?= $(CROSS_COMPILE)ranlib
  86. OBJCOPY ?= $(CROSS_COMPILE)objcopy
  87. NM ?= $(CROSS_COMPILE)nm
  88. OBJDUMP ?= $(CROSS_COMPILE)objdump
  89. PARSEROM ?= $(PERL) ./util/parserom.pl
  90. MAKEROM ?= $(PERL) ./util/makerom.pl
  91. MKCONFIG ?= $(PERL) ./util/mkconfig.pl
  92. SYMCHECK ?= $(PERL) ./util/symcheck.pl
  93. SORTOBJDUMP ?= $(PERL) ./util/sortobjdump.pl
  94. NRV2B ?= ./util/nrv2b
  95. ZBIN ?= ./util/zbin
  96. DOXYGEN ?= doxygen
  97. # Common flags
  98. #
  99. CFLAGS += -I include -I arch/$(ARCH)/include -I . -DARCH=$(ARCH)
  100. CFLAGS += -Os -ffreestanding
  101. CFLAGS += -Wall -W
  102. CFLAGS += -g
  103. CFLAGS += $(EXTRA_CFLAGS)
  104. ASFLAGS += $(EXTRA_ASFLAGS)
  105. LDFLAGS += $(EXTRA_LDFLAGS)
  106. ifneq ($(NO_WERROR),1)
  107. CFLAGS += -Werror
  108. endif
  109. # CFLAGS for specific object types
  110. #
  111. CFLAGS_c +=
  112. CFLAGS_S += -DASSEMBLY
  113. # Base object name of the current target
  114. #
  115. OBJECT = $(firstword $(subst ., ,$(@F)))
  116. # CFLAGS for specific object files. You can define
  117. # e.g. CFLAGS_rtl8139, and have those flags automatically used when
  118. # compiling bin/rtl8139.o.
  119. #
  120. OBJ_CFLAGS = $(CFLAGS_$(OBJECT)) -DOBJECT=$(subst -,_,$(OBJECT))
  121. $(BIN)/%.flags :
  122. @$(ECHO) $(OBJ_CFLAGS)
  123. # Rules for specific object types.
  124. #
  125. COMPILE_c = $(CC) $(CFLAGS) $(CFLAGS_c) $(OBJ_CFLAGS)
  126. RULE_c = $(Q)$(COMPILE_c) -c $< -o $@
  127. RULE_c_to_dbg%.o = $(Q)$(COMPILE_c) -Ddebug_$(OBJECT)=$* -c $< -o $@
  128. RULE_c_to_c = $(Q)$(COMPILE_c) -E -c $< > $@
  129. RULE_c_to_s = $(Q)$(COMPILE_c) -S -g0 -c $< -o $@
  130. PREPROCESS_S = $(CPP) $(CFLAGS) $(CFLAGS_S) $(OBJ_CFLAGS)
  131. ASSEMBLE_S = $(AS) $(ASFLAGS)
  132. RULE_S = $(Q)$(PREPROCESS_S) $< | $(ASSEMBLE_S) -o $@
  133. RULE_S_to_s = $(Q)$(PREPROCESS_S) $< > $@
  134. DEBUG_TARGETS += dbg%.o c s
  135. # SRCDIRS lists all directories containing source files.
  136. #
  137. SRCDIRS += libgcc
  138. SRCDIRS += core
  139. SRCDIRS += proto
  140. SRCDIRS += net net/tcp net/udp
  141. SRCDIRS += image
  142. SRCDIRS += drivers/bus
  143. SRCDIRS += drivers/net
  144. SRCDIRS += drivers/net/e1000
  145. SRCDIRS += drivers/block
  146. SRCDIRS += drivers/scsi
  147. SRCDIRS += drivers/ata
  148. SRCDIRS += drivers/nvs
  149. SRCDIRS += drivers/bitbash
  150. SRCDIRS += drivers/infiniband
  151. SRCDIRS += interface/pxe
  152. SRCDIRS += tests
  153. SRCDIRS += crypto crypto/axtls crypto/matrixssl
  154. SRCDIRS += hci hci/commands hci/tui
  155. SRCDIRS += hci/mucurses hci/mucurses/widgets
  156. SRCDIRS += usr
  157. # NON_AUTO_SRCS lists files that are excluded from the normal
  158. # automatic build system.
  159. #
  160. NON_AUTO_SRCS += core/elf_loader.c
  161. NON_AUTO_SRCS += drivers/net/prism2.c
  162. # Rules for finalising files. TGT_MAKEROM_FLAGS is defined as part of
  163. # the automatic build system and varies by target; it includes the
  164. # "-p 0x1234,0x5678" string to set the PCI IDs.
  165. #
  166. FINALISE_rom = $(MAKEROM) $(MAKEROM_FLAGS) $(TGT_MAKEROM_FLAGS) \
  167. -i$(IDENT) -s 0 $@
  168. # Some ROMs require specific flags to be passed to makerom.pl
  169. #
  170. MAKEROM_FLAGS_3c503 = -3
  171. # Drag in architecture-specific Makefile
  172. #
  173. MAKEDEPS += arch/$(ARCH)/Makefile
  174. include arch/$(ARCH)/Makefile
  175. # Drag in the automatic build system and other housekeeping functions
  176. MAKEDEPS += Makefile.housekeeping
  177. include Makefile.housekeeping