aboutsummaryrefslogtreecommitdiff
path: root/contrib/plugins/Makefile
diff options
context:
space:
mode:
authorGreg Manning <gmanning@rapitasystems.com>2023-11-06 18:51:04 +0000
committerAlex Bennée <alex.bennee@linaro.org>2023-11-08 15:15:23 +0000
commit330fe3b03f6451889bec6f5c9f7e8bb5009c80c3 (patch)
treebf2ba5a952418a518b2d70ab410774d2cb42afdb /contrib/plugins/Makefile
parentfb691b8cbabf5bde7d25a7f720d5ec7d5b1341e1 (diff)
downloadqemu-330fe3b03f6451889bec6f5c9f7e8bb5009c80c3.zip
qemu-330fe3b03f6451889bec6f5c9f7e8bb5009c80c3.tar.gz
qemu-330fe3b03f6451889bec6f5c9f7e8bb5009c80c3.tar.bz2
plugins: make test/example plugins work on windows
Generate a qemu_plugin_api.lib delay import lib on windows, for windows qemu plugins to link against. Implement an example dll load fail hook to link up the API functions correctly when a plugin is loaded on windows. Update the build scripts for the test and example plugins to use these things. Signed-off-by: Greg Manning <gmanning@rapitasystems.com> Acked-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20231102172053.17692-3-gmanning@rapitasystems.com> [AJB: use find_program for dlltool, s/Windows/windows/] Cc: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Alex Bennée <alex.bennee@linaro.org> Message-Id: <20231106185112.2755262-15-alex.bennee@linaro.org>
Diffstat (limited to 'contrib/plugins/Makefile')
-rw-r--r--contrib/plugins/Makefile20
1 files changed, 16 insertions, 4 deletions
diff --git a/contrib/plugins/Makefile b/contrib/plugins/Makefile
index 8ba78c7..751fa38 100644
--- a/contrib/plugins/Makefile
+++ b/contrib/plugins/Makefile
@@ -22,7 +22,14 @@ NAMES += hwprofile
NAMES += cache
NAMES += drcov
-SONAMES := $(addsuffix .so,$(addprefix lib,$(NAMES)))
+ifeq ($(CONFIG_WIN32),y)
+SO_SUFFIX := .dll
+LDLIBS += $(shell $(PKG_CONFIG) --libs glib-2.0)
+else
+SO_SUFFIX := .so
+endif
+
+SONAMES := $(addsuffix $(SO_SUFFIX),$(addprefix lib,$(NAMES)))
# The main QEMU uses Glib extensively so it's perfectly fine to use it
# in plugins (which many example do).
@@ -35,15 +42,20 @@ all: $(SONAMES)
%.o: %.c
$(CC) $(CFLAGS) $(PLUGIN_CFLAGS) -c -o $@ $<
-lib%.so: %.o
-ifeq ($(CONFIG_DARWIN),y)
+ifeq ($(CONFIG_WIN32),y)
+lib%$(SO_SUFFIX): %.o win32_linker.o ../../plugins/qemu_plugin_api.lib
+ $(CC) -shared -o $@ $^ $(LDLIBS)
+else ifeq ($(CONFIG_DARWIN),y)
+lib%$(SO_SUFFIX): %.o
$(CC) -bundle -Wl,-undefined,dynamic_lookup -o $@ $^ $(LDLIBS)
else
+lib%$(SO_SUFFIX): %.o
$(CC) -shared -o $@ $^ $(LDLIBS)
endif
+
clean:
- rm -f *.o *.so *.d
+ rm -f *.o *$(SO_SUFFIX) *.d
rm -Rf .libs
.PHONY: all clean