1 # Initialise variables that get added to throughout the various Makefiles
3 MAKEDEPS := Makefile .toolcheck
12 # Grab the central Config file.
17 # If no architecture is specified in Config or on the command-line,
18 # use that of the build machine.
21 ARCH := $(shell uname -m | sed -e s,i[3456789]86,i386,)
24 # handle x86_64 like i386, but set -m32 option for 32bit code only
30 # Drag in architecture-specific Config
32 MAKEDEPS += arch/$(ARCH)/Config
33 include arch/$(ARCH)/Config
35 # If invoked with no build target, print out a helpfully suggestive
39 @echo '===================================================='
41 @echo ' *** WARNING: THE INSTRUCTIONS BELOW DO NOT FULLY WORK YET !!! ***'
42 @echo ' *** PLEASE STAY TUNED ***'
44 @echo 'No target specified. To specify a target, do: '
46 @echo ' make bin/<rom-name>.<output-format> '
48 @echo 'where <output-format> is one of {$(MEDIA) }'
52 @echo ' make all<output-format>s'
54 @echo 'to generate all possible images of format <output-format>'
58 @echo ' make allzroms '
60 @echo 'will generate all possible .zrom (rom burnable) images, and'
62 @echo ' make allzdsks'
64 @echo 'will generate all possible .zdsk (bootable floppy) images, or'
66 @echo '===================================================='
69 # Locations of utilities
72 CPP ?= gcc -E -Wp,-Wall
78 CC ?= $(CROSS_COMPILE)gcc
79 AS ?= $(CROSS_COMPILE)as
80 LD ?= $(CROSS_COMPILE)ld
81 SIZE ?= $(CROSS_COMPILE)size
82 AR ?= $(CROSS_COMPILE)ar
83 RANLIB ?= $(CROSS_COMPILE)ranlib
84 OBJCOPY ?= $(CROSS_COMPILE)objcopy
85 NM ?= $(CROSS_COMPILE)nm
86 OBJDUMP ?= $(CROSS_COMPILE)objdump
87 PARSEROM ?= $(PERL) ./util/parserom.pl
88 MAKEROM ?= $(PERL) ./util/makerom.pl
89 MKCONFIG ?= $(PERL) ./util/mkconfig.pl
90 SYMCHECK ?= $(PERL) ./util/symcheck.pl
91 SORTOBJDUMP ?= $(PERL) ./util/sortobjdump.pl
95 # Location to place generated files
101 CFLAGS += -I include -I arch/$(ARCH)/include -I . -DARCH=$(ARCH)
102 CFLAGS += -Os -ffreestanding
105 CFLAGS += $(EXTRA_CFLAGS)
106 ASFLAGS += $(EXTRA_ASFLAGS)
107 LDFLAGS += $(EXTRA_LDFLAGS)
109 # CFLAGS for specific object types
112 CFLAGS_S += -DASSEMBLY
114 # Base object name of the current target
116 OBJECT = $(firstword $(subst ., ,$(@F)))
118 # CFLAGS for specific object files. You can define
119 # e.g. CFLAGS_rtl8139, and have those flags automatically used when
120 # compiling bin/rtl8139.o.
122 OBJ_CFLAGS = $(CFLAGS_$(OBJECT)) -DOBJECT=$(subst -,_,$(OBJECT))
126 # Rules for specific object types.
128 COMPILE_c = $(CC) $(CFLAGS) $(CFLAGS_c) $(OBJ_CFLAGS)
129 RULE_c = $(Q)$(COMPILE_c) -c $< -o $@
130 RULE_c_to_dbg%.o = $(Q)$(COMPILE_c) -Ddebug_$(OBJECT)=$* -c $< -o $@
131 RULE_c_to_c = $(Q)$(COMPILE_c) -E -c $< > $@
132 RULE_c_to_s = $(Q)$(COMPILE_c) -S -g0 -c $< -o $@
134 PREPROCESS_S = $(CPP) $(CFLAGS) $(CFLAGS_S) $(OBJ_CFLAGS)
135 ASSEMBLE_S = $(AS) $(ASFLAGS)
136 RULE_S = $(Q)$(PREPROCESS_S) $< | $(ASSEMBLE_S) -o $@
137 RULE_S_to_s = $(Q)$(PREPROCESS_S) $< > $@
139 DEBUG_TARGETS += dbg%.o c s
141 # SRCDIRS lists all directories containing source files.
145 SRCDIRS += net net/tcp net/udp
147 SRCDIRS += drivers/bus
148 SRCDIRS += drivers/net
149 SRCDIRS += drivers/block
150 SRCDIRS += drivers/scsi
151 SRCDIRS += drivers/ata
152 SRCDIRS += drivers/nvs
153 SRCDIRS += drivers/bitbash
154 SRCDIRS += interface/pxe
156 SRCDIRS += crypto crypto/axtls crypto/matrixssl
157 SRCDIRS += hci hci/commands hci/tui
158 SRCDIRS += hci/mucurses hci/mucurses/widgets
161 # NON_AUTO_SRCS lists files that are excluded from the normal
162 # automatic build system.
164 NON_AUTO_SRCS += core/elf_loader.c
165 NON_AUTO_SRCS += drivers/net/prism2.c
167 # Rules for finalising files. TGT_MAKEROM_FLAGS is defined as part of
168 # the automatic build system and varies by target; it includes the
169 # "-p 0x1234,0x5678" string to set the PCI IDs.
171 FINALISE_rom = $(MAKEROM) $(MAKEROM_FLAGS) $(TGT_MAKEROM_FLAGS) \
174 # Some ROMs require specific flags to be passed to makerom.pl
176 MAKEROM_FLAGS_3c503 = -3
178 # Drag in architecture-specific Makefile
180 MAKEDEPS += arch/$(ARCH)/Makefile
181 include arch/$(ARCH)/Makefile
183 # Drag in the automatic build system and other housekeeping functions
184 MAKEDEPS += Makefile.housekeeping
185 include Makefile.housekeeping