int nc, nl, np, nxo, na;
+#ifdef XIFY
+char **ilist;
+int ni;
+
+/*char in_path[BUFSIZ];*/
+char out_path[BUFSIZ];
+#endif
+
#define cunlink(s) if (s) unlink(s)
#ifndef __P
void error __P((char *s, char *x));
int getsuf __P((char as[]));
char *setsuf __P((char *as, int ch));
+#ifdef XIFY
+int xify_include __P((char *in_name));
+int xify_file __P((char *in_name, struct stat *in_statbuf));
+#endif
int callsys __P((char *f, char **v));
int nodup __P((char **l, char *os));
char *savestr __P((register char *cp));
char *assource;
#endif
int i, j, c;
+#ifdef XIFY
+ struct stat statbuf;
+#endif
/* ld currently adds upto 5 args; 10 is room to spare */
av = (char **)calloc(argc+10, sizeof (char **));
if (plist[i][2] == '/')
plist[i] = strspl("-I", strspl(t, plist[i] + 2));
}
+ ilist = (char **)calloc(0x100, sizeof (char **));
#else
if (pflag==0)
sprintf(tmp0, "/tmp/ctm%05.5d", getpid());
#ifdef XIFY
c = getsuf(clist[i]);
if (c == 'c') {
- t = ".xify";
- if (mkdir(t, 0777) == -1 && errno != EEXIST) {
- error("can't mkdir: %s", t);
- exit(1);
+ if (stat(clist[i], &statbuf)) {
+ error("not found: %s", clist[i]);
+ goto nogood;
}
- t = strspl(".xify/x_", setsuf(clist[i], 'c'));
- av[0] = "xify"; av[1] = clist[i]; av[2] = t; av[3] = 0;
- if (callsys(xify, av)) {
+ if (xify_file(clist[i], &statbuf)) {
+ nogood:
cflag++;
eflag++;
continue;
}
- clist[i] = t;
+ clist[i] = savestr(out_path);
}
av[0] = "gcc"; av[1] = "-o";
na = 2;
return (s1);
}
+#ifdef XIFY
+int xify_file(in_name, in_statbuf) char *in_name; struct stat *in_statbuf; {
+ int i;
+ struct stat out_statbuf;
+ /* note: out_path is an output parameter on success */
+
+ for (i = strlen(in_name); i > 0 && in_name[i - 1] != '/'; --i)
+ ;
+ bcopy(in_name, out_path, i);
+ strcpy(out_path + i, ".xify/x_");
+ strcat(out_path + i, in_name + i);
+ if (
+ stat(out_path, &out_statbuf) == 0 && (
+ out_statbuf.st_mtim.tv_sec > in_statbuf->st_mtim.tv_sec || (
+ out_statbuf.st_mtim.tv_sec == in_statbuf->st_mtim.tv_sec &&
+ out_statbuf.st_mtim.tv_nsec >= in_statbuf->st_mtim.tv_nsec
+ )
+ )
+
+ )
+ return 0;
+
+ out_path[i + 5] = 0;
+ if (mkdir(out_path, 0777) == -1 && errno != EEXIST) {
+ error("can't mkdir: %s\n", out_path);
+ return 1;
+ }
+ out_path[i + 5] = '/';
+
+ av[0] = "xify"; av[1] = in_name; av[2] = out_path; av[3] = 0;
+ return callsys(xify, av);
+}
+#endif
+
int callsys(f, v) char *f; char **v; {
int t, status;
char **cpp;
#ifdef XIFY
char *gcc = "/usr/bin/gcc";
+
char **av;
int na;
+
+char in_path[BUFSIZ];
+char out_path[BUFSIZ];
#else
/*
* Base of the string table of the current module (pass1 and pass2).
void delexit __P((void));
void endload __P((int argc, char **argv));
#ifdef XIFY
-void xify_lib __P((char *in_name));
+void xify_library __P((char *in_name));
int callsys __P((char *f, char **v));
#else
void load1arg __P((register char *cp));
ap[--i]='-';
#ifdef XIFY
filname = ap + i;
- xify_lib(filname + 2);
+ xify_library(filname + 2);
av[na++] = strspl("-lx_", filname + 2);
#else
}
#ifdef XIFY
-void xify_lib(in_name) char *in_name; {
+void xify_library(in_name) char *in_name; {
int i, j;
- char in_path[BUFSIZ];
- char out_path[BUFSIZ];
struct stat statbuf;
for (int i = 0; i < ndir; ++i) {
- j = strlen(dirs[i]) - 6; /* always ends with "/.xify" */
+ j = strlen(dirs[i]) - 5; /* remove ".xify" */
bcopy(dirs[i], in_path, j);
- strcpy(in_path + j, "/lib");
+ strcpy(in_path + j, "lib");
strcat(in_path + j, in_name);
strcat(in_path + j, ".a");
if (stat(in_path, &statbuf) == 0)
exit(1);
found:
- j += 6; /* j = strlen(dirs[i]); */
+ j += 5; /* j = strlen(dirs[i]); */
bcopy(dirs[i], out_path, j);
strcpy(out_path + j, "/libx_");
strcat(out_path + j, in_name);