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