xref: /qemu/contrib/plugins/Makefile (revision 940bb5fa)
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
20NAMES += lockstep
21NAMES += hwprofile
22NAMES += cache
23NAMES += drcov
24
25SONAMES := $(addsuffix .so,$(addprefix lib,$(NAMES)))
26
27# The main QEMU uses Glib extensively so it's perfectly fine to use it
28# in plugins (which many example do).
29PLUGIN_CFLAGS := $(shell $(PKG_CONFIG) --cflags glib-2.0)
30PLUGIN_CFLAGS += -fPIC -Wall
31PLUGIN_CFLAGS += -I$(TOP_SRC_PATH)/include/qemu
32
33all: $(SONAMES)
34
35%.o: %.c
36	$(CC) $(CFLAGS) $(PLUGIN_CFLAGS) -c -o $@ $<
37
38lib%.so: %.o
39ifeq ($(CONFIG_DARWIN),y)
40	$(CC) -bundle -Wl,-undefined,dynamic_lookup -o $@ $^ $(LDLIBS)
41else
42	$(CC) -shared -o $@ $^ $(LDLIBS)
43endif
44
45clean:
46	rm -f *.o *.so *.d
47	rm -Rf .libs
48
49.PHONY: all clean
50.SECONDARY:
51