xref: /openbmc/qemu/contrib/plugins/Makefile (revision 6ea3f1f0)
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
31NAMES += stoptrigger
32
33ifeq ($(CONFIG_WIN32),y)
34SO_SUFFIX := .dll
35LDLIBS += $(shell $(PKG_CONFIG) --libs glib-2.0)
36else
37SO_SUFFIX := .so
38endif
39
40SONAMES := $(addsuffix $(SO_SUFFIX),$(addprefix lib,$(NAMES)))
41
42# The main QEMU uses Glib extensively so it is perfectly fine to use it
43# in plugins (which many example do).
44PLUGIN_CFLAGS := $(shell $(PKG_CONFIG) --cflags glib-2.0)
45PLUGIN_CFLAGS += -fPIC -Wall
46PLUGIN_CFLAGS += -I$(TOP_SRC_PATH)/include/qemu
47
48# Helper that honours V=1 so we get some output when compiling
49quiet-@ = $(if $(V),,@$(if $1,printf "  %-7s %s\n" "$(strip $1)" "$(strip $2)" && ))
50quiet-command = $(call quiet-@,$2,$3)$1
51
52# for including , in command strings
53COMMA := ,
54
55all: $(SONAMES)
56
57%.o: %.c
58	$(call quiet-command, \
59		$(CC) $(CFLAGS) $(PLUGIN_CFLAGS) -c -o $@ $<, \
60	        BUILD, plugin $@)
61
62ifeq ($(CONFIG_WIN32),y)
63lib%$(SO_SUFFIX): %.o win32_linker.o ../../plugins/libqemu_plugin_api.a
64	$(call quiet-command, \
65		$(CC) -shared -o $@ $^ $(LDLIBS), \
66		LINK, plugin $@)
67else ifeq ($(CONFIG_DARWIN),y)
68lib%$(SO_SUFFIX): %.o
69	$(call quiet-command, \
70		$(CC) -bundle -Wl$(COMMA)-undefined$(COMMA)dynamic_lookup -o $@ $^ $(LDLIBS), \
71		LINK, plugin $@)
72else
73lib%$(SO_SUFFIX): %.o
74	$(call quiet-command, \
75		$(CC) -shared -o $@ $^ $(LDLIBS), \
76		LINK, plugin $@)
77endif
78
79
80clean distclean:
81	rm -f *.o *$(SO_SUFFIX) *.d
82	rm -Rf .libs
83
84.PHONY: all clean
85.SECONDARY:
86