Change make license
[platform/upstream/make.git] / makefile.com
1 $!
2 $! Makefile.com - builds GNU Make for VMS
3 $!
4 $! P1 = LIST will provide compiler listings.
5 $! P2 = DEBUG will build an image with debug information
6 $! P3 = WALL will enable all warning messages (some are suppressed since
7 $!      one macro intentionally causes an error condition)
8 $!
9 $! In case of problems with the install you might contact me at
10 $! zinser@decus.de (preferred) or zinser@sysdev.deutsche-boerse.com
11 $
12 $! hb
13 $! But don't ask Martin Zinser about the lines, I added/changed.
14 $! In case of an error do some cleanup
15 $ on error then $ goto cleanup
16 $! in case somebody set up her/his own symbol for cc
17 $ set symbol/scope=(nolocal,noglobal)
18 $!
19 $! Just some general constants...
20 $!
21 $ true  = 1
22 $ false = 0
23 $ tmpnam = "temp_" + f$getjpi("","pid")
24 $ tt = tmpnam + ".txt"
25 $ tc = tmpnam + ".c"
26 $!
27 $! Look for the compiler used
28 $!
29 $ lval = ""
30 $ if f$search("SYS$SYSTEM:DECC$COMPILER.EXE").eqs.""
31 $  then
32 $   if f$trnlnm("SYS").eqs."" then def/nolog sys sys$library:
33 $   ccopt = ""
34 $  else
35 $   ccopt = "/decc/prefix=(all,except=(globfree,glob))"
36 $   if f$trnlnm("SYS").eqs.""
37 $    then
38 $     if f$trnlnm("DECC$LIBRARY_INCLUDE").nes.""
39 $      then
40 $       define sys decc$library_include:
41 $      else
42 $       if f$search("SYS$COMMON:[DECC$LIB.REFERENCE]DECC$RTLDEF.DIR").nes."" -
43            then lval = "SYS$COMMON:[DECC$LIB.REFERENCE.DECC$RTLDEF],"
44 $       if f$search("SYS$COMMON:[DECC$LIB.REFERENCE]SYS$STARLET_C.DIR").nes."" -
45            then lval = lval+"SYS$COMMON:[DECC$LIB.REFERENCE.SYS$STARLET_C],"
46 $       lval=lval+"SYS$LIBRARY:"
47 $       define sys 'lval
48 $      endif
49 $   endif
50 $ endif
51 $!
52 $!
53 $ if (p1 .eqs. "LIST")
54 $ then
55 $   ccopt = ccopt + "/list/show=(expan,inclu)"
56 $ endif
57 $!
58 $! Should we build a debug image
59 $!
60 $ if (p2.eqs."DEBUG")
61 $  then
62 $   ccopt = ccopt + "/noopt/debug"
63 $   lopt = "/debug"
64 $ else
65 $   lopt = ""
66 $ endif
67 $!
68 $! Do we want to see all warnings
69 $!
70 $ if (p3.nes."WALL")
71 $ then
72 $   gosub check_cc_qual
73 $ endif
74 $ filelist = "[.src]ar [.src]arscan [.src]commands [.src]default [.src]dir " + -
75              "[.src]expand [.src]file [.src]function [.src]guile " + -
76              "[.src]hash [.src]implicit [.src]job [.src]load [.src]main " + -
77              "[.src]misc [.src]read [.src]remake [.src]remote-stub " + -
78              "[.src]rule [.src]output [.src]signame [.src]variable " + -
79              "[.src]version [.src]strcache [.src]vpath " + -
80              "[.src]vmsfunctions [.src]vmsify [.src]vms_progname " + -
81              "[.src]vms_exit [.src]vms_export_symbol " + -
82              "[.lib]alloca [.lib]fnmatch [.lib]glob [.src]getopt1 [.src]getopt"
83 $!
84 $ copy [.src]config.h-vms [.src]config.h
85 $ copy [.lib]fnmatch.in.h [.lib]fnmatch.h
86 $ copy [.lib]glob.in.h [.lib]glob.h
87 $ n=0
88 $ open/write optf make.opt
89 $ loop:
90 $ cfile = f$elem(n," ",filelist)
91 $ if cfile .eqs. " " then goto linkit
92 $ write sys$output "Compiling ''cfile'..."
93 $ call compileit 'cfile'
94 $ n = n + 1
95 $ goto loop
96 $ linkit:
97 $ close optf
98 $ link/exe=make make.opt/opt'lopt
99 $ goto cleanup
100 $
101 $ cleanup:
102 $ if f$trnlnm("SYS").nes."" then $ deassign sys
103 $ if f$trnlnm("OPTF").nes."" then $ close optf
104 $ if f$search("make.opt").nes."" then $ del make.opt;*
105 $ exit
106 $!
107 $!-----------------------------------------------------------------------------
108 $!
109 $! Check if this is a define relating to the properties of the C/C++
110 $! compiler
111 $!
112 $CHECK_CC_QUAL:
113 $ open/write tmpc 'tc
114 $ ccqual = "/warn=(disable=questcompare)"
115 $ write tmpc "#include <stdio.h>"
116 $ write tmpc "unsigned int i = 1;"
117 $ write tmpc "int main(){"
118 $ write tmpc "if (i < 0){printf(""Mission impossible\n"");}}"
119 $ close tmpc
120 $ gosub cc_qual_check
121 $ return
122 $!
123 $!-----------------------------------------------------------------------------
124 $!
125 $! Check for properties of C/C++ compiler
126 $!
127 $CC_QUAL_CHECK:
128 $ cc_qual = false
129 $ set message/nofac/noident/nosever/notext
130 $ cc 'ccqual' 'tmpnam'
131 $ if $status then cc_qual = true
132 $ set message/fac/ident/sever/text
133 $ delete/nolog 'tmpnam'.*;*
134 $ if cc_qual then ccopt = ccopt + ccqual
135 $ return
136 $!-----------------------------------------------------------------------------
137 $!
138 $ compileit : subroutine
139 $ ploc = f$locate("]",p1)
140 $! filnam = p1
141 $ if ploc .lt. f$length(p1)
142 $ then
143 $   objdir = f$extract(0, ploc+1, p1)
144 $   write optf p1
145 $ else
146 $   objdir := []
147 $   write optf objdir+p1
148 $ endif
149 $ cc'ccopt'/nested=none/include=([],[.src],[.lib])/obj='objdir' -
150   /define=("allocated_variable_expand_for_file=alloc_var_expand_for_file",-
151   "unlink=remove","HAVE_CONFIG_H","VMS") -
152   'p1'
153 $ exit
154 $ endsubroutine : compileit
155 $!
156 $!-----------------------------------------------------------------------------
157 $!Copyright (C) 1996-2020 Free Software Foundation, Inc.
158 $!This file is part of GNU Make.
159 $!
160 $!GNU Make is free software; you can redistribute it and/or modify it under
161 $!the terms of the GNU General Public License as published by the Free Software
162 $!Foundation; either version 3 of the License, or (at your option) any later
163 $!version.
164 $!
165 $!GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
166 $!WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
167 $!FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
168 $!details.
169 $!
170 $!You should have received a copy of the GNU General Public License along with
171 $!this program.  If not, see <http://www.gnu.org/licenses/>.