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
83 # Location to place generated files
89 CFLAGS += -I include -I arch/$(ARCH)/include -I . -DARCH=$(ARCH)
90 CFLAGS += -Os -ffreestanding
91 CFLAGS += -Wall -W -Wno-format
92 CFLAGS += $(EXTRA_CFLAGS)
93 ASFLAGS += $(EXTRA_ASFLAGS)
94 LDFLAGS += $(EXTRA_LDFLAGS)
96 # CFLAGS for specific object types
99 CFLAGS_S += -DASSEMBLY
101 # Base object name of the current target
103 OBJECT = $(firstword $(subst ., ,$(@F)))
105 # CFLAGS for specific object files. You can define
106 # e.g. CFLAGS_rtl8139, and have those flags automatically used when
107 # compiling bin/rtl8139.o.
109 OBJ_CFLAGS = $(CFLAGS_$(OBJECT)) -DOBJECT=$(subst -,_,$(OBJECT))
113 # Rules for specific object types.
115 COMPILE_c = $(CC) $(CFLAGS) $(CFLAGS_c) $(OBJ_CFLAGS)
116 RULE_c = $(COMPILE_c) -c $< -o $@
117 RULE_c_to_dbg.o = $(COMPILE_c) -Ddebug_$(OBJECT) -c $< -o $@
118 RULE_c_to_dbg2.o = $(COMPILE_c) -Ddebug_$(OBJECT)=2 -c $< -o $@
119 RULE_c_to_c = $(COMPILE_c) -E -c $< > $@
120 RULE_c_to_s = $(COMPILE_c) -S -c $< -o $@
122 PREPROCESS_S = $(CPP) $(CFLAGS) $(CFLAGS_S) $(OBJ_CFLAGS)
123 ASSEMBLE_S = $(AS) $(ASFLAGS)
124 RULE_S = $(PREPROCESS_S) $< | $(ASSEMBLE_S) -o $@
125 RULE_S_to_s = $(PREPROCESS_S) $< > $@
127 DEBUG_TARGETS += dbg2.o dbg.o c s
129 # SRCDIRS lists all directories containing source files.
132 SRCDIRS += drivers/bus
133 SRCDIRS += drivers/net
134 #SRCDIRS += drivers/disk
136 # NON_AUTO_SRCS lists files that are excluded from the normal
137 # automatic build system.
139 NON_AUTO_SRCS += core/elf_loader.c
140 NON_AUTO_SRCS += drivers/net/prism2.c
142 # Rules for finalising files. TGT_MAKEROM_FLAGS is defined as part of
143 # the automatic build system and varies by target; it includes the
144 # "-p 0x1234,0x5678" string to set the PCI IDs.
146 FINALISE_rom = $(MAKEROM) $(MAKEROM_FLAGS) $(TGT_MAKEROM_FLAGS) \
149 # Some ROMs require specific flags to be passed to makerom.pl
151 MAKEROM_FLAGS_3c503 = -3
153 # Drag in architecture-specific Makefile
155 MAKEDEPS += arch/$(ARCH)/Makefile
156 include arch/$(ARCH)/Makefile
158 # Drag in the automatic build system and other housekeeping functions
159 MAKEDEPS += Makefile.housekeeping
160 include Makefile.housekeeping