aboutsummaryrefslogtreecommitdiffstats
path: root/xen/Makefile
blob: 16ba9c2046348185057e2dde1fef1bcc0c82a8aa (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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
# Default is to install to local 'dist' directory.
DISTDIR ?= ../dist
DESTDIR ?= $(DISTDIR)/install

INSTALL			= install
INSTALL_DATA		= $(INSTALL) -m0644
INSTALL_DIR		= $(INSTALL) -d -m0755

# This is the correct place to edit the build version.
# All other places this is stored (eg. compile.h) should be autogenerated.
export XEN_VERSION       = 3
export XEN_SUBVERSION    = 0
export XEN_EXTRAVERSION  = -devel
export XEN_FULLVERSION   = $(XEN_VERSION).$(XEN_SUBVERSION)$(XEN_EXTRAVERSION)

export BASEDIR          := $(CURDIR)

include Rules.mk

default: build
$(TARGET).gz: $(TARGET)
	gzip -f -9 < $< > $@.new
	mv $@.new $@

debug:	
	objdump -D -S $(TARGET)-syms > $(TARGET).s

dist: install

build: $(TARGET).gz

install: $(TARGET).gz
	[ -d $(DESTDIR)/boot ] || $(INSTALL_DIR) $(DESTDIR)/boot
	$(INSTALL_DATA) $(TARGET).gz $(DESTDIR)/boot/$(notdir $(TARGET))-$(XEN_VERSION).$(XEN_SUBVERSION)$(XEN_EXTRAVERSION).gz
	ln -f -s $(notdir $(TARGET))-$(XEN_VERSION).$(XEN_SUBVERSION)$(XEN_EXTRAVERSION).gz $(DESTDIR)/boot/$(notdir $(TARGET))-$(XEN_VERSION).$(XEN_SUBVERSION).gz
	ln -f -s $(notdir $(TARGET))-$(XEN_VERSION).$(XEN_SUBVERSION)$(XEN_EXTRAVERSION).gz $(DESTDIR)/boot/$(notdir $(TARGET))-$(XEN_VERSION).gz
	ln -f -s $(notdir $(TARGET))-$(XEN_VERSION).$(XEN_SUBVERSION)$(XEN_EXTRAVERSION).gz $(DESTDIR)/boot/$(notdir $(TARGET)).gz
	$(INSTALL_DATA) $(TARGET)-syms $(DESTDIR)/boot/$(notdir $(TARGET))-syms-$(XEN_VERSION).$(XEN_SUBVERSION)$(XEN_EXTRAVERSION)
	[ -d $(DESTDIR)/usr/include/xen/io ] || \
		$(INSTALL_DIR) $(DESTDIR)/usr/include/xen/io
	$(INSTALL_DATA) include/public/*.h $(DESTDIR)/usr/include/xen
	$(INSTALL_DATA) include/public/io/*.h $(DESTDIR)/usr/include/xen/io
	$(INSTALL_DATA) include/public/COPYING $(DESTDIR)/usr/include/xen

clean: delete-unfresh-files
	$(MAKE) -C tools clean
	$(MAKE) -C common clean
	$(MAKE) -C drivers clean
	$(MAKE) -C acm clean
	$(MAKE) -C arch/$(TARGET_ARCH) clean
	rm -f include/asm *.o $(TARGET)* *~ core
	rm -f include/asm-*/asm-offsets.h
	rm -f tools/figlet/*.o tools/figlet/figlet

$(TARGET): delete-unfresh-files
	$(MAKE) include/xen/compile.h
	[ -e include/asm ] || ln -sf asm-$(TARGET_ARCH) include/asm
	$(MAKE) -C arch/$(TARGET_ARCH) asm-offsets.s
	$(MAKE) include/asm-$(TARGET_ARCH)/asm-offsets.h
	$(MAKE) -C common
	$(MAKE) -C drivers
ifdef ACM_USE_SECURITY_POLICY
	$(MAKE) -C acm
endif
	$(MAKE) -C arch/$(TARGET_ARCH)

# drivers/char/console.o may contain static banner/compile info. Blow it away.
delete-unfresh-files:
	rm -f include/xen/banner.h include/xen/compile.h drivers/char/console.o
	$(MAKE) -C arch/$(TARGET_ARCH) delete-unfresh-files

# compile.h contains dynamic build info. Rebuilt on every 'make' invocation.
include/xen/compile.h: LANG=C
include/xen/compile.h: include/xen/compile.h.in include/xen/banner.h
	@sed -e 's/@@date@@/$(shell date)/g' \
	    -e 's/@@time@@/$(shell date +%T)/g' \
	    -e 's/@@whoami@@/$(shell whoami)/g' \
	    -e 's/@@domain@@/$(shell ([ -x /bin/dnsdomainname ] && /bin/dnsdomainname) || ([ -x /bin/domainname ] && /bin/domainname || echo [unknown]))/g' \
	    -e 's/@@hostname@@/$(shell hostname)/g' \
	    -e 's/@@compiler@@/$(shell $(CC) $(CFLAGS) -v 2>&1 | tail -1)/g' \
	    -e 's/@@version@@/$(XEN_VERSION)/g' \
	    -e 's/@@subversion@@/$(XEN_SUBVERSION)/g' \
	    -e 's/@@extraversion@@/$(XEN_EXTRAVERSION)/g' \
	    -e 's!@@changeset@@!$(shell bk changes -nd':D: :T: :REV: :MD5KEY:' -r+ 2>/dev/null || echo information unavailable)!g' \
	    < include/xen/compile.h.in > $@.new
	@cat include/xen/banner.h >> $@.new
	@mv -f $@.new $@

tools/figlet/figlet: tools/figlet/figlet.o
	$(HOSTCC) -o $@ $<
tools/figlet/figlet.o: tools/figlet/figlet.c
	$(HOSTCC) -o $@ -c $<

include/xen/banner.h: tools/figlet/figlet tools/figlet/xen.flf
	tools/figlet/figlet -d tools/figlet Xen $(XEN_FULLVERSION) > $@.new
	@mv -f $@.new $@

include/asm-$(TARGET_ARCH)/asm-offsets.h: arch/$(TARGET_ARCH)/asm-offsets.s
	@(set -e; \
	  echo "/*"; \
	  echo " * DO NOT MODIFY."; \
	  echo " *"; \
	  echo " * This file was auto-generated from $<"; \
	  echo " *"; \
	  echo " */"; \
	  echo ""; \
	  echo "#ifndef __ASM_OFFSETS_H__"; \
	  echo "#define __ASM_OFFSETS_H__"; \
	  echo ""; \
	  sed -ne "/^->/{s:^->\([^ ]*\) [\$$#]*\([^ ]*\) \(.*\):#define \1 \2 /* \3 */:; s:->::; p;}"; \
	  echo ""; \
	  echo "#endif") <$< >$@

.PHONY: default debug install dist clean delete-unfresh-files TAGS tags

SUBDIRS = acm arch/$(TARGET_ARCH) common drivers 
define all_sources
    ( find include/asm-$(TARGET_ARCH) -name SCCS -prune -o -name '*.h' -print; \
      find include -type d -name SCCS -prune -o \( -name "asm-*" -o \
            -name config \) -prune -o -name '*.h' -print; \
      find $(SUBDIRS) -name SCCS -prune -o -name '*.[chS]' -print )
endef
TAGS: 
	$(all_sources) | etags -
tags: 
	$(all_sources) | xargs ctags
cscope: 
	$(all_sources) > cscope.files
	cscope -k -b -q
MAP:
	nm $(TARGET) | grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | sort > System.map