summaryrefslogtreecommitdiff
path: root/Makefile
blob: f1d65585c42af3467168f3f4c6f44d41c843beec (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
NAME=spice-nsis
VERSION=0.103
DISPLAYED_VERSION=$(VERSION)

# set to OVIRT to build the ovirt guest tools installer
MODE=SPICE

# Note: If you want to change the UN/INSTALLER name, you
# have to edit also the nsis source.
ifeq ($(MODE),SPICE)
# generated executable
INSTALLER=spice-guest-tools-$(VERSION).exe
# 'make install' target (in /usr/share)
INSTALL_NAME=spice-guest-tools-iso
else
ifeq ($(MODE),OVIRT)
INSTALLER=ovirt-guest-tools-setup-$(VERSION).exe
INSTALL_NAME=ovirt-guest-tools-iso
else
$(error Please set MODE to one of SPICE or OVIRT, not [$(MODE)])
endif
endif

TEMP_DIR=temp_dir

# common dependencies/sources

# From RPMs available at http://www.spice-space.org/download/windows/vdagent/vdagent-win-0.7.3/
VDA32BIN=/usr/i686-w64-mingw32/sys-root/mingw/bin
VDA64BIN=/usr/x86_64-w64-mingw32/sys-root/mingw/bin

# From virtio-win package available in https://fedoraproject.org/wiki/Windows_Virtio_Drivers#Yum.7CDnf_Repo
# TODO:
# We are currently extracting the drivers from an iso inside this RPM.
# Copy directly from the RPM once they are there. See also:
# https://bugzilla.redhat.com/1167941
VIRTIOWINISO=/usr/share/virtio-win/virtio-win.iso
# Replace this with the final directory once it's there
VIRTIOWINDRIVERS=$(TEMP_DIR)/virtio-win-drivers
# Used to re-de-duplicate the drivers as the tool we use (7z) does not support hard links.
# Built into recent Fedora because dracut requires it.
HARDLINK=/usr/sbin/hardlink
# We copy things around using rsync -H to keep hardlinked files hardlinked.
# Many of virtio-win drivers are so - using both of these together currently reduces the
# final oVirt iso from around 230MB to around 100MB.
RSYNC_AH=rsync --archive --hard-links

# ovirt dependencies/sources

# Available from http://resources.ovirt.org/pub/ovirt-3.6/rpm/fc22
OVIRTGA=/usr/share/ovirt-guest-agent-windows

# Available from http://www.microsoft.com/en-us/download/details.aspx?id=5582
# RPM wrapping this available from http://resources.ovirt.org/pub/ovirt-3.6/rpm/fc22
VCREDIST=/usr/share/vcredist-x86/vcredist_x86.exe

# Common definitions for targets
PREFIX=/usr/local
DATAROOT_DIR=$(PREFIX)/share

# install targets
INSTALL_DATA_DIR=$(DATAROOT_DIR)/$(INSTALL_NAME)

all: copy-files installer

copy-files: common-files extra-files

# Note that the installer does not depend here on the copied files,
# so that 'make install-*' will not have to recreate it.
# that's the "lazy" way. The correct way would have been to (automatically)
# add dependencies here per each external file we copy.
# If you do update one of the dependencies (say one of the drivers),
# run 'make clean' before trying again to build.
installer: $(INSTALLER)

$(INSTALLER): win-guest-tools.nsis
	makensis \
		-DVERSION="$(VERSION)" \
		-D"$(MODE)" \
		-DDISPLAYED_VERSION="$(DISPLAYED_VERSION)" \
		win-guest-tools.nsis

common-files: $(VIRTIOWINDRIVERS)
	mkdir -p bin/vdagent_x86 bin/vdagent_x64 drivers/virtio
	$(RSYNC_AH) "$(VDA32BIN)"/vdagent.exe bin/vdagent_x86/
	$(RSYNC_AH) "$(VDA32BIN)"/vdservice.exe bin/vdagent_x86/
	$(RSYNC_AH) "$(VDA64BIN)"/vdagent.exe bin/vdagent_x64/
	$(RSYNC_AH) "$(VDA64BIN)"/vdservice.exe bin/vdagent_x64/
	$(RSYNC_AH) "$(VIRTIOWINDRIVERS)"/* drivers/virtio/

# TODO: Drop this once the drivers are shipped as normal files. See comment above.
$(VIRTIOWINDRIVERS):
	mkdir -p "$(VIRTIOWINDRIVERS)"
	7z -o"$(VIRTIOWINDRIVERS)" x "$(VIRTIOWINISO)"
	# Deduplicate. source iso is already so, but 7z does not support hardlinks.
	# Do not fail on this.
	if [ -x "$(HARDLINK)" ]; then \
		"$(HARDLINK)" -vv "$(VIRTIOWINDRIVERS)"; \
	else \
		echo "Warning: $(HARDLINK) is missing. iso file will have many duplicate files"; \
	fi

# Extra files:

ifeq ($(MODE),SPICE)
extra-files:
	: TODO: Add here spice-specific files if any
else
ifeq ($(MODE),OVIRT)
extra-files:
	$(RSYNC_AH) \
		"$(OVIRTGA)/OVirtGuestService.exe" \
		"$(OVIRTGA)/default.ini" \
		"$(OVIRTGA)/default.ini" \
		"$(OVIRTGA)/default-logger.ini" \
		"$(OVIRTGA)/ovirt-guest-agent.ini" \
		"$(VCREDIST)" \
		bin/
endif
endif

clean:
	rm -rf *.exe bin drivers "$(TEMP_DIR)" "$(ISO_IMAGE)"