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
78 # Location to place generated files
82 # Library containing all compiled objects
87 CFLAGS += -I include -I arch/$(ARCH)/include -DARCH=$(ARCH)
88 CFLAGS += -Os -ffreestanding
89 CFLAGS += -Wall -W -Wno-format
90 CFLAGS += $(EXTRA_CFLAGS)
91 ASFLAGS += $(EXTRA_ASFLAGS)
92 LDFLAGS += $(EXTRA_LDFLAGS)
94 # CFLAGS for specific object types
97 CFLAGS_S += -DASSEMBLY
99 # Base object name of the current target
101 OBJECT = $(firstword $(subst ., ,$(@F)))
103 # CFLAGS for specific object files. You can define
104 # e.g. CFLAGS_rtl8139, and have those flags automatically used when
105 # compiling bin/rtl8139.o.
107 OBJ_CFLAGS = $(CFLAGS_$(OBJECT)) -DOBJECT=$(subst -,_,$(OBJECT))
111 # Rules for specific object types.
113 COMPILE_c = $(CC) $(CFLAGS) $(CFLAGS_c) $(OBJ_CFLAGS)
114 RULE_c = $(COMPILE_c) -c $< -o $@
115 RULE_c_to_dbg.o = $(COMPILE_c) -Ddebug_$(OBJECT) -c $< -o $@
116 RULE_c_to_c = $(COMPILE_c) -E -c $< > $@
117 RULE_c_to_s = $(COMPILE_c) -S -c $< -o $@
119 PREPROCESS_S = $(CPP) $(CFLAGS) $(CFLAGS_S) $(OBJ_CFLAGS)
120 ASSEMBLE_S = $(AS) $(ASFLAGS)
121 RULE_S = $(PREPROCESS_S) $< | $(ASSEMBLE_S) -o $@
122 RULE_S_to_s = $(PREPROCESS_S) $< > $@
124 DEBUG_TARGETS += dbg.o c s
126 # SRCDIRS lists all directories containing source files.
128 SRCDIRS += core drivers/bus drivers/net
131 # NON_AUTO_SRCS lists files that are excluded from the normal
132 # automatic build system.
134 NON_AUTO_SRCS += core/elf_loader.c
135 NON_AUTO_SRCS += drivers/net/prism2.c
137 # Rules for finalising files. TGT_MAKEROM_FLAGS is defined as part of
138 # the automatic build system and varies by target; it includes the
139 # "-p 0x1234,0x5678" string to set the PCI IDs.
141 FINALISE_rom = $(MAKEROM) $(MAKEROM_FLAGS) $(TGT_MAKEROM_FLAGS) \
144 # Drag in architecture-specific Makefile
146 MAKEDEPS += arch/$(ARCH)/Makefile
147 include arch/$(ARCH)/Makefile
149 # Drag in the automatic build system and other housekeeping functions
150 MAKEDEPS += Makefile.housekeeping
151 include Makefile.housekeeping