1 # Initialise variables that get added to throughout the various Makefiles
3 MAKEDEPS := Makefile .toolcheck
12 # Grab the central Config file.
17 # Location to place generated files
21 # If no architecture is specified in Config or on the command-line,
22 # use that of the build machine.
25 ARCH := $(shell uname -m | sed -e s,i[3456789]86,i386,)
28 # handle x86_64 like i386, but set -m32 option for 32bit code only
34 # Drag in architecture-specific Config
36 MAKEDEPS += arch/$(ARCH)/Config
37 include arch/$(ARCH)/Config
39 # If invoked with no build target, print out a helpfully suggestive
42 noargs : blib $(BIN)/NIC
43 @echo '===================================================='
45 @echo ' *** WARNING: THE INSTRUCTIONS BELOW DO NOT FULLY WORK YET !!! ***'
46 @echo ' *** PLEASE STAY TUNED ***'
48 @echo 'No target specified. To specify a target, do: '
50 @echo ' make bin/<rom-name>.<output-format> '
52 @echo 'where <output-format> is one of {$(MEDIA) }'
56 @echo ' make all<output-format>s'
58 @echo 'to generate all possible images of format <output-format>'
62 @echo ' make allroms '
64 @echo 'will generate all possible .rom (rom burnable) images, and'
68 @echo 'will generate all possible .dsk (bootable floppy) images, or'
70 @echo '===================================================='
73 # Locations of utilities
76 CPP ?= gcc -E -Wp,-Wall
82 CC ?= $(CROSS_COMPILE)gcc
83 AS ?= $(CROSS_COMPILE)as
84 LD ?= $(CROSS_COMPILE)ld
85 SIZE ?= $(CROSS_COMPILE)size
86 AR ?= $(CROSS_COMPILE)ar
87 RANLIB ?= $(CROSS_COMPILE)ranlib
88 OBJCOPY ?= $(CROSS_COMPILE)objcopy
89 NM ?= $(CROSS_COMPILE)nm
90 OBJDUMP ?= $(CROSS_COMPILE)objdump
91 PARSEROM ?= $(PERL) ./util/parserom.pl
92 MAKEROM ?= $(PERL) ./util/makerom.pl
93 MKCONFIG ?= $(PERL) ./util/mkconfig.pl
94 SYMCHECK ?= $(PERL) ./util/symcheck.pl
95 SORTOBJDUMP ?= $(PERL) ./util/sortobjdump.pl
102 CFLAGS += -I include -I arch/$(ARCH)/include -I . -DARCH=$(ARCH)
103 CFLAGS += -Os -ffreestanding
106 CFLAGS += $(EXTRA_CFLAGS)
107 ASFLAGS += $(EXTRA_ASFLAGS)
108 LDFLAGS += $(EXTRA_LDFLAGS)
110 ifneq ($(NO_WERROR),1)
114 # CFLAGS for specific object types
117 CFLAGS_S += -DASSEMBLY
119 # Base object name of the current target
121 OBJECT = $(firstword $(subst ., ,$(@F)))
123 # CFLAGS for specific object files. You can define
124 # e.g. CFLAGS_rtl8139, and have those flags automatically used when
125 # compiling bin/rtl8139.o.
127 OBJ_CFLAGS = $(CFLAGS_$(OBJECT)) -DOBJECT=$(subst -,_,$(OBJECT))
131 # Rules for specific object types.
133 COMPILE_c = $(CC) $(CFLAGS) $(CFLAGS_c) $(OBJ_CFLAGS)
134 RULE_c = $(Q)$(COMPILE_c) -c $< -o $@
135 RULE_c_to_dbg%.o = $(Q)$(COMPILE_c) -Ddebug_$(OBJECT)=$* -c $< -o $@
136 RULE_c_to_c = $(Q)$(COMPILE_c) -E -c $< > $@
137 RULE_c_to_s = $(Q)$(COMPILE_c) -S -g0 -c $< -o $@
139 PREPROCESS_S = $(CPP) $(CFLAGS) $(CFLAGS_S) $(OBJ_CFLAGS)
140 ASSEMBLE_S = $(AS) $(ASFLAGS)
141 RULE_S = $(Q)$(PREPROCESS_S) $< | $(ASSEMBLE_S) -o $@
142 RULE_S_to_s = $(Q)$(PREPROCESS_S) $< > $@
144 DEBUG_TARGETS += dbg%.o c s
146 # SRCDIRS lists all directories containing source files.
151 SRCDIRS += net net/tcp net/udp
153 SRCDIRS += drivers/bus
154 SRCDIRS += drivers/net
155 SRCDIRS += drivers/block
156 SRCDIRS += drivers/scsi
157 SRCDIRS += drivers/ata
158 SRCDIRS += drivers/nvs
159 SRCDIRS += drivers/bitbash
160 SRCDIRS += interface/pxe
162 SRCDIRS += crypto crypto/axtls crypto/matrixssl
163 SRCDIRS += hci hci/commands hci/tui
164 SRCDIRS += hci/mucurses hci/mucurses/widgets
167 # NON_AUTO_SRCS lists files that are excluded from the normal
168 # automatic build system.
170 NON_AUTO_SRCS += core/elf_loader.c
171 NON_AUTO_SRCS += drivers/net/prism2.c
173 # Rules for finalising files. TGT_MAKEROM_FLAGS is defined as part of
174 # the automatic build system and varies by target; it includes the
175 # "-p 0x1234,0x5678" string to set the PCI IDs.
177 FINALISE_rom = $(MAKEROM) $(MAKEROM_FLAGS) $(TGT_MAKEROM_FLAGS) \
180 # Some ROMs require specific flags to be passed to makerom.pl
182 MAKEROM_FLAGS_3c503 = -3
184 # Drag in architecture-specific Makefile
186 MAKEDEPS += arch/$(ARCH)/Makefile
187 include arch/$(ARCH)/Makefile
189 # Drag in the automatic build system and other housekeeping functions
190 MAKEDEPS += Makefile.housekeeping
191 include Makefile.housekeeping