1 # SPDX-License-Identifier: GPL-2.0
2 # Makefile for Hyper-V tools
3 include ../scripts/Makefile.include
6 libexecdir ?= /usr/libexec
7 sharedstatedir ?= /var/lib
10 srctree := $(patsubst %/,%,$(dir $(CURDIR)))
11 srctree := $(patsubst %/,%,$(dir $(srctree)))
14 # Do not use make's built-in rules
15 # (this improves performance and avoids hard-to-debug behaviour);
18 override CFLAGS += -O2 -Wall -g -D_GNU_SOURCE -I$(OUTPUT)include
20 ALL_TARGETS := hv_kvp_daemon hv_vss_daemon hv_fcopy_daemon
21 ALL_PROGRAMS := $(patsubst %,$(OUTPUT)%,$(ALL_TARGETS))
23 ALL_SCRIPTS := hv_get_dhcp_info.sh hv_get_dns_info.sh hv_set_ifconfig.sh
27 export srctree OUTPUT CC LD CFLAGS
28 include $(srctree)/tools/build/Makefile.include
30 HV_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 $@
36 HV_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 $@
42 HV_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 $@
50 find $(if $(OUTPUT),$(OUTPUT),.) -name '*.o' -delete -o -name '\.*.d' -delete
52 install: $(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); \
59 install -m 755 lsvmbus $(DESTDIR)$(sbindir); \
60 for script in $(ALL_SCRIPTS); do \
61 install $$script -m 755 $(DESTDIR)$(libexecdir)/hypervkvpd/$${script%.sh}; \
66 .PHONY: all install clean FORCE prepare