1 #
   2 # Copyright (c) 2012 Joyent, Inc.  All rights reserved.
   3 #
   4 
   5 #
   6 # V8PLUS and PREFIX_NODE must be defined in consumer's makefiles.
   7 # See documentation.
   8 #
   9 #PREFIX_NODE := $(shell dirname `bash -c 'hash node; hash -t node'`)/..
  10 #V8PLUS :=      $(shell $(PREFIX_NODE)/bin/node -e 'require("v8plus");')
  11 
  12 CC =            gcc
  13 CXX =           g++
  14 CTFCONVERT =    /opt/onbld/bin/i386/ctfconvert
  15 CTFMERGE =      /opt/onbld/bin/i386/ctfmerge
  16 CTF_LABEL =     v8plus_0.0.1
  17 
  18 NODE_EXEC =     $(PREFIX_NODE)/bin/node
  19 
  20 MODULE_DIR =    ../lib
  21 
  22 DEBUG_FLAGS =   -g
  23 WARN_FLAGS =    -Wall -Wextra -Werror
  24 PIC_FLAGS =     -fPIC
  25 OPT_FLAGS =     -O2
  26 C_STDFLAGS =    -std=c99
  27 CXX_STDFLAGS =  -std=c++0x
  28 
  29 CFLAGS =        $(DEBUG_FLAGS) \
  30                 $(WARN_FLAGS) \
  31                 $(PIC_FLAGS) \
  32                 $(OPT_FLAGS) \
  33                 $(C_STDFLAGS)
  34 CXXFLAGS =      $(DEBUG_FLAGS) \
  35                 $(WARN_FLAGS) \
  36                 $(PIC_FLAGS) \
  37                 $(OPT_FLAGS) \
  38                 $(CXX_STDFLAGS)
  39 
  40 STD_DEFS =      -D_GNU_SOURCE
  41 NODE_DEFS =     -DBUILDING_NODE_EXTENSION
  42 LF64_DEFS =     -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
  43 PIC_DEFS =      -DPIC
  44 NODE_INCS =     -isystem $(PREFIX_NODE)/include/node -I. -I$(V8PLUS)
  45 
  46 CPPFLAGS =      $(STD_DEFS) $(NODE_DEFS) $(LF64_DEFS) $(PIC_DEFS) $(NODE_INCS)
  47 CXXPPFLAGS =    $(CPPFLAGS)
  48 
  49 SHARED_FLAGS =  -shared
  50 ZTEXT =         -Wl,-ztext
  51 ZDEFS =         -Wl,-zdefs
  52 NODE_LIBDIR =   -L$(PREFIX_NODE)/lib
  53 MAPFILES =      $(MAPFILE)
  54 
  55 LDFLAGS =       $(SHARED_FLAGS) $(ZTEXT) $(ZDEFS) $(NODE_LIBDIR)
  56 LDFLAGS +=      $(MAPFILES:%=-Wl,-M,%)
  57 LIBS =          -lnvpair
  58 
  59 OBJS.c =        $(SRCS:.c=.o)
  60 OBJS =          $(OBJS.c:.cc=.o)
  61 
  62 OBJS +=         \
  63                 v8plus_csup.o \
  64                 v8plus_errno.o \
  65                 v8plus_objectwrap.o \
  66                 v8plus_subr.o
  67 
  68 GENERRNO_JS =   $(V8PLUS)/generrno.js
  69 GENERRNO =      NODE_PATH=$(V8PLUS)/node_modules \
  70                     $(NODE_EXEC) $(GENERRNO_JS)
  71 
  72 ERRNO_H =       v8plus_errno.h
  73 ERRNO_C =       v8plus_errno.c
  74 
  75 MAPFILE =       mapfile_node
  76 
  77 CTFCONVERT.o =  $(CTFCONVERT) -l $(CTF_LABEL) $@
  78 CTFMERGE.node = $(CTFMERGE) -l $(CTF_LABEL) -o $@ $(OBJS)