Usage example: tcc -c -xc ex5.cgi -xn ex2.c ex7.c ex6.cgi
Unified · Split
| @@ -290,8 +290,9 @@ int main(int argc, char **argv) · 289 unmodified lines | ||
| 290 | 290 | if (s->nb_libraries != 0) |
| 291 | 291 | tcc_error("cannot specify libraries with -c"); |
| 292 | 292 | /* accepts only a single input file */ |
| 293 | − if (s->nb_files != 1) | |
| 294 | − tcc_error("cannot specify multiple files with -c"); | |
| 293 | + if ((s->nb_files != 1) && s->outfile) { | |
| 294 | + tcc_error("cannot specify multiple files with -c and -o"); | |
| 295 | + } | |
| 295 | 296 | } |
| 296 | 297 | |
| 297 | 298 | if (s->output_type == TCC_OUTPUT_PREPROCESS) { |
| @@ -324,6 +325,28 @@ int main(int argc, char **argv) · 26 unmodified lines | ||
| 324 | 325 | printf("-> %s\n", filename); |
| 325 | 326 | if (tcc_add_file(s, filename, filetype) < 0) |
| 326 | 327 | ret = 1; |
| 328 | + else | |
| 329 | + if (s->output_type == TCC_OUTPUT_OBJ) { | |
| 330 | + const char *outfile = s->outfile; | |
| 331 | + if (!outfile) | |
| 332 | + outfile = default_outputfile(s, filename); | |
| 333 | + ret = !!tcc_output_file(s, outfile); | |
| 334 | + if (!ret) { | |
| 335 | + /* dump collected dependencies */ | |
| 336 | + if (s->gen_deps) | |
| 337 | + gen_makedeps(s, outfile, s->deps_outfile); | |
| 338 | + if ((i+1) < s->nb_files) { | |
| 339 | + tcc_delete(s); | |
| 340 | + s = tcc_new(); | |
| 341 | + tcc_parse_args(s, argc - 1, argv + 1); | |
| 342 | + tcc_set_environment(s); | |
| 343 | + if (s->output_type != TCC_OUTPUT_OBJ) | |
| 344 | + tcc_error("interlnal error"); | |
| 345 | + tcc_set_output_type(s, s->output_type); | |
| 346 | + } | |
| 347 | + } | |
| 348 | + } | |
| 349 | + else | |
| 327 | 350 | if (!first_file) |
| 328 | 351 | first_file = filename; |
| 329 | 352 | } |
| @@ -343,7 +366,7 @@ int main(int argc, char **argv) · 13 unmodified lines | ||
| 343 | 366 | } else if (s->output_type == TCC_OUTPUT_PREPROCESS) { |
| 344 | 367 | if (s->outfile) |
| 345 | 368 | fclose(s->ppfp); |
| 346 | − } else { | |
| 369 | + } else if (s->output_type != TCC_OUTPUT_OBJ) { | |
| 347 | 370 | if (!s->outfile) |
| 348 | 371 | s->outfile = default_outputfile(s, first_file); |
| 349 | 372 | ret = !!tcc_output_file(s, s->outfile); |