Subversion Repositories tendra.SVN

Rev

Rev 7 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 7 Rev 38
Line 73... Line 73...
73
    This routine tests whether a file with information i is needed in the
73
    This routine tests whether a file with information i is needed in the
74
    makefile for the given api.
74
    makefile for the given api.
75
*/
75
*/
76
 
76
 
77
static
77
static
-
 
78
		boolean
78
boolean need_info(info *i, char *api)
79
need_info(info * i, char *api)
79
{
80
{
80
    if (restrict_depth && !streq(api, i->api)) return(0);
81
	if (restrict_depth && !streq(api, i->api))
-
 
82
		return (0);
81
    return(i->implemented && i->tokens && i->src);
83
	return (i->implemented && i->tokens && i->src);
82
}
84
}
-
 
85
 
-
 
86
 
-
 
87
char           *template = "\n\
-
 
88
TCC?=   tcc\n\
-
 
89
TLD?=   tld\n\
-
 
90
PREFIX?=/usr/local\n\
-
 
91
LIB=    -NAME-.tl\n\
-
 
92
TCFLAGS?= -Ysystem+\n\
-
 
93
\n\
-
 
94
OBJS=\
-
 
95
	-OBJS-\n\
-
 
96
\n\
-
 
97
.SUFFIXES: .c .j\n\
-
 
98
\n\
-
 
99
$(LIB): $(OBJS)\n\
-
 
100
	$(TLD) $(TLDFLAGS) -mc -o $(LIB) $(OBJS)\n\
-
 
101
\n\
-
 
102
.c.j:\n\
-
 
103
	$(TCC) -Ybuilding $(TCFLAGS) -Fj -f-NAME-.h $<\n\
-
 
104
\n\
-
 
105
clean:\n\
-
 
106
	rm -f *.j\n\
-
 
107
	rm -f -NAME-.tl\n\
-
 
108
\n\
-
 
109
install: $(LIB)\n\
-
 
110
	install -d $(PREFIX)/lib\n\
-
 
111
	install -NAME-.tl $(PREFIX)/lib/-NAME-.tl\n\
-
 
112
\n\
-
 
113
";
-
 
114
 
-
 
115
 
83
 
116
 
84
 
117
 
85
/*
118
/*
86
    PRINT A MAKEFILE
119
    PRINT A MAKEFILE
87
 
120
 
Line 89... Line 122...
89
    from the list of files f.  There are two forms of the output, indicated
122
    from the list of files f.  There are two forms of the output, indicated
90
    by whole.
123
    by whole.
91
*/
124
*/
92
 
125
 
93
void
126
void
94
print_makefile(char *api, hash_elem *f, int whole)
127
print_makefile(char *api, hash_elem * f, int whole)
95
{
128
{
-
 
129
	hash_elem      *e;
96
    char *nm;
130
	char           *nm;
97
    FILE *output;
131
	FILE           *output;
98
    hash_elem *e;
132
	char           *pos;
99
    char *api2 = hack_name(api, "_Aa0");
133
	char           *api2 = hack_name(api, "_Aa0");
-
 
134
 
100
 
135
 
101
    /* Open output file */
-
 
102
    nm = (whole ? MAKEFILE_API : MAKEFILE);
136
	nm = (whole ? MAKEFILE_API : MAKEFILE);
103
    nm = string_printf(nm, output_src_dir, api, api2);
137
	nm = string_printf(nm, output_src_dir, api, api2);
-
 
138
	if (verbose > 1)
104
    if (verbose > 1) IGNORE printf("Creating %s ...", nm);
139
		printf("Creating %s ...", nm);
-
 
140
 
105
    create_dir(nm);
141
	create_dir(nm);
106
    output = fopen(nm, "w");
142
	output = fopen(nm, "w");
107
    if (output == null) {
143
	if (output == null) {
108
	error(ERR_SERIOUS, "Can't open output file, %s", nm);
144
		error(ERR_SERIOUS, "Can't open output file, %s", nm);
109
	return;
145
		return;
-
 
146
	}
-
 
147
	for (pos = template; *pos != 0; pos++) {
-
 
148
		if (*pos != '-') {
-
 
149
			fputc(*pos, output);
-
 
150
			continue;
110
    }
151
		}
111
    fprintf(output, "APILIB=\t%s.tl\n\n", api);
152
		if (strncmp("-NAME-", pos, strlen("-NAME-")) == 0) {
-
 
153
			pos += strlen("-NAME-") - 1;
112
	fputs("APIOBJS=\t", output);
154
			fputs(api, output);
-
 
155
			continue;
-
 
156
		}
-
 
157
		if (strncmp("-OBJS-", pos, strlen("-OBJS-")) == 0) {
-
 
158
			pos += strlen("-OBJS-") - 1;
-
 
159
 
113
	for ( e = f ; e != null ; e = e->next ) {
160
			for (e = f; e != null; e = e->next) {
114
		info *i = e->obj->u.u_info ;
161
				info           *i = e->obj->u.u_info;
115
		if ( need_info ( i, api ) ) {
162
				if (need_info(i, api)) {
116
			int m;
163
					int 		m;
117
			strcpy(buffer, basename(i->src));
164
					strcpy(buffer, basename(i->src));
118
			m = strlen(buffer) - 1;
165
					m = strlen(buffer) - 1;
119
			buffer[m] = 'j';
166
					buffer[m] = 'j';
120
			fprintf(output, "\\\n\t\tbuilding/%s.api/%s", api, basename(buffer));
167
					fprintf(output, "\\\n\t%s", basename(buffer));
-
 
168
				}
-
 
169
			}
-
 
170
			continue;
121
		}
171
		}
-
 
172
		fputc(*pos, output);
-
 
173
 
122
	}
174
	}
123
	fputs("\n", output);
175
	fclose (output);
124
    /* End of makefile */
-
 
125
    IGNORE fclose(output);
-
 
126
    return;
-
 
127
}
176
}
-
 
177
 
-
 
178