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