freebsd,linux,sunos: make stack non-executable
[platform/upstream/nodejs.git] / node.gyp
1 {
2   'variables': {
3     'v8_use_snapshot%': 'true',
4     'node_use_dtrace%': 'false',
5     'node_use_etw%': 'false',
6     'node_use_perfctr%': 'false',
7     'node_has_winsdk%': 'false',
8     'node_shared_v8%': 'false',
9     'node_shared_zlib%': 'false',
10     'node_shared_http_parser%': 'false',
11     'node_shared_cares%': 'false',
12     'node_shared_libuv%': 'false',
13     'node_use_openssl%': 'true',
14     'node_shared_openssl%': 'false',
15     'node_use_mdb%': 'false',
16     'node_v8_options%': '',
17     'library_files': [
18       'src/node.js',
19       'lib/_debugger.js',
20       'lib/_linklist.js',
21       'lib/assert.js',
22       'lib/buffer.js',
23       'lib/child_process.js',
24       'lib/console.js',
25       'lib/constants.js',
26       'lib/crypto.js',
27       'lib/cluster.js',
28       'lib/dgram.js',
29       'lib/dns.js',
30       'lib/domain.js',
31       'lib/events.js',
32       'lib/freelist.js',
33       'lib/fs.js',
34       'lib/http.js',
35       'lib/_http_agent.js',
36       'lib/_http_client.js',
37       'lib/_http_common.js',
38       'lib/_http_incoming.js',
39       'lib/_http_outgoing.js',
40       'lib/_http_server.js',
41       'lib/https.js',
42       'lib/module.js',
43       'lib/net.js',
44       'lib/os.js',
45       'lib/path.js',
46       'lib/punycode.js',
47       'lib/querystring.js',
48       'lib/readline.js',
49       'lib/repl.js',
50       'lib/smalloc.js',
51       'lib/stream.js',
52       'lib/_stream_readable.js',
53       'lib/_stream_writable.js',
54       'lib/_stream_duplex.js',
55       'lib/_stream_transform.js',
56       'lib/_stream_passthrough.js',
57       'lib/string_decoder.js',
58       'lib/sys.js',
59       'lib/timers.js',
60       'lib/tracing.js',
61       'lib/tls.js',
62       'lib/_tls_common.js',
63       'lib/_tls_legacy.js',
64       'lib/_tls_wrap.js',
65       'lib/tty.js',
66       'lib/url.js',
67       'lib/util.js',
68       'lib/vm.js',
69       'lib/zlib.js',
70       'deps/debugger-agent/lib/_debugger_agent.js',
71     ],
72   },
73
74   'targets': [
75     {
76       'target_name': 'node',
77       'type': 'executable',
78
79       'dependencies': [
80         'node_js2c#host',
81         'deps/debugger-agent/debugger-agent.gyp:debugger-agent',
82       ],
83
84       'include_dirs': [
85         'src',
86         'tools/msvs/genfiles',
87         'deps/uv/src/ares',
88         '<(SHARED_INTERMEDIATE_DIR)' # for node_natives.h
89       ],
90
91       'sources': [
92         'src/fs_event_wrap.cc',
93         'src/cares_wrap.cc',
94         'src/handle_wrap.cc',
95         'src/node.cc',
96         'src/node_buffer.cc',
97         'src/node_constants.cc',
98         'src/node_contextify.cc',
99         'src/node_file.cc',
100         'src/node_http_parser.cc',
101         'src/node_javascript.cc',
102         'src/node_main.cc',
103         'src/node_os.cc',
104         'src/node_v8.cc',
105         'src/node_stat_watcher.cc',
106         'src/node_watchdog.cc',
107         'src/node_zlib.cc',
108         'src/node_i18n.cc',
109         'src/pipe_wrap.cc',
110         'src/signal_wrap.cc',
111         'src/smalloc.cc',
112         'src/spawn_sync.cc',
113         'src/string_bytes.cc',
114         'src/stream_wrap.cc',
115         'src/tcp_wrap.cc',
116         'src/timer_wrap.cc',
117         'src/tty_wrap.cc',
118         'src/process_wrap.cc',
119         'src/udp_wrap.cc',
120         'src/uv.cc',
121         # headers to make for a more pleasant IDE experience
122         'src/async-wrap.h',
123         'src/async-wrap-inl.h',
124         'src/base-object.h',
125         'src/base-object-inl.h',
126         'src/env.h',
127         'src/env-inl.h',
128         'src/handle_wrap.h',
129         'src/node.h',
130         'src/node_buffer.h',
131         'src/node_constants.h',
132         'src/node_file.h',
133         'src/node_http_parser.h',
134         'src/node_internals.h',
135         'src/node_javascript.h',
136         'src/node_root_certs.h',
137         'src/node_version.h',
138         'src/node_watchdog.h',
139         'src/node_wrap.h',
140         'src/node_i18n.h',
141         'src/pipe_wrap.h',
142         'src/queue.h',
143         'src/smalloc.h',
144         'src/tty_wrap.h',
145         'src/tcp_wrap.h',
146         'src/udp_wrap.h',
147         'src/req_wrap.h',
148         'src/string_bytes.h',
149         'src/stream_wrap.h',
150         'src/tree.h',
151         'src/util.h',
152         'src/util-inl.h',
153         'src/util.cc',
154         'deps/http_parser/http_parser.h',
155         '<(SHARED_INTERMEDIATE_DIR)/node_natives.h',
156         # javascript files to make for an even more pleasant IDE experience
157         '<@(library_files)',
158         # node.gyp is added to the project by default.
159         'common.gypi',
160       ],
161
162       'defines': [
163         'NODE_WANT_INTERNALS=1',
164         'ARCH="<(target_arch)"',
165         'PLATFORM="<(OS)"',
166         'NODE_TAG="<(node_tag)"',
167         'NODE_V8_OPTIONS="<(node_v8_options)"',
168       ],
169
170       'conditions': [
171         [ 'v8_enable_i18n_support==1', {
172           'defines': [ 'NODE_HAVE_I18N_SUPPORT=1' ],
173           'dependencies': [
174             '<(icu_gyp_path):icui18n',
175             '<(icu_gyp_path):icuuc',
176           ],
177           'conditions': [
178             [ 'icu_small=="true"', {
179               'defines': [ 'NODE_HAVE_SMALL_ICU=1' ],
180           }]],
181         }],
182         [ 'node_use_openssl=="true"', {
183           'defines': [ 'HAVE_OPENSSL=1' ],
184           'sources': [
185             'src/node_crypto.cc',
186             'src/node_crypto_bio.cc',
187             'src/node_crypto_clienthello.cc',
188             'src/node_crypto.h',
189             'src/node_crypto_bio.h',
190             'src/node_crypto_clienthello.h',
191             'src/tls_wrap.cc',
192             'src/tls_wrap.h'
193           ],
194           'conditions': [
195             [ 'node_shared_openssl=="false"', {
196               'dependencies': [
197                 './deps/openssl/openssl.gyp:openssl',
198
199                 # For tests
200                 './deps/openssl/openssl.gyp:openssl-cli',
201               ],
202               # Do not let unused OpenSSL symbols to slip away
203               'xcode_settings': {
204                 'OTHER_LDFLAGS': [
205                   '-Wl,-force_load,<(PRODUCT_DIR)/libopenssl.a',
206                 ],
207               },
208               'conditions': [
209                 ['OS in "linux freebsd"', {
210                   'ldflags': [
211                     '-Wl,--whole-archive <(PRODUCT_DIR)/libopenssl.a -Wl,--no-whole-archive',
212                   ],
213                 }],
214               ],
215             }]]
216         }, {
217           'defines': [ 'HAVE_OPENSSL=0' ]
218         }],
219         [ 'node_use_dtrace=="true"', {
220           'defines': [ 'HAVE_DTRACE=1' ],
221           'dependencies': [
222             'node_dtrace_header',
223             'specialize_node_d',
224           ],
225           'include_dirs': [ '<(SHARED_INTERMEDIATE_DIR)' ],
226
227           #
228           # DTrace is supported on linux, solaris, mac, and bsd.  There are
229           # three object files associated with DTrace support, but they're
230           # not all used all the time:
231           #
232           #   node_dtrace.o           all configurations
233           #   node_dtrace_ustack.o    not supported on mac and linux
234           #   node_dtrace_provider.o  All except OS X.  "dtrace -G" is not
235           #                           used on OS X.
236           #
237           # Note that node_dtrace_provider.cc and node_dtrace_ustack.cc do not
238           # actually exist.  They're listed here to trick GYP into linking the
239           # corresponding object files into the final "node" executable.  These
240           # object files are generated by "dtrace -G" using custom actions
241           # below, and the GYP-generated Makefiles will properly build them when
242           # needed.
243           #
244           'sources': [ 'src/node_dtrace.cc' ],
245           'conditions': [
246             [ 'OS=="linux"', {
247               'sources': [
248                 '<(SHARED_INTERMEDIATE_DIR)/node_dtrace_provider.o',
249                 '<(SHARED_INTERMEDIATE_DIR)/libuv_dtrace_provider.o',
250               ],
251             }],
252             [ 'OS!="mac" and OS!="linux"', {
253               'sources': [
254                 'src/node_dtrace_ustack.cc',
255                 'src/node_dtrace_provider.cc',
256               ]
257             }
258           ] ]
259         } ],
260         [ 'node_use_mdb=="true"', {
261           'dependencies': [ 'node_mdb' ],
262           'include_dirs': [ '<(SHARED_INTERMEDIATE_DIR)' ],
263           'sources': [
264             'src/node_mdb.cc',
265           ],
266         } ],
267         [ 'node_use_etw=="true"', {
268           'defines': [ 'HAVE_ETW=1' ],
269           'dependencies': [ 'node_etw' ],
270           'sources': [
271             'src/node_win32_etw_provider.h',
272             'src/node_win32_etw_provider-inl.h',
273             'src/node_win32_etw_provider.cc',
274             'src/node_dtrace.cc',
275             'tools/msvs/genfiles/node_etw_provider.h',
276             'tools/msvs/genfiles/node_etw_provider.rc',
277           ]
278         } ],
279         [ 'node_use_perfctr=="true"', {
280           'defines': [ 'HAVE_PERFCTR=1' ],
281           'dependencies': [ 'node_perfctr' ],
282           'sources': [
283             'src/node_win32_perfctr_provider.h',
284             'src/node_win32_perfctr_provider.cc',
285             'src/node_counters.cc',
286             'src/node_counters.h',
287             'tools/msvs/genfiles/node_perfctr_provider.rc',
288           ]
289         } ],
290         [ 'v8_postmortem_support=="true"', {
291           'dependencies': [ 'deps/v8/tools/gyp/v8.gyp:postmortem-metadata' ],
292           'xcode_settings': {
293             'OTHER_LDFLAGS': [
294               '-Wl,-force_load,<(V8_BASE)',
295             ],
296           },
297         }],
298         [ 'node_shared_v8=="false"', {
299           'sources': [
300             'deps/v8/include/v8.h',
301             'deps/v8/include/v8-debug.h',
302           ],
303           'dependencies': [ 'deps/v8/tools/gyp/v8.gyp:v8' ],
304         }],
305
306         [ 'node_shared_zlib=="false"', {
307           'dependencies': [ 'deps/zlib/zlib.gyp:zlib' ],
308         }],
309
310         [ 'node_shared_http_parser=="false"', {
311           'dependencies': [ 'deps/http_parser/http_parser.gyp:http_parser' ],
312         }],
313
314         [ 'node_shared_cares=="false"', {
315           'dependencies': [ 'deps/cares/cares.gyp:cares' ],
316         }],
317
318         [ 'node_shared_libuv=="false"', {
319           'dependencies': [ 'deps/uv/uv.gyp:libuv' ],
320         }],
321
322         [ 'OS=="win"', {
323           'sources': [
324             'src/res/node.rc',
325           ],
326           'defines': [
327             'FD_SETSIZE=1024',
328             # we need to use node's preferred "win32" rather than gyp's preferred "win"
329             'PLATFORM="win32"',
330             '_UNICODE=1',
331           ],
332           'libraries': [ '-lpsapi.lib' ]
333         }, { # POSIX
334           'defines': [ '__POSIX__' ],
335         }],
336         [ 'OS=="mac"', {
337           # linking Corefoundation is needed since certain OSX debugging tools
338           # like Instruments require it for some features
339           'libraries': [ '-framework CoreFoundation' ],
340           'defines!': [
341             'PLATFORM="mac"',
342           ],
343           'defines': [
344             # we need to use node's preferred "darwin" rather than gyp's preferred "mac"
345             'PLATFORM="darwin"',
346           ],
347         }],
348         [ 'OS=="freebsd"', {
349           'libraries': [
350             '-lutil',
351             '-lkvm',
352           ],
353         }],
354         [ 'OS=="solaris"', {
355           'libraries': [
356             '-lkstat',
357             '-lumem',
358           ],
359           'defines!': [
360             'PLATFORM="solaris"',
361           ],
362           'defines': [
363             # we need to use node's preferred "sunos"
364             # rather than gyp's preferred "solaris"
365             'PLATFORM="sunos"',
366           ],
367         }],
368         [ 'OS=="freebsd" or OS=="linux"', {
369           'ldflags': [ '-Wl,-z,noexecstack' ],
370         }],
371         [ 'OS=="sunos"', {
372           'ldflags': [ '-Wl,-M,/usr/lib/ld/map.noexstk' ],
373         }],
374         [
375           'OS in "linux freebsd" and node_shared_v8=="false"', {
376             'ldflags': [
377               '-Wl,--whole-archive <(V8_BASE) -Wl,--no-whole-archive',
378             ],
379         }],
380       ],
381       'msvs_settings': {
382         'VCLinkerTool': {
383           'SubSystem': 1, # /subsystem:console
384         },
385         'VCManifestTool': {
386           'EmbedManifest': 'true',
387           'AdditionalManifestFiles': 'src/res/node.exe.extra.manifest'
388         }
389       },
390     },
391     # generate ETW header and resource files
392     {
393       'target_name': 'node_etw',
394       'type': 'none',
395       'conditions': [
396         [ 'node_use_etw=="true" and node_has_winsdk=="true"', {
397           'actions': [
398             {
399               'action_name': 'node_etw',
400               'inputs': [ 'src/res/node_etw_provider.man' ],
401               'outputs': [
402                 'tools/msvs/genfiles/node_etw_provider.rc',
403                 'tools/msvs/genfiles/node_etw_provider.h',
404                 'tools/msvs/genfiles/node_etw_providerTEMP.BIN',
405               ],
406               'action': [ 'mc <@(_inputs) -h tools/msvs/genfiles -r tools/msvs/genfiles' ]
407             }
408           ]
409         } ]
410       ]
411     },
412     # generate perf counter header and resource files
413     {
414       'target_name': 'node_perfctr',
415       'type': 'none',
416       'conditions': [
417         [ 'node_use_perfctr=="true" and node_has_winsdk=="true"', {
418           'actions': [
419             {
420               'action_name': 'node_perfctr_man',
421               'inputs': [ 'src/res/node_perfctr_provider.man' ],
422               'outputs': [
423                 'tools/msvs/genfiles/node_perfctr_provider.h',
424                 'tools/msvs/genfiles/node_perfctr_provider.rc',
425                 'tools/msvs/genfiles/MSG00001.BIN',
426               ],
427               'action': [ 'ctrpp <@(_inputs) '
428                           '-o tools/msvs/genfiles/node_perfctr_provider.h '
429                           '-rc tools/msvs/genfiles/node_perfctr_provider.rc'
430               ]
431             },
432           ],
433         } ]
434       ]
435     },
436     {
437       'target_name': 'node_js2c',
438       'type': 'none',
439       'toolsets': ['host'],
440       'actions': [
441         {
442           'action_name': 'node_js2c',
443           'inputs': [
444             '<@(library_files)',
445             './config.gypi',
446           ],
447           'outputs': [
448             '<(SHARED_INTERMEDIATE_DIR)/node_natives.h',
449           ],
450           'conditions': [
451             [ 'node_use_dtrace=="false" and node_use_etw=="false"', {
452               'inputs': [ 'src/notrace_macros.py' ]
453             }],
454             [ 'node_use_perfctr=="false"', {
455               'inputs': [ 'src/perfctr_macros.py' ]
456             }]
457           ],
458           'action': [
459             '<(python)',
460             'tools/js2c.py',
461             '<@(_outputs)',
462             '<@(_inputs)',
463           ],
464         },
465       ],
466     }, # end node_js2c
467     {
468       'target_name': 'node_dtrace_header',
469       'type': 'none',
470       'conditions': [
471         [ 'node_use_dtrace=="true"', {
472           'actions': [
473             {
474               'action_name': 'node_dtrace_header',
475               'inputs': [ 'src/node_provider.d' ],
476               'outputs': [ '<(SHARED_INTERMEDIATE_DIR)/node_provider.h' ],
477               'action': [ 'dtrace', '-h', '-xnolibs', '-s', '<@(_inputs)',
478                 '-o', '<@(_outputs)' ]
479             }
480           ]
481         } ]
482       ]
483     },
484     {
485       'target_name': 'node_mdb',
486       'type': 'none',
487       'conditions': [
488         [ 'node_use_mdb=="true"',
489           {
490             'dependencies': [ 'deps/mdb_v8/mdb_v8.gyp:mdb_v8' ],
491             'actions': [
492               {
493                 'action_name': 'node_mdb',
494                 'inputs': [ '<(PRODUCT_DIR)/obj.target/deps/mdb_v8/mdb_v8.so' ],
495                 'outputs': [ '<(PRODUCT_DIR)/obj.target/node/src/node_mdb.o' ],
496                 'conditions': [
497                   [ 'target_arch=="ia32"', {
498                     'action': [ 'elfwrap', '-o', '<@(_outputs)', '<@(_inputs)' ],
499                   } ],
500                   [ 'target_arch=="x64"', {
501                     'action': [ 'elfwrap', '-64', '-o', '<@(_outputs)', '<@(_inputs)' ],
502                   } ],
503                 ],
504               },
505             ],
506           },
507         ],
508       ],
509     },
510     {
511       'target_name': 'node_dtrace_provider',
512       'type': 'none',
513       'conditions': [
514         [ 'node_use_dtrace=="true" and OS!="mac" and OS!="linux"', {
515           'actions': [
516             {
517               'action_name': 'node_dtrace_provider_o',
518               'inputs': [
519                 '<(OBJ_DIR)/libuv/deps/uv/src/unix/core.o',
520                 '<(OBJ_DIR)/node/src/node_dtrace.o',
521               ],
522               'outputs': [
523                 '<(OBJ_DIR)/node/src/node_dtrace_provider.o'
524               ],
525               'action': [ 'dtrace', '-G', '-xnolibs', '-s', 'src/node_provider.d',
526                 '-s', 'deps/uv/src/unix/uv-dtrace.d', '<@(_inputs)',
527                 '-o', '<@(_outputs)' ]
528             }
529           ]
530         }],
531         [ 'node_use_dtrace=="true" and OS=="linux"', {
532           'actions': [
533             {
534               'action_name': 'node_dtrace_provider_o',
535               'inputs': [ 'src/node_provider.d' ],
536               'outputs': [
537                 '<(SHARED_INTERMEDIATE_DIR)/node_dtrace_provider.o'
538               ],
539               'action': [
540                 'dtrace', '-C', '-G', '-s', '<@(_inputs)', '-o', '<@(_outputs)'
541               ],
542             },
543             {
544               'action_name': 'libuv_dtrace_provider_o',
545               'inputs': [ 'deps/uv/src/unix/uv-dtrace.d' ],
546               'outputs': [
547                 '<(SHARED_INTERMEDIATE_DIR)/libuv_dtrace_provider.o'
548               ],
549               'action': [
550                 'dtrace', '-C', '-G', '-s', '<@(_inputs)', '-o', '<@(_outputs)'
551               ],
552             },
553           ],
554         }],
555       ]
556     },
557     {
558       'target_name': 'node_dtrace_ustack',
559       'type': 'none',
560       'conditions': [
561         [ 'node_use_dtrace=="true" and OS!="mac" and OS!="linux"', {
562           'actions': [
563             {
564               'action_name': 'node_dtrace_ustack_constants',
565               'inputs': [
566                 '<(V8_BASE)'
567               ],
568               'outputs': [
569                 '<(SHARED_INTERMEDIATE_DIR)/v8constants.h'
570               ],
571               'action': [
572                 'tools/genv8constants.py',
573                 '<@(_outputs)',
574                 '<@(_inputs)'
575               ]
576             },
577             {
578               'action_name': 'node_dtrace_ustack',
579               'inputs': [
580                 'src/v8ustack.d',
581                 '<(SHARED_INTERMEDIATE_DIR)/v8constants.h'
582               ],
583               'outputs': [
584                 '<(OBJ_DIR)/node/src/node_dtrace_ustack.o'
585               ],
586               'conditions': [
587                 [ 'target_arch=="ia32"', {
588                   'action': [
589                     'dtrace', '-32', '-I<(SHARED_INTERMEDIATE_DIR)', '-Isrc',
590                     '-C', '-G', '-s', 'src/v8ustack.d', '-o', '<@(_outputs)',
591                   ]
592                 } ],
593                 [ 'target_arch=="x64"', {
594                   'action': [
595                     'dtrace', '-64', '-I<(SHARED_INTERMEDIATE_DIR)', '-Isrc',
596                     '-C', '-G', '-s', 'src/v8ustack.d', '-o', '<@(_outputs)',
597                   ]
598                 } ],
599               ]
600             },
601           ]
602         } ],
603       ]
604     },
605     {
606       'target_name': 'specialize_node_d',
607       'type': 'none',
608       'conditions': [
609         [ 'node_use_dtrace=="true"', {
610           'actions': [
611             {
612               'action_name': 'specialize_node_d',
613               'inputs': [
614                 'src/node.d'
615               ],
616               'outputs': [
617                 '<(PRODUCT_DIR)/node.d',
618               ],
619               'action': [
620                 'tools/specialize_node_d.py',
621                 '<@(_outputs)',
622                 '<@(_inputs)',
623                 '<@(OS)',
624                 '<@(target_arch)',
625               ],
626             },
627           ],
628         } ],
629       ]
630     }
631   ] # end targets
632 }