aboutsummaryrefslogtreecommitdiff
path: root/Makefile
blob: 28c35efeb23766b8a9efdef72a7c880b25c63cff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#
# Copyright 1999 Silicon Graphics, Inc.
# Copyright 2002-2004 Guido Guenther <agx@sigxcpu.org>
# Copyright (C) 2004 by Thiemo Seufer
#  

# default subarch
SUBARCH ?= IP22

ifeq ($(SUBARCH),IP22)
KERNELADDR=0x88002000
MAXLOADSIZE=0x1700000
LOADADDR=0x88802000
TIP_LOADADDR=0x89702000
OUTPUTFORMAT=ecoff-bigmips
endif
ifeq ($(SUBARCH),IP32)
KERNELADDR=0x80004000
MAXLOADSIZE=0x1400000
LOADADDR=0x81404000
TIP_LOADADDR=$(LOADADDR)
OUTPUTFORMAT=elf32-tradbigmips
endif

# these contain subarch independent files
SUBARCH_INDEP_DIRS=	\
	arclib

# these contain subarch dependent files
SUBARCH_DIRS=		\
	common		\
	ext2load        \
	tip22

define indep-tgt
$(foreach sd,$(SUBARCH_INDEP_DIRS),$(1)-subarch-indep-$(sd))
endef

define dep-tgt
$(foreach sd,$(SUBARCH_DIRS),$(1)-subarch-dep-$(sd))
endef

define build-indep-tgt
$(call indep-tgt,build)
endef

define build-dep-tgt
$(call dep-tgt,build)
endef

define install-indep-tgt
$(call indep-tgt,install)
endef

define install-dep-tgt
$(call dep-tgt,install)
endef

define clean-indep-tgt
$(call indep-tgt,clean)
endef

define clean-dep-tgt
$(call dep-tgt,clean)
endef

define submake
@$(MAKE) -C $(1) SUBARCH=$(SUBARCH)           \
                 LOADADDR=$(LOADADDR)         \
                 TIP_LOADADDR=$(TIP_LOADADDR) \
                 MAXLOADSIZE=$(MAXLOADSIZE)   \
                 KERNELADDR=$(KERNELADDR)     \
                 OUTPUTFORMAT=$(OUTPUTFORMAT) \
                 $(2)
endef


all: build

build: build-subarch-indep build-subarch-dep
build-subarch-indep: $(build-indep-tgt)
build-subarch-dep: $(build-dep-tgt)

$(build-indep-tgt):
	$(call submake,$(patsubst build-subarch-indep-%,%,$@),all)

$(build-dep-tgt):
	$(call submake,$(patsubst build-subarch-dep-%,%,$@),all)

install: install-subarch-indep install-subarch-dep
install-subarch-indep: $(install-indep-tgt)
install-subarch-dep: $(install-dep-tgt)

$(install-indep-tgt):
	$(call submake,$(patsubst install-subarch-indep-%,%,$@),install)

$(install-dep-tgt):
	$(call submake,$(patsubst install-subarch-dep-%,%,$@),install)

clean: clean-subarch-indep clean-subarch-dep
clean-subarch-indep: $(clean-indep-tgt)
clean-subarch-dep: $(clean-dep-tgt)

$(clean-indep-tgt):
	$(call submake,$(patsubst clean-subarch-indep-%,%,$@),clean)

$(clean-dep-tgt):
	$(call submake,$(patsubst clean-subarch-dep-%,%,$@),clean)


.PHONY: all \
	build build-subarch-indep build-subarch-dep \
	$(build-indep-tgt) $(build-dep-tgt) \
	clean clean-subarch-indep clean-subarch-dep \
	$(clean-indep-tgt) $(clean-dep-tgt)