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 | if (s->nb_libraries != 0) | 290 | if (s->nb_libraries != 0) |
| 291 | tcc_error("cannot specify libraries with -c"); | 291 | tcc_error("cannot specify libraries with -c"); |
| 292 | /* accepts only a single input file */ | 292 | /* accepts only a single input file */ |
| 293 | if (s->nb_files != 1) | 293 | if ((s->nb_files != 1) && s->outfile) { |
| 294 | tcc_error("cannot specify multiple files with -c"); | 294 | tcc_error("cannot specify multiple files with -c and -o"); |
| 295 | } | ||
| 295 | } | 296 | } |
| 296 | 297 | ||
| 297 | if (s->output_type == TCC_OUTPUT_PREPROCESS) { | 298 | if (s->output_type == TCC_OUTPUT_PREPROCESS) { |
| @@ -324,6 +325,28 @@ int main(int argc, char **argv) · 26 unmodified lines | |||
| 324 | printf("-> %s\n", filename); | 325 | printf("-> %s\n", filename); |
| 325 | if (tcc_add_file(s, filename, filetype) < 0) | 326 | if (tcc_add_file(s, filename, filetype) < 0) |
| 326 | ret = 1; | 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 | if (!first_file) | 350 | if (!first_file) |
| 328 | first_file = filename; | 351 | first_file = filename; |
| 329 | } | 352 | } |
| @@ -343,7 +366,7 @@ int main(int argc, char **argv) · 13 unmodified lines | |||
| 343 | } else if (s->output_type == TCC_OUTPUT_PREPROCESS) { | 366 | } else if (s->output_type == TCC_OUTPUT_PREPROCESS) { |
| 344 | if (s->outfile) | 367 | if (s->outfile) |
| 345 | fclose(s->ppfp); | 368 | fclose(s->ppfp); |
| 346 | } else { | 369 | } else if (s->output_type != TCC_OUTPUT_OBJ) { |
| 347 | if (!s->outfile) | 370 | if (!s->outfile) |
| 348 | s->outfile = default_outputfile(s, first_file); | 371 | s->outfile = default_outputfile(s, first_file); |
| 349 | ret = !!tcc_output_file(s, s->outfile); | 372 | ret = !!tcc_output_file(s, s->outfile); |