blob: f6026d4950808501e2c82fce9b3866376ba17486 [file] [log] [blame]
Ronald G. Minnich99acb492003-06-17 16:51:06 +00001## This is Architecture independant part of the makefile
2
Greg Watson51305ee2003-06-24 16:07:07 +00003uses HAVE_OPTION_TABLE
Ronald G. Minnich99acb492003-06-17 16:51:06 +00004
5makedefine CPP:= $(CC) -no-gcc -x assembler-with-cpp -DASSEMBLY -E
6makedefine LIBGCC_FILE_NAME := $(shell $(CC) -print-libgcc-file-name)
7makedefine GCC_INC_DIR := $(shell $(CC) -print-search-dirs | sed -ne "s/install: \(.*\)/\1include/gp")
8
9makedefine CPPFLAGS := -I$(TOP)/src/include -I$(TOP)/src/arch/$(ARCH)/include -I$(GCC_INC_DIR) $(CPUFLAGS)
Eric Biederman7dea9552004-06-29 05:38:37 +000010makedefine ROMCCPPFLAGS := -D__ROMCC__=0 -D__ROMCC_MINOR__=64
Ronald G. Minnich99acb492003-06-17 16:51:06 +000011makedefine CFLAGS := $(CPU_OPT) $(CPPFLAGS) -Os -nostdinc -nostdlib -fno-builtin -Wall
12
13makedefine HOSTCFLAGS:= -Os -Wall
14
Greg Watson109959d2003-07-14 18:00:10 +000015makerule ldscript.ld
16 depends "ldoptions $(LDSUBSCRIPTS-1)"
17 action "echo \"INCLUDE ldoptions\" > $@ ; for file in $(LDSUBSCRIPTS-1) ; do echo \"INCLUDE $$file\" >> $@ ; done"
18end
Ronald G. Minnich99acb492003-06-17 16:51:06 +000019
Greg Watson109959d2003-07-14 18:00:10 +000020#makerule cpuflags
21# depends "Makefile.settings"
22# action "perl -e 'print \"CPUFLAGS :=\n\"; foreach $$var (split(\" \", $$ENV{VARIABLES})) { if (exists($$ENV{$$var})) { print \"CPUFLAGS += -D$$var\" . (length($$ENV{$$var})?\"=\x27$$ENV{$$var}\x27\":\"\") .\"\n\"} else { print \"CPUFLAGS += -U$$var\n\"} }' > $@"
23#end
Ronald G. Minnich99acb492003-06-17 16:51:06 +000024
Greg Watson109959d2003-07-14 18:00:10 +000025#makerule ldoptions
26# depends "Makefile.settings"
27# action "perl -e 'foreach $$var (split(\" \", $$ENV{VARIABLES})) { if ($$ENV{$$var} =~ m/^(0x[0-9a-fA-F]+|0[0-7]+|[0-9]+)$$/) { print \"$$var = $$ENV{$$var};\n\"; }}' > $@"
28#end
Ronald G. Minnich99acb492003-06-17 16:51:06 +000029
Greg Watson109959d2003-07-14 18:00:10 +000030makerule linuxbios.strip
31 depends "linuxbios"
32 action "$(OBJCOPY) -O binary linuxbios linuxbios.strip"
33end
Ronald G. Minnich99acb492003-06-17 16:51:06 +000034
Greg Watson109959d2003-07-14 18:00:10 +000035makerule linuxbios_c.o
36 depends "$(DRIVER) linuxbios.a $(LIBGCC_FILE_NAME)"
37 action "$(CC) -nostdlib -r -o $@ c_start.o $(DRIVER) linuxbios.a $(LIBGCC_FILE_NAME)"
38end
Ronald G. Minnich99acb492003-06-17 16:51:06 +000039
Greg Watson109959d2003-07-14 18:00:10 +000040makerule linuxbios_c
41 depends "linuxbios_c.o $(TOP)/src/config/linuxbios_c.ld ldoptions"
42 action "$(CC) -nostdlib -nostartfiles -static -o $@ -T $(TOP)/src/config/linuxbios_c.ld linuxbios_c.o"
43 action "$(CROSS_COMPILE)nm -n linuxbios_c | sort > linuxbios_c.map"
44end
Ronald G. Minnich99acb492003-06-17 16:51:06 +000045
46##
47## By default compress the C part of linuxbios
48##
Ronald G. Minnich99acb492003-06-17 16:51:06 +000049makedefine LINUXBIOS_PAYLOAD-$(CONFIG_COMPRESS):=linuxbios_payload.nrv2b
50makedefine LINUXBIOS_PAYLOAD-$(CONFIG_UNCOMPRESSED):=linuxbios_payload.bin
51
Greg Watson109959d2003-07-14 18:00:10 +000052makerule linuxbios_payload.bin
53 depends "linuxbios_c"
54 action "$(OBJCOPY) -O binary $< $@"
55end
Ronald G. Minnich99acb492003-06-17 16:51:06 +000056
Greg Watson109959d2003-07-14 18:00:10 +000057makerule linuxbios_payload.nrv2b
58 depends "linuxbios_payload.bin nrv2b"
59 action "./nrv2b e $< $@"
60end
Ronald G. Minnich99acb492003-06-17 16:51:06 +000061
Greg Watson109959d2003-07-14 18:00:10 +000062makerule linuxbios_payload
63 depends "$(LINUXBIOS_PAYLOAD-1)"
64 action "cp $(LINUXBIOS_PAYLOAD-1) linuxbios_payload"
65end
66
67makerule linuxbios
Greg Watsonc8ea12d2003-11-09 23:29:05 +000068 depends "crt0.o $(INIT-OBJECTS) linuxbios_payload ldscript.ld"
69 action "$(CC) -nostdlib -nostartfiles -static -o $@ -T ldscript.ld crt0.o $(INIT-OBJECTS)"
Greg Watson109959d2003-07-14 18:00:10 +000070 action "$(CROSS_COMPILE)nm -n linuxbios | sort > linuxbios.map"
71end
72
73makerule linuxbios.a
Greg Watsond0580342003-07-20 23:28:01 +000074 depends "$(OBJECTS)"
Greg Watson109959d2003-07-14 18:00:10 +000075 action "rm -f linuxbios.a"
Greg Watsond0580342003-07-20 23:28:01 +000076 action "ar cr linuxbios.a $(OBJECTS)"
Greg Watson109959d2003-07-14 18:00:10 +000077end
78
79#makerule crt0.S
80# depends "$(CRT0)"
81# action "cp $< $@"
82#end
Ronald G. Minnich99acb492003-06-17 16:51:06 +000083
84# the buildrom tool
Greg Watson109959d2003-07-14 18:00:10 +000085makerule buildrom
86 depends "$(TOP)/util/buildrom/buildrom.c"
87 action "$(HOSTCC) -o $@ $<"
88end
89
Ronald G. Minnich99acb492003-06-17 16:51:06 +000090# Force crt0.s (which has build time version code in it to rebuild every time)
91makedefine .PHONY : crt0.s
Greg Watson109959d2003-07-14 18:00:10 +000092makerule crt0.s
93 depends "crt0.S $(CRT0_INCLUDES)"
94 action "@echo \"$(CPP) ... $< > $@ \""
95 action "$(CPP) $(CPPFLAGS) -I. -I$(TOP)/src $< > $@.new && mv $@.new $@"
96end
Ronald G. Minnich99acb492003-06-17 16:51:06 +000097
Greg Watson109959d2003-07-14 18:00:10 +000098makerule crt0.o
Greg Watsonc8ea12d2003-11-09 23:29:05 +000099 depends "crt0.s"
Greg Watson109959d2003-07-14 18:00:10 +0000100 action "@echo $(CC) ... -o $@ $<"
Greg Watsonc8ea12d2003-11-09 23:29:05 +0000101 action "@$(CC) -c $(CPU_OPT) -o $@ $<"
Greg Watson109959d2003-07-14 18:00:10 +0000102end
Ronald G. Minnich99acb492003-06-17 16:51:06 +0000103
Greg Watson109959d2003-07-14 18:00:10 +0000104makerule etags
105 depends "$(SOURCES)"
106 action "etags $(SOURCES)"
107end
108makerule tags
109 depends "$(SOURCES)"
110 action "ctags $(SOURCES)"
111end
112makerule documentation
113 depends "$(SOURCES)"
114 action "doxygen LinuxBIOSDoc.config"
115end
Ronald G. Minnich99acb492003-06-17 16:51:06 +0000116
Greg Watson109959d2003-07-14 18:00:10 +0000117makerule ./romcc
118 depends "$(TOP)/util/romcc/romcc.c"
Eric Biedermand67e7652004-05-28 14:18:45 +0000119 action "$(HOSTCC) -g $(HOSTCFLAGS) $< -o $@"
Greg Watson109959d2003-07-14 18:00:10 +0000120end
Ronald G. Minnich99acb492003-06-17 16:51:06 +0000121
Greg Watson109959d2003-07-14 18:00:10 +0000122makerule build_opt_tbl
Eric Biederman5cd81732004-03-11 15:01:31 +0000123 depends "$(TOP)/util/options/build_opt_tbl.c $(TOP)/src/include/pc80/mc146818rtc.h $(TOP)/src/include/boot/linuxbios_tables.h Makefile.settings Makefile"
124 action "$(HOSTCC) $(HOSTCFLAGS) $(CPUFLAGS) $< -o $@"
Greg Watson109959d2003-07-14 18:00:10 +0000125end
Ronald G. Minnich99acb492003-06-17 16:51:06 +0000126
Greg Watson109959d2003-07-14 18:00:10 +0000127#makerule /$(TARGET_DIR)/option_table.c
128# depends "build_opt_tbl $(MAINBOARD)/cmos.layout"
129# action "./build_opt_tbl -b --config $(MAINBOARD)/cmos.layout"
130#end
131
132makerule option_table.c
133 depends "build_opt_tbl $(MAINBOARD)/cmos.layout"
Eric Biederman5cd81732004-03-11 15:01:31 +0000134 action "./build_opt_tbl -b --config $(MAINBOARD)/cmos.layout --header option_table.h"
135end
136
137makerule option_table.h
138 depends "build_opt_tbl $(MAINBOARD)/cmos.layout"
139 action "./build_opt_tbl -b --config $(MAINBOARD)/cmos.layout --header option_table.h"
Greg Watson109959d2003-07-14 18:00:10 +0000140end
Ronald G. Minnich99acb492003-06-17 16:51:06 +0000141
142if HAVE_OPTION_TABLE
143object ./option_table.o
144#special rule
Greg Watson109959d2003-07-14 18:00:10 +0000145#makerule option_table.o
146# depends "option_table.c"
147# action "$(CC) -c $(CFLAGS) -o $@ $<"
148#end
Ronald G. Minnich99acb492003-06-17 16:51:06 +0000149# object option_table.o
150end
151
Greg Watson109959d2003-07-14 18:00:10 +0000152makerule clean
153 action "rm -f linuxbios.* *~"
154 action "rm -f linuxbios"
155 action "rm -f ldscript.ld"
Ronald G. Minnichffc161e2003-07-23 01:42:29 +0000156 action "rm -f a.out *.s *.l *.o *.E *.inc"
157 action "rm -f TAGS tags romcc"
158 action "rm -f docipl buildrom chips.c *chip.c linuxbios_c* linuxbios_pay*"
Greg Watson109959d2003-07-14 18:00:10 +0000159 action "rm -f build_opt_tbl option_table.c crt0.S"
160end
Ronald G. Minnich99acb492003-06-17 16:51:06 +0000161
162# do standard config files that the user need not specify
163# for now, this is just 'lib', but it may be more later.
164dir /lib
165dir /console
166dir /stream
167dir /devices
168dir /pc80
169dir /boot