summaryrefslogtreecommitdiff
path: root/contrib/chem/chem.am
blob: b46b488c95d1ab0488a6cc4b67e1e87f547e1fb9 (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
# Automake rules for `chem' (integration into the `groff' source tree)

# File position: <groff-source>/contrib/chem/chem.am

# Copyright (C) 2006, 2009, 2010, 2013-14
#   Free Software Foundation, Inc.
# Written by Bernd Warken <groff-bernd.warken-72@web.de>.
# Moved to automake by Bertrand Garrigues

# This file is part of `chem' which is part of `groff'.

# `groff' is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License (GPL) version 2 as
# published by the Free Software Foundation.

# `groff' is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.

# The GPL2 license text is available in the internet at
# <http://www.gnu.org/licenses/gpl-2.0.html>.

########################################################################

chem_srcdir = $(top_srcdir)/contrib/chem
bin_SCRIPTS += chem

# Files installed in $(datasubdir)/pic
chempicdir = $(datasubdir)/pic
dist_chempic_DATA = contrib/chem/chem.pic


CHEM_GENEXAMPLES = contrib/chem/examples/README
CHEM_EXAMPLES =  \
  contrib/chem/examples/atp.chem \
  contrib/chem/examples/cholesterin.chem \
  contrib/chem/examples/ethamivan.chem \
  contrib/chem/examples/lsd.chem \
  contrib/chem/examples/morphine.chem \
  contrib/chem/examples/penicillin.chem \
  contrib/chem/examples/reserpine.chem

if BUILD_EXAMPLES
# Files installed in $(exampledir)/chem
chemexampledir = $(exampledir)/chem
nodist_chemexample_DATA = $(CHEM_GENEXAMPLES)
dist_chemexample_DATA = $(CHEM_EXAMPLES)

# Files installed in $(exampledir)/chem/122. All the .chem files in 122 are 
# lazily installed by the local install target
chemexample122dir = $(chemexampledir)/122
nodist_chemexample122_DATA = contrib/chem/examples/122/README
endif
EXTRA_DIST += \
  contrib/chem/ChangeLog \
  contrib/chem/chem.man \
  contrib/chem/chem.pic \
  contrib/chem/chem.pl \
  contrib/chem/README.txt \
  contrib/chem/examples/README.txt \
  contrib/chem/examples/122/README.txt

man1_MANS += contrib/chem/chem.n
MOSTLYCLEANFILES += $(CHEM_GENEXAMPLES) $(nodist_chemexample122_DATA) \
  contrib/chem/README

# This is strangly built but not installed
all: contrib/chem/README

contrib/chem/README: $(chem_srcdir)/README.txt
	@$(MKDIR_P) contrib/chem/
	sed -e "s|[@]g[@]|$(g)|g" $? >$@

contrib/chem/examples/README: $(chem_srcdir)/examples/README.txt
	@$(MKDIR_P) contrib/chem/examples
	sed -e "s|[@]g[@]|$(g)|g" $? >$@

contrib/chem/examples/122/README: $(chem_srcdir)/examples/122/README.txt
	@$(MKDIR_P) contrib/chem/examples/122
	sed -e "s|[@]g[@]|$(g)|g" $? >$@

chem: $(chem_srcdir)/chem.pl $(SH_DEPS_SED_SCRIPT)
	rm -f $@
	sed -f "$(SH_DEPS_SED_SCRIPT)" \
	    -e "s|[@]g[@]|$(g)|g" \
	    -e "s|[@]BINDIR[@]|$(DESTDIR)$(bindir)|g" \
	    -e "s|[@]MACRODIR[@]|$(DESTDIR)$(tmacdir)|g" \
	    -e "s|[@]PICDIR[@]|$(DESTDIR)$(datasubdir)/pic|g" \
	    -e "s|[@]VERSION[@]|$(VERSION)|g" \
	    -e "$(SH_SCRIPT_SED_CMD)" \
	    $(chem_srcdir)/chem.pl >$@
	chmod +x $@

install-data-local: install_chem_extra
install_chem_extra:
if BUILD_EXAMPLES
	-test -d $(DESTDIR)$(chemexample122dir) \
          || $(mkinstalldirs) $(DESTDIR)$(chemexample122dir);
	for i in $(chem_srcdir)/examples/122/*.chem; do \
	  n=`echo $$i | sed 's|$(chem_srcdir)/examples/122/||g'`; \
	  $(INSTALL_DATA) $$i $(DESTDIR)$(chemexample122dir)/$$n; \
	done
endif

uninstall-local: uninstall_chem_extra
uninstall_chem_extra:
if BUILD_EXAMPLES
	rm -f $(DESTDIR)$(exampledir)/chem/122/*
	-rmdir $(DESTDIR)$(exampledir)/chem/122
	rm -f $(DESTDIR)$(exampledir)/chem/*
	-rmdir $(DESTDIR)$(exampledir)/chem
endif
	-rmdir $(DESTDIR)$(datasubdir)/pic

dist-hook: dist_chem
dist_chem:
	chmod u+w $(distdir)/contrib/chem/examples/122
	for i in $(chem_srcdir)/examples/122/*.chem; do \
	  cp -f $$i $(distdir)/contrib/chem/examples/122; \
	done