xref: /linux/tools/hv/Makefile (revision 3f41368fbfe1b3d5922d317fe1a0a0cab6846802)
1# SPDX-License-Identifier: GPL-2.0
2# Makefile for Hyper-V tools
3include ../scripts/Makefile.include
4
5ARCH := $(shell uname -m 2>/dev/null)
6sbindir ?= /usr/sbin
7libexecdir ?= /usr/libexec
8sharedstatedir ?= /var/lib
9
10ifeq ($(srctree),)
11srctree := $(patsubst %/,%,$(dir $(CURDIR)))
12srctree := $(patsubst %/,%,$(dir $(srctree)))
13endif
14
15# Do not use make's built-in rules
16# (this improves performance and avoids hard-to-debug behaviour);
17MAKEFLAGS += -r
18
19override CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include
20
21ALL_TARGETS := hv_kvp_daemon hv_vss_daemon
22ifneq ($(ARCH), aarch64)
23ALL_TARGETS += hv_fcopy_uio_daemon
24endif
25ALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS))
26
27ALL_SCRIPTS := hv_get_dhcp_info.sh hv_get_dns_info.sh hv_set_ifconfig.sh
28
29all: $(ALL_PROGRAMS)
30
31export srctree OUTPUT CC LD CFLAGS
32include $(srctree)/tools/build/Makefile.include
33
34HV_KVP_DAEMON_IN := $(OUTPUT)hv_kvp_daemon-in.o
35$(HV_KVP_DAEMON_IN): FORCE
36	$(Q)$(MAKE) $(build)=hv_kvp_daemon
37$(OUTPUT)hv_kvp_daemon: $(HV_KVP_DAEMON_IN)
38	$(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
39
40HV_VSS_DAEMON_IN := $(OUTPUT)hv_vss_daemon-in.o
41$(HV_VSS_DAEMON_IN): FORCE
42	$(Q)$(MAKE) $(build)=hv_vss_daemon
43$(OUTPUT)hv_vss_daemon: $(HV_VSS_DAEMON_IN)
44	$(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
45
46HV_FCOPY_UIO_DAEMON_IN := $(OUTPUT)hv_fcopy_uio_daemon-in.o
47$(HV_FCOPY_UIO_DAEMON_IN): FORCE
48	$(Q)$(MAKE) $(build)=hv_fcopy_uio_daemon
49$(OUTPUT)hv_fcopy_uio_daemon: $(HV_FCOPY_UIO_DAEMON_IN)
50	$(QUIET_LINK)$(CC) $(CFLAGS) $(LDFLAGS) $< -o $@
51
52clean:
53	rm -f $(ALL_PROGRAMS)
54	find $(or $(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete
55
56install: $(ALL_PROGRAMS)
57	install -d -m 755 $(DESTDIR)$(sbindir); \
58	install -d -m 755 $(DESTDIR)$(libexecdir)/hypervkvpd; \
59	install -d -m 755 $(DESTDIR)$(sharedstatedir); \
60	for program in $(ALL_PROGRAMS); do \
61		install $$program -m 755 $(DESTDIR)$(sbindir);	\
62	done; \
63	install -m 755 lsvmbus $(DESTDIR)$(sbindir); \
64	for script in $(ALL_SCRIPTS); do \
65		install $$script -m 755 $(DESTDIR)$(libexecdir)/hypervkvpd/$${script%.sh}; \
66	done
67
68FORCE:
69
70.PHONY: all install clean FORCE prepare
71