AFS_component_version_number.c: Respect SOURCE_DATE_EPOCH if set
[openafs.git] / src / config / config.c
1 /*
2  * Copyright 2000, International Business Machines Corporation and others.
3  * All Rights Reserved.
4  *
5  * This software has been released under the terms of the IBM Public
6  * License.  For details, see the LICENSE file in the top-level source
7  * directory or online at http://www.openafs.org/dl/license10.html
8  */
9
10 #include <sys/types.h>
11 #include <sys/file.h>
12 #include <sys/time.h>
13 #include <stdio.h>
14 #include <string.h>
15 #include <stdlib.h>
16 #include <errno.h>
17
18 #include "AFS_component_version_number.c"
19
20 /* prototypes */
21 int mc_copy(FILE *, FILE *, char **);
22
23 int
24 main(int argc, char **argv)
25 {
26     FILE *infile;
27     FILE *outfile;
28     char *alist[5];
29     int code;
30     char *sysname;
31
32     if (argc != 4) {
33         printf
34             ("config: usage is 'config <from file> <to file> <system name>'\n");
35         exit(1);
36     }
37     infile = fopen(argv[1], "r");
38     if (!infile) {
39         printf("config: input file %s not found.\n", argv[1]);
40         exit(1);
41     }
42     outfile = fopen(argv[2], "w+");
43     if (!outfile) {
44         printf("config: output file %s not found.\n", argv[2]);
45         exit(1);
46     }
47     memset (alist, 0, sizeof (alist));
48     alist[0] = argv[3];
49     alist[1] = "all";
50
51     /* This allows JUST arch or JUST OS/version,
52      * Linux 2.6 uses the in-kernel build system, so
53      * just 'linux26' is enough. */
54     sysname = strdup (alist[0]);
55     alist[2] = strchr (sysname, '_');
56     if (alist[2]) {
57         alist[3] = sysname;
58         *alist[2] = 0;
59         alist[2]++;
60     }
61     code = mc_copy(infile, outfile, alist);
62     if (code) {
63         printf("config: failed to correctly write makefile '%s', code %d\n",
64                argv[2], code);
65         exit(1);
66     } else {
67         printf("Wrote new makefile '%s'.\n", argv[2]);
68         exit(0);
69     }
70 }