| 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 | XS_DEPENDS = Makefile Makefile.main ARB.xs debug.h Makefile.PL | 
|---|
| 39 |  | 
|---|
| 40 | # ------------------------------------------------------------ | 
|---|
| 41 | # variables for Makefile | 
|---|
| 42 |  | 
|---|
| 43 | MYEXTLIB := | 
|---|
| 44 | PASTHRU_INC := | 
|---|
| 45 | PASTHRU_DEFINE := | 
|---|
| 46 |  | 
|---|
| 47 | export MYEXTLIB PASTHRU_INC PASTHRU_DEFINE dflags | 
|---|
| 48 | export CC CXX A_CC A_CXX | 
|---|
| 49 |  | 
|---|
| 50 | # ------------------------------------------------------------ | 
|---|
| 51 |  | 
|---|
| 52 | ifeq ($(AUTODEPENDS),1) | 
|---|
| 53 | all: | 
|---|
| 54 | +test -f .depends || $(MAKETHIS) "AUTODEPENDS=0" .depends | 
|---|
| 55 | +$(MAKETHIS) "AUTODEPENDS=2" all | 
|---|
| 56 | else | 
|---|
| 57 | all: realall | 
|---|
| 58 | endif | 
|---|
| 59 |  | 
|---|
| 60 | realall: perlmain.c $(TARGETS) | 
|---|
| 61 |  | 
|---|
| 62 | perlmain.c: perlmain_source.c | 
|---|
| 63 | cp $< $@ | 
|---|
| 64 |  | 
|---|
| 65 | $(TARGET_PM) : ARB.pm | 
|---|
| 66 | cp $< $@ | 
|---|
| 67 |  | 
|---|
| 68 | $(TARGET_SO) : $(ARB_SO) | 
|---|
| 69 | cp $< $@ | 
|---|
| 70 |  | 
|---|
| 71 | $(ARB_SO) : $(XS_DEPENDS) depends.stamp | 
|---|
| 72 | -rm $(ARB_SO) | 
|---|
| 73 | @echo "Used perl version: `perl -v | grep 'This is perl'`" | 
|---|
| 74 | @echo "-------- calling MakeMaker-Makefile" | 
|---|
| 75 | ( $(PMAKE) $@ || (echo "------ failed[1].. retry once"; $(PMAKE) $@)) | 
|---|
| 76 | @echo "-------- post-recreating .depends" | 
|---|
| 77 | +$(MAKETHIS) "DEPENDS=0" .depends | 
|---|
| 78 | +$(MAKETHIS) $@ # recurse | 
|---|
| 79 |  | 
|---|
| 80 | ARB.c : $(XS_DEPENDS) | 
|---|
| 81 | @echo "-------- calling MakeMaker-Makefile (to get depends)" | 
|---|
| 82 | ( $(PMAKE) $@ || (echo "------ failed[2].. retry once"; $(PMAKE) $@)) | 
|---|
| 83 | @echo "-------- end of MakeMaker-Makefile" | 
|---|
| 84 |  | 
|---|
| 85 | # buildMakefile | 
|---|
| 86 |  | 
|---|
| 87 | # ------------------------------------------------------------ | 
|---|
| 88 | # hack to compile with gcc 4.7.3 and perl 5.10.1 | 
|---|
| 89 | # (see http://bugs.arb-home.de/changeset/10566 for why) | 
|---|
| 90 |  | 
|---|
| 91 | PERL_GCC_INCOMPAT:= v5.10.1___4.7.3 | 
|---|
| 92 | PERL_GCC:=$(shell perl -e 'print "$$^V\n";')___$(COMPILER_VERSION) | 
|---|
| 93 | WONT_COMPILE_CXX11:=$(findstring $(PERL_GCC),$(PERL_GCC_INCOMPAT)) | 
|---|
| 94 |  | 
|---|
| 95 | ifneq ('$(WONT_COMPILE_CXX11)','') | 
|---|
| 96 | hacked_cflags:=$(subst -std=gnu++11,,$(cross_cflags)) | 
|---|
| 97 | else | 
|---|
| 98 | hacked_cflags:=$(cross_cflags) | 
|---|
| 99 | endif | 
|---|
| 100 |  | 
|---|
| 101 | used_cflags:=$(subst -Weffc++,,$(hacked_cflags)) -Wno-literal-suffix $(CXX_INCLUDES) | 
|---|
| 102 | used_lflags:=$(cross_lflags) | 
|---|
| 103 |  | 
|---|
| 104 | MAKE_MAKEFILE=make_arbperl_makefile.pl | 
|---|
| 105 |  | 
|---|
| 106 | Makefile : $(MAKE_MAKEFILE) typemap Makefile.main $(ARB_MAINMAKEFILE) | 
|---|
| 107 | ( PATH=/usr/arb/bin:${PATH}; \ | 
|---|
| 108 | export PATH; \ | 
|---|
| 109 | echo calling perl $(MAKE_MAKEFILE) "$(used_cflags)" "$(used_lflags)"; \ | 
|---|
| 110 | perl $(MAKE_MAKEFILE) "$(used_cflags)" "$(used_lflags)" ) | 
|---|
| 111 |  | 
|---|
| 112 | Makefile.PL : $(MAKE_MAKEFILE) | 
|---|
| 113 | ( \ | 
|---|
| 114 | echo "system('perl $< \"$(used_cflags)\" \"$(used_lflags)\"');" \ | 
|---|
| 115 | ) > $@ | 
|---|
| 116 |  | 
|---|
| 117 | ARB.xs : $(ARB_PROTO_2_XSUB) proto.h ARB.default.xs perlmain_source.c typemap | 
|---|
| 118 | -@test -f $@ && chmod a+w $@ | 
|---|
| 119 | $(ARB_PROTO_2_XSUB) proto.h ARB.default.xs typemap >$@ | 
|---|
| 120 | @test -f $@ && chmod a-w $@ | 
|---|
| 121 |  | 
|---|
| 122 | proto.h : $(HEADERS) $(THIS) depends.stamp | 
|---|
| 123 | cat $(HEADERS) > $@ | 
|---|
| 124 |  | 
|---|
| 125 | debug.h : $(THIS) | 
|---|
| 126 | echo "#undef DEBUG" > $@ | 
|---|
| 127 | echo "#undef NDEBUG" >> $@ | 
|---|
| 128 | ifeq ($(DEBUG),1) | 
|---|
| 129 | echo "#define DEBUG" >> $@ | 
|---|
| 130 | else | 
|---|
| 131 | echo "#define NDEBUG" >> $@ | 
|---|
| 132 | endif | 
|---|
| 133 |  | 
|---|
| 134 | clean: | 
|---|
| 135 | -test -f Makefile && $(MAKE) clean | 
|---|
| 136 | rm -f Makefile.old proto.h debug.h ARB.c ARB.xs .depends depends.stamp Makefile.PL $(TARGETS) | 
|---|
| 137 | rm -f Makefile | 
|---|
| 138 |  | 
|---|
| 139 | .depends: depends.stamp Makefile.main | 
|---|
| 140 | +test -f ARB.c || $(MAKETHIS) "AUTODEPENDS=0" ARB.c | 
|---|
| 141 | $(MAKEDEPEND) -f- $(MAKEDEPENDFLAGS) ARB.c 2>/dev/null | \ | 
|---|
| 142 | perl -ne 's/ARB.o:/depends.stamp:/g; print $$_;' | \ | 
|---|
| 143 | ../SOURCE_TOOLS/fix_depends.pl "(from PERL2ARB)" > $@ | 
|---|
| 144 |  | 
|---|
| 145 |  | 
|---|
| 146 | depends.stamp: | 
|---|
| 147 | touch $@ | 
|---|
| 148 |  | 
|---|
| 149 | ifeq ($(AUTODEPENDS),2) | 
|---|
| 150 | include .depends | 
|---|
| 151 | endif | 
|---|
| 152 |  | 
|---|