1if ENABLE_ATTRIB
2ATTRIB_DIR=libleptonattrib
3endif
4
5if ENABLE_CONTRIB
6CONTRIB_DIR=contrib
7endif
8
9SUBDIRS = \
10	liblepton \
11	${ATTRIB_DIR} \
12	libleptongui \
13	schematic \
14	utils \
15	symbols \
16	docs \
17	examples \
18	${CONTRIB_DIR}
19
20ACLOCAL_AMFLAGS = -I m4
21
22# We need to ensure that `make distcheck' *doesn't* find a git
23# repository!
24#
25# We also should be able to successfully build & install without
26# groff.
27false=/bin/sh -c '! :'
28DISTCHECK_CONFIGURE_FLAGS = \
29	GIT="$(false)" \
30	GROFF="$(false)" \
31	--disable-update-xdg-database
32
33BUILT_SOURCES = version.h
34
35TEST_LOG_DRIVER = $(GUILE) $(top_srcdir)/build-tools/test-driver.scm
36AM_TESTS_ENVIRONMENT = env \
37	LANG=C \
38	abs_top_builddir='$(abs_top_builddir)' \
39	abs_top_srcdir='$(abs_top_srcdir)' \
40	GUILE_AUTO_COMPILE='0' \
41	GUILE_LOAD_PATH='$(abs_top_srcdir)/tests' \
42	GUILE_LOAD_COMPILED_PATH='' \
43	LEPTON_INHIBIT_RC_FILES='yes' \
44	COMPARE='$(IM_COMPARE)' \
45	CONVERT='$(IM_CONVERT)' \
46	IDENTIFY='$(IM_IDENTIFY)' \
47	FILE='$(FILE)'
48
49TESTS = \
50	tests/cli.test \
51	tests/config.test \
52	tests/export.test \
53	tests/netlist.test \
54	tests/shell.test \
55	tests/update.test
56
57EXTRA_DIST = \
58	autogen.sh \
59	version.h \
60	version.h.in \
61	CODE_OF_CONDUCT.md \
62	CONTRIBUTING.md \
63	COPYING \
64	COPYING.LGPL \
65	NEWS.md \
66	README.md \
67	ChangeLog \
68	tests/env.scm \
69	$(TESTS)
70
71# Generate version.h. This works by looking at any git repository that
72# is present in the source directory (detected at configure time). If
73# there is a git repository, the HEAD commitid is checked every time
74# the package is built to see if it has changed. If so, version.h is
75# regenerated. If there isn't a git repository, version.h is just
76# assumed to be present (since the generated version.h is distributed
77# in the source tarball).
78if HAVE_GIT_REPO
79version.h: stamp-git $(top_builddir)/configure $(srcdir)/version.h.in
80	@if test ! -f version.h; then \
81	  rm -f stamp-git; \
82	  $(MAKE) $(AM_MAKEFLAGS) stamp-git; \
83	else :; fi
84
85	@date_ver=$(DATE_VERSION); dotted_ver=$(DOTTED_VERSION); \
86	git_commit=`cd $(srcdir) && $(GIT) rev-parse HEAD`; \
87	sed -e"s:^.*\(PACKAGE_DATE_VERSION\).*$$:#define \1 \"$$date_ver\":" \
88	    -e"s:^.*\(PACKAGE_DOTTED_VERSION\).*$$:#define \1 \"$$dotted_ver\":" \
89	    -e"s:^.*\(PACKAGE_GIT_COMMIT\).*$$:#define \1 \"$$git_commit\":" \
90	      < $(srcdir)/version.h.in > version.h.new; \
91	if diff version.h version.h.new > /dev/null 2>&1; then \
92	  echo "version.h is unchanged"; \
93	  rm -f version.h.new; \
94	else \
95	  echo "Recreating version.h"; \
96	  mv version.h.new version.h; \
97	fi
98stamp-git:
99	@last_version=`if test -f stamp-git; then cat stamp-git; else :; fi`; \
100	now_version=`cd $(srcdir) && $(GIT) rev-parse HEAD`; \
101	if test "X$$now_version" != "X$$last_version"; then \
102	  echo $$now_version > stamp-git; \
103	  echo "Now at git commit $$now_version..."; \
104	fi
105.PHONY: stamp-git
106endif HAVE_GIT_REPO
107
108doxygen:
109if ENABLE_DOXYGEN
110	@for subdir in libleptonattrib/docs libleptongui/docs \
111	  liblepton/docs ; do \
112	  (cd $$subdir; $(MAKE) doxygen) || exit 1; \
113	done
114else
115	@echo 'configure was not run with the --enable-doxygen switch.'
116	@echo 'The documentation cannot be built from the sources.'
117endif
118
119
120precompile:
121	@LEPTON_SCM_PRECOMPILE=1 \
122	LEPTON_SCM_PRECOMPILE_SCRIPT=$(datadir)/lepton-eda/scheme/schematic/precompile.scm \
123	LEPTON_SCM_PRECOMPILE_SCM_DIR=$(datadir)/lepton-eda/scheme \
124	LEPTON_SCM_PRECOMPILE_OUT_DIR=$(datadir)/lepton-eda/ccache \
125	LEPTON_SCM_PRECOMPILE_RECURSIVE=1 \
126	LEPTON_SCM_PRECOMPILE_FNAME_EXT=.scm \
127	$(bindir)/lepton-schematic
128
129
130install-data-local:
131	$(MKDIR_P) $(DESTDIR)$(docdir)
132	cp -v $(srcdir)/README.md $(DESTDIR)$(docdir)
133	cp -v $(srcdir)/NEWS.md $(DESTDIR)$(docdir)
134
135uninstall-local:
136	rm -vfr $(DESTDIR)$(includedir)/liblepton
137	rm -vfr $(DESTDIR)$(includedir)/libleptonattrib
138	rm -vfr $(DESTDIR)$(pkgdatadir)
139	rm -vfr $(DESTDIR)$(docdir)
140
141CLEANFILES = stamp-git
142