SUBDIRS = . build contrib data libide src plugins tools po tests doc

ACLOCAL_AMFLAGS = -I build/autotools

EXTRA_DIST =                                                                   \
	AUTHORS                                                                \
	$(NULL)

# --disable-gtk-doc until future notice
DISTCHECK_CONFIGURE_FLAGS =                                                    \
	--enable-introspection                                                 \
	--disable-gtk-doc                                                      \
	--disable-tracing                                                      \
	--enable-appstream-util                                                \
	--disable-maintainer-mode                                              \
	$(NULL)

GITIGNOREFILES =                                                               \
	**/*.swp                                                               \
	.flatpak-builder                                                       \
	*.o                                                                    \
	aclocal.m4                                                             \
	build-aux                                                              \
	ChangeLog                                                              \
	config                                                                 \
	config.h.in                                                            \
	gtk-doc.m4                                                             \
	gtk-doc.make                                                           \
	INSTALL                                                                \
	ABOUT-NLS                                                              \
	$(NULL)

AUTHORS:
	@if test -d "$(srcdir)/.git";                                          \
	then                                                                   \
		echo Creating $@ &&                                            \
		( cd "$(top_srcdir)" &&                                        \
		  echo '# Generated by Makefile. Do not edit.'; echo;          \
		  git log --no-merges --pretty=format:"%an" libide src plugins \
		  | sort | uniq ) > $@.tmp                                     \
		&& mv -f $@.tmp $@                                             \
		|| ( rm -f $@.tmp ;                                            \
		     echo Failed to generate $@ >&2 );                         \
	fi

dist-hook:
	@if test -d "$(srcdir)/.git";                                          \
	then                                                                   \
		echo Creating ChangeLog &&                                     \
		( cd "$(top_srcdir)" &&                                        \
		  echo '# Generated by Makefile. Do not edit.'; echo;          \
		  $(top_srcdir)/missing --run git log --stat ) > ChangeLog.tmp \
		&& mv -f ChangeLog.tmp $(top_distdir)/ChangeLog                \
		|| ( rm -f ChangeLog.tmp ;                                     \
		     echo Failed to generate ChangeLog >&2 );                  \
	else                                                                   \
		echo A git clone is required to generate a ChangeLog >&2;      \
	fi

.PHONY: AUTHORS

RUNTIME_TYPELIB_PATH = libide:contrib/egg:contrib/pnl:contrib/tmpl:$(GI_TYPELIB_PATH)

run:
	@ LSAN_OPTIONS=suppressions=$(top_srcdir)/build/asan.supp              \
	ASAN_OPTIONS=alloc_dealloc_mismatch=0                                  \
	PEAS_DEBUG=1                                                           \
	GB_IN_TREE_PLUGINS=1                                                   \
	GB_IN_TREE_FONTS=1                                                     \
	GB_IN_TREE_STYLE_SCHEMES=1                                             \
	GI_TYPELIB_PATH="$(RUNTIME_TYPELIB_PATH)"                              \
	GOBJECT_DEBUG=instance-count                                           \
	PYTHONDONTWRITEBYTECODE=yes                                            \
	PATH=$(top_builddir)/src:${PATH}                                       \
	$(LIBTOOL) --mode=execute gdb                                          \
	    -ex 'handle SIGPIPE nostop noprint pass'                           \
	    -ex run                                                            \
	    --args src/gnome-builder -vvvv -s $(ARGS)

strace:
	@ PEAS_DEBUG=1                                                         \
	GB_IN_TREE_PLUGINS=1                                                   \
	GB_IN_TREE_FONTS=1                                                     \
	GB_IN_TREE_STYLE_SCHEMES=1                                             \
	GI_TYPELIB_PATH="$(RUNTIME_TYPELIB_PATH)"                              \
	GOBJECT_DEBUG=instance-count                                           \
	PYTHONDONTWRITEBYTECODE=yes                                            \
	PATH=$(top_builddir)/src:${PATH}                                       \
	$(LIBTOOL) --mode=execute strace -T src/gnome-builder -vvvv -s $(ARGS)

debug:
	@ LSAN_OPTIONS=suppressions=$(top_srcdir)/build/asan.supp              \
	ASAN_OPTIONS=alloc_dealloc_mismatch=0                                  \
	G_SLICE=always-malloc                                                  \
	PEAS_DEBUG=1                                                           \
	GB_IN_TREE_PLUGINS=1                                                   \
	GB_IN_TREE_FONTS=1                                                     \
	GB_IN_TREE_STYLE_SCHEMES=1                                             \
	GI_TYPELIB_PATH="$(RUNTIME_TYPELIB_PATH)"                              \
	G_DEBUG=fatal-criticals                                                \
	GOBJECT_DEBUG=instance-count                                           \
	PYTHONDONTWRITEBYTECODE=yes                                            \
	PATH=$(top_builddir)/src:${PATH}                                       \
	$(LIBTOOL) --mode=execute gdb                                          \
	    -ex 'handle SIGPIPE nostop noprint pass'                           \
	    -ex run                                                            \
	    --args src/gnome-builder -vvvv -s $(ARGS)

valgrind:
	@ PEAS_DEBUG=1                                                         \
	GB_IN_TREE_PLUGINS=1                                                   \
	GB_IN_TREE_FONTS=1                                                     \
	GB_IN_TREE_STYLE_SCHEMES=1                                             \
	GI_TYPELIB_PATH="$(RUNTIME_TYPELIB_PATH)"                              \
	G_DEBUG=fatal-criticals                                                \
	G_SLICE=always-malloc                                                  \
	PYTHONDONTWRITEBYTECODE=yes                                            \
	PATH=$(top_builddir)/src:${PATH}                                       \
	$(LIBTOOL) --mode=execute valgrind src/gnome-builder -vvvv -s $(ARGS)

-include $(top_srcdir)/git.mk
