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 # Drag in architecture-specific Config
26 MAKEDEPS += arch/$(ARCH)/Config
27 include arch/$(ARCH)/Config
29 # If invoked with no build target, print out a helpfully suggestive
33 @echo '===================================================='
34 @echo 'No target specified. To specify a target, do: '
36 @echo ' $(MAKE) bin/<rom-name>.<output-format> '
38 @echo 'where <output-format> is one of [z]{$(MEDIA) }'
42 @echo ' $(MAKE) all<output-format>s'
44 @echo 'to generate all possible images of format <output-format>'
48 @echo ' make allzroms '
50 @echo 'will generate all possible .zrom (rom burnable) images, and'
52 @echo ' make allzdsks'
54 @echo 'will generate all possible .zdsk (bootable floppy) images, or'
56 @echo '===================================================='
59 # Locations of utilities
62 CPP ?= gcc -E -Wp,-Wall
67 CC ?= $(CROSS_COMPILE)gcc
68 AS ?= $(CROSS_COMPILE)as
69 LD ?= $(CROSS_COMPILE)ld
70 SIZE ?= $(CROSS_COMPILE)size
71 AR ?= $(CROSS_COMPILE)ar
72 RANLIB ?= $(CROSS_COMPILE)ranlib
73 OBJCOPY ?= $(CROSS_COMPILE)objcopy
74 NM ?= $(CROSS_COMPILE)nm
75 OBJDUMP ?= $(CROSS_COMPILE)objdump
76 PARSEROM ?= $(PERL) ./util/parserom.pl
77 MAKEROM ?= $(PERL) ./util/makerom.pl
78 MKCONFIG ?= $(PERL) ./util/mkconfig.pl
79 SYMCHECK ?= $(PERL) ./util/symcheck.pl
80 SORTOBJDUMP ?= $(PERL) ./util/sortobjdump.pl
84 # Location to place generated files
90 CFLAGS += -I include -I arch/$(ARCH)/include -I . -DARCH=$(ARCH)
91 CFLAGS += -Os -ffreestanding
94 CFLAGS += $(EXTRA_CFLAGS)
95 ASFLAGS += $(EXTRA_ASFLAGS)
96 LDFLAGS += $(EXTRA_LDFLAGS)
98 # CFLAGS for specific object types
101 CFLAGS_S += -DASSEMBLY
103 # Base object name of the current target
105 OBJECT = $(firstword $(subst ., ,$(@F)))
107 # CFLAGS for specific object files. You can define
108 # e.g. CFLAGS_rtl8139, and have those flags automatically used when
109 # compiling bin/rtl8139.o.
111 OBJ_CFLAGS = $(CFLAGS_$(OBJECT)) -DOBJECT=$(subst -,_,$(OBJECT))
115 # Rules for specific object types.
117 COMPILE_c = $(CC) $(CFLAGS) $(CFLAGS_c) $(OBJ_CFLAGS)
118 RULE_c = $(COMPILE_c) -c $< -o $@
119 RULE_c_to_dbg.o = $(COMPILE_c) -Ddebug_$(OBJECT) -c $< -o $@
120 RULE_c_to_dbg2.o = $(COMPILE_c) -Ddebug_$(OBJECT)=2 -c $< -o $@
121 RULE_c_to_c = $(COMPILE_c) -E -c $< > $@
122 RULE_c_to_s = $(COMPILE_c) -S -g0 -c $< -o $@
124 PREPROCESS_S = $(CPP) $(CFLAGS) $(CFLAGS_S) $(OBJ_CFLAGS)
125 ASSEMBLE_S = $(AS) $(ASFLAGS)
126 RULE_S = $(PREPROCESS_S) $< | $(ASSEMBLE_S) -o $@
127 RULE_S_to_s = $(PREPROCESS_S) $< > $@
129 DEBUG_TARGETS += dbg2.o dbg.o c s
131 # SRCDIRS lists all directories containing source files.
135 SRCDIRS += net net/uip net/tcp
137 SRCDIRS += drivers/bus
138 SRCDIRS += drivers/net
139 SRCDIRS += drivers/block
140 SRCDIRS += drivers/scsi
141 SRCDIRS += drivers/ata
142 SRCDIRS += drivers/nvs
143 SRCDIRS += drivers/bitbash
144 SRCDIRS += interface/pxe
147 # NON_AUTO_SRCS lists files that are excluded from the normal
148 # automatic build system.
150 NON_AUTO_SRCS += core/elf_loader.c
151 NON_AUTO_SRCS += drivers/net/prism2.c
153 # Rules for finalising files. TGT_MAKEROM_FLAGS is defined as part of
154 # the automatic build system and varies by target; it includes the
155 # "-p 0x1234,0x5678" string to set the PCI IDs.
157 FINALISE_rom = $(MAKEROM) $(MAKEROM_FLAGS) $(TGT_MAKEROM_FLAGS) \
160 # Some ROMs require specific flags to be passed to makerom.pl
162 MAKEROM_FLAGS_3c503 = -3
164 # Drag in architecture-specific Makefile
166 MAKEDEPS += arch/$(ARCH)/Makefile
167 include arch/$(ARCH)/Makefile
169 # Drag in the automatic build system and other housekeeping functions
170 MAKEDEPS += Makefile.housekeeping
171 include Makefile.housekeeping