1#  Copyright 1999-2016 ImageMagick Studio LLC, a non-profit organization
2#  dedicated to making software imaging solutions freely available.
3#
4#  You may not use this file except in compliance with the License.  You may
5#  obtain a copy of the License at
6#
7#    http://www.imagemagick.org/script/license.php
8#
9#  Unless required by applicable law or agreed to in writing, software
10#  distributed under the License is distributed on an "AS IS" BASIS,
11#  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12#  See the License for the specific language governing permissions and
13#  limitations under the License.
14#
15#  Copyright (C) 2003 - 2008 GraphicsMagick Group
16#
17#  Makefile for building PerlMagick.
18
19# If source files missing, see if they can be obtained via VPATH
20#
21$(PERLMAGICK)/quantum/@MAGICK_ABI_SUFFIX@.xs: $(PERLMAGICK)/quantum/quantum.xs
22	$(AM_V_GEN) $(LN_S) quantum.xs $@
23
24$(PERLMAGICK)/quantum/@MAGICK_ABI_SUFFIX@.pm: $(PERLMAGICK)/quantum/quantum.pm
25	$(AM_V_GEN) $(LN_S) quantum.pm $@
26
27perl-quantum-sources: $(PERLMAGICK)/quantum/@MAGICK_ABI_SUFFIX@.xs $(PERLMAGICK)/quantum/@MAGICK_ABI_SUFFIX@.pm
28
29perl-sources: perl-quantum-sources
30	@if test -n "$(VPATH)" ; then \
31	  echo "Linking PerlMagick Sources ..." ; \
32	  imagemagick=`(cd $(VPATH) ; pwd)` && \
33	  ( cd $(PERLMAGICK) && \
34	    sh $$imagemagick/config/lndir.sh $$imagemagick/$(PERLMAGICK) ; ) \
35	fi ; \
36	touch perl-sources
37
38if WITH_PERL
39
40PERLMAGICK=PerlMagick
41PERLMAKEMAKER=$(PERLMAGICK)/Makefile.PL
42PERLMAKEFILE=$(PERLMAGICK)/Makefile
43
44PERLMAGICK_ALL_LOCAL_TARGETS = all-perl
45PERLMAGICK_INSTALL_EXEC_LOCAL_TARGETS = install-exec-perl
46PERLMAGICK_INSTALL_DATA_LOCAL_TARGETS =
47PERLMAGICK_UNINSTALL_LOCAL_TARGETS = uninstall-exec-perl
48PERLMAGICK_CLEAN_LOCAL_TARGETS = clean-perl
49PERLMAGICK_DISTCLEAN_LOCAL_TARGETS = clean-perl
50PERLMAGICK_MAINTAINER_CLEAN_LOCAL_TARGETS = distclean-local
51PERLMAGICK_TESTS = PerlMagick/check.sh
52
53if WITH_PERL_DYNAMIC
54
55PERLMAGICK_CHECKSCRPTS =
56
57$(PERLMAKEFILE): perl-sources $(MAGICKCORE_LIBS) $(MAGICKWAND_LIBS) $(PERLMAKEMAKER)
58	cd $(PERLMAGICK) && @PERL@ Makefile.PL $(PERL_MAKE_OPTIONS)
59
60install-exec-perl: $(PERLMAKEFILE)
61	( cd $(PERLMAGICK) && $(MAKE) CC='@CC@' && \
62	$(MAKE) CC='@CC@' install )
63
64all-perl: perl-sources
65
66uninstall-exec-perl: $(PERLMAKEFILE)
67	echo "Uninstall not supported for PerlMagick"
68
69check-perl: $(PERLMAKEFILE)
70	cd $(PERLMAGICK) && $(abs_top_builddir)/magick.sh $(MAKE) CC='@CC@' test
71
72perl-build: $(PERLMAKEFILE)
73	( cd $(PERLMAGICK) && $(MAKE) CC='@CC@' )
74
75else
76if WITH_PERL_STATIC
77
78PERLSTATICNAME=PerlMagick
79
80PERLMAGICK_CHECKSCRPTS = perl-build
81
82$(PERLMAKEFILE): perl-sources $(MAGICKCORE_LIBS) $(MAGICKWAND_LIBS) $(PERLMAKEMAKER)
83	cd $(PERLMAGICK) && @PERL@ Makefile.PL MAP_TARGET=$(PERLSTATICNAME) $(PERL_MAKE_OPTIONS) && $(MAKE) Makefile ; $(MAKE) Makefile
84
85$(PERLMAGICK)/$(PERLSTATICNAME): $(MAGICKCORE_LIBS) $(MAGICKWAND_LIBS) $(PERLMAKEFILE)
86	( rm -f $(PERLMAGICK)/$(PERLSTATICNAME) ; cd $(PERLMAGICK) && $(MAKE) CC='@CC@' $(PERLSTATICNAME) ; $(MAKE) CC='@CC@' $(PERLSTATICNAME) )
87
88all-perl: $(PERLMAGICK)/$(PERLSTATICNAME)
89
90install-exec-perl: $(PERLMAGICK)/$(PERLSTATICNAME)
91	rm -f "$(DESTDIR)$(BIN_DIR)/$(PERLSTATICNAME)"
92	if test "x$(DESTDIR)" = "x" -o "$(PERL_SUPPORTS_DESTDIR)" = 'yes' ; then \
93	  ( cd $(PERLMAGICK) && \
94	    $(MAKE) -f Makefile.aperl CC='@CC@' inst_perl MAP_TARGET=$(PERLSTATICNAME) \
95	    INSTALLBIN="$(BIN_DIR)" \
96	  ) ; \
97	else \
98	  ( cd $(PERLMAGICK) && \
99	    $(MAKE) -f Makefile.aperl CC='@CC@' inst_perl MAP_TARGET=$(PERLSTATICNAME) \
100	    INSTALLBIN="$(DESTDIR)$(BIN_DIR)" PREFIX="$(DESTDIR)$(prefix)" \
101	  ) ; \
102	fi
103
104uninstall-exec-perl:
105	rm -f '$(DESTDIR)$(BIN_DIR)/$(PERLSTATICNAME)'
106
107check-perl: $(PERLMAGICK)/$(PERLSTATICNAME)
108	cd $(PERLMAGICK) && $(abs_top_builddir)/magick.sh $(MAKE) -f Makefile.aperl CC='@CC@' test
109
110perl-build: $(PERLMAGICK)/$(PERLSTATICNAME)
111
112endif # WITH_PERL_STATIC
113endif # WTIH_PERL_DYNAMIC
114
115
116clean-perl:
117	(cd $(PERLMAGICK) && \
118	( if test -f Makefile.old ; then $(MAKE) -f Makefile.old CC='@CC@' clean ; fi ) ; \
119	( if test -f Makefile ; then $(MAKE) CC='@CC@' clean ; fi ) ; \
120	( if test -f Makefile ; then $(MAKE) CC='@CC@' clean ; fi ) ; \
121	rm -f Makefile.old PerlMagick ; \
122	rm -f t/output* t/jng/*_tmp.jng t/*/output* ; \
123	rm -f quantum/@MAGICK_ABI_SUFFIX@.xs;\
124	rm -f quantum/@MAGICK_ABI_SUFFIX@.pm;\
125	rm -f Magick.pm;)
126	rm -f perl-sources
127
128distclean-perl: clean-perl
129
130else
131# Satisfy makefile requirements if not building PERL
132all-perl:
133install-exec-perl:
134uninstall-exec-perl:
135check-perl:
136clean-perl:
137distclean-perl:
138endif # WITH_PERL
139