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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. # Location to place generated files
  2. #
  3. BIN := bin
  4. # Initialise variables that get added to throughout the various Makefiles
  5. #
  6. MAKEDEPS := Makefile .toolcheck .echocheck
  7. SRCDIRS :=
  8. SRCS :=
  9. NON_AUTO_SRCS :=
  10. DRIVERS :=
  11. ROMS :=
  12. MEDIA :=
  13. NON_AUTO_MEDIA :=
  14. # Locations of utilities
  15. #
  16. HOST_CC := gcc
  17. RM := rm -f
  18. TOUCH := touch
  19. MKDIR := mkdir
  20. CP := cp
  21. ECHO := echo
  22. PRINTF := printf
  23. PERL := /usr/bin/perl
  24. CC := $(CROSS_COMPILE)gcc
  25. CPP := $(CROSS_COMPILE)gcc -E -Wp,-Wall
  26. AS := $(CROSS_COMPILE)as
  27. LD := $(CROSS_COMPILE)ld
  28. SIZE := $(CROSS_COMPILE)size
  29. AR := $(CROSS_COMPILE)ar
  30. RANLIB := $(CROSS_COMPILE)ranlib
  31. OBJCOPY := $(CROSS_COMPILE)objcopy
  32. NM := $(CROSS_COMPILE)nm
  33. OBJDUMP := $(CROSS_COMPILE)objdump
  34. PARSEROM := $(PERL) ./util/parserom.pl
  35. MAKEROM := $(PERL) ./util/makerom.pl
  36. MKCONFIG := $(PERL) ./util/mkconfig.pl
  37. SYMCHECK := $(PERL) ./util/symcheck.pl
  38. SORTOBJDUMP := $(PERL) ./util/sortobjdump.pl
  39. NRV2B := ./util/nrv2b
  40. ZBIN := ./util/zbin
  41. DOXYGEN := doxygen
  42. # If invoked with no build target, print out a helpfully suggestive
  43. # message.
  44. #
  45. noargs : blib $(BIN)/NIC $(BIN)/gpxe.dsk $(BIN)/gpxe.iso $(BIN)/gpxe.usb
  46. @$(ECHO) '==========================================================='
  47. @$(ECHO)
  48. @$(ECHO) 'To create a bootable floppy, type'
  49. @$(ECHO) ' cat $(BIN)/gpxe.dsk > /dev/fd0'
  50. @$(ECHO) 'where /dev/fd0 is your floppy drive. This will erase any'
  51. @$(ECHO) 'data already on the disk.'
  52. @$(ECHO)
  53. @$(ECHO) 'To create a bootable USB key, type'
  54. @$(ECHO) ' cat $(BIN)/gpxe.usb > /dev/sdX'
  55. @$(ECHO) 'where /dev/sdX is your USB key, and is *not* a real hard'
  56. @$(ECHO) 'disk on your system. This will erase any data already on'
  57. @$(ECHO) 'the USB key.'
  58. @$(ECHO)
  59. @$(ECHO) 'To create a bootable CD-ROM, burn the ISO image '
  60. @$(ECHO) '$(BIN)/gpxe.iso to a blank CD-ROM.'
  61. @$(ECHO)
  62. @$(ECHO) 'These images contain drivers for all supported cards. You'
  63. @$(ECHO) 'can build more customised images, and ROM images, using'
  64. @$(ECHO) ' make bin/<rom-name>.<output-format>'
  65. @$(ECHO)
  66. @$(ECHO) '==========================================================='
  67. # Grab the central Config file.
  68. #
  69. MAKEDEPS += Config
  70. include Config
  71. # If no architecture is specified in Config or on the command-line,
  72. # use that of the build machine.
  73. #
  74. ARCH ?= $(shell uname -m | sed -e s,i[3456789]86,i386,)
  75. # handle x86_64 like i386, but set -m32 option for 32bit code only
  76. ifeq ($(ARCH),x86_64)
  77. ARCH := i386
  78. CFLAGS += -m32
  79. ASFLAGS += --32
  80. LDFLAGS += -m elf_i386
  81. endif
  82. # Drag in architecture-specific Config
  83. #
  84. MAKEDEPS += arch/$(ARCH)/Config
  85. include arch/$(ARCH)/Config
  86. # Common flags
  87. #
  88. CFLAGS += -I include -I arch/$(ARCH)/include -I . -DARCH=$(ARCH)
  89. CFLAGS += -Os -ffreestanding
  90. CFLAGS += -Wall -W
  91. CFLAGS += -g
  92. CFLAGS += $(EXTRA_CFLAGS)
  93. ASFLAGS += $(EXTRA_ASFLAGS)
  94. LDFLAGS += $(EXTRA_LDFLAGS)
  95. # Embedded image, if present
  96. #
  97. EMBEDDED_IMAGE ?= /dev/null
  98. ifneq ($(NO_WERROR),1)
  99. CFLAGS += -Werror
  100. endif
  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 += libgcc
  130. SRCDIRS += core
  131. SRCDIRS += proto
  132. SRCDIRS += net net/tcp net/udp
  133. SRCDIRS += image
  134. SRCDIRS += drivers/bus
  135. SRCDIRS += drivers/net
  136. SRCDIRS += drivers/net/e1000
  137. SRCDIRS += drivers/block
  138. SRCDIRS += drivers/scsi
  139. SRCDIRS += drivers/ata
  140. SRCDIRS += drivers/nvs
  141. SRCDIRS += drivers/bitbash
  142. SRCDIRS += drivers/infiniband
  143. SRCDIRS += interface/pxe
  144. SRCDIRS += tests
  145. SRCDIRS += crypto crypto/axtls crypto/matrixssl
  146. SRCDIRS += hci hci/commands hci/tui
  147. SRCDIRS += hci/mucurses hci/mucurses/widgets
  148. SRCDIRS += usr
  149. # NON_AUTO_SRCS lists files that are excluded from the normal
  150. # automatic build system.
  151. #
  152. NON_AUTO_SRCS += core/elf_loader.c
  153. NON_AUTO_SRCS += drivers/net/prism2.c
  154. # Rules for finalising files. TGT_MAKEROM_FLAGS is defined as part of
  155. # the automatic build system and varies by target; it includes the
  156. # "-p 0x1234,0x5678" string to set the PCI IDs.
  157. #
  158. FINALISE_rom = $(MAKEROM) $(MAKEROM_FLAGS) $(TGT_MAKEROM_FLAGS) \
  159. -i$(IDENT) -s 0 $@
  160. # Some ROMs require specific flags to be passed to makerom.pl
  161. #
  162. MAKEROM_FLAGS_3c503 = -3
  163. # Drag in architecture-specific Makefile
  164. #
  165. MAKEDEPS += arch/$(ARCH)/Makefile
  166. include arch/$(ARCH)/Makefile
  167. # Drag in the automatic build system and other housekeeping functions
  168. MAKEDEPS += Makefile.housekeeping
  169. include Makefile.housekeeping