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.1KB

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