source: trunk/PERL2ARB/Makefile.main

Last change on this file was 19493, checked in by westram, 12 months ago
  • homebrew build looked for wrong lib-suffix. patch from jan. thx :)
  • fixed a typo in warn_undefined_symbols.pl
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.1 KB
Line 
1# -*-Mode: Makefile;-*-
2#
3# To rebuild PERL2ARB from $ARBHOME call
4# make perl_clean perl
5
6ARB_MAINMAKEFILE=../Makefile
7THIS=Makefile.main
8
9# howto call Makefile.main (this file)
10MAKETHIS=$(MAKE) -f $(THIS)
11
12# howto call generated Makefile
13PMAKE=$(MAKE) "CC=$(A_CXX)"
14
15LIB=$(ARBHOME)/lib
16ARBDB=$(ARBHOME)/ARBDB
17
18# code in -> ../PERLTOOLS/arb_proto_2_xsub.cxx
19ARB_PROTO_2_XSUB=$(ARBHOME)/bin/arb_proto_2_xsub
20
21HEADERS = \
22        $(ARBDB)/ad_prot.h \
23        $(ARBDB)/ad_t_prot.h \
24
25ifeq ($(DARWIN),1)
26SO:=bundle
27LIBSO:=a
28else
29SO:=so
30LIBSO:= so
31endif
32
33ARB_SO=blib/arch/auto/ARB/ARB.$(SO)
34
35TARGET_PM=$(LIB)/ARB.pm
36TARGET_SO=$(LIB)/ARB.$(SO)
37
38TARGETS=$(TARGET_PM) $(TARGET_SO)
39
40DOC=perl-interface-function-list.txt
41
42XS_DEPENDS = Makefile Makefile.main ARB.xs debug.h Makefile.PL
43
44# ../SOURCE_TOOLS/filter_defined_symbols.pl
45SHOW_UNDEFINED=$(ARBHOME)/SOURCE_TOOLS/filter_defined_symbols.pl
46WARN_UNDEFINED=./warn_undefined_symbols.pl
47
48# ------------------------------------------------------------
49# variables for Makefile
50
51MYEXTLIB :=
52PASTHRU_INC :=
53PASTHRU_DEFINE :=
54
55export MYEXTLIB PASTHRU_INC PASTHRU_DEFINE dflags
56export CC CXX A_CC A_CXX
57
58# ------------------------------------------------------------
59# normal build calls this makefile with AUTODEPENDS==1
60
61ifeq ($(AUTODEPENDS),1)
62all:
63        @echo "-------- recurse $(THIS) to build depends"
64        +test -f .depends || $(MAKETHIS) "AUTODEPENDS=0" .depends
65        @echo "-------- done recurse $(THIS)"
66        @echo "-------- recurse $(THIS) to build all"
67        +$(MAKETHIS) "AUTODEPENDS=2" all
68        @echo "-------- done recurse $(THIS)"
69else
70all: realall
71endif
72
73realall: perlmain.c $(TARGETS) $(DOC)
74
75perlmain.c: perlmain_source.c
76        cp $< $@
77
78$(TARGET_PM) : ARB.pm
79        cp $< $@
80
81$(TARGET_SO) : $(ARB_SO) $(SHOW_UNDEFINED) $(WARN_UNDEFINED)
82        $(SHOW_UNDEFINED) $(ARB_SO) $(LIB)/libARBDB.$(LIBSO) $(LIB)/libCORE.$(LIBSO) | $(WARN_UNDEFINED)
83        cp $< $@
84
85# Note: the targets '$(ARB_SO)' and 'ARB.c' may not be called in parallel (causes failure)
86# To avoid doing that by mistake, they fail if AUTODEPENDS has wrong (unexpected) value.
87
88$(ARB_SO) : $(XS_DEPENDS) depends.stamp
89ifeq ($(AUTODEPENDS),2)
90        rm $(ARB_SO) || true
91        @echo "Used perl version: `perl -v | grep 'This is perl'`"
92        @echo "-------- calling MakeMaker-Makefile (to build module; AUTODEPENDS=$(AUTODEPENDS))"
93        $(PMAKE) $@
94        @echo "-------- end of MakeMaker-Makefile"
95else
96        $(error target '$@' not valid if AUTODEPENDS==$(AUTODEPENDS))
97endif
98
99ARB.c : $(XS_DEPENDS)
100ifeq ($(AUTODEPENDS),0)
101        @echo "-------- calling MakeMaker-Makefile (to generate C-source; AUTODEPENDS=$(AUTODEPENDS))"
102        $(PMAKE) $@
103        @echo "-------- end of MakeMaker-Makefile"
104else
105        $(error target '$@' not valid if AUTODEPENDS==$(AUTODEPENDS))
106endif
107# buildMakefile
108
109# ------------------------------------------------------------
110# hack to compile with gcc 4.7.x and perl 5.10.1
111# (see http://bugs.arb-home.de/changeset/10566 for why)
112
113PERL_GCC_INCOMPAT:= \
114        v5.10.1___4.7.1 \
115        v5.10.1___4.7.2 \
116        v5.10.1___4.7.3 \
117        v5.10.1___4.7.4 \
118
119PERL_GCC:=$(shell perl -e 'print "$$^V\n";')___$(COMPILER_VERSION)
120WONT_COMPILE_CXX11:=$(findstring $(PERL_GCC),$(PERL_GCC_INCOMPAT))
121
122ifneq ('$(WONT_COMPILE_CXX11)','')
123        hacked_cflags:=$(subst -std=gnu++11,,$(cflags4perl))
124else
125        hacked_cflags:=$(cflags4perl)
126endif
127ifeq ($(USE_CLANG),1)
128        hacked_cflags:=$(hacked_cflags) -Wno-duplicate-decl-specifier
129endif
130
131# disable several warnings for perl interface build
132# (would need changes in perl-core-api)
133
134disabled_warnings:= \
135        -Wno-zero-as-null-pointer-constant \
136        -Wno-literal-suffix \
137        -Wno-unused-parameter \
138
139used_cflags:=$(subst -Weffc++,,$(hacked_cflags)) $(disabled_warnings) $(CXX_INCLUDES)
140used_lflags:=$(lflags4perl)
141
142MAKE_MAKEFILE=make_arbperl_makefile.pl
143
144Makefile : $(MAKE_MAKEFILE) typemap Makefile.main $(ARB_MAINMAKEFILE) Makefile.PL
145        ( PATH=/usr/arb/bin:${PATH}; \
146          export PATH; \
147          echo calling perl $(MAKE_MAKEFILE) "$(used_cflags)" "$(used_lflags)"; \
148          perl $(MAKE_MAKEFILE) "$(used_cflags)" "$(used_lflags)" )
149
150Makefile.PL : $(MAKE_MAKEFILE)
151        ( \
152                echo "system('perl $< \"$(used_cflags)\" \"$(used_lflags)\"');" \
153        ) > $@
154
155ARB.xs : $(ARB_PROTO_2_XSUB) proto.h ARB.default.xs perlmain_source.c typemap
156        @(test -f $@ && chmod a+w $@) || true
157        $(ARB_PROTO_2_XSUB) proto.h ARB.default.xs typemap >$@
158        @test -f $@ && chmod a-w $@
159
160proto.h : $(HEADERS) $(THIS) depends.stamp
161        cat $(HEADERS) > $@
162
163debug.h : $(THIS)
164        echo "#undef DEBUG" > $@
165        echo "#undef NDEBUG" >> $@
166ifeq ($(DEBUG),1)
167        echo "#define DEBUG" >> $@
168else
169        echo "#define NDEBUG" >> $@
170endif
171
172c_source: $(TARGET_SO)
173        test -f ARB.c || (echo "Error: Expected ARB.c to exist, but it doesn't"; false)
174
175$(DOC): proto.h extract_perl_interface.pl c_source
176        ./extract_perl_interface.pl > $(DOC)
177
178clean:
179        -test -f Makefile && $(MAKE) clean
180        rm -f Makefile.old proto.h debug.h ARB.c ARB.xs .depends depends.stamp Makefile.PL $(TARGETS) $(DOC)
181        rm -f Makefile
182
183.depends: depends.stamp Makefile.main
184        @echo "-------- recurse $(THIS) to build C-module"
185        +test -f ARB.c || $(MAKETHIS) "AUTODEPENDS=0" ARB.c
186        @echo "-------- done recurse $(THIS)"
187        $(MAKEDEPEND) -f- $(MAKEDEPENDFLAGS) ARB.c 2>/dev/null | \
188                perl -ne 's/ARB.o:/depends.stamp:/g; print $$_;' | \
189                ../SOURCE_TOOLS/fix_depends.pl "(from PERL2ARB)" > $@
190
191
192depends.stamp:
193        touch $@
194
195ifeq ($(AUTODEPENDS),2)
196include .depends
197endif
198
Note: See TracBrowser for help on using the repository browser.