xref: /openbmc/qemu/contrib/plugins/Makefile (revision ad8a0f48)
1# -*- Mode: makefile -*-
2#
3# This Makefile example is fairly independent from the main makefile
4# so users can take and adapt it for their build. We only really
5# include config-host.mak so we don't have to repeat probing for
6# programs that the main configure has already done for us.
7#
8
9include config-host.mak
10
11TOP_SRC_PATH = $(SRC_PATH)/../..
12
13VPATH += $(SRC_PATH)
14
15NAMES :=
16NAMES += execlog
17NAMES += hotblocks
18NAMES += hotpages
19NAMES += howvec
20
21# The lockstep example communicates using unix sockets,
22# and can't be easily made to work on windows.
23ifneq ($(CONFIG_WIN32),y)
24NAMES += lockstep
25endif
26
27NAMES += hwprofile
28NAMES += cache
29NAMES += drcov
30NAMES += ips
31
32ifeq ($(CONFIG_WIN32),y)
33SO_SUFFIX := .dll
34LDLIBS += $(shell $(PKG_CONFIG) --libs glib-2.0)
35else
36SO_SUFFIX := .so
37endif
38
39SONAMES := $(addsuffix $(SO_SUFFIX),$(addprefix lib,$(NAMES)))
40
41# The main QEMU uses Glib extensively so it's perfectly fine to use it
42# in plugins (which many example do).
43PLUGIN_CFLAGS := $(shell $(PKG_CONFIG) --cflags glib-2.0)
44PLUGIN_CFLAGS += -fPIC -Wall
45PLUGIN_CFLAGS += -I$(TOP_SRC_PATH)/include/qemu
46
47all: $(SONAMES)
48
49%.o: %.c
50	$(CC) $(CFLAGS) $(PLUGIN_CFLAGS) -c -o $@ $<
51
52ifeq ($(CONFIG_WIN32),y)
53lib%$(SO_SUFFIX): %.o win32_linker.o ../../plugins/libqemu_plugin_api.a
54	$(CC) -shared -o $@ $^ $(LDLIBS)
55else ifeq ($(CONFIG_DARWIN),y)
56lib%$(SO_SUFFIX): %.o
57	$(CC) -bundle -Wl,-undefined,dynamic_lookup -o $@ $^ $(LDLIBS)
58else
59lib%$(SO_SUFFIX): %.o
60	$(CC) -shared -o $@ $^ $(LDLIBS)
61endif
62
63
64clean:
65	rm -f *.o *$(SO_SUFFIX) *.d
66	rm -Rf .libs
67
68.PHONY: all clean
69.SECONDARY:
70