1 | # -*-Mode: Makefile;-*- |
---|
2 | # |
---|
3 | # To rebuild PERL2ARB from $ARBHOME call |
---|
4 | # make perl_clean perl |
---|
5 | |
---|
6 | ARB_MAINMAKEFILE=../Makefile |
---|
7 | THIS=Makefile.main |
---|
8 | |
---|
9 | # howto call Makefile.main (this file) |
---|
10 | MAKETHIS=$(MAKE) -f $(THIS) |
---|
11 | |
---|
12 | # howto call generated Makefile |
---|
13 | PMAKE=$(MAKE) "CC=$(A_CXX)" |
---|
14 | |
---|
15 | LIB=$(ARBHOME)/lib |
---|
16 | ARBDB=$(ARBHOME)/ARBDB |
---|
17 | |
---|
18 | # code in -> ../PERLTOOLS/arb_proto_2_xsub.cxx |
---|
19 | ARB_PROTO_2_XSUB=$(ARBHOME)/bin/arb_proto_2_xsub |
---|
20 | |
---|
21 | HEADERS = \ |
---|
22 | $(ARBDB)/ad_prot.h \ |
---|
23 | $(ARBDB)/ad_t_prot.h \ |
---|
24 | |
---|
25 | ifeq ($(DARWIN),1) |
---|
26 | SO:=bundle |
---|
27 | LIBSO:=a |
---|
28 | else |
---|
29 | SO:=so |
---|
30 | LIBSO:= so |
---|
31 | endif |
---|
32 | |
---|
33 | ARB_SO=blib/arch/auto/ARB/ARB.$(SO) |
---|
34 | |
---|
35 | TARGET_PM=$(LIB)/ARB.pm |
---|
36 | TARGET_SO=$(LIB)/ARB.$(SO) |
---|
37 | |
---|
38 | TARGETS=$(TARGET_PM) $(TARGET_SO) |
---|
39 | |
---|
40 | DOC=perl-interface-function-list.txt |
---|
41 | |
---|
42 | XS_DEPENDS = Makefile Makefile.main ARB.xs debug.h Makefile.PL |
---|
43 | |
---|
44 | # ../SOURCE_TOOLS/filter_defined_symbols.pl |
---|
45 | SHOW_UNDEFINED=$(ARBHOME)/SOURCE_TOOLS/filter_defined_symbols.pl |
---|
46 | WARN_UNDEFINED=./warn_undefined_symbols.pl |
---|
47 | |
---|
48 | # ------------------------------------------------------------ |
---|
49 | # variables for Makefile |
---|
50 | |
---|
51 | MYEXTLIB := |
---|
52 | PASTHRU_INC := |
---|
53 | PASTHRU_DEFINE := |
---|
54 | |
---|
55 | export MYEXTLIB PASTHRU_INC PASTHRU_DEFINE dflags |
---|
56 | export CC CXX A_CC A_CXX |
---|
57 | |
---|
58 | # ------------------------------------------------------------ |
---|
59 | # normal build calls this makefile with AUTODEPENDS==1 |
---|
60 | |
---|
61 | ifeq ($(AUTODEPENDS),1) |
---|
62 | all: |
---|
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)" |
---|
69 | else |
---|
70 | all: realall |
---|
71 | endif |
---|
72 | |
---|
73 | realall: perlmain.c $(TARGETS) $(DOC) |
---|
74 | |
---|
75 | perlmain.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 |
---|
89 | ifeq ($(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" |
---|
95 | else |
---|
96 | $(error target '$@' not valid if AUTODEPENDS==$(AUTODEPENDS)) |
---|
97 | endif |
---|
98 | |
---|
99 | ARB.c : $(XS_DEPENDS) |
---|
100 | ifeq ($(AUTODEPENDS),0) |
---|
101 | @echo "-------- calling MakeMaker-Makefile (to generate C-source; AUTODEPENDS=$(AUTODEPENDS))" |
---|
102 | $(PMAKE) $@ |
---|
103 | @echo "-------- end of MakeMaker-Makefile" |
---|
104 | else |
---|
105 | $(error target '$@' not valid if AUTODEPENDS==$(AUTODEPENDS)) |
---|
106 | endif |
---|
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 | |
---|
113 | PERL_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 | |
---|
119 | PERL_GCC:=$(shell perl -e 'print "$$^V\n";')___$(COMPILER_VERSION) |
---|
120 | WONT_COMPILE_CXX11:=$(findstring $(PERL_GCC),$(PERL_GCC_INCOMPAT)) |
---|
121 | |
---|
122 | ifneq ('$(WONT_COMPILE_CXX11)','') |
---|
123 | hacked_cflags:=$(subst -std=gnu++11,,$(cflags4perl)) |
---|
124 | else |
---|
125 | hacked_cflags:=$(cflags4perl) |
---|
126 | endif |
---|
127 | ifeq ($(USE_CLANG),1) |
---|
128 | hacked_cflags:=$(hacked_cflags) -Wno-duplicate-decl-specifier |
---|
129 | endif |
---|
130 | |
---|
131 | # disable several warnings for perl interface build |
---|
132 | # (would need changes in perl-core-api) |
---|
133 | |
---|
134 | disabled_warnings:= \ |
---|
135 | -Wno-zero-as-null-pointer-constant \ |
---|
136 | -Wno-literal-suffix \ |
---|
137 | -Wno-unused-parameter \ |
---|
138 | |
---|
139 | used_cflags:=$(subst -Weffc++,,$(hacked_cflags)) $(disabled_warnings) $(CXX_INCLUDES) |
---|
140 | used_lflags:=$(lflags4perl) |
---|
141 | |
---|
142 | MAKE_MAKEFILE=make_arbperl_makefile.pl |
---|
143 | |
---|
144 | Makefile : $(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 | |
---|
150 | Makefile.PL : $(MAKE_MAKEFILE) |
---|
151 | ( \ |
---|
152 | echo "system('perl $< \"$(used_cflags)\" \"$(used_lflags)\"');" \ |
---|
153 | ) > $@ |
---|
154 | |
---|
155 | ARB.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 | |
---|
160 | proto.h : $(HEADERS) $(THIS) depends.stamp |
---|
161 | cat $(HEADERS) > $@ |
---|
162 | |
---|
163 | debug.h : $(THIS) |
---|
164 | echo "#undef DEBUG" > $@ |
---|
165 | echo "#undef NDEBUG" >> $@ |
---|
166 | ifeq ($(DEBUG),1) |
---|
167 | echo "#define DEBUG" >> $@ |
---|
168 | else |
---|
169 | echo "#define NDEBUG" >> $@ |
---|
170 | endif |
---|
171 | |
---|
172 | c_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 | |
---|
178 | clean: |
---|
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 | |
---|
192 | depends.stamp: |
---|
193 | touch $@ |
---|
194 | |
---|
195 | ifeq ($(AUTODEPENDS),2) |
---|
196 | include .depends |
---|
197 | endif |
---|
198 | |
---|