1 #
   2 # CDDL HEADER START
   3 #
   4 # The contents of this file are subject to the terms of the
   5 # Common Development and Distribution License, Version 1.0 only
   6 # (the "License").  You may not use this file except in compliance
   7 # with the License.
   8 #
   9 # You can obtain a copy of the license at COPYING
  10 # See the License for the specific language governing permissions
  11 # and limitations under the License.
  12 #
  13 # When distributing Covered Code, include this CDDL HEADER in each
  14 # file and include the License file at COPYING.
  15 # If applicable, add the following below this CDDL HEADER, with the
  16 # fields enclosed by brackets "[]" replaced with your own identifying
  17 # information: Portions Copyright [yyyy] [name of copyright owner]
  18 #
  19 # CDDL HEADER END
  20 #
  21 # Copyright (c) 2012, Joyent, Inc.
  22 #
  23 
  24 BASE =          $(PWD)
  25 DESTDIR =       $(BASE)/../proto
  26 
  27 ifeq ($(shell uname -s),Darwin)
  28 MAKE =          make
  29 PATH =          $(DESTDIR)/usr/bin:/bin:/usr/bin:/usr/sbin:/sbin:/opt/local/bin
  30 else
  31 MAKE =          gmake
  32 PATH =          $(DESTDIR)/usr/bin:/usr/bin:/usr/sbin:/sbin:/opt/local/bin
  33 endif
  34 
  35 PARALLEL =      -j128
  36 GCC =           $(DESTDIR)/usr/bin/gcc
  37 GXX =           $(DESTDIR)/usr/bin/g++
  38 
  39 SYSINCDIRS =    /usr/include
  40 SYSLIBDIRS =    /usr/lib /lib
  41 
  42 CPPFLAGS =      $(SYSINCDIRS:%=-isystem $(DESTDIR)/%)
  43 LDFLAGS =       $(SYSLIBDIRS:%=-L$(DESTDIR)/%) -Wl,-zassert-deflib \
  44                     -Wl,-zfatal-warnings
  45 
  46 PREFIX_NODE =   $(DESTDIR)/usr/node/0.8
  47 
  48 DEBUG_FLAGS =   -g
  49 WARN_FLAGS =    -Wall -Wextra -Werror
  50 PIC_FLAGS =     -fPIC
  51 OPT_FLAGS =     -O2
  52 
  53 NODE_CFLAGS =   $(DEBUG_FLAGS) $(WARN_FLAGS) $(PIC_FLAGS) $(OPT_FLAGS)
  54 
  55 STD_DEFS =      -D_GNU_SOURCE
  56 NODE_DEFS =     -DBUILDING_NODE_EXTENSION
  57 LF64_DEFS =     -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
  58 PIC_DEFS =      -DPIC
  59 NODE_INCS =     -isystem $(PREFIX_NODE)/include/node -I.
  60 
  61 NODE_CPPFLAGS = $(STD_DEFS) $(NODE_DEFS) $(LF64_DEFS) $(PIC_DEFS) $(NODE_INCS)
  62 
  63 SHARED_FLAGS =  -shared
  64 ZTEXT =         -Wl,-ztext
  65 NODE_LIBDIR =   -L$(PREFIX_NODE)/lib
  66 
  67 NODE_LDFLAGS =  $(SHARED_FLAGS) $(ZTEXT) $(NODE_LIBDIR)
  68 
  69 SUBDIR_CC =             CC="$(GCC)"
  70 SUBDIR_CXX =            CXX="$(GXX)"
  71 SUBDIR_CPPFLAGS =       CPPFLAGS="$(CPPFLAGS)"
  72 SUBDIR_CFLAGS =         CFLAGS="$(CFLAGS)"
  73 SUBDIR_CXXFLAGS =       CXXFLAGS="$(CXXFLAGS)"
  74 SUBDIR_LDFLAGS =        LDFLAGS="$(LDFLAGS)"
  75 SUBDIR_LIBS =           LIBS="$(LIBS)"
  76 SUBDIR_MAKE =           MAKE="$(MAKE)"
  77 SUBDIR_DESTDIR =        DESTDIR="$(DESTDIR)"
  78 
  79 SUBDIR_ENV = \
  80         $(SUBDIR_CC) \
  81         $(SUBDIR_CXX) \
  82         $(SUBDIR_CPPFLAGS) \
  83         $(SUBDIR_CFLAGS) \
  84         $(SUBDIR_CXXFLAGS) \
  85         $(SUBDIR_LDFLAGS) \
  86         $(SUBDIR_LIBS) \
  87         $(SUBDIR_MAKE) \
  88         $(SUBDIR_DESTDIR)