import source from 1.3.40
[external/swig.git] / vms / genbuild.py
1 import os.path, string, posix, pyvms
2 #
3 #
4
5 IDIR = ['swig_root:[source.swig]', 'swig_root:[source.doh.include]',
6         'swig_root:[source.include]', 'swig_root:[source.preprocessor]'] 
7
8 def new_file(fg, dirname):
9     global IDIR
10     fn = 'swig_root:[vms.scripts]compil_' + os.path.basename(dirname) + '.com'
11     print >> fg, '$ @' + fn
12     f = open(fn, 'w')
13     print >> f, '$!'
14     print >> f, '$! Generated by genbuild.py'
15     print >> f, '$!'
16     print >> f, '$ libname = "swig_root:[vms.o_alpha]swig.olb"'
17     print >> f, '$'
18     print >> f, '$ set default', pyvms.crtl_to_vms(dirname)[0][0]
19     print >> f, '$'
20     print >> f, "$ idir := ", IDIR[0]
21     for i in range(1, len(IDIR)):
22         print >> f, '$ idir = idir + ",' + IDIR[i] + '"'
23     print >> f, '$'
24     print >> f, "$ iflags = \"/include=(''idir', sys$disk:[])\""
25     print >> f, '$ oflags = \"/object=swig_root:[vms.o_alpha]'
26     print >> f, "$ cflags = \"''oflags'''iflags'''dflags'\""
27     print >> f, "$ cxxflags = \"''oflags'''iflags'''dflags'\""
28     print >> f, '$'
29     return f
30
31
32 def end_file(f):
33     print >>f,"""$ exit
34 $!
35 $!
36 $MAKE: SUBROUTINE   !SUBROUTINE TO CHECK DEPENDENCIES
37 $ V = 'F$Verify(0)
38 $! P1 = What we are trying to make
39 $! P2 = Command to make it
40 $! P3 = Source file
41 $! P4 - P8  What it depends on
42 $
43 $ modname = f$parse(p3,,,"name")
44 $ set noon
45 $ set message/nofacility/noident/noseverity/notext
46 $ libr/lis=swig_root:[vms]swiglib.tmp/full/width=132/only='modname' 'libname'
47 $ set message/facility/ident/severity/text
48 $ on error then exit
49 $ open/read swigtmp swig_root:[vms]swiglib.tmp
50 $! skip header
51 $ read swigtmp r
52 $ read swigtmp r
53 $ read swigtmp r
54 $ read swigtmp r
55 $ read swigtmp r
56 $ read swigtmp r
57 $ read swigtmp r
58 $ read swigtmp r
59 $ read swigtmp r
60 $!
61 $
62 $ read/end=module_not_found swigtmp r
63 $ modfound = 1
64 $ Time = f$cvtime(f$extract(49, 20, r))
65 $ goto end_search_module
66 $ module_not_found:
67 $ modfound = 0
68 $
69 $ end_search_module:
70 $ close swigtmp
71 $ delete swig_root:[vms]swiglib.tmp;*
72 $
73 $ if modfound .eq. 0 then $ goto Makeit
74 $
75 $! Time = F$CvTime(F$File(P1,"RDT"))
76 $arg=3
77 $Loop:
78 $       Argument = P'arg
79 $       If Argument .Eqs. "" Then Goto Exit
80 $       El=0
81 $Loop2:
82 $       File = F$Element(El," ",Argument)
83 $       If File .Eqs. " " Then Goto Endl
84 $       AFile = ""
85 $Loop3:
86 $       OFile = AFile
87 $       AFile = F$Search(File)
88 $       If AFile .Eqs. "" .Or. AFile .Eqs. OFile Then Goto NextEl
89 $       If F$CvTime(F$File(AFile,"RDT")) .Ges. Time Then Goto Makeit
90 $       Goto Loop3
91 $NextEL:
92 $       El = El + 1
93 $       Goto Loop2
94 $EndL:
95 $ arg=arg+1
96 $ If arg .Le. 8 Then Goto Loop
97 $ Goto Exit
98 $
99 $Makeit:
100 $ VV=F$VERIFY(1)
101 $ 'P2' 'P3'
102 $ VV='F$Verify(VV)
103 $Exit:
104 $ If V Then Set Verify
105 $ENDSUBROUTINE"""
106
107
108 def listRep(args, dirname, filenames):
109     fg = args[0]
110     first = 1
111     for fn in filenames:
112         if fn[-2:] == '.c':
113             if first:
114                 first = 0
115                 fc = new_file(fg, dirname)
116
117             cstr = "\"cc ''cflags'\" "
118             line = "$ call make swig_root:[vms.o_alpha]"
119             line += fn[:-1] + 'obj -'
120             print >> fc, line
121             line = "\t" + cstr + fn
122             print >> fc, line
123         elif fn[-4:] == '.cxx':
124             if first:
125                 first = 0
126                 fc = new_file(fg, dirname)
127
128             cstr = "\"cxx ''cxxflags'\" "
129             line = "$ call make swig_root:[vms.o_alpha]"
130             line += fn[:-3] + 'obj -'
131             print >> fc, line
132             line = "\t" + cstr + fn
133             print >> fc, line
134     if first == 0:
135         end_file(fc)
136         fc.close()
137 #
138 def genbuild(f, dir):
139     os.path.walk(dir, listRep, (f,))
140     cmd = 'set default swig_root:[vms]'
141 #
142 f = open('swig_root:[vms.scripts]build_all.com','w')
143 print >> f, '$!'
144 print >> f, '$! Generated by genbuild.py'
145 print >> f, '$!'
146 print >> f, '$ set default swig_root:[vms]'
147 print >> f, '$'
148 print >> f, '$ @swig_root:[vms]build_init'
149 #
150 genbuild(f, '/swig_root/source')
151 print >> f, '$'
152 print >> f, '$ set default swig_root:[vms]'
153 print >> f, '$'
154 print >> f, '$ @swig_root:[vms]build_end'
155 f.close