blob: 19a382c96f8b8dd8e61c11988f854c75c8db1802 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
#define _XOPEN_SOURCE 700
#include <libgen.h>
#include <stdio.h>
#include <string.h>
#include <unistd.h>
#include "maje.h"
static void usage(char *progname)
{
printf("usage: %s [dir]\n", progname);
}
int main(int argc, char *argv[])
{
char *srcdir = NULL;
int c;
while ((c = getopt(argc, argv, "")) != -1) {
switch (c) {
default:
usage(argv[0]);
return 1;
}
}
srcdir = argv[optind];
if (srcdir == NULL) {
srcdir = ".";
}
struct majefile **sources = find_source_files(srcdir);
char *mainname = find_main(sources);
if (!mainname) {
printf("libraries not yet supported\n");
return 0;
}
char *target = strdup(mainname);
target[strlen(target) - 2] = '\0';
target = basename(target);
FILE *makefile = fopen("Makefile", "w");
if (makefile == NULL) {
perror("fopen");
return 1;
}
make_makefile("Makefile", sources, target);
return 0;
}
|