/
Makefile
118 lines (100 loc) · 4.09 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License, Version 1.0 only
# (the "License"). You may not use this file except in compliance
# with the License.
#
# You can obtain a copy of the license at COPYING
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at COPYING.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
# Copyright (c) 2013, Joyent, Inc. All rights reserved.
#
MAJOR_VER = 0.8
VER = node-v0.8.20
include ../Makefile.defs
NODE_ROOT = $(DESTDIR)/usr/node/$(MAJOR_VER)
VERSIONJS = $(NODE_ROOT)/node_modules/platform_node_version.js
CFLAGS += -Wno-unknown-pragmas
#
# Node's build system is super broken. If we pass it LIBS at configure time,
# it ignores it. If we pass it LIBS at make time, it completely replaces all
# libraries, including those the build system itself would normally add.
# So our only option is to add this to LDFLAGS, which has to be passed at
# build time... including for the install target, because the generated
# makefiles have missing dependencies and rebuild stuff when installing.
# This has to be the most complicated, baroque, pointlessly wrong way
# imaginable to build something with a few dozen source files. The next time
# you are here reading this and trying to work around the next piece of
# Node build stupidity, just stop. Rip all this out, write a simple makefile,
# and copy it in at unpack time like we do for bzip2.
#
LDFLAGS += -lumem
ifeq ($(STRAP),strap)
LDFLAGS += $(SYSLIBDIRS:%=-R$(DESTDIR)/%)
endif
AUTOCONF_OPTS += \
--with-dtrace \
--openssl-use-sys \
--openssl-libpath=$(DESTDIR)/lib \
--openssl-includes=$(DESTDIR)/usr/include \
--shared-openssl-libname=sunw_crypto,sunw_ssl \
--shared-zlib \
--shared-zlib-libpath=$(DESTDIR)/lib \
--shared-zlib-includes=$(DESTDIR)/usr/include \
--prefix=/usr/node/$(MAJOR_VER)
AUTOCONF_CFLAGS = CFLAGS="$(CPPFLAGS) $(CFLAGS)"
AUTOCONF_LIBS =
AUTOCONF_ENV += CXXFLAGS="$(CPPFLAGS) $(CFLAGS)"
#
# Jump through hoops to get the locally-run build tools to build with the
# correct compiler and without referencing anything in the proto area.
# This is needed because the proto area may contain libraries that are not
# present or are of different versions on the build machine itself. A
# patch to the python configure program is also required to make this work.
#
AUTOCONF_ENV += LDFLAGS.host="-Wl,-i"
AUTOCONF_ENV += CXX.host="$(BASE)/wrapper $(GXX.host)"
AUTOCONF_ENV += CC.host="$(BASE)/wrapper $(GCC.host)"
AUTOCONF_ENV += CXX_host="$(BASE)/wrapper $(GXX.host)"
AUTOCONF_ENV += CC_host="$(BASE)/wrapper $(GCC.host)"
AUTOCONF_ENV += LINK.host="$(BASE)/wrapper $(GXX.host)"
OVERRIDES += $(AUTOCONF_ENV)
AUTOCONF_OUT = build/default/config.h
PATCHES = Patches/*
CLEANFILES += genversionjs
all: all_autoconf
all_autoconf: wrapper
#
# We build a host tool against the installed header so that we can spew a
# JavaScript file containing the version of the installed node.js binary.
#
genversionjs: genversionjs.c install_autoconf
$(GCC.host) -o $@ -include $(NODE_ROOT)/include/node/node_version.h $<
#
# Ready for another hack? This wrapper "translates" target gcc options into
# ones suitable for running on the host during the build. This is needed
# because node's build system doesn't have any way to pass different options
# for the host and taget, and tries to build host tools as part of the build.
# Hooray, node!
#
wrapper: wrapper.c
$(GCC.host) -Wall -Wextra -Werror -O2 -o $@ $<
# - platform_node_version.js is autogenerated with the current node version
# - we move man pages as we want them in /usr/node/0.8/man
install: install_autoconf genversionjs
mkdir -p $(NODE_ROOT)/node_modules
./genversionjs > $(VERSIONJS)
rm -rf $(NODE_ROOT)/man
mv $(NODE_ROOT)/share/man $(NODE_ROOT)/
include ../Makefile.targ