| 1 | # -*-Mode: Makefile;-*- |
|---|
| 2 | # |
|---|
| 3 | # To rebuild PERL2ARB from $ARBHOME call |
|---|
| 4 | # make perl_clean perl |
|---|
| 5 | |
|---|
| 6 | THIS=Makefile.main |
|---|
| 7 | MAKETHIS=$(MAKE) -f $(THIS) |
|---|
| 8 | #MAKETHIS=$(MAKE) -d -f $(THIS) |
|---|
| 9 | |
|---|
| 10 | LIB=$(ARBHOME)/lib |
|---|
| 11 | ARBDB=$(ARBHOME)/ARBDB |
|---|
| 12 | ARB_PROTO_2_XSUB=$(ARBHOME)/bin/arb_proto_2_xsub |
|---|
| 13 | |
|---|
| 14 | HEADERS = \ |
|---|
| 15 | $(ARBDB)/ad_prot.h \ |
|---|
| 16 | $(ARBDB)/ad_t_prot.h \ |
|---|
| 17 | |
|---|
| 18 | ifdef DARWIN |
|---|
| 19 | SO:=bundle |
|---|
| 20 | else |
|---|
| 21 | SO:=so |
|---|
| 22 | endif |
|---|
| 23 | |
|---|
| 24 | ARB_SO=blib/arch/auto/ARB/ARB.$(SO) |
|---|
| 25 | |
|---|
| 26 | TARGET_PM=$(LIB)/ARB.pm |
|---|
| 27 | TARGET_SO=$(LIB)/ARB.$(SO) |
|---|
| 28 | |
|---|
| 29 | TARGETS=$(TARGET_PM) $(TARGET_SO) |
|---|
| 30 | |
|---|
| 31 | XS_DEPENDS = Makefile ARB.xs debug.h Makefile.PL |
|---|
| 32 | |
|---|
| 33 | # ------------------------------------------------------------ |
|---|
| 34 | # variables for Makefile |
|---|
| 35 | |
|---|
| 36 | MYEXTLIB := |
|---|
| 37 | PASTHRU_INC := |
|---|
| 38 | PASTHRU_DEFINE := |
|---|
| 39 | |
|---|
| 40 | export MYEXTLIB PASTHRU_INC PASTHRU_DEFINE dflags |
|---|
| 41 | |
|---|
| 42 | # ------------------------------------------------------------ |
|---|
| 43 | |
|---|
| 44 | all: perlmain.c $(TARGETS) |
|---|
| 45 | |
|---|
| 46 | perlmain.c: perlmain_source.c |
|---|
| 47 | cp $< $@ |
|---|
| 48 | |
|---|
| 49 | $(TARGET_PM) : ARB.pm |
|---|
| 50 | cp $< $@ |
|---|
| 51 | |
|---|
| 52 | $(TARGET_SO) : $(ARB_SO) |
|---|
| 53 | cp $< $@ |
|---|
| 54 | |
|---|
| 55 | $(ARB_SO) : $(XS_DEPENDS) depends.stamp |
|---|
| 56 | -rm $(ARB_SO) |
|---|
| 57 | @echo "-------- calling MakeMaker-Makefile" |
|---|
| 58 | ( $(MAKE) "dflags=${dflags}" $@ || \ |
|---|
| 59 | (echo "------ failed.. retry once"; \ |
|---|
| 60 | $(MAKE) "dflags=${dflags}" $@)) |
|---|
| 61 | @echo "-------- post-recreating .depends" |
|---|
| 62 | $(MAKETHIS) "DEPENDS=0" .depends |
|---|
| 63 | $(MAKETHIS) $@ # recurse |
|---|
| 64 | |
|---|
| 65 | ARB.c : $(XS_DEPENDS) |
|---|
| 66 | @echo "-------- calling MakeMaker-Makefile (to get depends)" |
|---|
| 67 | ( $(MAKE) "dflags=${dflags}" $@ || \ |
|---|
| 68 | (echo "------ failed.. retry once"; \ |
|---|
| 69 | $(MAKE) "dflags=${dflags}" $@ )) |
|---|
| 70 | @echo "-------- end of MakeMaker-Makefile" |
|---|
| 71 | |
|---|
| 72 | Makefile : $(MACH).PL typemap |
|---|
| 73 | ( PATH=/usr/arb/bin:${PATH}; \ |
|---|
| 74 | export PATH; \ |
|---|
| 75 | echo calling perl ${MACH}.PL; \ |
|---|
| 76 | perl ${MACH}.PL ) |
|---|
| 77 | |
|---|
| 78 | Makefile.PL : $(MACH).PL |
|---|
| 79 | cp -p $< $@ |
|---|
| 80 | |
|---|
| 81 | ARB.xs : $(ARB_PROTO_2_XSUB) proto.h ARB.xs.default |
|---|
| 82 | -@test -f $@ && chmod a+w $@ |
|---|
| 83 | LD_LIBRARY_PATH=$(LIB):$(LD_LIBRARY_PATH) $(ARB_PROTO_2_XSUB) proto.h ARB.xs.default > $@ |
|---|
| 84 | @test -f $@ && chmod a-w $@ |
|---|
| 85 | |
|---|
| 86 | proto.h : $(HEADERS) $(THIS) depends.stamp |
|---|
| 87 | cat $(HEADERS) > $@ |
|---|
| 88 | |
|---|
| 89 | debug.h : $(THIS) |
|---|
| 90 | echo "#undef DEBUG" > $@ |
|---|
| 91 | echo "#undef NDEBUG" >> $@ |
|---|
| 92 | ifeq ($(DEBUG),1) |
|---|
| 93 | echo "#define DEBUG" >> $@ |
|---|
| 94 | else |
|---|
| 95 | echo "#define NDEBUG" >> $@ |
|---|
| 96 | endif |
|---|
| 97 | |
|---|
| 98 | clean: |
|---|
| 99 | -test -f Makefile && $(MAKE) clean |
|---|
| 100 | rm -f Makefile.old proto.h debug.h ARB.c ARB.xs .depends depends.stamp Makefile.PL $(TARGETS) |
|---|
| 101 | |
|---|
| 102 | .depends: depends.stamp Makefile.main |
|---|
| 103 | test -f ARB.c || $(MAKETHIS) "AUTODEPENDS=0" ARB.c |
|---|
| 104 | $(MAKEDEPEND) -f- $(MAKEDEPENDFLAGS) ARB.c 2>/dev/null | \ |
|---|
| 105 | perl -ne 's/ARB.o:/depends.stamp:/g; print $$_;' | \ |
|---|
| 106 | ../SOURCE_TOOLS/fix_depends.pl > $@ |
|---|
| 107 | |
|---|
| 108 | |
|---|
| 109 | depends.stamp: |
|---|
| 110 | touch $@ |
|---|
| 111 | |
|---|
| 112 | ifeq ($(AUTODEPENDS),1) |
|---|
| 113 | include .depends |
|---|
| 114 | endif |
|---|
| 115 | |
|---|