Contents of /tags/mkinitrd-6_4_0/klibc/Makefile
Parent Directory | Revision Log
Revision 1313 -
(show annotations)
(download)
Fri May 27 18:20:23 2011 UTC (13 years, 4 months ago) by niro
File size: 5202 byte(s)
Fri May 27 18:20:23 2011 UTC (13 years, 4 months ago) by niro
File size: 5202 byte(s)
tagged 'mkinitrd-6_4_0'
1 | SRCROOT = . |
2 | |
3 | # *DOCUMENTATION* |
4 | # To see a list of typical targets execute "make help" |
5 | |
6 | # kbuild compatibility |
7 | export srctree := $(shell pwd) |
8 | export objtree := $(shell pwd) |
9 | export KLIBCSRC := usr/klibc |
10 | export VERSION := $(shell cat $(srctree)/$(KLIBCSRC)/version) |
11 | export KLIBCINC := usr/include |
12 | export KLIBCOBJ := usr/klibc |
13 | export KLIBCKERNELSRC ?= linux |
14 | export KLIBCKERNELOBJ ?= $(KLIBCKERNELSRC) |
15 | |
16 | export VPATH := $(srctree) |
17 | |
18 | include $(srctree)/scripts/Kbuild.include |
19 | |
20 | KLIBCROSS ?= $(CROSS_COMPILE) |
21 | export KLIBCROSS |
22 | export CC := $(KLIBCROSS)gcc |
23 | export LD := $(KLIBCROSS)ld |
24 | export AR := $(KLIBCROSS)ar |
25 | export RANLIB := $(KLIBCROSS)ranlib |
26 | export STRIP := $(KLIBCROSS)strip |
27 | export NM := $(KLIBCROSS)nm |
28 | export OBJCOPY := $(KLIBCROSS)objcopy |
29 | export OBJDUMP := $(KLIBCROSS)objdump |
30 | |
31 | 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/sh.*/sh/) |
34 | export KLIBCARCH ?= $(ARCH) |
35 | export KLIBCARCHDIR := $(shell echo $(KLIBCARCH) | sed -e s/s390x/s390/) |
36 | |
37 | export HOSTCC := gcc |
38 | export HOSTCFLAGS := -Wall -Wstrict-prototypes -O2 -fomit-frame-pointer |
39 | export PERL := perl |
40 | |
41 | # Location for installation |
42 | export prefix = /usr |
43 | export bindir = $(prefix)/bin |
44 | export libdir = $(prefix)/lib |
45 | export mandir = $(prefix)/man |
46 | export INSTALLDIR = $(prefix)/lib/klibc |
47 | export INSTALLROOT = |
48 | |
49 | # Create a fake .config as present in the kernel tree |
50 | # But if it exists leave it alone |
51 | $(if $(wildcard $(objtree)/.config),,\ |
52 | $(shell cp $(srctree)/defconfig $(objtree)/.config)) |
53 | |
54 | # Prefix Make commands with $(Q) to silence them |
55 | # Use quiet_cmd_xxx, cmd_xxx to create nice output |
56 | # use make V=1 to get verbose output |
57 | |
58 | ifdef V |
59 | ifeq ("$(origin V)", "command line") |
60 | KBUILD_VERBOSE = $(V) |
61 | endif |
62 | endif |
63 | ifndef KBUILD_VERBOSE |
64 | KBUILD_VERBOSE = 0 |
65 | endif |
66 | |
67 | ifeq ($(KBUILD_VERBOSE),1) |
68 | quiet = |
69 | Q = |
70 | else |
71 | quiet=quiet_ |
72 | Q = @ |
73 | endif |
74 | |
75 | # If the user is running make -s (silent mode), suppress echoing of |
76 | # commands |
77 | |
78 | ifneq ($(findstring s,$(MAKEFLAGS)),) |
79 | quiet=silent_ |
80 | endif |
81 | |
82 | export quiet Q KBUILD_VERBOSE |
83 | |
84 | # Do not print "Entering directory ..." |
85 | MAKEFLAGS += --no-print-directory |
86 | |
87 | # Shorthand to call Kbuild.klibc |
88 | klibc := -f $(srctree)/scripts/Kbuild.klibc obj |
89 | |
90 | # Very first target |
91 | .PHONY: all klcc klibc |
92 | all: klcc klibc |
93 | |
94 | $(objtree)/.config: $(srctree)/defconfig |
95 | @echo "defconfig has changed, please remove or edit .config" |
96 | @false |
97 | |
98 | $(KLIBCKERNELSRC): |
99 | @echo "Cannot find kernel sources." |
100 | @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 |
104 | |
105 | rpmbuild = $(shell which rpmbuild 2>/dev/null || which rpm) |
106 | |
107 | klibc.spec: klibc.spec.in $(KLIBCSRC)/version |
108 | sed -e 's/@@VERSION@@/$(VERSION)/g' < $< > $@ |
109 | |
110 | # Build klcc - it is the first target |
111 | klcc: $(objtree)/.config |
112 | $(Q)$(MAKE) $(klibc)=klcc |
113 | |
114 | klibc: $(objtree)/.config |
115 | $(Q)$(MAKE) $(klibc)=. |
116 | |
117 | test: klibc |
118 | $(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 |
142 | # Caveat: works only for .c files where we have a Kbuild file in same dir |
143 | %.o: %.c FORCE |
144 | $(Q)$(MAKE) $(klibc)=$(dir $<) $(dir $<)$(notdir $@) |
145 | |
146 | %.s: %.c FORCE |
147 | $(Q)$(MAKE) $(klibc)=$(dir $<) $(dir $<)$(notdir $@) |
148 | |
149 | %.i: %.c FORCE |
150 | $(Q)$(MAKE) $(klibc)=$(dir $<) $(dir $<)$(notdir $@) |
151 | |
152 | FORCE: ; |
153 | ### |
154 | # clean: remove generated files |
155 | # mrproper does a full cleaning including .config and linux symlink |
156 | FIND_IGNORE := \( -name .git \) -prune -o |
157 | quiet_cmd_rmfiles = $(if $(wildcard $(rm-files)),RM $(wildcard $(rm-files))) |
158 | cmd_rmfiles = rm -f $(rm-files) |
159 | clean: |
160 | $(Q)$(MAKE) -f $(srctree)/scripts/Makefile.clean obj=. |
161 | $(Q)find . $(FIND_IGNORE) \ |
162 | \( -name *.o -o -name *.a -o -name '.*.cmd' -o \ |
163 | -name '.*.d' -o -name '.*.tmp' \) \ |
164 | -type f -print | xargs rm -f |
165 | |
166 | rm-files := $(objtree)/.config linux |
167 | distclean mrproper: clean |
168 | $(Q)find . $(FIND_IGNORE) \ |
169 | \( -name '*.orig' -o -name '*.rej' -o -name '*~' \ |
170 | -o -name '*.bak' -o -name '#*#' -o -name '.*.orig' \ |
171 | -o -name '.*.rej' -o -size 0 \ |
172 | -o -name '*%' -o -name '.*.cmd' -o -name 'core' \) \ |
173 | -type f -print | xargs rm -f |
174 | $(call cmd,rmfiles) |
175 | |
176 | install: all |
177 | $(Q)$(MAKE) -f $(srctree)/scripts/Kbuild.install obj=. |
178 | |
179 | # This does all the prep work needed to turn a freshly exported git repository |
180 | # into a release tarball tree |
181 | release: klibc.spec |
182 | rm -f maketar.sh .config |