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

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