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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  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. # 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. ECHO ?= /bin/echo -e
  63. HOST_CC ?= gcc
  64. CPP ?= gcc -E -Wp,-Wall
  65. RM ?= rm -f
  66. TOUCH ?= touch
  67. MKDIR ?= mkdir
  68. CP ?= cp
  69. PERL ?= /usr/bin/perl
  70. CC ?= $(CROSS_COMPILE)gcc
  71. AS ?= $(CROSS_COMPILE)as
  72. LD ?= $(CROSS_COMPILE)ld
  73. SIZE ?= $(CROSS_COMPILE)size
  74. AR ?= $(CROSS_COMPILE)ar
  75. RANLIB ?= $(CROSS_COMPILE)ranlib
  76. OBJCOPY ?= $(CROSS_COMPILE)objcopy
  77. NM ?= $(CROSS_COMPILE)nm
  78. OBJDUMP ?= $(CROSS_COMPILE)objdump
  79. PARSEROM ?= $(PERL) ./util/parserom.pl
  80. MAKEROM ?= $(PERL) ./util/makerom.pl
  81. MKCONFIG ?= $(PERL) ./util/mkconfig.pl
  82. SYMCHECK ?= $(PERL) ./util/symcheck.pl
  83. SORTOBJDUMP ?= $(PERL) ./util/sortobjdump.pl
  84. NRV2B ?= ./util/nrv2b
  85. ZBIN ?= ./util/zbin
  86. DOXYGEN ?= doxygen
  87. # Common flags
  88. #
  89. CFLAGS += -I include -I arch/$(ARCH)/include -I . -DARCH=$(ARCH)
  90. CFLAGS += -Os -ffreestanding
  91. CFLAGS += -Wall -W
  92. CFLAGS += -g
  93. CFLAGS += $(EXTRA_CFLAGS)
  94. ASFLAGS += $(EXTRA_ASFLAGS)
  95. LDFLAGS += $(EXTRA_LDFLAGS)
  96. ifneq ($(NO_WERROR),1)
  97. CFLAGS += -Werror
  98. endif
  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 += libgcc
  128. SRCDIRS += core
  129. SRCDIRS += proto
  130. SRCDIRS += net net/tcp net/udp
  131. SRCDIRS += image
  132. SRCDIRS += drivers/bus
  133. SRCDIRS += drivers/net
  134. SRCDIRS += drivers/block
  135. SRCDIRS += drivers/scsi
  136. SRCDIRS += drivers/ata
  137. SRCDIRS += drivers/nvs
  138. SRCDIRS += drivers/bitbash
  139. SRCDIRS += drivers/infiniband
  140. SRCDIRS += interface/pxe
  141. SRCDIRS += tests
  142. SRCDIRS += crypto crypto/axtls crypto/matrixssl
  143. SRCDIRS += hci hci/commands hci/tui
  144. SRCDIRS += hci/mucurses hci/mucurses/widgets
  145. SRCDIRS += usr
  146. # NON_AUTO_SRCS lists files that are excluded from the normal
  147. # automatic build system.
  148. #
  149. NON_AUTO_SRCS += core/elf_loader.c
  150. NON_AUTO_SRCS += drivers/net/prism2.c
  151. # Rules for finalising files. TGT_MAKEROM_FLAGS is defined as part of
  152. # the automatic build system and varies by target; it includes the
  153. # "-p 0x1234,0x5678" string to set the PCI IDs.
  154. #
  155. FINALISE_rom = $(MAKEROM) $(MAKEROM_FLAGS) $(TGT_MAKEROM_FLAGS) \
  156. -i$(IDENT) -s 0 $@
  157. # Some ROMs require specific flags to be passed to makerom.pl
  158. #
  159. MAKEROM_FLAGS_3c503 = -3
  160. # Drag in architecture-specific Makefile
  161. #
  162. MAKEDEPS += arch/$(ARCH)/Makefile
  163. include arch/$(ARCH)/Makefile
  164. # Drag in the automatic build system and other housekeeping functions
  165. MAKEDEPS += Makefile.housekeeping
  166. include Makefile.housekeeping