1 /* Id */
2 /* $NetBSD: prog_ccom.c,v 1.1.1.1 2016/02/09 20:29:12 plunky Exp $ */
3
4 /*-
5 * Copyright (c) 2014 Iain Hibbert.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a copy
8 * of this software and associated documentation files (the "Software"), to deal
9 * in the Software without restriction, including without limitation the rights
10 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11 * copies of the Software, and to permit persons to whom the Software is
12 * furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included in
15 * all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23 * THE SOFTWARE.
24 */
25
26 #include "driver.h"
27
28 static int
ccom_exec(const char * infile,const char * outfile)29 ccom_exec(const char *infile, const char *outfile)
30 {
31 list_t *l;
32 char *prog;
33
34 if (ccom_name == NULL)
35 error("No C compiler was defined");
36
37 l = list_alloc();
38
39 prog = find_file(ccom_name, &progdirs, X_OK);
40 list_add_nocopy(l, prog);
41
42 Wflag_add(l, W_CCOM);
43
44 if (opt.stabs)
45 list_add(l, "-g");
46 if (opt.O > 0) {
47 list_add(l, "-xtemps");
48 list_add(l, "-xdeljumps");
49 list_add(l, "-xinline");
50 list_add(l, "-xdce");
51 }
52 if (opt.gnu89 || opt.gnu99)
53 list_add(l, "-xgcc");
54 if (opt.pic)
55 list_add(l, "-k");
56 if (opt.profile)
57 list_add(l, "-p");
58
59 if (infile != NULL)
60 list_add(l, infile);
61 else if (outfile != NULL)
62 list_add(l, "-");
63
64 if (outfile != NULL)
65 list_add(l, outfile);
66
67 rv = list_exec(l);
68 list_free(l);
69 return rv;
70 }
71