1# Licensed to the Apache Software Foundation (ASF) under one or more
2# contributor license agreements.  See the NOTICE file distributed with
3# this work for additional information regarding copyright ownership.
4# The ASF licenses this file to You under the Apache License, Version 2.0
5# (the "License"); you may not use this file except in compliance with
6# the License.  You may obtain a copy of the License at
7#
8#     http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16BEGIN {
17
18  # ff bits: 1(debug), 2(prerelease), 4(patched), 8(vendor) and 32(special)
19  # debug is summed based on the /Define _DEBUG
20  # prerelease is based on the -dev extension,
21  # patched is based on a non-standard "-ver" extension, 
22  # special and vendor are toggled by their args.
23  #
24  ff = 0;
25
26  file=ARGV[1];
27  desc=ARGV[2];
28  rel_h=ARGV[3];
29
30  i = 4;
31  while (length(ARGV[i])) {
32    if (match(ARGV[i], /icon=/)) {
33      icon = substr(ARGV[i], 6);
34    }
35    if (match(ARGV[i], /vendor=/)) {
36      vendor = substr(ARGV[i], 8);
37      ff = ff + 8;
38    }
39    if (match(ARGV[i], /special=/)) {
40      special = substr(ARGV[i], 9);
41      ff = ff + 32;
42    }
43    i = i + 1
44  }
45
46  i = i - 1;
47  while (i) {
48    delete ARGV[i];
49    i = i - 1;
50  }
51
52  while ((getline < rel_h) > 0) {
53    if (match ($0, /^.*\* Copyright /)) {
54      copyright = substr($0, RLENGTH + 1);
55    }
56    if (match ($0, /^#define AP_SERVER_MAJORVERSION_NUMBER /)) {
57      ver_major = $3;
58    }
59    else if (match ($0, /^#define AP_SERVER_MINORVERSION_NUMBER /)) {
60      ver_minor = $3;
61    }
62    else if (match ($0, /^#define AP_SERVER_PATCHLEVEL_NUMBER /)) {
63      ver_patch = $3;
64    }
65    else if (match ($0, /^#define AP_SERVER_DEVBUILD_BOOLEAN /)) {
66      ver_devbuild = $3;
67    }
68    else if (match ($0, /^#define AP_SERVER_ADD_STRING +"[^"]+"/)) {
69      ver_build = substr($3, 2, length($3) - 2);
70    }
71  }
72
73  ver = ver_major "." ver_minor "." ver_patch;
74  if (!ver_devbuild) {
75    verc = ver_major "," ver_minor "," ver_patch;
76  } else if (!match (ver_build, /-dev/)) {
77    ff = ff + 2;
78    verc = ver_major "," ver_minor "," ver_patch "," 100;
79    ver = ver ver_build;
80  } else {
81    ff = ff + 2;
82    verc = ver_major "," ver_minor "," ver_patch "," 0;
83    ver = ver ver_build;
84  }
85  
86  if (length(vendor)) {
87    ff = ff + 8;
88  }
89
90  if (length(icon)) {
91    print "1 ICON DISCARDABLE \"" icon "\"";
92  }
93  print "1 VERSIONINFO";
94  print " FILEVERSION " verc "";
95  print " PRODUCTVERSION " verc "";
96  print " FILEFLAGSMASK 0x3fL";
97  print "#if defined(_DEBUG)"
98  print " FILEFLAGS 0x" sprintf("%02x", ff + 1) "L";
99  print "#else"
100  print " FILEFLAGS 0x" sprintf("%02x", ff) "L";
101  print "#endif"
102  print " FILEOS 0x40004L";
103  print " FILETYPE 0x1L";
104  print " FILESUBTYPE 0x0L";
105  print "BEGIN";
106  print "  BLOCK \"StringFileInfo\"";
107  print "  BEGIN";
108  print "    BLOCK \"040904b0\"";
109  print "    BEGIN";
110  print "      VALUE \"Comments\", "\
111     "\"Licensed under the Apache License, Version 2.0 (the \"\"License\"\"); "\
112     "you may not use this file except in compliance with the License.  "\
113     "You may obtain a copy of the License at\\r\\n\\r\\n"\
114     "http://www.apache.org/licenses/LICENSE-2.0\\r\\n\\r\\n"\
115     "Unless required by applicable law or agreed to in writing, "\
116     "software distributed under the License is distributed on an "\
117     "\"\"AS IS\"\" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, "\
118     "either express or implied.  See the License for the specific "\
119     "language governing permissions and limitations under the License.\\0\"";
120  print "      VALUE \"CompanyName\", \"Apache Software Foundation\\0\"";
121  print "      VALUE \"FileDescription\", \"" desc "\\0\"";
122  print "      VALUE \"FileVersion\", \"" ver "\\0\"";
123  print "      VALUE \"InternalName\", \"" file "\\0\"";
124  print "      VALUE \"LegalCopyright\", \"Copyright " copyright "\\0\"";
125  print "      VALUE \"OriginalFilename\", \"" file "\\0\"";
126  if (vendor) {
127    print "      VALUE \"PrivateBuild\", \"" vendor "\\0\"";
128  }
129  if (special) {
130    print "      VALUE \"SpecialBuild\", \"" vendor "\\0\"";
131  }
132  print "      VALUE \"ProductName\", \"Apache HTTP Server\\0\"";
133  print "      VALUE \"ProductVersion\", \"" ver "\\0\"";
134  print "    END";
135  print "  END";
136  print "  BLOCK \"VarFileInfo\"";
137  print "  BEGIN";
138  print "    VALUE \"Translation\", 0x409, 1200";
139  print "  END";
140  print "END";
141}
142