~ubuntu-branches/ubuntu/trusty/erlang/trusty

« back to all changes in this revision

Viewing changes to erts/etc/common/erlc.c

  • Committer: Bazaar Package Importer
  • Author(s): Clint Byrum
  • Date: 2011-05-05 15:48:43 UTC
  • mfrom: (3.5.13 sid)
  • Revision ID: james.westby@ubuntu.com-20110505154843-0om6ekzg6m7ugj27
Tags: 1:14.b.2-dfsg-3ubuntu1
* Merge from debian unstable.  Remaining changes:
  - Drop libwxgtk2.8-dev build dependency. Wx isn't in main, and not
    supposed to.
  - Drop erlang-wx binary.
  - Drop erlang-wx dependency from -megaco, -common-test, and -reltool, they
    do not really need wx. Also drop it from -debugger; the GUI needs wx,
    but it apparently has CLI bits as well, and is also needed by -megaco,
    so let's keep the package for now.
  - debian/patches/series: Do what I meant, and enable build-options.patch
    instead.
* Additional changes:
  - Drop erlang-wx from -et
* Dropped Changes:
  - patches/pcre-crash.patch: CVE-2008-2371: outer level option with
    alternatives caused crash. (Applied Upstream)
  - fix for ssl certificate verification in newSSL: 
    ssl_cacertfile_fix.patch (Applied Upstream)
  - debian/patches/series: Enable native.patch again, to get stripped beam
    files and reduce the package size again. (build-options is what
    actually accomplished this)
  - Remove build-options.patch on advice from upstream and because it caused
    odd build failures.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * %CopyrightBegin%
3
 
 * 
4
 
 * Copyright Ericsson AB 1997-2009. All Rights Reserved.
5
 
 * 
 
3
 *
 
4
 * Copyright Ericsson AB 1997-2011. All Rights Reserved.
 
5
 *
6
6
 * The contents of this file are subject to the Erlang Public License,
7
7
 * Version 1.1, (the "License"); you may not use this file except in
8
8
 * compliance with the License. You should have received a copy of the
9
9
 * Erlang Public License along with this software. If not, it can be
10
10
 * retrieved online at http://www.erlang.org/.
11
 
 * 
 
11
 *
12
12
 * Software distributed under the License is distributed on an "AS IS"
13
13
 * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
14
14
 * the License for the specific language governing rights and limitations
15
15
 * under the License.
16
 
 * 
 
16
 *
17
17
 * %CopyrightEnd%
18
18
 */
19
19
/*
28
28
#include <winbase.h>
29
29
/* FIXE ME config_win32.h? */
30
30
#define HAVE_STRERROR 1
 
31
#define snprintf _snprintf
31
32
#endif
32
33
 
33
34
#include <ctype.h>
148
149
main(int argc, char** argv)
149
150
{
150
151
    char cwd[MAXPATHLEN];       /* Current working directory. */
151
 
    char** rpc_eargv;           /* Pointer to the beginning of arguments
152
 
                                 * if calling a running Erlang system
153
 
                                 * via erl_rpc().
154
 
                                 */
155
152
    int eargv_size;
156
153
    int eargc_base;             /* How many arguments in the base of eargv. */
157
154
    char* emulator;
160
157
    env = get_env("ERLC_EMULATOR");
161
158
    emulator = env ? env : get_default_emulator(argv[0]);
162
159
 
 
160
    if (strlen(emulator) >= MAXPATHLEN)
 
161
        error("Value of environment variable ERLC_EMULATOR is too large");
 
162
 
163
163
    /*
164
164
     * Allocate the argv vector to be used for arguments to Erlang.
165
165
     * Arrange for starting to pushing information in the middle of
170
170
     * base of the eargv vector, and move it up later.
171
171
     */
172
172
 
173
 
    eargv_size = argc*4+100;
 
173
    eargv_size = argc*6+100;
174
174
    eargv_base = (char **) emalloc(eargv_size*sizeof(char*));
175
175
    eargv = eargv_base;
176
176
    eargc = 0;
189
189
    PUSH2("-mode", "minimal");
190
190
    PUSH2("-boot", "start_clean");
191
191
    PUSH3("-s", "erl_compile", "compile_cmdline");
192
 
    rpc_eargv = eargv+eargc;
193
192
 
194
193
    /*
195
194
     * Push standard arguments to Erlang.
262
261
            case 'I':
263
262
                PUSH2("@i", process_opt(&argc, &argv, 0));
264
263
                break;
 
264
            case 'M':
 
265
                {
 
266
                    char *buf, *key, *val;
 
267
                    size_t buf_len;
 
268
 
 
269
                    if (argv[1][2] == '\0') { /* -M */
 
270
                        /* Push the following options:
 
271
                         *   o  'makedep'
 
272
                         *   o  {makedep_output, standard_io}
 
273
                         */
 
274
                        buf = strsave("makedep");
 
275
                        PUSH2("@option", buf);
 
276
 
 
277
                        key = "makedep_output";
 
278
                        val = "standard_io";
 
279
                        buf_len = 1 + strlen(key) + 1 + strlen(val) + 1 + 1;
 
280
                        buf = emalloc(buf_len);
 
281
                        snprintf(buf, buf_len, "{%s,%s}", key, val);
 
282
                        PUSH2("@option", buf);
 
283
                    } else if (argv[1][3] == '\0') {
 
284
                        switch(argv[1][2]) {
 
285
                        case 'D': /* -MD */
 
286
                            /* Push the following options:
 
287
                             *   o  'makedep'
 
288
                             */
 
289
                            buf = strsave("makedep");
 
290
                            PUSH2("@option", buf);
 
291
                            break;
 
292
                        case 'F': /* -MF <file> */
 
293
                            /* Push the following options:
 
294
                             *   o  'makedep'
 
295
                             *   o  {makedep_output, <file>}
 
296
                             */
 
297
                            buf = strsave("makedep");
 
298
                            PUSH2("@option", buf);
 
299
 
 
300
                            key = "makedep_output";
 
301
                            val = process_opt(&argc, &argv, 1);
 
302
                            buf_len = 1 + strlen(key) + 2 + strlen(val) + 2 + 1;
 
303
                            buf = emalloc(buf_len);
 
304
                            snprintf(buf, buf_len, "{%s,\"%s\"}", key, val);
 
305
                            PUSH2("@option", buf);
 
306
                            break;
 
307
                        case 'T': /* -MT <target> */
 
308
                            /* Push the following options:
 
309
                             *   o  {makedep_target, <target>}
 
310
                             */
 
311
                            key = "makedep_target";
 
312
                            val = process_opt(&argc, &argv, 1);
 
313
                            buf_len = 1 + strlen(key) + 2 + strlen(val) + 2 + 1;
 
314
                            buf = emalloc(buf_len);
 
315
                            snprintf(buf, buf_len, "{%s,\"%s\"}", key, val);
 
316
                            PUSH2("@option", buf);
 
317
                            break;
 
318
                        case 'Q': /* -MQ <target> */
 
319
                            /* Push the following options:
 
320
                             *   o  {makedep_target, <target>}
 
321
                             *   o  makedep_quote_target
 
322
                             */
 
323
                            key = "makedep_target";
 
324
                            val = process_opt(&argc, &argv, 1);
 
325
                            buf_len = 1 + strlen(key) + 2 + strlen(val) + 2 + 1;
 
326
                            buf = emalloc(buf_len);
 
327
                            snprintf(buf, buf_len, "{%s,\"%s\"}", key, val);
 
328
                            PUSH2("@option", buf);
 
329
 
 
330
                            buf = strsave("makedep_quote_target");
 
331
                            PUSH2("@option", buf);
 
332
                            break;
 
333
                        case 'G': /* -MG */
 
334
                            /* Push the following options:
 
335
                             *   o  makedep_add_missing
 
336
                             */
 
337
                            buf = strsave("makedep_add_missing");
 
338
                            PUSH2("@option", buf);
 
339
                            break;
 
340
                        case 'P': /* -MP */
 
341
                            /* Push the following options:
 
342
                             *   o  makedep_phony
 
343
                             */
 
344
                            buf = strsave("makedep_add_missing");
 
345
                            PUSH2("@option", buf);
 
346
                            break;
 
347
                        default:
 
348
                            goto error;
 
349
                        }
 
350
                    }
 
