Merge tag 'v9.1.0'
[qemu/ar7.git] / contrib / plugins / Makefile
blobedf256cd9d11f0a00ff839f9d98656c885f9ebe9
1 # -*- Mode: makefile -*-
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.
9 include config-host.mak
11 TOP_SRC_PATH = $(SRC_PATH)/../..
13 VPATH += $(SRC_PATH)
15 NAMES :=
16 NAMES += execlog
17 NAMES += hotblocks
18 NAMES += hotpages
19 NAMES += howvec
21 # The lockstep example communicates using unix sockets,
22 # and can't be easily made to work on windows.
23 ifneq ($(CONFIG_WIN32),y)
24 NAMES += lockstep
25 endif
27 NAMES += hwprofile
28 NAMES += cache
29 NAMES += drcov
30 NAMES += ips
31 NAMES += stoptrigger
33 ifeq ($(CONFIG_WIN32),y)
34 SO_SUFFIX := .dll
35 LDLIBS += $(shell $(PKG_CONFIG) --libs glib-2.0)
36 else
37 SO_SUFFIX := .so
38 endif
40 SONAMES := $(addsuffix $(SO_SUFFIX),$(addprefix lib,$(NAMES)))
42 # The main QEMU uses Glib extensively so it is perfectly fine to use it
43 # in plugins (which many example do).
44 PLUGIN_CFLAGS := $(shell $(PKG_CONFIG) --cflags glib-2.0)
45 PLUGIN_CFLAGS += -fPIC -Wall
46 PLUGIN_CFLAGS += -I$(TOP_SRC_PATH)/include/qemu
48 # Helper that honours V=1 so we get some output when compiling
49 quiet-@ = $(if $(V),,@$(if $1,printf " %-7s %s\n" "$(strip $1)" "$(strip $2)" && ))
50 quiet-command = $(call quiet-@,$2,$3)$1
52 # for including , in command strings
53 COMMA := ,
55 all: $(SONAMES)
57 %.o: %.c
58 $(call quiet-command, \
59 $(CC) $(CFLAGS) $(PLUGIN_CFLAGS) -c -o $@ $<, \
60 BUILD, plugin $@)
62 ifeq ($(CONFIG_WIN32),y)
63 lib%$(SO_SUFFIX): %.o win32_linker.o ../../plugins/libqemu_plugin_api.a
64 $(call quiet-command, \
65 $(CC) -shared -o $@ $^ $(LDLIBS), \
66 LINK, plugin $@)
67 else ifeq ($(CONFIG_DARWIN),y)
68 lib%$(SO_SUFFIX): %.o
69 $(call quiet-command, \
70 $(CC) -bundle -Wl$(COMMA)-undefined$(COMMA)dynamic_lookup -o $@ $^ $(LDLIBS), \
71 LINK, plugin $@)
72 else
73 lib%$(SO_SUFFIX): %.o
74 $(call quiet-command, \
75 $(CC) -shared -o $@ $^ $(LDLIBS), \
76 LINK, plugin $@)
77 endif
80 clean:
81 rm -f *.o *$(SO_SUFFIX) *.d
82 rm -Rf .libs
84 .PHONY: all clean
85 .SECONDARY: