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
77 CC ?= $(CROSS_COMPILE)gcc
78 AS ?= $(CROSS_COMPILE)as
79 LD ?= $(CROSS_COMPILE)ld
80 SIZE ?= $(CROSS_COMPILE)size
81 AR ?= $(CROSS_COMPILE)ar
82 RANLIB ?= $(CROSS_COMPILE)ranlib
83 OBJCOPY ?= $(CROSS_COMPILE)objcopy
84 NM ?= $(CROSS_COMPILE)nm
85 OBJDUMP ?= $(CROSS_COMPILE)objdump
86 PARSEROM ?= $(PERL) ./util/parserom.pl
87 MAKEROM ?= $(PERL) ./util/makerom.pl
88 MKCONFIG ?= $(PERL) ./util/mkconfig.pl
89 SYMCHECK ?= $(PERL) ./util/symcheck.pl
90 SORTOBJDUMP ?= $(PERL) ./util/sortobjdump.pl
94 # Location to place generated files
100 CFLAGS += -I include -I arch/$(ARCH)/include -I . -DARCH=$(ARCH)
101 CFLAGS += -Os -ffreestanding
104 CFLAGS += $(EXTRA_CFLAGS)
105 ASFLAGS += $(EXTRA_ASFLAGS)
106 LDFLAGS += $(EXTRA_LDFLAGS)
108 # CFLAGS for specific object types
111 CFLAGS_S += -DASSEMBLY
113 # Base object name of the current target
115 OBJECT = $(firstword $(subst ., ,$(@F)))
117 # CFLAGS for specific object files. You can define
118 # e.g. CFLAGS_rtl8139, and have those flags automatically used when
119 # compiling bin/rtl8139.o.
121 OBJ_CFLAGS = $(CFLAGS_$(OBJECT)) -DOBJECT=$(subst -,_,$(OBJECT))
125 # Rules for specific object types.
127 COMPILE_c = $(CC) $(CFLAGS) $(CFLAGS_c) $(OBJ_CFLAGS)
128 RULE_c = $(Q)$(COMPILE_c) -c $< -o $@
129 RULE_c_to_dbg%.o = $(Q)$(COMPILE_c) -Ddebug_$(OBJECT)=$* -c $< -o $@
130 RULE_c_to_c = $(Q)$(COMPILE_c) -E -c $< > $@
131 RULE_c_to_s = $(Q)$(COMPILE_c) -S -g0 -c $< -o $@
133 PREPROCESS_S = $(CPP) $(CFLAGS) $(CFLAGS_S) $(OBJ_CFLAGS)
134 ASSEMBLE_S = $(AS) $(ASFLAGS)
135 RULE_S = $(Q)$(PREPROCESS_S) $< | $(ASSEMBLE_S) -o $@
136 RULE_S_to_s = $(Q)$(PREPROCESS_S) $< > $@
138 DEBUG_TARGETS += dbg%.o c s
140 # SRCDIRS lists all directories containing source files.
144 SRCDIRS += net net/tcp net/udp
146 SRCDIRS += drivers/bus
147 SRCDIRS += drivers/net
148 SRCDIRS += drivers/block
149 SRCDIRS += drivers/scsi
150 SRCDIRS += drivers/ata
151 SRCDIRS += drivers/nvs
152 SRCDIRS += drivers/bitbash
153 SRCDIRS += interface/pxe
155 SRCDIRS += crypto crypto/axtls crypto/matrixssl
156 SRCDIRS += hci hci/commands hci/tui
157 SRCDIRS += hci/mucurses hci/mucurses/widgets
160 # NON_AUTO_SRCS lists files that are excluded from the normal
161 # automatic build system.
163 NON_AUTO_SRCS += core/elf_loader.c
164 NON_AUTO_SRCS += drivers/net/prism2.c
166 # Rules for finalising files. TGT_MAKEROM_FLAGS is defined as part of
167 # the automatic build system and varies by target; it includes the
168 # "-p 0x1234,0x5678" string to set the PCI IDs.
170 FINALISE_rom = $(MAKEROM) $(MAKEROM_FLAGS) $(TGT_MAKEROM_FLAGS) \
173 # Some ROMs require specific flags to be passed to makerom.pl
175 MAKEROM_FLAGS_3c503 = -3
177 # Drag in architecture-specific Makefile
179 MAKEDEPS += arch/$(ARCH)/Makefile
180 include arch/$(ARCH)/Makefile
182 # Drag in the automatic build system and other housekeeping functions
183 MAKEDEPS += Makefile.housekeeping
184 include Makefile.housekeeping