1 |
SRCROOT = . |
SRCROOT = . |
2 |
|
|
3 |
|
# *DOCUMENTATION* |
4 |
|
# To see a list of typical targets execute "make help" |
5 |
|
|
6 |
# kbuild compatibility |
# kbuild compatibility |
7 |
export srctree := $(shell pwd) |
export srctree := $(shell pwd) |
8 |
export objtree := $(shell pwd) |
export objtree := $(shell pwd) |
9 |
export KLIBCSRC := usr/klibc |
export KLIBCSRC := usr/klibc |
10 |
export VERSION := $(shell cat $(KLIBCSRC)/version) |
export VERSION := $(shell cat $(srctree)/$(KLIBCSRC)/version) |
11 |
export KLIBCINC := usr/include |
export KLIBCINC := usr/include |
12 |
export KLIBCOBJ := usr/klibc |
export KLIBCOBJ := usr/klibc |
13 |
export KLIBCKERNELSRC := linux/ |
export KLIBCKERNELSRC ?= linux |
14 |
export KLIBCKERNELOBJ := linux/ |
export KLIBCKERNELOBJ ?= $(KLIBCKERNELSRC) |
15 |
include scripts/Kbuild.include |
|
16 |
|
export VPATH := $(srctree) |
17 |
|
|
18 |
|
include $(srctree)/scripts/Kbuild.include |
19 |
|
|
20 |
KLIBCROSS ?= $(CROSS_COMPILE) |
KLIBCROSS ?= $(CROSS_COMPILE) |
21 |
export KLIBCROSS |
export KLIBCROSS |
30 |
|
|
31 |
NOSTDINC_FLAGS := -nostdlib -nostdinc -isystem $(shell $(CC) -print-file-name=include) |
NOSTDINC_FLAGS := -nostdlib -nostdinc -isystem $(shell $(CC) -print-file-name=include) |
32 |
|
|
33 |
ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/parisc64/parisc/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/ -e s/sh4/sh/) |
ARCH := $(shell uname -m | sed -e s/i.86/i386/ -e s/parisc64/parisc/ -e s/sun4u/sparc64/ -e s/arm.*/arm/ -e s/sa110/arm/ -e s/sh.*/sh/) |
34 |
export KLIBCARCH ?= $(ARCH) |
export KLIBCARCH ?= $(ARCH) |
35 |
export KLIBCARCHDIR := $(shell echo $(KLIBCARCH) | sed -e s/s390x/s390/) |
export KLIBCARCHDIR := $(shell echo $(KLIBCARCH) | sed -e s/s390x/s390/) |
36 |
|
|
48 |
|
|
49 |
# Create a fake .config as present in the kernel tree |
# Create a fake .config as present in the kernel tree |
50 |
# But if it exists leave it alone |
# But if it exists leave it alone |
51 |
$(if $(wildcard $(objtree)/.config),,$(shell cp defconfig .config)) |
$(if $(wildcard $(objtree)/.config),,\ |
52 |
|
$(shell cp $(srctree)/defconfig $(objtree)/.config)) |
53 |
|
|
54 |
# Prefix Make commands with $(Q) to silence them |
# Prefix Make commands with $(Q) to silence them |
55 |
# Use quiet_cmd_xxx, cmd_xxx to create nice output |
# Use quiet_cmd_xxx, cmd_xxx to create nice output |
91 |
.PHONY: all klcc klibc |
.PHONY: all klcc klibc |
92 |
all: klcc klibc |
all: klcc klibc |
93 |
|
|
94 |
.config: defconfig linux |
$(objtree)/.config: $(srctree)/defconfig $(KLIBCKERNELOBJ) |
95 |
@echo "defconfig has changed, please remove or edit .config" |
@echo "defconfig has changed, please remove or edit .config" |
96 |
@false |
@false |
97 |
|
|
98 |
linux: |
$(KLIBCKERNELSRC): |
99 |
@echo "The 'linux' symlink is missing; it should point to a kernel tree " |
@echo "Cannot find kernel sources." |
100 |
@echo "configured for the $(KLIBCARCH) architecture." |
@echo "Either make a 'linux' symlink point to a kernel tree " |
101 |
|
@echo "configured for the $(KLIBCARCH) architecture or specify " |
102 |
|
@echo "KLIBCKERNELSRC=<path> to the build." |
103 |
@false |
@false |
104 |
|
|
105 |
rpmbuild = $(shell which rpmbuild 2>/dev/null || which rpm) |
rpmbuild = $(shell which rpmbuild 2>/dev/null || which rpm) |
108 |
sed -e 's/@@VERSION@@/$(VERSION)/g' < $< > $@ |
sed -e 's/@@VERSION@@/$(VERSION)/g' < $< > $@ |
109 |
|
|
110 |
# Build klcc - it is the first target |
# Build klcc - it is the first target |
111 |
klcc: .config |
klcc: $(objtree)/.config |
112 |
$(Q)$(MAKE) $(klibc)=klcc |
$(Q)$(MAKE) $(klibc)=klcc |
113 |
|
|
114 |
klibc: .config |
klibc: $(objtree)/.config |
115 |
$(Q)$(MAKE) $(klibc)=. |
$(Q)$(MAKE) $(klibc)=. |
116 |
|
|
117 |
test: klibc |
test: klibc |
118 |
$(Q)$(MAKE) $(klibc)=usr/klibc/tests |
$(Q)$(MAKE) $(klibc)=usr/klibc/tests |
119 |
|
|
120 |
|
help: |
121 |
|
@echo 'Cleaning targets:' |
122 |
|
@echo ' clean - Remove most generated files' |
123 |
|
@echo ' mrproper - Remove all generated files + config' |
124 |
|
@echo ' distclean - mprproper + editor backup + patch files' |
125 |
|
@echo '' |
126 |
|
@echo 'Build targets:' |
127 |
|
@echo 'all - Build all targets' |
128 |
|
@echo 'install - Install klibc' |
129 |
|
@echo 'klcc - Wrapper around gcc to compile against klibc' |
130 |
|
@echo 'test - Run klibc tests' |
131 |
|
@echo |
132 |
|
@echo 'Build options:' |
133 |
|
@echo 'KLIBCKERNELSRC - Path to a configured linux-2.6 tree' |
134 |
|
@echo 'KLIBCKERNELOBJ - Path to kernel output dir (defaults to KLIBCKERNELSRC)' |
135 |
|
@echo 'make V=0|1 [targets] 0 => quiet build (default), 1 => verbose build' |
136 |
|
@echo |
137 |
|
@echo 'Sample invocation:' |
138 |
|
@echo 'make KLIBCKERNELSRC=`pwd`/../linux-2.6' |
139 |
|
|
140 |
### |
### |
141 |
# allow one to say make dir/file.o |
# allow one to say make dir/file.o |
163 |
-name '.*.d' -o -name '.*.tmp' \) \ |
-name '.*.d' -o -name '.*.tmp' \) \ |
164 |
-type f -print | xargs rm -f |
-type f -print | xargs rm -f |
165 |
|
|
166 |
rm-files := .config linux |
rm-files := $(objtree)/.config linux |
167 |
distclean mrproper: clean |
distclean mrproper: clean |
168 |
$(Q)find . $(FIND_IGNORE) \ |
$(Q)find . $(FIND_IGNORE) \ |
169 |
\( -name '*.orig' -o -name '*.rej' -o -name '*~' \ |
\( -name '*.orig' -o -name '*.rej' -o -name '*~' \ |