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) 2013, Joyent, Inc.  All rights reserved.
  22 #
  23 
  24 MAJOR_VER =     0.8
  25 VER =   node-v0.8.20
  26 
  27 include ../Makefile.defs
  28 
  29 NODE_ROOT =     $(DESTDIR)/usr/node/$(MAJOR_VER)
  30 VERSIONJS =     $(NODE_ROOT)/node_modules/platform_node_version.js
  31 
  32 CFLAGS +=       -Wno-unknown-pragmas
  33 
  34 #
  35 # Node's build system is super broken.  If we pass it LIBS at configure time,
  36 # it ignores it.  If we pass it LIBS at make time, it completely replaces all
  37 # libraries, including those the build system itself would normally add.
  38 # So our only option is to add this to LDFLAGS, which has to be passed at
  39 # build time... including for the install target, because the generated
  40 # makefiles have missing dependencies and rebuild stuff when installing.
  41 # This has to be the most complicated, baroque, pointlessly wrong way
  42 # imaginable to build something with a few dozen source files.  The next time
  43 # you are here reading this and trying to work around the next piece of
  44 # Node build stupidity, just stop.  Rip all this out, write a simple makefile,
  45 # and copy it in at unpack time like we do for bzip2.
  46 #
  47 LDFLAGS +=      -lumem
  48 
  49 AUTOCONF_OPTS += \
  50         --with-dtrace \
  51         --openssl-use-sys \
  52         --openssl-libpath=$(DESTDIR)/lib \
  53         --openssl-includes=$(DESTDIR)/usr/include \
  54         --shared-openssl-libname=sunw_crypto,sunw_ssl \
  55         --shared-zlib \
  56         --shared-zlib-libpath=$(DESTDIR)/lib \
  57         --shared-zlib-includes=$(DESTDIR)/usr/include \
  58         --prefix=/usr/node/$(MAJOR_VER)
  59 
  60 AUTOCONF_CFLAGS =       CFLAGS="$(CPPFLAGS) $(CFLAGS)"
  61 AUTOCONF_LIBS =
  62 AUTOCONF_ENV +=         CXXFLAGS="$(CPPFLAGS) $(CFLAGS)"
  63 
  64 #
  65 # Jump through hoops to get the locally-run build tools to build with the
  66 # correct compiler and without referencing anything in the proto area.
  67 # This is needed because the proto area may contain libraries that are not
  68 # present or are of different versions on the build machine itself.  A
  69 # patch to the python configure program is also required to make this work.
  70 #
  71 AUTOCONF_ENV +=         LDFLAGS.host="-Wl,-i"
  72 AUTOCONF_ENV +=         CXX.host="$(BASE)/wrapper $(GXX.host)"
  73 AUTOCONF_ENV +=         CC.host="$(BASE)/wrapper $(GCC.host)"
  74 AUTOCONF_ENV +=         CXX_host="$(BASE)/wrapper $(GXX.host)"
  75 AUTOCONF_ENV +=         CC_host="$(BASE)/wrapper $(GCC.host)"
  76 AUTOCONF_ENV +=         LINK.host="$(BASE)/wrapper $(GXX.host)"
  77 
  78 OVERRIDES +=    $(AUTOCONF_ENV)
  79 
  80 AUTOCONF_OUT =  build/default/config.h
  81 
  82 PATCHES =       Patches/*
  83 CLEANFILES +=   genversionjs
  84 
  85 all: all_autoconf
  86 
  87 all_autoconf: wrapper
  88 
  89 #
  90 # We build a host tool against the installed header so that we can spew a
  91 # JavaScript file containing the version of the installed node.js binary.
  92 #
  93 genversionjs: genversionjs.c install_autoconf
  94         $(GCC.host) -o $@ -include $(NODE_ROOT)/include/node/node_version.h $<
  95 
  96 #
  97 # Ready for another hack?  This wrapper "translates" target gcc options into
  98 # ones suitable for running on the host during the build.  This is needed
  99 # because node's build system doesn't have any way to pass different options
 100 # for the host and taget, and tries to build host tools as part of the build.
 101 # Hooray, node!
 102 #
 103 wrapper: wrapper.c
 104         $(GCC.host) -Wall -Wextra -Werror -O2 -o $@ $<
 105 
 106 # - platform_node_version.js is autogenerated with the current node version
 107 # - we move man pages as we want them in /usr/node/0.8/man
 108 install: install_autoconf genversionjs
 109         mkdir -p $(NODE_ROOT)/node_modules
 110         ./genversionjs > $(VERSIONJS)
 111         rm -rf $(NODE_ROOT)/man
 112         mv $(NODE_ROOT)/share/man $(NODE_ROOT)/
 113 
 114 include ../Makefile.targ