summaryrefslogtreecommitdiff
path: root/Makefile
blob: 17948ed290305e9fae0893f2af44d18d912d6b1e (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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
PROGRAM = shotwell
PROGRAM_THUMBNAILER = shotwell-video-thumbnailer
PROGRAM_MIGRATOR = shotwell-settings-migrator

VERSION = 0.18.1
GITVER := $(shell git log -n 1 2>/dev/null | head -n 1 | awk '{print $$2}')
GETTEXT_PACKAGE = $(PROGRAM)
BUILD_ROOT = 1

ifndef VALAC
VALAC := $(shell which valac)
else
VALAC := $(shell which $(VALAC))
endif

VALAC_VERSION := `$(VALAC) --version | awk '{print $$2}'`
MIN_VALAC_VERSION := 0.20.1
INSTALL_PROGRAM := install
INSTALL_DATA := install -m 644

export MIN_GLIB_VERSION=2.30.0

# defaults that may be overridden by configure.mk
PREFIX=/usr/local
BUILD_RELEASE=1
LIB=lib

-include configure.mk
ifndef LIBEXECDIR
LIBEXECDIR=$(PREFIX)/share/shotwell
endif

CORE_SUPPORTED_LANGUAGES=$(shell cat po/LINGUAS)

LOCAL_LANG_DIR=locale-langpack
SYSTEM_LANG_DIR := $(DESTDIR)$(PREFIX)/share/locale

VALAFLAGS := $(foreach w,$(CPPFLAGS) $(CFLAGS) $(LDFLAGS),-X $(w)) --enable-checking --target-glib=2.32 --thread --fatal-warnings --enable-experimental --enable-deprecated $(USER_VALAFLAGS)
ifdef UNITY_SUPPORT
VALAFLAGS := $(VALAFLAGS) --define UNITY_SUPPORT
endif

ifdef WITH_GPHOTO_25
VALAFLAGS := $(VALAFLAGS) --define WITH_GPHOTO_25
endif

DEFINES := _PREFIX='"$(PREFIX)"' _VERSION='"$(VERSION)"' GETTEXT_PACKAGE='"$(GETTEXT_PACKAGE)"' \
	_LANG_SUPPORT_DIR='"$(SYSTEM_LANG_DIR)"' _LIB='"${LIB}"' _LIBEXECDIR='"$(LIBEXECDIR)"'

ifdef GITVER
DEFINES := $(DEFINES) _GIT_VERSION='"$(GITVER)"'
VALAFLAGS := $(VALAFLAGS) --define=_GITVERSION
endif

EXPORT_FLAGS = -export-dynamic

include units.mk
include plugins/plugins.mk

UNUNITIZED_SRC_FILES = \
	main.vala \
	AppWindow.vala \
	CollectionPage.vala \
	Thumbnail.vala \
	ThumbnailCache.vala \
	CheckerboardLayout.vala \
	PhotoPage.vala \
	Page.vala \
	SortedList.vala \
	Dimensions.vala \
	Box.vala \
	Photo.vala \
	Orientation.vala \
	BatchImport.vala \
	Dialogs.vala \
	Resources.vala \
	Debug.vala \
	ColorTransformation.vala \
	Properties.vala \
	CustomComponents.vala \
	Event.vala \
	International.vala \
	AppDirs.vala \
	PixbufCache.vala \
	CommandManager.vala \
	Commands.vala \
	SlideshowPage.vala \
	LibraryFiles.vala \
	Printing.vala \
	Tag.vala \
	Screensaver.vala \
	Exporter.vala \
	DirectoryMonitor.vala \
	LibraryMonitor.vala \
	VideoSupport.vala \
	Tombstone.vala \
	MetadataWriter.vala \
	Application.vala \
	TimedQueue.vala \
	MediaPage.vala \
	MediaDataRepresentation.vala \
	DesktopIntegration.vala \
	MediaInterfaces.vala \
	MediaMetadata.vala \
	VideoMetadata.vala \
	MediaMonitor.vala \
	PhotoMonitor.vala \
	VideoMonitor.vala \
	SearchFilter.vala \
	MediaViewTracker.vala \
	UnityProgressBar.vala \
	Upgrades.vala 

THUMBNAILER_SRC_FILES = \
	shotwell-video-thumbnailer.vala

VAPI_FILES = \
	ExtendedPosix.vapi \
	LConv.vapi \
	libexif.vapi \
	libraw.vapi \
	webkitgtk-3.0.vapi \
	unique-3.0.vapi \
	unity.vapi

DEPS_FILES = \
	webkitgtk-3.0.deps \
	unique-3.0.deps \
	unity.deps

ifdef WITH_GPHOTO_25
GPHOTO_VAPI_FILE = vapi/gphoto-2.5/libgphoto2.vapi
else
GPHOTO_VAPI_FILE = vapi/gphoto-2.4/libgphoto2.vapi
endif

RESOURCE_FILES = \
	collection.ui \
	direct.ui \
	direct_context.ui \
	events_directory.ui \
	event.ui \
	fullscreen.ui \
	import_queue.ui \
	import.ui \
	media.ui \
	offline.ui \
	photo.ui \
	photo_context.ui \
	savedsearch.ui \
	search_bar.ui \
	search_sidebar_context.ui \
	set_background_dialog.glade \
	shotwell.glade \
	shotwell.xml \
	sidebar_default_context.ui \
	tag_sidebar_context.ui \
	tags.ui \
	top.ui \
	trash.ui 

SYS_INTEGRATION_FILES = \
	shotwell.appdata.xml \
	shotwell.desktop.head \
	shotwell-viewer.desktop.head \
	org.yorba.shotwell.gschema.xml \
	org.yorba.shotwell-extras.gschema.xml \
	shotwell.convert

SCHEMA_FILES := $(shell ls misc/*.gschema.xml)

SRC_HEADER_FILES = \
	gphoto.h

TEXT_FILES = \
	AUTHORS \
	COPYING \
	INSTALL \
	MAINTAINERS \
	NEWS \
	README \
	THANKS

ICON_FILES = \
	all-rejected.png \
	crop-pivot-reticle.png \
	crop.svg \
	drag_nub.png \
	enhance.png \
	five-star-filter.svg \
	five-stars.svg \
	flag-page.png \
	flag-trinket.png \
	four-star-filter-plus.svg \
	four-stars.svg \
	image-adjust.svg \
	import-all.png \
	import.svg \
	make-primary.svg \
	merge.svg \
	multiple-events.png \
	multiple-tags.png \
	no-event.png \
	noninterpretable-video.png \
	one-event.png \
	one-star-filter-plus.svg \
	one-star.svg \
	one-tag.png \
	pin-toolbar.svg \
	publish.png \
	redeye.png \
	rejected.svg \
	shotwell-16.svg \
	shotwell-24.svg \
	shotwell.ico \
	shotwell-street.jpg \
	shotwell.svg \
	sprocket.png \
	straighten.svg \
	three-star-filter-plus.svg \
	three-stars.svg \
	two-star-filter-plus.svg \
	two-stars.svg \
	videos-page.png \
	zoom-in.png \
	zoom-out.png \
	slideshow-extension-point.png \
	generic-plugin.png \
	filter-raw.png \
	filter-photos.png \
	filter-videos.png \
	filter-flagged.png

VAPI_DIRS = \
	./vapi

ifdef WITH_GPHOTO_25
VAPI_DIRS += ./vapi/gphoto-2.5
else
VAPI_DIRS += ./vapi/gphoto-2.4
endif


HEADER_DIRS = \
	./vapi

LOCAL_PKGS = \
	ExtendedPosix \
	posix \
	LConv

EXT_PKGS = \
	atk \
	gdk-3.0 \
	gee-0.8 \
	gexiv2 \
	gio-unix-2.0 \
	glib-2.0 \
	gmodule-2.0 \
	gstreamer-1.0 \
	gstreamer-base-1.0 \
	gstreamer-pbutils-1.0 \
	gtk+-3.0 \
	gudev-1.0 \
	libexif \
	libgphoto2 \
	json-glib-1.0 \
	libraw \
	libsoup-2.4 \
	libxml-2.0 \
	sqlite3 \
	webkitgtk-3.0
ifdef UNITY_SUPPORT
EXT_PKGS += unity
endif

THUMBNAILER_PKGS = \
    gtk+-3.0 \
    gee-0.8 \
    gstreamer-1.0 \
    gstreamer-base-1.0

DIRECT_LIBS =

EXT_PKG_VERSIONS = \
	gee-0.8 >= 0.8.5 \
	gexiv2 >= 0.4.90 \
	gio-unix-2.0 >= 2.20 \
	glib-2.0 >= $(MIN_GLIB_VERSION) \
	gmodule-2.0 >= 2.24.0 \
	gstreamer-1.0 >= 1.0.0 \
	gstreamer-base-1.0 >= 1.0.0 \
	gstreamer-plugins-base-1.0 >= 1.0.0 \
	gstreamer-pbutils-1.0 >= 1.0.0 \
	gtk+-3.0 >= 3.6.0 \
	gudev-1.0 >= 145 \
	libexif >= 0.6.16 \
	libgphoto2 >= 2.4.2 \
	libraw >= 0.13.2 \
	libsoup-2.4 >= 2.26.0 \
	libxml-2.0 >= 2.6.32 \
	rest-0.7 >= 0.7 \
	sqlite3 >= 3.5.9 \
	webkitgtk-3.0 >= 1.4.0 \
	gnome-doc-utils

DIRECT_LIBS_VERSIONS =

VALA_PKGS = $(EXT_PKGS) $(LOCAL_PKGS)

ifndef BUILD_DIR
BUILD_DIR=src
endif

DESKTOP_APP_SHORT_NAME="Shotwell"
DESKTOP_APP_FULL_NAME="Shotwell Photo Manager"
DESKTOP_APPLICATION_COMMENT="Organize your photos"
DESKTOP_APPLICATION_CLASS="Photo Manager"
DESKTOP_APP_KEYWORDS="album;camera;cameras;crop;edit;enhance;export;gallery;image;images;import;organize;photo;photographs;photos;picture;pictures;photography;print;publish;rotate;share;tags;video;facebook;flickr;picasa;youtube;piwigo;"
DIRECT_EDIT_DESKTOP_APP_SHORT_NAME="Shotwell"
DIRECT_EDIT_DESKTOP_APP_FULL_NAME="Shotwell Photo Viewer"
DIRECT_EDIT_DESKTOP_APPLICATION_CLASS="Photo Viewer"
TEMPORARY_DESKTOP_FILES = misc/shotwell.desktop misc/shotwell-viewer.desktop

# for help page and translation .po files
include help/Makefile.am

# Process the units
UNIT_MKS := $(foreach unit,$(UNITS),src/$(unit)/mk/$(notdir $(unit)).mk)
include $(UNIT_MKS)

UNITIZE_DIR := src/.unitize
UNITIZE_ENTRIES := $(foreach unit,$(APP_UNITS),$(UNITIZE_DIR)/_$(unit)_unitize_entry.vala)
UNITIZE_INITS := $(foreach nm,$(UNIT_NAMESPACES),$(UNITIZE_DIR)/_$(nm)Internals.vala)
UNITIZE_STAMP := $(UNITIZE_DIR)/.unitized

PLUGINS_DIR := plugins
PLUGINS_SO := $(foreach plugin,$(PLUGINS),$(PLUGINS_DIR)/$(plugin)/$(plugin).so)
EXTRA_PLUGINS_SO := $(foreach plugin,$(EXTRA_PLUGINS),$(PLUGINS_DIR)/$(plugin)/$(plugin).so)
PLUGINS_DIST_FILES := `$(MAKE) --directory=plugins --no-print-directory listfiles`

THUMBNAILER_DIR := thumbnailer
THUMBNAILER_BIN := $(THUMBNAILER_DIR)/$(PROGRAM_THUMBNAILER)
EXPANDED_THUMBNAILER_SRC_FILES := $(foreach file, $(THUMBNAILER_SRC_FILES), $(THUMBNAILER_DIR)/$(file))

MIGRATOR_DIR := settings-migrator
MIGRATOR_BIN := $(MIGRATOR_DIR)/$(PROGRAM_MIGRATOR)

EXPANDED_CORE_PO_FILES := $(foreach po,$(CORE_SUPPORTED_LANGUAGES),po/$(po).po)

EXPANDED_SRC_FILES := $(UNITIZED_SRC_FILES) $(foreach src,$(UNUNITIZED_SRC_FILES),src/$(src)) \
	$(UNITIZE_INITS) $(UNITIZE_ENTRIES)
EXPANDED_DIST_SRC_FILES := $(UNITIZED_SRC_FILES) $(foreach src,$(UNUNITIZED_SRC_FILES),src/$(src))
EXPANDED_C_FILES := $(foreach file,$(subst src,$(BUILD_DIR),$(EXPANDED_SRC_FILES)),$(file:.vala=.c))
EXPANDED_OBJ_FILES := $(foreach file,$(subst src,$(BUILD_DIR),$(EXPANDED_SRC_FILES)),$(file:.vala=.o))
EXPANDED_SYS_INTEGRATION_FILES := $(foreach file,$(SYS_INTEGRATION_FILES),misc/$(file))
EXPANDED_ICON_FILES := $(foreach file,$(ICON_FILES),icons/$(file))
EXPANDED_VAPI_FILES := $(foreach vapi,$(VAPI_FILES),vapi/$(vapi))
EXPANDED_DEPS_FILES := $(foreach deps,$(DEPS_FILES),vapi/$(deps))
EXPANDED_SRC_HEADER_FILES := $(foreach header,$(SRC_HEADER_FILES),vapi/$(header))
EXPANDED_RESOURCE_FILES := $(foreach res,$(RESOURCE_FILES),ui/$(res))
EXPANDED_DOC_IMAGES := $(foreach file,$(DOC_IMAGES),help/C/figures/$(file))
EXPANDED_DOC_PAGES := $(foreach page,$(DOC_PAGES),help/C/$(page))
EXPANDED_DOC_PO := $(foreach lang,$(DOC_LINGUAS),help/$(lang)/$(lang).po)
EXPANDED_XLAT_DOC_PAGES := \
	$(foreach lang,$(DOC_LINGUAS),\
		$(foreach page,$(DOC_PAGES),help/$(lang)/$(page)))
VALA_STAMP := $(BUILD_DIR)/.stamp
LANG_STAMP := $(LOCAL_LANG_DIR)/.langstamp
DOC_LANG_STAMP := help/.langstamp
MAKE_FILES := Makefile $(CONFIG_IN) $(UNIT_MKS) unitize.mk units.mk
PC_INPUT := shotwell-plugin-dev-1.0.m4
PC_FILE := $(PC_INPUT:.m4=.pc)

DIST_FILES = Makefile configure chkver $(EXPANDED_DIST_SRC_FILES) $(EXPANDED_VAPI_FILES) \
	$(EXPANDED_DEPS_FILES) $(EXPANDED_SRC_HEADER_FILES) $(EXPANDED_RESOURCE_FILES) $(TEXT_FILES) \
	$(EXPANDED_ICON_FILES) $(EXPANDED_SYS_INTEGRATION_FILES) $(EXPANDED_CORE_PO_FILES) \
	po/LINGUAS po/POTFILES.in po/POTFILES.skip \
	$(EXPANDED_DOC_PAGES) $(EXPANDED_DOC_IMAGES) $(EXPANDED_DOC_PO) help/Makefile.am \
	apport/shotwell.py $(UNIT_RESOURCES) $(UNIT_MKS) \
	unitize.mk units.mk $(PC_INPUT) $(PLUGINS_DIST_FILES) \
	vapi/gphoto-2.5/libgphoto2.vapi vapi/gphoto-2.4/libgphoto2.vapi \
	$(EXPANDED_THUMBNAILER_SRC_FILES) $(MIGRATOR_BIN)

DIST_TAR = $(PROGRAM)-$(VERSION).tar
DIST_TAR_XZ = $(DIST_TAR).xz
PACKAGE_ORIG_XZ = $(PROGRAM)_`parsechangelog | grep Version | sed 's/.*: //'`.orig.tar.xz

VALAFLAGS := $(VALAFLAGS) $(VALA_DEFINES) --vapidir=plugins/

VALA_CFLAGS := `pkg-config --cflags $(EXT_PKGS) $(DIRECT_LIBS) gthread-2.0` \
	$(foreach hdir,$(HEADER_DIRS),-I$(hdir)) \
	$(foreach def,$(DEFINES),-D$(def))

VALA_LDFLAGS := `pkg-config --libs $(EXT_PKGS) $(DIRECT_LIBS) gthread-2.0`

# REQUIRED_CFLAGS absolutely get appended to CFLAGS, whatever the
# the value of CFLAGS in the environment
REQUIRED_CFLAGS := -fPIC

# setting CFLAGS in configure.mk overrides build type
ifndef CFLAGS
ifdef BUILD_DEBUG
CFLAGS = -O0 -g -pipe
PLUGIN_CFLAGS = -O0 -g -pipe
else
CFLAGS = -O2 -g -pipe
PLUGIN_CFLAGS = -O2 -g -pipe
endif
endif

CFLAGS += $(PROFILE_FLAGS) $(REQUIRED_CFLAGS)
PLUGIN_CFLAGS += $(PROFILE_FLAGS) $(REQUIRED_CFLAGS)

# Required for gudev-1.0
CFLAGS += -DG_UDEV_API_IS_SUBJECT_TO_CHANGE

all: pkgcheck valacheck desktop

ifdef ENABLE_BUILD_FOR_GLADE
all: $(PLUGINS_DIR) lib$(PROGRAM).so $(PROGRAM) $(PC_FILE)
else
all: $(PLUGINS_DIR) $(PROGRAM) $(PC_FILE)
endif


include src/plugins/mk/interfaces.mk

$(LANG_STAMP): $(EXPANDED_CORE_PO_FILES)
	@$(foreach po,$(CORE_SUPPORTED_LANGUAGES),`mkdir -p $(LOCAL_LANG_DIR)/$(po)/LC_MESSAGES ; \
		msgfmt -c -o $(LOCAL_LANG_DIR)/$(po)/LC_MESSAGES/shotwell.mo po/$(po).po`)
	@touch $(LANG_STAMP)

clean:
	rm -f $(EXPANDED_C_FILES)
	rm -f $(EXPANDED_OBJ_FILES)
	rm -f $(VALA_STAMP)
	rm -rf $(PROGRAM)-$(VERSION)
	rm -f $(PROGRAM)
	rm -f $(THUMBNAILER_DIR)/$(PROGRAM_THUMBNAILER)
	rm -rf $(LOCAL_LANG_DIR)
	rm -f $(LANG_STAMP)
	rm -f $(DOC_LANG_STAMP)
	rm -f $(EXPANDED_XLAT_DOC_PAGES)
	rm -f $(TEMPORARY_DESKTOP_FILES)
	rm -f lib$(PROGRAM).so
	rm -rf $(UNITIZE_DIR)
	rm -f $(PLUGIN_VAPI)
	rm -f $(PLUGIN_HEADER)
	rm -f $(PLUGIN_DEPS)
	rm -f $(PLUGINS_SO)
	rm -f $(EXTRA_PLUGINS_SO)
	@$(MAKE) --directory=plugins clean
	rm -f $(PC_FILE)

cleantemps:
	rm -f $(EXPANDED_C_FILES)
	rm -f $(EXPANDED_OBJ_FILES)
	rm -f $(VALA_STAMP)
	rm -f $(LANG_STAMP)
	rm -f $(DOC_LANG_STAMP)
	rm -f $(TEMPORARY_DESKTOP_FILES)
	@$(MAKE) --directory=plugins cleantemps
	rm -f misc/gschemas.compiled

package:
	$(MAKE) dist
	cp $(DIST_TAR_XZ) $(PACKAGE_ORIG_XZ)
	rm -f $(DIST_TAR_XZ)

misc/shotwell.desktop: misc/shotwell.desktop.head $(EXPANDED_CORE_PO_FILES)
	cp misc/shotwell.desktop.head misc/shotwell.desktop
	@ $(foreach lang,$(CORE_SUPPORTED_LANGUAGES), echo X-GNOME-FullName[$(lang)]=`TEXTDOMAINDIR=locale-langpack \
		LANGUAGE=$(lang) gettext --domain=shotwell $(DESKTOP_APP_FULL_NAME)` \
		>> misc/shotwell.desktop ; \
		echo GenericName[$(lang)]=`TEXTDOMAINDIR=locale-langpack LANGUAGE=$(lang) \
		gettext --domain=shotwell $(DESKTOP_APPLICATION_CLASS)` >> misc/shotwell.desktop ; \
		echo Comment[$(lang)]=`TEXTDOMAINDIR=locale-langpack LANGUAGE=$(lang) gettext \
		--domain=shotwell $(DESKTOP_APPLICATION_COMMENT)` >> misc/shotwell.desktop ; \
		echo Keywords[$(lang)]=`TEXTDOMAINDIR=locale-langpack LANGUAGE=$(lang) gettext \
		--domain=shotwell $(DESKTOP_APP_KEYWORDS)` >> misc/shotwell.desktop ;) 
ifndef DISABLE_DESKTOP_VALIDATE
	@ desktop-file-validate misc/shotwell.desktop 1>misc/shotwell.desktop.errors 2>&1; \
	if test -s misc/shotwell.desktop.errors; then \
		echo -e "\nThe file misc/shotwell.desktop.head or one of the .po files contains errors and may need to be edited.\nPlease see the file misc/shotwell.desktop.errors for details."; \
		exit 1; \
	else rm -f misc/shotwell.desktop.errors; \
	fi
endif
	
misc/shotwell-viewer.desktop: misc/shotwell-viewer.desktop.head $(EXPANDED_CORE_PO_FILES)
	cp misc/shotwell-viewer.desktop.head misc/shotwell-viewer.desktop
	$(foreach lang,$(CORE_SUPPORTED_LANGUAGES), echo X-GNOME-FullName[$(lang)]=`TEXTDOMAINDIR=locale-langpack \
		LANGUAGE=$(lang) gettext --domain=shotwell $(DESKTOP_APP_FULL_NAME)` \
		echo X-GNOME-FullName[$(lang)]=`TEXTDOMAINDIR=locale-langpack LANGUAGE=$(lang) gettext \
		--domain=shotwell $(DIRECT_EDIT_DESKTOP_APP_FULL_NAME)` >> misc/shotwell-viewer.desktop ; \
		echo GenericName[$(lang)]=`TEXTDOMAINDIR=locale-langpack LANGUAGE=$(lang) gettext \
		--domain=shotwell $(DIRECT_EDIT_DESKTOP_APPLICATION_CLASS)` >> misc/shotwell-viewer.desktop ;)
ifndef DISABLE_DESKTOP_VALIDATE
	@ desktop-file-validate misc/shotwell-viewer.desktop 1>misc/shotwell-viewer.desktop.errors 2>&1; \
	if test -s misc/shotwell-viewer.desktop.errors; then \
		echo -e S"\nThe file misc/shotwell-viewer.desktop.head or one of the .po files contains errors and may need to be edited.\nPlease see the file misc/shotwell-viewer.desktop.errors for details."; \
		exit 1; \
	else rm -f misc/shotwell-viewer.desktop.errors; \
	fi
endif

.PHONY: desktop
desktop: misc/shotwell.desktop misc/shotwell-viewer.desktop

.PHONY: dist
dist:
	mkdir -p $(PROGRAM)-$(VERSION)
	cp --parents --preserve $(DIST_FILES) $(PROGRAM)-$(VERSION)
	tar --xz -cvf $(DIST_TAR_XZ) $(PROGRAM)-$(VERSION)
	rm -rf $(PROGRAM)-$(VERSION)

distclean: clean
	rm -f configure.mk
	rm -f $(DIST_TAR_XZ)
	@$(MAKE) --directory=plugins distclean

.PHONY: install
install:
	touch $(LANG_STAMP)
	mkdir -p $(DESTDIR)$(PREFIX)/bin
	$(INSTALL_PROGRAM) $(PROGRAM) $(DESTDIR)$(PREFIX)/bin
	mkdir -p $(DESTDIR)$(LIBEXECDIR)
	$(INSTALL_PROGRAM) $(THUMBNAILER_BIN) $(DESTDIR)$(LIBEXECDIR)
	$(INSTALL_PROGRAM) $(MIGRATOR_BIN) $(DESTDIR)$(LIBEXECDIR)
	mkdir -p $(DESTDIR)$(PREFIX)/share/shotwell/icons
	$(INSTALL_DATA) icons/* $(DESTDIR)$(PREFIX)/share/shotwell/icons
	mkdir -p $(DESTDIR)$(PREFIX)/share/icons/hicolor/scalable/apps
	$(INSTALL_DATA) icons/shotwell.svg $(DESTDIR)$(PREFIX)/share/icons/hicolor/scalable/apps
	mkdir -p $(DESTDIR)$(PREFIX)/share/icons/hicolor/16x16/apps
	$(INSTALL_DATA) icons/shotwell-16.svg $(DESTDIR)$(PREFIX)/share/icons/hicolor/16x16/apps/shotwell.svg
	mkdir -p $(DESTDIR)$(PREFIX)/share/icons/hicolor/24x24/apps
	$(INSTALL_DATA) icons/shotwell-24.svg $(DESTDIR)$(PREFIX)/share/icons/hicolor/24x24/apps/shotwell.svg
	mkdir -p $(DESTDIR)$(PREFIX)/share/glib-2.0/schemas
	$(INSTALL_DATA) misc/org.yorba.shotwell.gschema.xml $(DESTDIR)$(PREFIX)/share/glib-2.0/schemas
	$(INSTALL_DATA) misc/org.yorba.shotwell-extras.gschema.xml $(DESTDIR)$(PREFIX)/share/glib-2.0/schemas
ifndef DISABLE_SCHEMAS_COMPILE
	glib-compile-schemas $(DESTDIR)$(PREFIX)/share/glib-2.0/schemas
endif
ifndef DISABLE_GSETTINGS_CONVERT_INSTALL
	mkdir -p $(DESTDIR)/usr/share/GConf/gsettings
	$(INSTALL_DATA) misc/shotwell.convert $(DESTDIR)/usr/share/GConf/gsettings
endif
ifndef DISABLE_ICON_UPDATE
	-gtk-update-icon-cache -t -f $(DESTDIR)$(PREFIX)/share/icons/hicolor || :
endif
	mkdir -p $(DESTDIR)$(PREFIX)/share/shotwell/ui
	$(INSTALL_DATA) ui/* $(DESTDIR)$(PREFIX)/share/shotwell/ui
	mkdir -p $(DESTDIR)$(PREFIX)/share/applications
	mkdir -p $(DESTDIR)$(PREFIX)/share/appdata
	$(INSTALL_DATA) misc/shotwell.desktop $(DESTDIR)$(PREFIX)/share/applications
	$(INSTALL_DATA) misc/shotwell-viewer.desktop $(DESTDIR)$(PREFIX)/share/applications
	$(INSTALL_DATA) misc/shotwell.appdata.xml $(DESTDIR)$(PREFIX)/share/appdata
ifndef DISABLE_DESKTOP_UPDATE
	-update-desktop-database || :
endif
ifdef ENABLE_APPORT_HOOK_INSTALL
	mkdir -p $(DESTDIR)$(PREFIX)/share/apport/package-hooks
	$(INSTALL_DATA) apport/shotwell.py $(DESTDIR)$(PREFIX)/share/apport/package-hooks
endif
ifndef DISABLE_HELP_INSTALL
	mkdir -p $(DESTDIR)$(PREFIX)/share/gnome/help/shotwell/C
	$(INSTALL_DATA) $(EXPANDED_DOC_PAGES) $(DESTDIR)$(PREFIX)/share/gnome/help/shotwell/C
	mkdir -p $(DESTDIR)$(PREFIX)/share/gnome/help/shotwell/C/figures
	$(INSTALL_DATA) $(EXPANDED_DOC_IMAGES) $(DESTDIR)$(PREFIX)/share/gnome/help/shotwell/C/figures
	$(foreach lang,$(DOC_LINGUAS),`mkdir -p $(DESTDIR)$(PREFIX)/share/gnome/help/shotwell/$(lang)`)
	$(foreach lang,$(DOC_LINGUAS),\
		$(foreach page,$(DOC_PAGES),\
			`$(INSTALL_DATA) help/$(lang)/$(page) $(DESTDIR)$(PREFIX)/share/gnome/help/shotwell/$(lang)`\
		)\
	)
endif
	-$(foreach lang,$(CORE_SUPPORTED_LANGUAGES),`mkdir -p $(SYSTEM_LANG_DIR)/$(lang)/LC_MESSAGES ; \
		$(INSTALL_DATA) $(LOCAL_LANG_DIR)/$(lang)/LC_MESSAGES/shotwell.mo \
		$(SYSTEM_LANG_DIR)/$(lang)/LC_MESSAGES/shotwell.mo`)
	mkdir -p $(DESTDIR)$(PREFIX)/$(LIB)/shotwell/plugins/builtin
	$(INSTALL_PROGRAM) $(PLUGINS_SO) $(DESTDIR)$(PREFIX)/$(LIB)/shotwell/plugins/builtin
ifdef PLUGINS_RC
	$(INSTALL_DATA) $(PLUGINS_RC) $(DESTDIR)$(PREFIX)/$(LIB)/shotwell/plugins/builtin
endif
ifndef DISABLE_EXTRA_PLUGINS_INSTALL
	$(INSTALL_PROGRAM) $(EXTRA_PLUGINS_SO) $(DESTDIR)$(PREFIX)/$(LIB)/shotwell/plugins/builtin
ifdef EXTRA_PLUGINS_RC
	$(INSTALL_DATA) $(EXTRA_PLUGINS_RC) $(DESTDIR)$(PREFIX)/$(LIB)/shotwell/plugins/builtin
endif
endif
ifdef INSTALL_HEADERS
	mkdir -p $(DESTDIR)$(PREFIX)/include/shotwell/plugins
	$(INSTALL_DATA) $(PLUGIN_HEADER) $(DESTDIR)$(PREFIX)/include/shotwell/plugins
	mkdir -p $(DESTDIR)$(PREFIX)/share/vala/vapi
	$(INSTALL_DATA) $(PLUGIN_VAPI) $(DESTDIR)$(PREFIX)/share/vala/vapi
	$(INSTALL_DATA) $(PLUGIN_DEPS) $(DESTDIR)$(PREFIX)/share/vala/vapi
	test -d $(DESTDIR)$(PREFIX)/$(LIB)/pkgconfig || mkdir -p $(DESTDIR)$(PREFIX)/$(LIB)/pkgconfig
	$(INSTALL_DATA) $(PC_FILE) $(DESTDIR)$(PREFIX)/$(LIB)/pkgconfig
endif

# Old versions of Makefile installed util binaries to $(PREFIX)/bin, so uninstall from there for now
uninstall:
	rm -f $(DESTDIR)$(PREFIX)/bin/$(PROGRAM)
	rm -f $(DESTDIR)$(PREFIX)/bin/$(PROGRAM_THUMBNAILER)
	rm -f $(DESTDIR)$(PREFIX)/bin/$(PROGRAM_MIGRATOR)
	rm -f $(DESTDIR)$(LIBEXECDIR)/$(PROGRAM_THUMBNAILER)
	rm -f $(DESTDIR)$(LIBEXECDIR)/$(PROGRAM_MIGRATOR)
	rm -fr $(DESTDIR)$(PREFIX)/share/shotwell
	rm -f $(DESTDIR)$(PREFIX)/share/icons/hicolor/scalable/apps/shotwell.svg
	rm -f $(DESTDIR)$(PREFIX)/share/icons/hicolor/16x16/apps/shotwell.svg
	rm -f $(DESTDIR)$(PREFIX)/share/icons/hicolor/24x24/apps/shotwell.svg
	rm -f $(DESTDIR)$(PREFIX)/share/applications/shotwell.desktop
	rm -f $(DESTDIR)$(PREFIX)/share/applications/shotwell-viewer.desktop
	rm -f $(DESTDIR)$(PREFIX)/share/appdata/shotwell.appdata.xml
ifndef DISABLE_DESKTOP_UPDATE
	-update-desktop-database || :
endif
ifndef DISABLE_HELP_INSTALL
	rm -rf $(DESTDIR)$(PREFIX)/share/gnome/help/shotwell
endif
ifdef ENABLE_APPORT_HOOK_INSTALL
	rm -f $(DESTDIR)$(PREFIX)/share/apport/package-hooks/shotwell.py
endif
	$(foreach lang,$(CORE_SUPPORTED_LANGUAGES),`rm -f $(SYSTEM_LANG_DIR)/$(lang)/LC_MESSAGES/shotwell.mo`)
	rm -rf $(DESTDIR)$(PREFIX)/$(LIB)/shotwell/plugins/builtin
ifdef INSTALL_HEADERS
	rm -rf $(DESTDIR)$(PREFIX)/include/shotwell
	rm -f $(foreach vapi,$(PLUGIN_VAPI),$(DESTDIR)$(PREFIX)/share/vala/vapi/$(notdir $(vapi)))
	rm -f $(foreach dep,$(PLUGIN_DEPS),$(DESTDIR)$(PREFIX)/share/vala/vapi/$(notdir $(dep)))
	rm -f $(DESTDIR)$(PREFIX)/$(LIB)/pkgconfig/$(PC_FILE)
endif
	rm -f $(DESTDIR)$(PREFIX)/share/glib-2.0/schemas/org.yorba.shotwell.gschema.xml
	rm -f $(DESTDIR)$(PREFIX)/share/glib-2.0/schemas/org.yorba.shotwell-extras.gschema.xml
ifndef DISABLE_SCHEMAS_COMPILE
	glib-compile-schemas $(DESTDIR)$(PREFIX)/share/glib-2.0/schemas
endif
ifndef DISABLE_GSETTINGS_CONVERT_INSTALL
	rm -f $(DESTDIR)/usr/share/GConf/gsettings/shotwell.convert
endif

$(PC_FILE): $(PC_INPUT) $(MAKE_FILES)
	m4 '-D_VERSION_=$(VERSION)' '-D_PREFIX_=$(PREFIX)' '-D_REQUIREMENTS_=$(PLUGIN_PKG_REQS)' \
		'-D_LIB_=$(LIB)' $< > $@

$(UNITIZE_STAMP): $(MAKE_FILES) src/unit/rc/UnitInternals.m4 src/unit/rc/unitize_entry.m4
	@mkdir -p $(UNITIZE_DIR)
	@$(foreach unit,$(APP_UNITS),\
		`m4 '-D_APP_UNIT_=$(unit)' src/unit/rc/unitize_entry.m4 > $(UNITIZE_DIR)/_$(unit)_unitize_entry.vala`)
	@$(foreach nm,$(UNIT_NAMESPACES),\
		`m4 '-D_UNIT_NAME_=$(nm)' '-D_UNIT_USES_INITS_=$($(nm)_USES_INITS)' '-D_UNIT_USES_TERMINATORS_=$($(nm)_USES_TERMINATORS)' src/unit/rc/UnitInternals.m4 > $(UNITIZE_DIR)/_$(nm)Internals.vala`)
	@touch $@

$(UNITIZE_INITS) $(UNITIZE_ENTRIES): $(UNITIZE_STAMP)
	@

# EXPANDED_SRC_FILES includes UNITIZE_INITS and UNITIZE_ENTRY
$(VALA_STAMP): $(EXPANDED_SRC_FILES) $(EXPANDED_VAPI_FILES) $(GPHOTO_VAPI_FILE) $(EXPANDED_SRC_HEADER_FILES)
	$(call check_valac_version)
	@echo Compiling Vala code...
	@mkdir -p $(BUILD_DIR)
	$(VALAC) --ccode --directory=$(BUILD_DIR) --basedir=src \
		$(foreach pkg,$(VALA_PKGS),--pkg=$(pkg)) \
		$(foreach vapidir,$(VAPI_DIRS),--vapidir=$(vapidir)) \
		$(foreach def,$(DEFINES),-X -D$(def)) \
		$(foreach hdir,$(HEADER_DIRS),-X -I$(hdir)) \
		$(VALAFLAGS) \
		$(EXPANDED_SRC_FILES)
	@touch $@

# Do not remove hard tab or at symbol; necessary for dependencies to complete.
$(EXPANDED_C_FILES): $(VALA_STAMP)
	@

$(EXPANDED_OBJ_FILES): %.o: %.c $(CONFIG_IN) Makefile
	$(CC) -c $(VALA_CFLAGS) $(CPPFLAGS) $(CFLAGS) -o $@ $<

$(PROGRAM): $(EXPANDED_OBJ_FILES) $(RESOURCES) $(LANG_STAMP) $(THUMBNAILER_BIN) misc/gschemas.compiled $(DOC_LANG_STAMP)
	$(CC) $(EXPANDED_OBJ_FILES) $(CFLAGS) $(LDFLAGS) $(RESOURCES) $(VALA_LDFLAGS) $(EXPORT_FLAGS) -o $@

misc/gschemas.compiled: $(SCHEMA_FILES)
	rm -f misc/gschemas.compiled
	glib-compile-schemas misc

$(DOC_LANG_STAMP): $(EXPANDED_DOC_PAGES) $(EXPANDED_DOC_PO)
	$(foreach lang,$(DOC_LINGUAS), \
		$(foreach page,$(DOC_PAGES), `xml2po -m mallard -p help/$(lang)/$(lang).po -o help/$(lang)/$(page) help/C/$(page)`))
	@touch $(DOC_LANG_STAMP)

$(THUMBNAILER_BIN): $(EXPANDED_THUMBNAILER_SRC_FILES)
	$(VALAC) $(EXPANDED_THUMBNAILER_SRC_FILES) $(VALAFLAGS) -o $@ $(foreach pkg,$(THUMBNAILER_PKGS),--pkg=$(pkg))

$(PLUGINS_SO) $(EXTRA_PLUGINS_SO): $(PLUGINS_DIR)
	@

.PHONY: $(PLUGINS_DIR)
$(PLUGINS_DIR): $(PLUGIN_VAPI) $(PLUGIN_HEADER) $(PLUGIN_DEPS)
	$(call check_valac_version)
	@$(MAKE) --directory=$@ PLUGINS_VERSION="$(VERSION)" USER_VALAFLAGS="$(USER_VALAFLAGS)" \
		PLUGIN_CFLAGS="$(PLUGIN_CFLAGS)"

.PHONY: docs
docs:
# valadoc complains if the directory already exists
	@rm -rf docs
	valadoc --directory=docs --package-name=shotwell-plugin-dev --package-version=$(VERSION) --verbose \
		--no-protected \
		$(foreach def,$(DEFINES),--define=$(def)) \
		$(foreach pkg,$(VALA_PKGS),--pkg=$(pkg)) \
		$(foreach vapidir,$(VAPI_DIRS),--vapidir=$(vapidir)) \
		$(PLUGIN_INTERFACES)

glade: lib$(PROGRAM).so

lib$(PROGRAM).so: $(EXPANDED_OBJ_FILES) $(RESOURCES) $(LANG_STAMP)
	$(CC) $(EXPANDED_OBJ_FILES) $(CFLAGS) $(LDFLAGS) $(RESOURCES) $(VALA_LDFLAGS) $(EXPORT_FLAGS) -shared -o $@

.PHONY: pkgcheck
pkgcheck:
	@if ! test -f configure.mk; then echo "Please run ./configure first."; exit 2; fi 

.PHONY: valacheck
valacheck:
	@ $(VALAC) --version >/dev/null 2>/dev/null || ( echo 'Shotwell requires Vala compiler $(MIN_VALAC_VERSION) or greater.  No valac found in path or $$VALAC.'; exit 1 )
	@ ./chkver min $(VALAC_VERSION) $(MIN_VALAC_VERSION) || ( echo 'Shotwell requires Vala compiler $(MIN_VALAC_VERSION) or greater.  You are running' $(VALAC_VERSION) '\b.'; exit 1 )
	$(if $(MAX_VALAC_VERSION),\
		@ ./chkver max $(VALAC_VERSION) $(MAX_VALAC_VERSION) || ( echo 'Shotwell cannot be built by Vala compiler $(MAX_VALAC_VERSION) or greater.  You are running' $(VALAC_VERSION) '\b.'; exit 1 ),)



ifndef ASSUME_PKGS
ifdef EXT_PKG_VERSIONS
	@pkg-config --print-errors --exists '$(EXT_PKG_VERSIONS) $(DIRECT_LIBS_VERSIONS)'
endif
ifdef EXT_PKGS
	@pkg-config --print-errors --exists $(EXT_PKGS) $(DIRECT_LIBS_VERSIONS)
endif
endif
	@ type msgfmt > /dev/null || ( echo 'msgfmt (usually found in the gettext package) is missing and is required to build Shotwell. ' ; exit 1 )
ifndef DISABLE_DESKTOP_VALIDATE
	@ type desktop-file-validate > /dev/null || ( echo 'desktop-file-validate (usually found in the desktop-file-utils package) is missing and is required to build Shotwell. ' ; exit 1 )
endif