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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  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. # If no architecture is specified in Config or on the command-line,
  16. # use that of the build machine.
  17. #
  18. ifndef ARCH
  19. ARCH := $(shell uname -m | sed -e s,i[3456789]86,i386,)
  20. endif
  21. # Drag in architecture-specific Config
  22. #
  23. MAKEDEPS += arch/$(ARCH)/Config
  24. include arch/$(ARCH)/Config
  25. # If invoked with no build target, print out a helpfully suggestive
  26. # message.
  27. #
  28. noargs :
  29. @echo '===================================================='
  30. @echo 'No target specified. To specify a target, do: '
  31. @echo
  32. @echo ' $(MAKE) bin/<rom-name>.<output-format> '
  33. @echo
  34. @echo 'where <output-format> is one of [z]{$(MEDIA) }'
  35. @echo
  36. @echo 'or: '
  37. @echo
  38. @echo ' $(MAKE) all<output-format>s'
  39. @echo
  40. @echo 'to generate all possible images of format <output-format>'
  41. @echo
  42. @echo 'For example, '
  43. @echo
  44. @echo ' make allzroms '
  45. @echo
  46. @echo 'will generate all possible .zrom (rom burnable) images, and'
  47. @echo
  48. @echo ' make allzdsks'
  49. @echo
  50. @echo 'will generate all possible .zdsk (bootable floppy) images, or'
  51. @echo
  52. @echo '===================================================='
  53. @exit 1
  54. # Locations of utilities
  55. #
  56. HOST_CC ?= gcc
  57. CPP ?= gcc -E -Wp,-Wall
  58. RM ?= rm -f
  59. TOUCH ?= touch
  60. MKDIR ?= mkdir
  61. PERL ?= /usr/bin/perl
  62. CC ?= $(CROSS_COMPILE)gcc
  63. AS ?= $(CROSS_COMPILE)as
  64. LD ?= $(CROSS_COMPILE)ld
  65. SIZE ?= $(CROSS_COMPILE)size
  66. AR ?= $(CROSS_COMPILE)ar
  67. RANLIB ?= $(CROSS_COMPILE)ranlib
  68. OBJCOPY ?= $(CROSS_COMPILE)objcopy
  69. NM ?= $(CROSS_COMPILE)nm
  70. OBJDUMP ?= $(CROSS_COMPILE)objdump
  71. PARSEROM ?= $(PERL) ./util/parserom.pl
  72. MAKEROM ?= $(PERL) ./util/makerom.pl
  73. MKCONFIG ?= $(PERL) ./util/mkconfig.pl
  74. SYMCHECK ?= $(PERL) ./util/symcheck.pl
  75. SORTOBJDUMP ?= $(PERL) ./util/sortobjdump.pl
  76. NRV2B ?= ./util/nrv2b
  77. DOXYGEN ?= doxygen
  78. # Location to place generated files
  79. #
  80. BIN ?= bin
  81. # Common flags
  82. #
  83. CFLAGS += -I include -I arch/$(ARCH)/include -I . -DARCH=$(ARCH)
  84. CFLAGS += -Os -ffreestanding
  85. CFLAGS += -Wall -W
  86. CFLAGS += -g
  87. CFLAGS += $(EXTRA_CFLAGS)
  88. ASFLAGS += $(EXTRA_ASFLAGS)
  89. LDFLAGS += $(EXTRA_LDFLAGS)
  90. # CFLAGS for specific object types
  91. #
  92. CFLAGS_c +=
  93. CFLAGS_S += -DASSEMBLY
  94. # Base object name of the current target
  95. #
  96. OBJECT = $(firstword $(subst ., ,$(@F)))
  97. # CFLAGS for specific object files. You can define
  98. # e.g. CFLAGS_rtl8139, and have those flags automatically used when
  99. # compiling bin/rtl8139.o.
  100. #
  101. OBJ_CFLAGS = $(CFLAGS_$(OBJECT)) -DOBJECT=$(subst -,_,$(OBJECT))
  102. $(BIN)/%.flags :
  103. @echo $(OBJ_CFLAGS)
  104. # Rules for specific object types.
  105. #
  106. COMPILE_c = $(CC) $(CFLAGS) $(CFLAGS_c) $(OBJ_CFLAGS)
  107. RULE_c = $(COMPILE_c) -c $< -o $@
  108. RULE_c_to_dbg.o = $(COMPILE_c) -Ddebug_$(OBJECT) -c $< -o $@
  109. RULE_c_to_dbg2.o = $(COMPILE_c) -Ddebug_$(OBJECT)=2 -c $< -o $@
  110. RULE_c_to_c = $(COMPILE_c) -E -c $< > $@
  111. RULE_c_to_s = $(COMPILE_c) -S -g0 -c $< -o $@
  112. PREPROCESS_S = $(CPP) $(CFLAGS) $(CFLAGS_S) $(OBJ_CFLAGS)
  113. ASSEMBLE_S = $(AS) $(ASFLAGS)
  114. RULE_S = $(PREPROCESS_S) $< | $(ASSEMBLE_S) -o $@
  115. RULE_S_to_s = $(PREPROCESS_S) $< > $@
  116. DEBUG_TARGETS += dbg2.o dbg.o c s
  117. # SRCDIRS lists all directories containing source files.
  118. #
  119. SRCDIRS += core
  120. SRCDIRS += proto
  121. SRCDIRS += net net/uip net/tcp
  122. #SRCDIRS += image
  123. SRCDIRS += drivers/bus
  124. SRCDIRS += drivers/net
  125. SRCDIRS += drivers/block
  126. SRCDIRS += drivers/scsi
  127. SRCDIRS += drivers/ata
  128. SRCDIRS += drivers/nvs
  129. SRCDIRS += drivers/bitbash
  130. SRCDIRS += interface/pxe
  131. SRCDIRS += tests
  132. SRCDIRS += crypto
  133. SRCDIRS += hci/mucurses
  134. # NON_AUTO_SRCS lists files that are excluded from the normal
  135. # automatic build system.
  136. #
  137. NON_AUTO_SRCS += core/elf_loader.c
  138. NON_AUTO_SRCS += drivers/net/prism2.c
  139. # Rules for finalising files. TGT_MAKEROM_FLAGS is defined as part of
  140. # the automatic build system and varies by target; it includes the
  141. # "-p 0x1234,0x5678" string to set the PCI IDs.
  142. #
  143. FINALISE_rom = $(MAKEROM) $(MAKEROM_FLAGS) $(TGT_MAKEROM_FLAGS) \
  144. -i$(IDENT) $@
  145. # Some ROMs require specific flags to be passed to makerom.pl
  146. #
  147. MAKEROM_FLAGS_3c503 = -3
  148. # Drag in architecture-specific Makefile
  149. #
  150. MAKEDEPS += arch/$(ARCH)/Makefile
  151. include arch/$(ARCH)/Makefile
  152. # Drag in the automatic build system and other housekeeping functions
  153. MAKEDEPS += Makefile.housekeeping
  154. include Makefile.housekeeping