Imported Upstream version 1.22.4
[platform/upstream/groff.git] / contrib / chem / chem.am
1 # Automake rules for 'chem'
2
3 # File position: <groff-source>/contrib/chem/chem.am
4
5 # Copyright (C) 2006-2018 Free Software Foundation, Inc.
6 # Written by Bernd Warken <groff-bernd.warken-72@web.de>.
7 # Moved to automake by Bertrand Garrigues
8 #
9 # Last update: 22 Aug 2015
10 #
11 # This file is part of 'chem' which is part of 'groff'.
12 #
13 # 'groff' is free software; you can redistribute it and/or modify it
14 # under the terms of the GNU General Public License (GPL) version 2 as
15 # published by the Free Software Foundation.
16 #
17 # 'groff' is distributed in the hope that it will be useful, but
18 # WITHOUT ANY WARRANTY; without even the implied warranty of
19 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20 # General Public License for more details.
21 #
22 # The GPL2 license text is available in the internet at
23 # <http://www.gnu.org/licenses/gpl-2.0.html>.
24
25 ########################################################################
26
27 chem_srcdir = $(top_srcdir)/contrib/chem
28 prefixexecbin_SCRIPTS += chem
29
30 # Files installed in $(datasubdir)/pic
31 chempicdir = $(datasubdir)/pic
32 dist_chempic_DATA = contrib/chem/chem.pic
33
34
35 CHEM_GENEXAMPLES = contrib/chem/examples/README
36 CHEM_EXAMPLES =  \
37   contrib/chem/examples/atp.chem \
38   contrib/chem/examples/cholesterin.chem \
39   contrib/chem/examples/ethamivan.chem \
40   contrib/chem/examples/lsd.chem \
41   contrib/chem/examples/morphine.chem \
42   contrib/chem/examples/penicillin.chem \
43   contrib/chem/examples/reserpine.chem
44
45 if BUILD_EXAMPLES
46 # Files installed in $(exampledir)/chem
47 chemexampledir = $(exampledir)/chem
48 nodist_chemexample_DATA = $(CHEM_GENEXAMPLES)
49 dist_chemexample_DATA = $(CHEM_EXAMPLES)
50
51 # Files installed in $(exampledir)/chem/122. All the .chem files in 122 are 
52 # lazily installed by the local install target
53 chemexample122dir = $(chemexampledir)/122
54 nodist_chemexample122_DATA = contrib/chem/examples/122/README
55 endif
56 EXTRA_DIST += \
57   contrib/chem/ChangeLog \
58   contrib/chem/chem.1.man \
59   contrib/chem/chem.pic \
60   contrib/chem/chem.pl \
61   contrib/chem/README.txt \
62   contrib/chem/examples/README.txt \
63   contrib/chem/examples/122/README.txt
64
65 man1_MANS += contrib/chem/chem.1
66 MOSTLYCLEANFILES += $(CHEM_GENEXAMPLES) $(nodist_chemexample122_DATA) \
67   contrib/chem/README
68
69 # This is strangly built but not installed
70 all: contrib/chem/README
71
72 contrib/chem/README: $(chem_srcdir)/README.txt
73         $(AM_V_GEN)$(MKDIR_P) contrib/chem/ \
74         && sed -e "s|[@]g[@]|$(g)|g" $? >$@
75
76 contrib/chem/examples/README: $(chem_srcdir)/examples/README.txt
77         $(AM_V_GEN)$(MKDIR_P) contrib/chem/examples \
78         && sed -e "s|[@]g[@]|$(g)|g" $? >$@
79
80 contrib/chem/examples/122/README: $(chem_srcdir)/examples/122/README.txt
81         $(AM_V_GEN)$(MKDIR_P) contrib/chem/examples/122 \
82         && sed -e "s|[@]g[@]|$(g)|g" $? >$@
83
84 chem: $(chem_srcdir)/chem.pl $(SH_DEPS_SED_SCRIPT)
85         $(AM_V_GEN)$(RM) $@ \
86         && sed -f "$(SH_DEPS_SED_SCRIPT)" \
87                -e "s|[@]g[@]|$(g)|g" \
88                -e "s|[@]BINDIR[@]|$(DESTDIR)$(bindir)|g" \
89                -e "s|[@]MACRODIR[@]|$(DESTDIR)$(tmacdir)|g" \
90                -e "s|[@]PICDIR[@]|$(DESTDIR)$(datasubdir)/pic|g" \
91                -e "s|[@]VERSION[@]|$(VERSION)|g" \
92                -e "$(SH_SCRIPT_SED_CMD)" \
93                $(chem_srcdir)/chem.pl \
94                >$@ \
95         && chmod +x $@
96
97 install-data-local: install_chem_extra
98 install_chem_extra:
99 if BUILD_EXAMPLES
100         -test -d $(DESTDIR)$(chemexample122dir) \
101           || $(mkinstalldirs) $(DESTDIR)$(chemexample122dir);
102         for i in $(chem_srcdir)/examples/122/*.chem; do \
103           n=`echo $$i | sed 's|$(chem_srcdir)/examples/122/||g'`; \
104           $(INSTALL_DATA) $$i $(DESTDIR)$(chemexample122dir)/$$n; \
105         done
106 endif
107
108 uninstall-local: uninstall_chem_extra
109 uninstall_chem_extra:
110 if BUILD_EXAMPLES
111         $(RM) $(DESTDIR)$(exampledir)/chem/122/*
112         -rmdir $(DESTDIR)$(exampledir)/chem/122
113         $(RM) $(DESTDIR)$(exampledir)/chem/*
114         -rmdir $(DESTDIR)$(exampledir)/chem
115 endif
116         -rmdir $(DESTDIR)$(datasubdir)/pic
117
118 dist-hook: dist_chem
119 dist_chem:
120         chmod u+w $(distdir)/contrib/chem/examples/122
121         for i in $(chem_srcdir)/examples/122/*.chem; do \
122           cp -f $$i $(distdir)/contrib/chem/examples/122; \
123         done
124
125
126 ########################################################################
127 # Editor settings
128 ########################################################################
129 #
130 # Local Variables:
131 # mode: makefile-automake
132 # fill-column: 72
133 # End:
134 # vim: set filetype=automake textwidth=72: