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 ifeq ($(STRAP),strap) 50 LDFLAGS += $(SYSLIBDIRS:%=-R$(DESTDIR)/%) 51 endif 52 53 AUTOCONF_OPTS += \ 54 --with-dtrace \ 55 --openssl-use-sys \ 56 --openssl-libpath=$(DESTDIR)/lib \ 57 --openssl-includes=$(DESTDIR)/usr/include \ 58 --shared-openssl-libname=sunw_crypto,sunw_ssl \ 59 --shared-zlib \ 60 --shared-zlib-libpath=$(DESTDIR)/lib \ 61 --shared-zlib-includes=$(DESTDIR)/usr/include \ 62 --prefix=/usr/node/$(MAJOR_VER) 63 64 AUTOCONF_CFLAGS = CFLAGS="$(CPPFLAGS) $(CFLAGS)" 65 AUTOCONF_LIBS = 66 AUTOCONF_ENV += CXXFLAGS="$(CPPFLAGS) $(CFLAGS)" 67 68 # 69 # Jump through hoops to get the locally-run build tools to build with the 70 # correct compiler and without referencing anything in the proto area. 71 # This is needed because the proto area may contain libraries that are not 72 # present or are of different versions on the build machine itself. A 73 # patch to the python configure program is also required to make this work. 74 # 75 AUTOCONF_ENV += LDFLAGS.host="-Wl,-i" 76 AUTOCONF_ENV += CXX.host="$(BASE)/wrapper $(GXX.host)" 77 AUTOCONF_ENV += CC.host="$(BASE)/wrapper $(GCC.host)" 78 AUTOCONF_ENV += CXX_host="$(BASE)/wrapper $(GXX.host)" 79 AUTOCONF_ENV += CC_host="$(BASE)/wrapper $(GCC.host)" 80 AUTOCONF_ENV += LINK.host="$(BASE)/wrapper $(GXX.host)" 81 82 OVERRIDES += $(AUTOCONF_ENV) 83 84 AUTOCONF_OUT = build/default/config.h 85 86 PATCHES = Patches/* 87 CLEANFILES += genversionjs 88 89 all: all_autoconf 90 91 all_autoconf: wrapper 92 93 # 94 # We build a host tool against the installed header so that we can spew a 95 # JavaScript file containing the version of the installed node.js binary. 96 # 97 genversionjs: genversionjs.c install_autoconf 98 $(GCC.host) -o $@ -include $(NODE_ROOT)/include/node/node_version.h $< 99 100 # 101 # Ready for another hack? This wrapper "translates" target gcc options into 102 # ones suitable for running on the host during the build. This is needed 103 # because node's build system doesn't have any way to pass different options 104 # for the host and taget, and tries to build host tools as part of the build. 105 # Hooray, node! 106 # 107 wrapper: wrapper.c 108 $(GCC.host) -Wall -Wextra -Werror -O2 -o $@ $< 109 110 # - platform_node_version.js is autogenerated with the current node version 111 # - we move man pages as we want them in /usr/node/0.8/man 112 install: install_autoconf genversionjs 113 mkdir -p $(NODE_ROOT)/node_modules 114 ./genversionjs > $(VERSIONJS) 115 rm -rf $(NODE_ROOT)/man 116 mv $(NODE_ROOT)/share/man $(NODE_ROOT)/ 117 118 include ../Makefile.targ