351
                }
 
352
                break;
265
353
            case 'o':
266
354
                PUSH2("@outdir", process_opt(&argc, &argv, 0));
267
355
                break;
310
398
            case 'W':           /* Enable warnings. */
311
399
                if (strcmp(argv[1]+2, "all") == 0) {
312
400
                    PUSH2("@warn", "999");
 
401
                } else if (strcmp(argv[1]+2, "error") == 0) {
 
402
                    PUSH2("@option", "warnings_as_errors");
313
403
                } else if (isdigit((int)argv[1][2])) {
314
404
                    PUSH2("@warn", argv[1]+2);
315
405
                } else {
417
507
static void
418
508
push_words(char* src)
419
509
{
420
 
    char sbuf[1024];
 
510
    char sbuf[MAXPATHLEN];
421
511
    char* dst;
422
512
 
423
513
    dst = sbuf;
561
651
        {"-hybrid", "compile using hybrid-heap emulator"},
562
652
        {"-help", "shows this help text"},
563
653
        {"-I path", "where to search for include files"},
 
654
        {"-M", "generate a rule for make(1) describing the dependencies"},
 
655
        {"-MF file", "write the dependencies to 'file'"},
 
656
        {"-MT target", "change the target of the rule emitted by dependency "
 
657
                "generation"},
 
658
        {"-MQ target", "same as -MT but quote characters special to make(1)"},
 
659
        {"-MG", "consider missing headers as generated files and add them to "
 
660
                "the dependencies"},
 
661
        {"-MP", "add a phony target for each dependency"},
 
662
        {"-MD", "same as -M -MT file (with default 'file')"},
564
663
        {"-o name", "name output directory or file"},
565
664
        {"-pa path", "add path to the front of Erlang's code path"},
566
665
        {"-pz path", "add path to the end of Erlang's code path"},
567
666
        {"-smp", "compile using SMP emulator"},
568
667
        {"-v", "verbose compiler output"},
 
668
        {"-Werror", "make all warnings into errors"},
569
669
        {"-W0", "disable warnings"},
570
670
        {"-Wnumber", "set warning level to number"},
571
671
        {"-Wall", "enable all warnings"},
592
692
    va_list ap;
593
693
    
594
694
    va_start(ap, format);
595
 
    vsprintf(sbuf, format, ap);
 
695
    erts_vsnprintf(sbuf, sizeof(sbuf), format, ap);
596
696
    va_end(ap);
597
697
    fprintf(stderr, "erlc: %s\n", sbuf);
598
698
    exit(1);
621
721
    char sbuf[MAXPATHLEN];
622
722
    char* s;
623
723
 
 
724
    if (strlen(progname) >= sizeof(sbuf))
 
725
        return ERL_NAME;
 
726
 
624
727
    strcpy(sbuf, progname);
625
728
    for (s = sbuf+strlen(sbuf); s >= sbuf; s--) {
626
729
        if (IS_DIRSEP(*s)) {