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 PARSEROM ?= $(PERL) ./util/parserom.pl
75 MAKEROM ?= $(PERL) ./util/makerom.pl
76 MKCONFIG ?= $(PERL) ./util/mkconfig.pl
79 # Location to place generated files
85 CFLAGS += -I include -I arch/$(ARCH)/include -I . -DARCH=$(ARCH)
86 CFLAGS += -Os -ffreestanding
87 CFLAGS += -Wall -W -Wno-format
88 CFLAGS += $(EXTRA_CFLAGS)
89 ASFLAGS += $(EXTRA_ASFLAGS)
90 LDFLAGS += $(EXTRA_LDFLAGS)
92 # CFLAGS for specific object types
95 CFLAGS_S += -DASSEMBLY
97 # Base object name of the current target
99 OBJECT = $(firstword $(subst ., ,$(@F)))
101 # CFLAGS for specific object files. You can define
102 # e.g. CFLAGS_rtl8139, and have those flags automatically used when
103 # compiling bin/rtl8139.o.
105 OBJ_CFLAGS = $(CFLAGS_$(OBJECT)) -DOBJECT=$(subst -,_,$(OBJECT))
109 # Rules for specific object types.
111 COMPILE_c = $(CC) $(CFLAGS) $(CFLAGS_c) $(OBJ_CFLAGS)
112 RULE_c = $(COMPILE_c) -c $< -o $@
113 RULE_c_to_dbg.o = $(COMPILE_c) -Ddebug_$(OBJECT) -c $< -o $@
114 RULE_c_to_c = $(COMPILE_c) -E -c $< > $@
115 RULE_c_to_s = $(COMPILE_c) -S -c $< -o $@
117 PREPROCESS_S = $(CPP) $(CFLAGS) $(CFLAGS_S) $(OBJ_CFLAGS)
118 ASSEMBLE_S = $(AS) $(ASFLAGS)
119 RULE_S = $(PREPROCESS_S) $< | $(ASSEMBLE_S) -o $@
120 RULE_S_to_s = $(PREPROCESS_S) $< > $@
122 DEBUG_TARGETS += dbg.o c s
124 # SRCDIRS lists all directories containing source files.
126 SRCDIRS += core drivers/bus drivers/net
129 # NON_AUTO_SRCS lists files that are excluded from the normal
130 # automatic build system.
132 NON_AUTO_SRCS += core/elf_loader.c
133 NON_AUTO_SRCS += drivers/net/prism2.c
135 # Rules for finalising files. TGT_MAKEROM_FLAGS is defined as part of
136 # the automatic build system and varies by target; it includes the
137 # "-p 0x1234,0x5678" string to set the PCI IDs.
139 FINALISE_rom = $(MAKEROM) $(MAKEROM_FLAGS) $(TGT_MAKEROM_FLAGS) \
142 # Some ROMs require specific flags to be passed to makerom.pl
144 MAKEROM_FLAGS_3c503 = -3
146 # Drag in architecture-specific Makefile
148 MAKEDEPS += arch/$(ARCH)/Makefile
149 include arch/$(ARCH)/Makefile
151 # Drag in the automatic build system and other housekeeping functions
152 MAKEDEPS += Makefile.housekeeping
153 include Makefile.housekeeping