source: branches/ali/PERL2ARB/Makefile.main

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