Subversion Repositories tendra.SVN

Rev

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

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