summaryrefslogtreecommitdiff
path: root/plugins/Makefile.plugin.mk
blob: c26c67274c63fac68a6829d714e531f184eacdd4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80

# Generic plug-in Makefile for Shotwell standard plugins.
#
# Requires PLUGIN and SRC_FILES be set to the name of the plugin binary (minus extension) and that 
# the directory is registered in plugins.mk.
#
# To use, include this file in each plug-in directory's Makefile after setting appropriate variables.
# Also be sure that each plug-in has a dummy_main() function to satisfy valac's linkage.
#
# NOTE: This file is called from the cwd of each directory, hence the relative paths should be
# read as such.

ifndef VALAC
VALAC := valac
endif
MAKE_FILES := Makefile ../Makefile.plugin.mk ../plugins.mk
HEADER_FILES := ../shotwell-plugin-dev-1.0.vapi ../shotwell-plugin-dev-1.0.h \
	../shotwell-plugin-dev-1.0.deps

include ../plugins.mk

# automatically include shotwell-plugin-dev-1.0's dependencies
# NOTE: This line will generate an error when running "make dist" from the master Makefile.
# It can be safely ignored.
PKGS := $(shell sed ':a;N;$$!ba;s/\n/ /g' ../shotwell-plugin-dev-1.0.deps) $(PKGS)

# automatically include the shotwell-plugin-dev-1.0 package as a local dependency
EXT_PKGS := $(PKGS)
PKGS := shotwell-plugin-dev-1.0 $(PKGS) $(PLUGIN_PKGS)

CFILES := $(notdir $(SRC_FILES:.vala=.c))
OFILES := $(notdir $(SRC_FILES:.vala=.o))

CFLAGS := $(shell pkg-config --print-errors --cflags $(EXT_PKGS) $(PLUGIN_PKGS)) \
	-nostdlib -export-dynamic $(PLUGIN_CFLAGS)
LIBS := $(shell pkg-config --print-errors --libs $(EXT_PKGS) $(PLUGIN_PKGS))
DEFINES := -D_VERSION='"$(PLUGINS_VERSION)"' -DGETTEXT_PACKAGE='"shotwell"'

all: $(PLUGIN).so

PLUGIN_EXTRAFLAGS ?= --vapidir=../common --pkg shotwell-plugin-common
PLUGIN_EXTRALINKFLAGS ?= -L../common/ -lshotwell-plugin-common

.stamp: $(SRC_FILES) $(MAKE_FILES) $(HEADER_FILES)
	$(VALAC) --target-glib=$(MIN_GLIB_VERSION) -g --enable-checking --fatal-warnings --ccode --enable-deprecated \
		--vapidir=../ $(foreach pkg,$(PKGS),--pkg=$(pkg)) $(foreach pkg,$(CUSTOM_VAPI_PKGS),--pkg=$(pkg)) \
		$(USER_VALAFLAGS) \
		$(PLUGIN_EXTRAFLAGS) \
		--vapidir=../../vapi \
		$(SRC_FILES)
	@touch .stamp

$(CFILES): .stamp
	@

.c.o:
	$(CC) -c $(CFLAGS) $(DEFINES) -I../.. -I ../common $<

$(PLUGIN).so: $(OFILES)
	$(CC) $(LDFLAGS) -shared $(OFILES) $(LIBS) $(PLUGIN_EXTRALINKFLAGS) -o $@

.PHONY: cleantemps
cleantemps:
	@rm -f $(notdir $(SRC_FILES:.vala=.c)) $(notdir $(SRC_FILES:.vala=.o))
	@rm -f .stamp

.PHONY: clean
clean: cleantemps
	@rm -f $(PLUGIN).so $(OFILES) $(CFILES)

.PHONY: distclean
distclean: clean

PLUGIN_DIR ?= $(PLUGIN)

.PHONY: listfiles
listfiles:
	@printf "plugins/$(PLUGIN_DIR)/Makefile $(foreach file,$(SRC_FILES),plugins/$(PLUGIN_DIR)/$(file)) "
	@printf "$(foreach rc,$(RC_FILES),plugins/$(PLUGIN_DIR)/$(rc)) "