aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2001-10-24 05:26:42 +0000
committerEric Andersen <andersen@codepoet.org>2001-10-24 05:26:42 +0000
commit4bcdd7214217bfdaa2c4015425d439686d5b8b0b (patch)
tree667d387f80c5b5c69ab8b24044614f999f00668a
parentbdfd0d78bc44e73d693510e70087857785b3b521 (diff)
downloadbusybox-w32-4bcdd7214217bfdaa2c4015425d439686d5b8b0b.tar.gz
busybox-w32-4bcdd7214217bfdaa2c4015425d439686d5b8b0b.tar.bz2
busybox-w32-4bcdd7214217bfdaa2c4015425d439686d5b8b0b.zip
Oops. Forgot these....
-rw-r--r--Rules.mak195
-rw-r--r--applets/Makefile35
2 files changed, 230 insertions, 0 deletions
diff --git a/Rules.mak b/Rules.mak
new file mode 100644
index 000000000..a6f111695
--- /dev/null
+++ b/Rules.mak
@@ -0,0 +1,195 @@
1#
2# This file contains rules which are shared between multiple Makefiles.
3#
4
5#
6# False targets.
7#
8.PHONY: dummy
9
10#
11# Special variables which should not be exported
12#
13unexport EXTRA_AFLAGS
14unexport EXTRA_CFLAGS
15unexport EXTRA_LDFLAGS
16unexport EXTRA_ARFLAGS
17unexport SUBDIRS
18unexport SUB_DIRS
19unexport ALL_SUB_DIRS
20unexport O_TARGET
21
22unexport obj-y
23unexport obj-n
24unexport obj-
25unexport export-objs
26unexport subdir-y
27unexport subdir-n
28unexport subdir-
29
30#
31# Get things started.
32#
33first_rule: sub_dirs
34 $(MAKE) all_targets
35
36SUB_DIRS := $(subdir-y)
37ALL_SUB_DIRS := $(sort $(subdir-y) $(subdir-n) $(subdir-))
38
39
40#
41# Common rules
42#
43
44%.s: %.c
45 $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -S $< -o $@
46
47%.i: %.c
48 $(CPP) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) $< > $@
49
50%.o: %.c
51 $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -c -o $@ $<
52 @ ( \
53 echo 'ifeq ($(strip $(subst $(comma),:,$(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@))),$$(strip $$(subst $$(comma),:,$$(CFLAGS) $$(EXTRA_CFLAGS) $$(CFLAGS_$@))))' ; \
54 echo 'FILES_FLAGS_UP_TO_DATE += $@' ; \
55 echo 'endif' \
56 ) > $(dir $@)/.$(notdir $@).flags
57
58%.o: %.s
59 $(AS) $(AFLAGS) $(EXTRA_CFLAGS) -o $@ $<
60
61# Old makefiles define their own rules for compiling .S files,
62# but these standard rules are available for any Makefile that
63# wants to use them. Our plan is to incrementally convert all
64# the Makefiles to these standard rules. -- rmk, mec
65ifdef USE_STANDARD_AS_RULE
66
67%.s: %.S
68 $(CPP) $(AFLAGS) $(EXTRA_AFLAGS) $(AFLAGS_$@) $< > $@
69
70%.o: %.S
71 $(CC) $(AFLAGS) $(EXTRA_AFLAGS) $(AFLAGS_$@) -c -o $@ $<
72
73endif
74
75%.lst: %.c
76 $(CC) $(CFLAGS) $(EXTRA_CFLAGS) $(CFLAGS_$@) -g -c -o $*.o $<
77 $(TOPDIR)/scripts/makelst $* $(TOPDIR) $(OBJDUMP)
78#
79#
80#
81all_targets: $(O_TARGET) $(L_TARGET)
82
83#
84# Rule to compile a set of .o files into one .o file
85#
86ifdef O_TARGET
87$(O_TARGET): $(obj-y)
88 rm -f $@
89 ifneq "$(strip $(obj-y))" ""
90 $(LD) $(EXTRA_LDFLAGS) -r -o $@ $(filter $(obj-y), $^)
91 else
92 $(AR) rcs $@
93 endif
94 @ ( \
95 echo 'ifeq ($(strip $(subst $(comma),:,$(EXTRA_LDFLAGS) $(obj-y))),$$(strip $$(subst $$(comma),:,$$(EXTRA_LDFLAGS) $$(obj-y))))' ; \
96 echo 'FILES_FLAGS_UP_TO_DATE += $@' ; \
97 echo 'endif' \
98 ) > $(dir $@)/.$(notdir $@).flags
99endif # O_TARGET
100
101#
102# Rule to compile a set of .o files into one .a file
103#
104ifdef L_TARGET
105$(L_TARGET): $(obj-y)
106 rm -f $@
107 $(AR) $(EXTRA_ARFLAGS) rcs $@ $(obj-y)
108 @ ( \
109 echo 'ifeq ($(strip $(subst $(comma),:,$(EXTRA_ARFLAGS) $(obj-y))),$$(strip $$(subst $$(comma),:,$$(EXTRA_ARFLAGS) $$(obj-y))))' ; \
110 echo 'FILES_FLAGS_UP_TO_DATE += $@' ; \
111 echo 'endif' \
112 ) > $(dir $@)/.$(notdir $@).flags
113endif
114
115
116#
117# This make dependencies quickly
118#
119fastdep: dummy
120 $(TOPDIR)/scripts/mkdep $(CFLAGS) $(EXTRA_CFLAGS) -- $(wildcard *.[chS]) > .depend
121ifdef ALL_SUB_DIRS
122 $(MAKE) $(patsubst %,_sfdep_%,$(ALL_SUB_DIRS)) _FASTDEP_ALL_SUB_DIRS="$(ALL_SUB_DIRS)"
123endif
124
125ifdef _FASTDEP_ALL_SUB_DIRS
126$(patsubst %,_sfdep_%,$(_FASTDEP_ALL_SUB_DIRS)):
127 $(MAKE) -C $(patsubst _sfdep_%,%,$@) fastdep
128endif
129
130
131#
132# A rule to make subdirectories
133#
134subdir-list = $(sort $(patsubst %,_subdir_%,$(SUB_DIRS)))
135sub_dirs: dummy $(subdir-list)
136
137ifdef SUB_DIRS
138$(subdir-list) : dummy
139 $(MAKE) -C $(patsubst _subdir_%,%,$@)
140endif
141
142#
143# A rule to do nothing
144#
145dummy:
146
147#
148# This is useful for testing
149#
150script:
151 $(SCRIPT)
152
153#
154# include dependency files if they exist
155#
156ifneq ($(wildcard .depend),)
157include .depend
158endif
159
160ifneq ($(wildcard $(TOPDIR)/.hdepend),)
161include $(TOPDIR)/.hdepend
162endif
163
164#
165# Find files whose flags have changed and force recompilation.
166# For safety, this works in the converse direction:
167# every file is forced, except those whose flags are positively up-to-date.
168#
169FILES_FLAGS_UP_TO_DATE :=
170
171# For use in expunging commas from flags, which mung our checking.
172comma = ,
173
174FILES_FLAGS_EXIST := $(wildcard .*.flags)
175ifneq ($(FILES_FLAGS_EXIST),)
176include $(FILES_FLAGS_EXIST)
177endif
178
179FILES_FLAGS_CHANGED := $(strip \
180 $(filter-out $(FILES_FLAGS_UP_TO_DATE), \
181 $(O_TARGET) $(L_TARGET) $(active-objs) \
182 ))
183
184# A kludge: .S files don't get flag dependencies (yet),
185# because that will involve changing a lot of Makefiles. Also
186# suppress object files explicitly listed in $(IGNORE_FLAGS_OBJS).
187# This allows handling of assembly files that get translated into
188# multiple object files (see arch/ia64/lib/idiv.S, for example).
189FILES_FLAGS_CHANGED := $(strip \
190 $(filter-out $(patsubst %.S, %.o, $(wildcard *.S) $(IGNORE_FLAGS_OBJS)), \
191 $(FILES_FLAGS_CHANGED)))
192
193ifneq ($(FILES_FLAGS_CHANGED),)
194$(FILES_FLAGS_CHANGED): dummy
195endif
diff --git a/applets/Makefile b/applets/Makefile
new file mode 100644
index 000000000..0688a8f3d
--- /dev/null
+++ b/applets/Makefile
@@ -0,0 +1,35 @@
1# Makefile for busybox
2#
3# Copyright (C) 1999,2000,2001 by Erik Andersen <andersee@debian.org>
4#
5# This program is free software; you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation; either version 2 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13# General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program; if not, write to the Free Software
17# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18#
19
20TOPDIR :=..
21L_TARGET := applets.a
22EXTRA_CFLAGS+=-I $(TOPDIR)/applets
23
24obj-y :=
25obj-n :=
26obj- :=
27
28obj-y += applets.o busybox.o usage.o
29
30# Hand off to toplevel Rules.mak
31include $(TOPDIR)/Rules.mak
32
33clean:
34 rm -f $(L_TARGET) *.o core
35