| 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 | else |
|---|
| 28 | SO:=so |
|---|
| 29 | endif |
|---|
| 30 | |
|---|
| 31 | ARB_SO=blib/arch/auto/ARB/ARB.$(SO) |
|---|
| 32 | |
|---|
| 33 | TARGET_PM=$(LIB)/ARB.pm |
|---|
| 34 | TARGET_SO=$(LIB)/ARB.$(SO) |
|---|
| 35 | |
|---|
| 36 | TARGETS=$(TARGET_PM) $(TARGET_SO) |
|---|
| 37 | |
|---|
| 38 | DOC=perl-interface-function-list.txt |
|---|
| 39 | |
|---|
| 40 | XS_DEPENDS = Makefile Makefile.main ARB.xs debug.h Makefile.PL |
|---|
| 41 | |
|---|
| 42 | # ../SOURCE_TOOLS/filter_defined_symbols.pl |
|---|
| 43 | SHOW_UNDEFINED=$(ARBHOME)/SOURCE_TOOLS/filter_defined_symbols.pl |
|---|
| 44 | WARN_UNDEFINED=./warn_undefined_symbols.pl |
|---|
| 45 | |
|---|
| 46 | # ------------------------------------------------------------ |
|---|
| 47 | # variables for Makefile |
|---|
| 48 | |
|---|
| 49 | MYEXTLIB := |
|---|
| 50 | PASTHRU_INC := |
|---|
| 51 | PASTHRU_DEFINE := |
|---|
| 52 | |
|---|
| 53 | export MYEXTLIB PASTHRU_INC PASTHRU_DEFINE dflags |
|---|
| 54 | export CC CXX A_CC A_CXX |
|---|
| 55 | |
|---|
| 56 | # ------------------------------------------------------------ |
|---|
| 57 | # normal build calls this makefile with AUTODEPENDS==1 |
|---|
| 58 | |
|---|
| 59 | ifeq ($(AUTODEPENDS),1) |
|---|
| 60 | all: |
|---|
| 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)" |
|---|
| 67 | else |
|---|
| 68 | all: realall |
|---|
| 69 | endif |
|---|
| 70 | |
|---|
| 71 | realall: perlmain.c $(TARGETS) $(DOC) |
|---|
| 72 | |
|---|
| 73 | perlmain.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 |
|---|
| 87 | ifeq ($(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" |
|---|
| 93 | else |
|---|
| 94 | $(error target '$@' not valid if AUTODEPENDS==$(AUTODEPENDS)) |
|---|
| 95 | endif |
|---|
| 96 | |
|---|
| 97 | ARB.c : $(XS_DEPENDS) |
|---|
| 98 | ifeq ($(AUTODEPENDS),0) |
|---|
| 99 | @echo "-------- calling MakeMaker-Makefile (to generate C-source; AUTODEPENDS=$(AUTODEPENDS))" |
|---|
| 100 | $(PMAKE) $@ |
|---|
| 101 | @echo "-------- end of MakeMaker-Makefile" |
|---|
| 102 | else |
|---|
| 103 | $(error target '$@' not valid if AUTODEPENDS==$(AUTODEPENDS)) |
|---|
| 104 | endif |
|---|
| 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 | |
|---|
| 111 | PERL_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 | |
|---|
| 117 | PERL_GCC:=$(shell perl -e 'print "$$^V\n";')___$(COMPILER_VERSION) |
|---|
| 118 | WONT_COMPILE_CXX11:=$(findstring $(PERL_GCC),$(PERL_GCC_INCOMPAT)) |
|---|
| 119 | |
|---|
| 120 | ifneq ('$(WONT_COMPILE_CXX11)','') |
|---|
| 121 | hacked_cflags:=$(subst -std=gnu++11,,$(cflags4perl)) |
|---|
| 122 | else |
|---|
| 123 | hacked_cflags:=$(cflags4perl) |
|---|
| 124 | endif |
|---|
| 125 | ifeq ($(USE_CLANG),1) |
|---|
| 126 | hacked_cflags:=$(hacked_cflags) -Wno-duplicate-decl-specifier |
|---|
| 127 | endif |
|---|
| 128 | |
|---|
| 129 | # disable several warnings for perl interface build |
|---|
| 130 | # (would need changes in perl-core-api) |
|---|
| 131 | |
|---|
| 132 | disabled_warnings:= \ |
|---|
| 133 | -Wno-zero-as-null-pointer-constant \ |
|---|
| 134 | -Wno-literal-suffix \ |
|---|
| 135 | -Wno-unused-parameter \ |
|---|
| 136 | |
|---|
| 137 | used_cflags:=$(subst -Weffc++,,$(hacked_cflags)) $(disabled_warnings) $(CXX_INCLUDES) |
|---|
| 138 | used_lflags:=$(lflags4perl) |
|---|
| 139 | |
|---|
| 140 | MAKE_MAKEFILE=make_arbperl_makefile.pl |
|---|
| 141 | |
|---|
| 142 | Makefile : $(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 | |
|---|
| 148 | Makefile.PL : $(MAKE_MAKEFILE) |
|---|
| 149 | ( \ |
|---|
| 150 | echo "system('perl $< \"$(used_cflags)\" \"$(used_lflags)\"');" \ |
|---|
| 151 | ) > $@ |
|---|
| 152 | |
|---|
| 153 | ARB.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 | |
|---|
| 158 | proto.h : $(HEADERS) $(THIS) depends.stamp |
|---|
| 159 | cat $(HEADERS) > $@ |
|---|
| 160 | |
|---|
| 161 | debug.h : $(THIS) |
|---|
| 162 | echo "#undef DEBUG" > $@ |
|---|
| 163 | echo "#undef NDEBUG" >> $@ |
|---|
| 164 | ifeq ($(DEBUG),1) |
|---|
| 165 | echo "#define DEBUG" >> $@ |
|---|
| 166 | else |
|---|
| 167 | echo "#define NDEBUG" >> $@ |
|---|
| 168 | endif |
|---|
| 169 | |
|---|
| 170 | c_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 | |
|---|
| 176 | clean: |
|---|
| 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 | |
|---|
| 190 | depends.stamp: |
|---|
| 191 | touch $@ |
|---|
| 192 | |
|---|
| 193 | ifeq ($(AUTODEPENDS),2) |
|---|
| 194 | include .depends |
|---|
| 195 | endif |
|---|
| 196 | |
|---|