1 /*
2 * %CopyrightBegin%
3 *
4 * Copyright Ericsson AB 1996-2016. All Rights Reserved.
5 *
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 * %CopyrightEnd%
19 */
20 /*
21 * Makes the file erl_version.h.
22 */
23
24 #ifdef HAVE_CONFIG_H
25 # include "config.h"
26 #endif
27 #include <stdio.h>
28 #include <stdlib.h>
29 #include <errno.h>
30 #include <time.h>
31
32 int
main(argc,argv)33 main(argc, argv)
34 int argc;
35 char** argv;
36 {
37 FILE *file;
38 #if ERTS_SAVED_COMPILE_TIME
39 time_t now;
40 #endif
41 char *cnow = "";
42
43 if (argc != 2) {
44 fprintf(stderr, "usage: mkver version\n");
45 exit(1);
46 }
47
48 if ((file = fopen("erl_version.h", "wb")) == NULL) {
49 fprintf(stderr, "Could not create file 'erl_version.h'!\n");
50 exit(1);
51 }
52
53 #if ERTS_SAVED_COMPILE_TIME
54 time(&now);
55 cnow = ctime(&now);
56 cnow[24] = '\0'; /* tidelipom */
57 #endif
58 fprintf(file, "/* This file was created by mkver -- don't modify.*/\n");
59 fprintf(file, "#define ERLANG_VERSION \"%s\"\n", argv[1]);
60 fprintf(file, "#define ERLANG_COMPILE_DATE \"%s\"\n", cnow);
61 fclose(file);
62
63 exit(0);
64 return 0;
65 }
66