1 $!========================================================================
3 $! Main Xpdf compile script for VMS.
5 $! Written by Patrick Moreau, Martin P.J. Zinser.
7 $! Copyright 1996-2003 Glyph & Cog, LLC
9 $!========================================================================
11 $! This procedure takes up to three (optional) parameters:
13 $! 1.) Configuration settings:
15 $! a4 - Use european A4 as the default paper size.
17 $! no_text_select - Disable text selection in Xpdf
19 $! opi_support - Compile Xpdf with support for the Open Prepress
22 $! 2.) Compiler detection:
24 $! In case you want to override the automatic compiler detection
25 $! specify either DECC or GCC as the second paramter,
26 $! e.g. @vms_make "" GCC
28 $! 3.) System Xpdf resource file
30 $! The default for this is decw$system_defaults:xpdfrc.dat, since this
31 $! is the standard place for systemwide Xdefaults files on OpenVMS. You
32 $! may provide a different file in p3.
34 $! External libraries (like T1lib, Freetype, and XPM) are supported via the
35 $! config file VMSLIB.DAT. Please check the sample file, which will be created
36 $! by this procedure upon first invocation, for the information you need to
39 $! Sample invocation of the script:
40 $! @vms_make a4,opi_support ""
42 $! In case of problems with the compile you may contact me at
43 $! zinser@decus.de (preferred) or zinser@sysdev.deutsche-boerse.com (work).
45 $!========================================================================
47 $ on error then goto err_exit
50 $! Just some general constants...
55 $ tmpnam = "temp_" + f$getjpi("","pid")
58 $! Setup variables holding "config" information
60 $ aconf_in_file = "aconf_h.in#aconf.h_in#aconf.h.in"
64 $ xlibs = "xt#xmu#motif"
69 $ compress_def = false
72 $ p2 = f$edit(p2,"upcase,trim")
73 $ if f$edit(p3,"trim") .eqs. ""
75 $ resfil = "decw$system_defaults:xpdfrc.dat"
83 $! Start building the option file
85 $ open/write optf xpdf.opt
86 $ open/write topt tmp.opt
87 $ write optf "Identification=""''name' ''version'"""
88 $ gosub check_create_vmslib
91 $ if (f$getsyi("HW_MODEL").ge.1024) .and. -
92 (f$locate("T1LIB",f$edit(libdefs,"UPCASE")) .lt. f$length(libdefs)) -
93 then float = "/float=ieee_float"
94 $ incs = "sys$library:,[-],[],[-.goo]''libincs'"
96 $ gosub check_compiler
100 $! aconf.h.in might be mapped in different ways, so go figure
104 $ fname = f$element(i,"#",aconf_in_file)
105 $ if fname .eqs. "#" then goto AMISS_ERR
106 $ if f$search(fname) .eqs. ""
111 $ open/read/err=aconf_err aconf_in 'fname'
112 $ open/write aconf aconf.h
114 $ read/end_of_file=aconf_exit aconf_in line
115 $ work = f$edit(line, "compress,trim")
116 $ if f$extract(0,6,work) .nes. "#undef"
120 $ def = f$element(1," ",work)
121 $ if ((f$locate("\''def'\",f$edit(libdefs,"UPCASE")) .lt. f$length(libdefs)) -
122 .or. (f$locate("#''def'#",f$edit(mydefs,"UPCASE")) .lt. f$length(mydefs)))
124 $ write aconf "#define ", def, " 1"
130 $! Make sure old-style VMS is defined along with __VMS
132 $ if f$locate("define ACONF_H",line) .lt. f$length(line)
134 $ write aconf "#define VMS 1"
140 $ write sys$output "Compiling in [.GOO]"
143 $ write sys$output "Compiling in [.XPDF]"
144 $ set default [-.xpdf]
148 $ dele/noconf/nolog tmp.opt;*
151 $ write sys$output "Input file ''fname' could not be opened"
154 $ write sys$output "No source for aconf.h found."
155 $ write sys$output "Tried any of ''aconf_in_file'"
157 $ write sys$output "C++ compiler required to build Xpdf"
160 $ write sys$output "Can not find [.internal] sub-dir in Freetype 2 tree"
163 $ set message/facil/ident/sever/text
165 $ close/nolog aconf_in
170 $ write sys$output "Exiting..."
172 $!------------------------------------------------------------------------------
174 $! Take care of driver file with information about external libraries
176 $CHECK_CREATE_VMSLIB:
178 $ if f$search("VMSLIB.DAT") .eqs. ""
180 $ type/out=vmslib.dat sys$input
182 ! This is a simple driver file with information used by vms_make.com to
183 ! check if external libraries (like t1lib and freetype) are available on
186 ! Layout of the file:
188 ! - Lines starting with ! are treated as comments
189 ! - Elements in a data line are separated by # signs
190 ! - The elements need to be listed in the following order
191 ! 1.) Name of the Library (only used for informative messages
193 ! 2.) Location where the object library can be found
194 ! 3.) Location where the include files for the library can be found
195 ! 4.) Include file used to verify library location
196 ! 5.) CPP define to pass to the build to indicate availability of
199 ! Example: The following lines show how definitions
200 ! might look like. They are site specific and the locations of the
201 ! library and include files need almost certainly to be changed.
203 ! Location: All of the libaries can be found at the following addresses
205 ! T1LIB: http://www.decus.de:8080/www/vms/sw/t1lib.htmlx
206 ! FREETYPE: http://www.decus.de:8080/www/vms/sw/freetype2.htmlx
207 ! XPM: http://www.decus.de:8080/www/vms/sw/xpm.htmlx
208 ! LIBPAPER: http://www.decus.de:8080/www/vms/sw/libpaper.htmlx
210 !T1LIB # pubbin:t1shr.exe # public$root:[xtools.libs.t1lib.lib.t1lib] # t1lib.h # HAVE_T1LIB_H
211 !FREETYPE # pubbin:freetype2shr.exe # public$root:[xtools.libs.ft2.include.freetype],public$root:[xtools.libs.ft2.include] # freetype.h # HAVE_FREETYPE_H\FREETYPE2
212 !XPM # pubbin:libxpm.olb # X11: # xpm.h # HAVE_X11_XPM_H
213 !LIBPAPER # pubbin:libpapershr.exe # public$root:[util.libs.paper.lib] # paper.h # HAVE_PAPER_H
214 $ write sys$output "New driver file vmslib.dat created."
215 $ write sys$output "Please customize libary locations for your site"
216 $ write sys$output "and afterwards re-execute vms_make.com"
217 $ write sys$output "Exiting..."
222 $! Open data file with location of libraries
224 $ open/read/end=end_lib/err=err_lib libdata VMSLIB.DAT
226 $ read/end=end_lib libdata libline
227 $ libline = f$edit(libline, "UNCOMMENT,COLLAPSE")
228 $ if libline .eqs. "" then goto LIB_LOOP ! Comment line
229 $ libname = f$edit(f$element(0,"#",libline),"UPCASE")
230 $ write sys$output "Processing ''libname' setup ..."
231 $ libloc = f$element(1,"#",libline)
232 $ libsrc = f$element(2,"#",libline)
233 $ testinc = f$element(3,"#",libline)
234 $ cppdef = f$element(4,"#",libline)
235 $ old_cpp = f$locate("=1",cppdef)
236 $ if old_cpp.lt.f$length(cppdef) then cppdef = f$extract(0,old_cpp,cppdef)
237 $ if f$search("''libloc'").eqs. ""
239 $ write sys$output "Can not find library ''libloc' - Skipping ''libname'"
243 $ libsrc_found = false
245 $ libsrcdir = f$element(libsrc_elem,",",libsrc)
246 $ if (libsrcdir .eqs. ",") then goto END_LIBSRC
247 $ if f$search("''libsrcdir'''testinc'") .nes. "" then libsrc_found = true
248 $ libsrc_elem = libsrc_elem + 1
251 $ if .not. libsrc_found
253 $ write sys$output "Can not find includes at ''libsrc' - Skipping ''libname'"
256 $ libdefs = libdefs + cppdef + "\"
257 $ libincs = libincs + "," + libsrc
259 $ libtype = f$edit(f$parse(libloc,,,"TYPE"),"UPCASE")
260 $ if f$locate("EXE",libtype) .lt. f$length(libtype) then lqual = "/share"
261 $ write optf libloc , lqual
262 $ write topt libloc , lqual
264 $! Nasty hack to get the freetype includes to work
266 $ if ((libname .eqs. "FREETYPE") .and. -
267 (f$locate("FREETYPE2",cppdef) .lt. f$length(cppdef)))
269 $ if ((f$search("freetype:freetype.h") .nes. "") .and. -
270 (f$search("freetype:[internal]ftobjs.h") .nes. ""))
272 $ write sys$output "Will use local definition of freetype logical"
277 $ ft2srcdir = f$element(ft2elem,",",libsrc)
278 $ if f$search("''ft2srcdir'''testinc'") .nes. ""
280 $ if f$search("''ft2srcdir'internal.dir") .nes. ""
282 $ ft2dev = f$parse("''ft2srcdir'",,,"device","no_conceal")
283 $ ft2dir = f$parse("''ft2srcdir'",,,"directory","no_conceal")
284 $ ft2conc = f$locate("][",ft2dir)
285 $ ft2len = f$length(ft2dir)
286 $ if ft2conc .lt. ft2len
288 $ ft2dir = f$extract(0,ft2conc,ft2dir) + -
289 f$extract(ft2conc+2,ft2len-2,ft2dir)
291 $ ft2dir = ft2dir - "]" + ".]"
292 $ define freetype 'ft2dev''ft2dir','ft2srcdir'
298 $ ft2elem = ft2elem + 1
304 $! Yet another special treatment for Xpm/X11
306 $ if (libname .eqs. "XPM")
308 $ my_x11 = f$parse("''libsrc'xpm.h",,,"device") + -
309 f$parse("''libsrc'xpm.h",,,"directory")
310 $ x11_save = f$trnlnm("X11")
311 $ define x11 'my_x11',decw$include
317 $!------------------------------------------------------------------------------
319 $! Take care of driver file with information about external libraries
323 $ if (def .eqs. "SYSTEM_XPDFRC")
325 $ write aconf "#define SYSTEM_XPDFRC """, resfil, """"
330 $!------------------------------------------------------------------------------
332 $! Check if this is a define relating to the properties of the C/C++
336 $ if (def .eqs. "HAVE_DIRENT_H")
338 $ copy sys$input: 'tc
344 $ gosub cc_prop_check
347 $ if (def .eqs. "HAVE_SYS_NDIR_H")
349 $ copy sys$input: 'tc
351 #include <sys/ndir.h>
355 $ gosub cc_prop_check
358 $ if (def .eqs. "HAVE_SYS_DIR_H")
360 $ copy sys$input: 'tc
366 $ gosub cc_prop_check
369 $ if (def .eqs. "HAVE_NDIR_H")
371 $ copy sys$input: 'tc
377 $ gosub cc_prop_check
380 $ if (def .eqs. "HAVE_SYS_SELECT_H")
382 $ copy sys$input: 'tc
384 #include <sys/select.h>
388 $ gosub cc_prop_check
391 $ if (def .eqs. "HAVE_SYS_BSDTYPES_H")
393 $ copy sys$input: 'tc
395 #include <sys/bsdtypes.h>
399 $ gosub cc_prop_check
402 $ if (def .eqs. "HAVE_STRINGS_H")
404 $ copy sys$input: 'tc
410 $ gosub cc_prop_check
413 $ if (def .eqs. "HAVE_POPEN")
415 $ copy sys$input: 'tc
421 pipe = popen("DIR","r");
425 $ gosub cc_prop_check
428 $ if (def .eqs. "HAVE_MKSTEMP")
430 $ copy sys$input: 'tc
435 mkstemp("tempXXXXXX");
438 $ gosub cc_prop_check
441 $ if (def .eqs. "HAVE_FSEEKO")
443 $ copy sys$input: 'tc
450 fp = fopen("temp.txt","r");
451 fseeko(fp,1,SEEK_SET);
455 $ gosub cc_prop_check
458 $ if (def .eqs. "_LARGE_FILES")
460 $ copy sys$input: 'tc
467 fp = fopen("temp.txt","r");
468 fseeko(fp,1,SEEK_SET);
472 $ gosub cc_prop_check
475 $ if (def .eqs. "HAVE_XTAPPSETEXITFLAG")
477 $ copy sys$input: 'tc
479 #include <X11/Intrinsic.h>
482 XtAppContext app_context;
483 app_context = XtCreateApplicationContext();
484 XtAppSetExitFlag(app_context);
488 $ gosub cc_prop_check
491 $ write aconf "/* ", line, " */"
493 $!------------------------------------------------------------------------------
495 $! Process config settings passed from the command line
496 $! (analog to Unix --enable-xxx)
502 $ qual_list = f$edit(p1,"upcase")
504 $ qual = f$element(i,",",qual_list)
505 $ if qual .eqs. "," then goto FINISH_DEF
507 $ if (qual .eqs. "A4")
509 $ mydefs = mydefs + "A4_PAPER#"
512 $ if (qual .eqs. "NO_TEXT_SELECT")
514 $ mydefs = mydefs + "NO_TEXT_SELECT#"
517 $ if (qual .eqs. "OPI_SUPPORT")
519 $ mydefs = mydefs + "OPI_SUPPORT#"
522 $ if (qual .eqs. "COMPRESS")
524 $ compress_def = true
527 $ write sys$output "Qualifier ''qual' not recognized, will be ignored"
533 $!------------------------------------------------------------------------------
535 $! Look for the compiler used
538 $ its_decc = (f$search("SYS$SYSTEM:CXX$COMPILER.EXE") .nes. "")
539 $ its_gnuc = .not. its_decc .and. (f$trnlnm("gnu_cc") .nes. "")
541 $! Exit if no compiler available
543 $ if (.not. (its_decc .or. its_gnuc)) then goto CXX_ERR
545 $! Override if requested from the commandline
547 $ if (p2 .eqs. "DECC")
552 $ if (p1 .eqs. "GNUC")
560 $ ccomp :== "cc/decc/prefix=all ''float'"
562 $! Take care of includes
564 $ cc_user = f$trnlnm("DECC$USER_INCLUDE")
565 $ cc_system = f$trnlnm("DECC$SYSTEM_INCLUDE")
566 $ cxx_user = f$trnlnm("CXX$USER_INCLUDE")
567 $ cxx_system = f$trnlnm("CXX$SYSTEM_INCLUDE")
568 $ define decc$system_include 'incs'
569 $ define decc$user_include 'incs'
570 $ define cxx$user_include 'incs'
571 $ define cxx$system_include 'incs'
573 $! Check version of the C++ compiler
575 $ create vms_xpdf_cc_test.cc
576 $ cxx/lis=vms_xpdf_cc_test.lis/show=all vms_xpdf_cc_test.cc
577 $ open list vms_xpdf_cc_test.lis
579 $ read/end=close_cxx list line
580 $ start = f$locate("__DECCXX_VER",line)
581 $ if start .ne. f$length(line)
583 $ cxx_ver = f$extract(start+13,8,line)
584 $ if cxx_ver .gt. 60000000
586 $ cxxdefs = "/warn=(disable=nosimpint)"
587 $ xpdf_link :== cxxlink
594 $ delete/noconfirm vms_xpdf_cc_test.*;*
595 $ cxxcomp :== "cxx/prefix=all ''cxxdefs' ''float' /include=cxx$user_include"
600 $ ccomp :== "gcc/nocase/include=(''incs')"
601 $ cxxcomp :== "gcc/plusplus/nocase/include=(''incs')"
602 $ write optf "gnu_cc:[000000]gcclib.olb/lib"
603 $ write optf "sys$share:vaxcrtl.exe/share"
606 $-------------------------------------------------------------------------------
608 $ delete/sym/glob cxxcomp
609 $ delete/sym/glob ccomp
610 $ delete/sym/glob xpdf_link
611 $ if (ft2def) then deassign freetype
614 $ if cc_user .eqs. ""
616 $ deass decc$user_include
618 $ define decc$user_include 'cc_user'
620 $ if cc_system .eqs. ""
622 $ deass decc$system_include
624 $ define decc$system_include 'cc_system'
626 $ if cxx_user .eqs. ""
628 $ deass cxx$user_include
630 $ define cxx$user_include 'cxx_user'
632 $ if cxx_system .eqs. ""
634 $ deass cxx$system_include
636 $ define cxx$system_include 'cxx_system'
639 $ if (x11_save .nes. "") then define x11 'x11_save'
642 $!------------------------------------------------------------------------------
644 $! Check for properties of C/C++ compiler
648 $ set message/nofac/noident/nosever/notext
649 $ on error then continue
651 $ if .not. ($status) then cc_prop = false
652 $ on error then continue
653 $! The headers might lie about the capabilities of the RTL
654 $ link/opt=tmp.opt 'tmpnam'
655 $ if .not. ($status) then cc_prop = false
656 $ set message/fac/ident/sever/text
657 $ on error then goto err_exit
658 $ delete/nolog 'tmpnam'.*;*
661 $ write sys$output "Checking for ''def'... yes"
662 $ write aconf "#define ''def' 1"
663 $ if (def .eqs. "HAVE_FSEEKO") .or. (def .eqs. "_LARGE_FILES") then -
664 write aconf "#define _LARGEFILE"
666 $ write sys$output "Checking for ''def'... no"
670 $!------------------------------------------------------------------------------
672 $! Check Xlibs and write to options file
675 $ If F$Type (xlibs) .nes. "STRING" Then xlibs = ""
676 $ need_xt = f$locate("XT",f$edit(xlibs,"upcase")) .lt. f$length(xlibs)
677 $ need_xmu = f$locate("XMU",f$edit(xlibs,"upcase")) .lt. f$length(xlibs)
678 $ need_xm = f$locate("MOTIF",f$edit(xlibs,"upcase")) .lt. f$length(xlibs)
679 $ On Error Then GoTo XUI
680 $ @sys$update:decw$get_image_version sys$share:decw$xlibshr.exe decw$version
681 $ if f$extract(4,3,decw$version).eqs."1.0"
683 $ if need_xt .or. need_xmu .or. need_xm
685 $ write optf "Sys$share:DECW$DWTLIBSHR.EXE/Share"
686 $ write topt "Sys$share:DECW$DWTLIBSHR.EXE/Share"
689 $ if f$extract(4,3,decw$version).eqs."1.1"
691 $ if need_xm then write optf "sys$share:decw$xmlibshr.exe/share"
692 $ if need_xt then write optf "sys$share:decw$xtshr.exe/share"
693 $ if nedd_xmu then write optf "sys$share:decw$xmulibshr.exe/share"
694 $ if need_xm then write topt "sys$share:decw$xmlibshr.exe/share"
695 $ if need_xt then write topt "sys$share:decw$xtshr.exe/share"
696 $ if nedd_xmu then write topt "sys$share:decw$xmulibshr.exe/share"
698 $ if f$extract(4,3,decw$version).eqs."1.2"
700 $ if need_xm then write optf "sys$share:decw$xmlibshr12.exe/share"
701 $ if need_xt then write optf "sys$share:decw$xtlibshrr5.exe/share"
702 $ if need_xmu then write optf "sys$share:decw$xmulibshrr5.exe/share"
703 $ if need_xm then write topt "sys$share:decw$xmlibshr12.exe/share"
704 $ if need_xt then write topt "sys$share:decw$xtlibshrr5.exe/share"
705 $ if need_xmu then write topt "sys$share:decw$xmulibshrr5.exe/share"
710 $ if need_xt .or. need_xmu
712 $ write optf "Sys$share:DECW$DWTLIBSHR.EXE/Share"
713 $ write topt "Sys$share:DECW$DWTLIBSHR.EXE/Share"
716 $ on error then goto err_exit
717 $ write optf "sys$share:decw$xlibshr.exe/share"
718 $ write topt "sys$share:decw$xlibshr.exe/share"
720 $!------------------------------------------------------------------------------
722 $! Check version of Xpdf to build
725 $ open/read in [.xpdf]config.h
726 $ check_string = "xpdfVersionNum"
728 $ read/end=vdone in rec
729 $ if (f$element(1," " ,rec) .nes. check_string) then goto vloop
730 $ start = f$locate(check_string,rec) + f$length(check_string)
731 $ len = f$length(rec) - start
732 $ version = f$edit(f$extract(start,len,rec),"COLLAPSE")
736 $!------------------------------------------------------------------------------