The Meson Build System
http://mesonbuild.com/
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
70 lines
1.6 KiB
70 lines
1.6 KiB
12 years ago
|
#include<stdio.h>
|
||
|
#include<assert.h>
|
||
8 years ago
|
#include<string.h>
|
||
12 years ago
|
|
||
12 years ago
|
#define ARRSIZE 80
|
||
|
|
||
12 years ago
|
int main(int argc, char **argv) {
|
||
|
char arr[ARRSIZE];
|
||
12 years ago
|
char *ofilename;
|
||
|
char *ifilename;
|
||
8 years ago
|
char *dfilename;
|
||
12 years ago
|
FILE *ifile;
|
||
|
FILE *ofile;
|
||
8 years ago
|
FILE *depfile;
|
||
12 years ago
|
size_t bytes;
|
||
8 years ago
|
int i;
|
||
12 years ago
|
|
||
8 years ago
|
if(argc != 4) {
|
||
|
fprintf(stderr, "%s <input file> <output file> <dependency file>\n", argv[0]);
|
||
12 years ago
|
return 1;
|
||
|
}
|
||
12 years ago
|
ifilename = argv[1];
|
||
|
ofilename = argv[2];
|
||
8 years ago
|
dfilename = argv[3];
|
||
12 years ago
|
ifile = fopen(argv[1], "r");
|
||
12 years ago
|
if(!ifile) {
|
||
12 years ago
|
fprintf(stderr, "Could not open source file %s.\n", argv[1]);
|
||
12 years ago
|
return 1;
|
||
|
}
|
||
12 years ago
|
ofile = fopen(ofilename, "w");
|
||
12 years ago
|
if(!ofile) {
|
||
|
fprintf(stderr, "Could not open target file %s\n", ofilename);
|
||
11 years ago
|
fclose(ifile);
|
||
12 years ago
|
return 1;
|
||
|
}
|
||
|
bytes = fread(arr, 1, ARRSIZE, ifile);
|
||
|
assert(bytes < 80);
|
||
|
assert(bytes > 0);
|
||
|
fwrite(arr, 1, bytes, ofile);
|
||
|
|
||
8 years ago
|
depfile = fopen(dfilename, "w");
|
||
|
if(!depfile) {
|
||
|
fprintf(stderr, "Could not open depfile %s\n", ofilename);
|
||
|
fclose(ifile);
|
||
|
fclose(ofile);
|
||
|
return 1;
|
||
|
}
|
||
|
for(i=0; i<strlen(ofilename); i++) {
|
||
|
if(ofilename[i] == ' ') {
|
||
|
fwrite("\\ ", 1, 2, depfile);
|
||
|
} else {
|
||
|
fwrite(&ofilename[i], 1, 1, depfile);
|
||
|
}
|
||
|
}
|
||
|
fwrite(": ", 1, 2, depfile);
|
||
|
for(i=0; i<strlen(ifilename); i++) {
|
||
|
if(ifilename[i] == ' ') {
|
||
|
fwrite("\\ ", 1, 2, depfile);
|
||
|
} else {
|
||
|
fwrite(&ifilename[i], 1, 1, depfile);
|
||
|
}
|
||
|
}
|
||
|
fwrite("\n", 1, 1, depfile);
|
||
|
|
||
12 years ago
|
fclose(ifile);
|
||
|
fclose(ofile);
|
||
8 years ago
|
fclose(depfile);
|
||
12 years ago
|
return 0;
|
||
|
}
|