Add axTLS sourcecode
[project/luci.git] / libs / nixio / axTLS / bindings / perl / Makefile
1 #
2 # Copyright (c) 2007, Cameron Rich
3 #
4 # All rights reserved.
5 #
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions are met:
8 #
9 # * Redistributions of source code must retain the above copyright notice,
10 #   this list of conditions and the following disclaimer.
11 # * Redistributions in binary form must reproduce the above copyright
12 #   notice, this list of conditions and the following disclaimer in the
13 #   documentation and/or other materials provided with the distribution.
14 # * Neither the name of the axTLS project nor the names of its
15 #   contributors may be used to endorse or promote products derived
16 #   from this software without specific prior written permission.
17 #
18 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
21 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
22 # CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
24 # TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 
26 # OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 # NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
28 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 #
30
31 AXTLS_HOME=../..
32
33 include $(AXTLS_HOME)/config/.config
34 include $(AXTLS_HOME)/config/makefile.conf
35
36 all: lib
37
38 ifdef CONFIG_PLATFORM_WIN32
39 TARGET=$(AXTLS_HOME)/$(STAGE)/axtlsp.dll
40 else
41 TARGET=$(AXTLS_HOME)/$(STAGE)/libaxtlsp.so
42 endif
43
44 ifneq ($(MAKECMDGOALS), clean)
45
46 ifdef CONFIG_PLATFORM_WIN32
47 PERL5_CORE:=$(shell cygpath -w "$(CONFIG_PERL_CORE)")
48 else
49 PERL5_CORE= $(shell perl -e 'use Config; print $$Config{archlib};')/CORE
50 endif
51
52 all: test_perl
53
54 test_perl:
55         @if ! [ -d "$(PERL5_CORE)" ]; then \
56                 echo "*** Error: Perl not installed at $(CONFIG_PERL_CORE) - go to " \
57         "http://www.cpan.org/authors/id/G/GR/GRAHAMC/SiePerl-5.8.0-bin-1.0-Win32.INSTALL.exe" && exit 1; \
58         fi
59
60 endif
61
62 lib: $(TARGET)
63 OBJ:=axTLSp_wrap.o
64 include $(AXTLS_HOME)/config/makefile.post
65
66 ifndef CONFIG_PLATFORM_WIN32        # Linux/Unix/Cygwin
67
68 #
69 # Could have used libperl.a, but it increases the library to over 1MB, so just
70 # use libperl.so. But this needs to be in the shared library path for things to
71 # work.
72 #
73 $(TARGET) : $(OBJ)
74         $(LD) $(LDFLAGS) -L$(AXTLS_HOME)/$(STAGE) -L$(PERL5_CORE) $(LDSHARED) -o $@ $(OBJ) -laxtls -lperl
75 ifdef CONFIG_PLATFORM_CYGWIN
76         cd $(AXTLS_HOME)/$(STAGE); ln -sf $(notdir $@) axtlsp.dll
77 endif
78         @install axtlsp.pm $(AXTLS_HOME)/$(STAGE)
79
80 CFLAGS += -D_GNU_SOURCE -I$(PERL5_CORE)
81 else
82 CFLAGS += /I"$(PERL5_CORE)"
83 LDFLAGS += $(CONFIG_PERL_LIB) /libpath:"$(PERL5_CORE)" axtls.lib /libpath:"$(AXTLS_HOME)/$(STAGE)"
84
85 $(TARGET) : $(OBJ)
86         $(LD) $(LDFLAGS) $(LDSHARED) /out:$@ $(OBJ)
87         install axtlsp.pm $(AXTLS_HOME)/$(STAGE)
88 endif # WIN32
89
90 clean::
91         @rm -f $(TARGET) axtls* *.i axTLSp* *.c .depend $(AXTLS_HOME)/$(STAGE)/axtlsp.pm