1 #
   2 # Copyright (c) 2012, Joyent, Inc.  All rights reserved.
   3 #
   4 
   5 include Makefile.defs
   6 
   7 #
   8 # ROOT is used only when building and running the below tools.
   9 #
  10 ROOT =          $(PWD)/..
  11 JSSTYLE =       $(ROOT)/tools/jsstyle/jsstyle
  12 JSLINT =        $(ROOT)/tools/javascriptlint/build/install/jsl
  13 CSTYLE =        $(ROOT)/tools/cstyle
  14 
  15 #
  16 # Tool options
  17 #
  18 JSSTYLE_OPTS = -o indent=4,strict-indent=1,doxygen,unparenthesized-return=0,continuation-at-front=1,leading-right-paren-ok=1
  19 
  20 JSSTYLE_OLDSKOOL_OPTS =
  21 
  22 #
  23 # Installation configuration.  Note that DESTDIR in particular is also
  24 # assumed to contain various build tools, headers, libraries, and other
  25 # artifacts of the platform build from which we incorporate runtime
  26 # dependency information.  The default DESTDIR is for standalone builds
  27 # only (i.e., without the rest of the platform) and is unlikely to work
  28 # without extra effort; it is overridden when make is invoked in this
  29 # subdirectory.
  30 #
  31 DESTDIR =               ../proto
  32 
  33 #
  34 # DESTNAME is used for the manifest target.  We set it to something
  35 # obvious here so that if it's not set, the manifest target doesn't do
  36 # bad things.
  37 #
  38 DESTNAME =      live.manifest
  39 
  40 SMARTDCBINDIR = $(DESTDIR)/smartdc/bin
  41 SMARTDCLIBDIR = $(DESTDIR)/smartdc/lib
  42 
  43 #
  44 # Per-target variable definitions go here.  See Makefile.defs and the targets
  45 # below and in Makefile.targ to see what's useful to append to or override.
  46 # If you need to create your own target anyway, you can either modify
  47 # variables here or incorporate your changes directly into the target; we
  48 # prefer modifying the generic variable to the extent that the change fits
  49 # naturally with an existing one so that we can pick up general changes in
  50 # Makefile.defs even for custom targets.
  51 #
  52 bootparams :    LIBS +=         -ldevinfo
  53 bootparams :    WARN_FLAGS +=   -Wno-unused
  54 diskinfo :      LIBS +=         -ldladm -ldiskmgt -lnvpair
  55 zfs_recv :      LIBS +=         -lsocket
  56 zfs_send :      LIBS +=         -lsocket
  57 vmbundle :      CPPFLAGS +=     -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
  58 sdc-on-tty :    CFLAGS +=       $(OPT_FLAG)
  59 zoneevent :     LIBS +=         -lnvpair -lsysevent
  60 
  61 # These files will get run through jsstyle and jslint on 'make check'
  62 JS_CHECK_TARGETS=\
  63   filewait.js \
  64         node_modules/{system,onlyif}.js \
  65         vm/sbin/*.js \
  66         vm/node_modules/{qmp,VM,dladm}.js \
  67         img/lib/*.js \
  68         img/sbin/imgadm \
  69         vm/lib/metadata/*.js
  70 
  71 JS_CHECK_OLDSKOOL_TARGETS = \
  72         disklayout.js \
  73         mkzpool.js \
  74         node_modules/disklayout.js
  75 
  76 # These files will get run through cstyle on 'make check'
  77 C_CHECK_TARGETS=\
  78         qemu-exec.c \
  79         vmunbundle.c \
  80         zfs_recv.c \
  81         zfs_send.c \
  82         zoneevent.c
  83 
  84 #
  85 # Generic flags we apply by default to everything.
  86 #
  87 CFLAGS +=       $(WARN_FLAGS)
  88 CXXFLAGS =      $(CFLAGS)
  89 
  90 #
  91 # Node native add-on patterns.  For add-ons with a single source file in the
  92 # root of the add-on tree and no headers of its own, follow the EXPAT.NODE
  93 # pattern here and below in the targets.  More complex examples (source
  94 # subdirectory, headers, multiple C++ sources) follow; see associated comments
  95 # if you are looking for a pattern to copy.
  96 #
  97 EXPAT_OBJDIR =  node-expat/build/Release
  98 EXPAT.NODE =    $(EXPAT_OBJDIR)/node-expat.node
  99 
 100 $(EXPAT.NODE) : WARN_FLAGS +=   -Wno-unused
 101 $(EXPAT.NODE) : CPPFLAGS +=     $(NODE_CPPFLAGS)
 102 $(EXPAT.NODE) : CXXFLAGS +=     $(NODE_CFLAGS)
 103 $(EXPAT.NODE) : LDFLAGS +=      $(NODE_LDFLAGS)
 104 $(EXPAT.NODE) : LIBS +=         -lexpat
 105 
 106 #
 107 # The kstat Node add-on follows the same pattern as EXPAT.NODE.
 108 #
 109 KSTAT_OBJDIR =  node-kstat/build/Release
 110 KSTAT.NODE =    $(KSTAT_OBJDIR)/kstat.node
 111 
 112 $(KSTAT.NODE) : WARN_FLAGS +=   -Wno-unused -Wno-write-strings -Wno-sign-compare
 113 $(KSTAT.NODE) : CPPFLAGS +=     $(NODE_CPPFLAGS)
 114 $(KSTAT.NODE) : CXXFLAGS +=     $(NODE_CFLAGS)
 115 $(KSTAT.NODE) : LDFLAGS +=      $(NODE_LDFLAGS)
 116 $(KSTAT.NODE) : LIBS +=         -lkstat
 117 
 118 #
 119 # The lockfd Node add-on is based on v8plus, which has its own system of
 120 # Makefiles.
 121 #
 122 LOCKFD_BINDING.NODE =           node-lockfd/lib/lockfd_binding.node
 123 
 124 LOCKFD_SRC_DIR =                $(PWD)/node-lockfd/src
 125 LOCKFD_V8PLUS_DIR =             $(PWD)/node-lockfd/node_modules/v8plus
 126 
 127 #
 128 # The dtrace-provider add-on uses a combination of C, assembly and C++ files in
 129 # multiple directories.
 130 #
 131 DTRACE_PROVIDER_OBJDIR =        node-dtrace-provider/build/Release
 132 DTRACE_PROVIDER_SRCDIR =        node-dtrace-provider
 133 DTRACE_PROVIDER.NODE =          $(DTRACE_PROVIDER_OBJDIR)/dtrace-provider.node
 134 
 135 DTRACE_PROVIDER_SRCS += \
 136                         dtrace_probe.cc \
 137                         dtrace_provider.cc
 138 
 139 DTRACE_PROVIDER_LIBUSDT_SRCS += \
 140                         libusdt/usdt.c \
 141                         libusdt/usdt_dof_file.c \
 142                         libusdt/usdt_probe.c \
 143                         libusdt/usdt_dof.c \
 144                         libusdt/usdt_dof_sections.c
 145 
 146 DTRACE_PROVIDER_LIBUSDT_ASM_SRCS += \
 147                         libusdt/usdt_tracepoints_i386.s
 148 
 149 DTRACE_PROVIDER_HDRS += \
 150                         node-dtrace-provider/dtrace_provider.h \
 151                         node-dtrace-provider/libusdt/usdt_internal.h \
 152                         node-dtrace-provider/libusdt/usdt.h
 153 
 154 DTRACE_PROVIDER_OBJS += \
 155                         $(DTRACE_PROVIDER_SRCS:%.cc=$(DTRACE_PROVIDER_OBJDIR)/%.o) \
 156                         $(DTRACE_PROVIDER_LIBUSDT_SRCS:%.c=$(DTRACE_PROVIDER_OBJDIR)/%.o) \
 157                         $(DTRACE_PROVIDER_LIBUSDT_ASM_SRCS:%.s=$(DTRACE_PROVIDER_OBJDIR)/%.o)
 158 
 159 $(DTRACE_PROVIDER.NODE) :       WARN_FLAGS +=   -Wno-unused -Wno-sign-compare
 160 $(DTRACE_PROVIDER.NODE) :       CFLAGS +=       $(NODE_CFLAGS)
 161 $(DTRACE_PROVIDER.NODE) :       CPPFLAGS +=     \
 162                                         $(NODE_CPPFLAGS) \
 163                                         -Inode-dtrace-provider/libusdt
 164 $(DTRACE_PROVIDER.NODE) :       CXXFLAGS +=     $(NODE_CFLAGS)
 165 $(DTRACE_PROVIDER.NODE) :       LDFLAGS +=      $(NODE_LDFLAGS)
 166 
 167 CLEANFILES +=   $(DTRACE_PROVIDER.NODE) $(DTRACE_PROVIDER_OBJS)
 168 
 169 #
 170 # The microtime Node add-on follows the same pattern as EXPAT.NODE.
 171 #
 172 MICROTIME_OBJDIR =      node-microtime/build/Release
 173 MICROTIME.NODE =        $(MICROTIME_OBJDIR)/microtime.node
 174 
 175 $(MICROTIME.NODE) :     WARN_FLAGS +=   -Wno-unused -Wno-write-strings -Wno-sign-compare
 176 $(MICROTIME.NODE) :     CPPFLAGS +=     $(NODE_CPPFLAGS)
 177 $(MICROTIME.NODE) :     CXXFLAGS +=     $(NODE_CFLAGS)
 178 $(MICROTIME.NODE) :     LDFLAGS +=      $(NODE_LDFLAGS)
 179 
 180 
 181 #
 182 # The sqlite3 add-on uses a combination of C + C++ files in multiple
 183 # directories, and has multiple header directories as well.
 184 #
 185 SQLITE3_OBJDIR =        node-sqlite3/build/Release
 186 SQLITE3_SRCDIR =        node-sqlite3/src
 187 SQLITE3_LIBSRCDIR =     node-sqlite3/deps/sqlite3
 188 SQLITE3_BINDINGS.NODE = $(SQLITE3_OBJDIR)/node_sqlite3.node
 189 
 190 SQLITE3_SRCS += \
 191         database.cc \
 192         node_sqlite3.cc \
 193         statement.cc
 194 
 195 SQLITE3_LIBSRCS +=      sqlite3.c
 196 
 197 SQLITE3_NODEHDRS += \
 198         async.h \
 199         macros.h \
 200         statement.h \
 201         threading.h
 202 
 203 SQLITE3_LIBHDRS += \
 204         sqlite3.h \
 205         sqlite3ext.h
 206 
 207 SQLITE3_OBJS =          \
 208                         $(SQLITE3_SRCS:%.cc=$(SQLITE3_OBJDIR)/%.o) \
 209                         $(SQLITE3_LIBSRCS:%.c=$(SQLITE3_OBJDIR)/%.o)
 210 SQLITE3_HDRS =          \
 211                         $(SQLITE3_NODEHDRS:%=$(SQLITE3_SRCDIR)/%) \
 212                         $(SQLITE3_LIBHDRS:%=$(SQLITE3_LIBSRCDIR)/%)
 213 CLEANFILES +=           $(SQLITE3_OBJS)
 214 
 215 SQLITE3_FLAGS = \
 216                                 -fdata-sections \
 217                                 -ffunction-sections \
 218                                 -fno-omit-frame-pointer \
 219                                 -fno-strict-aliasing \
 220                                 -fno-exceptions
 221 
 222 $(SQLITE3_BINDINGS.NODE) :      WARN_FLAGS =    -Wall -Werror
 223 $(SQLITE3_BINDINGS.NODE) :      CPPFLAGS += \
 224                                 $(NODE_CPPFLAGS) \
 225                                 -I$(SQLITE3_LIBSRCDIR) \
 226                                 -D_SQLITE_THREADSAFE=1 \
 227                                 -D_SQLITE_ENABLE_FTS3 \
 228                                 -D_SQLITE_ENABLE_RTREE \
 229                                 -D_LARGEFILE_SOURCE \
 230                                 -D_FILE_OFFSET_BITS=64 \
 231                                 -D_REENTRANT \
 232                                 -D_NDEBUG \
 233                                 -D_POSIX_PTHREAD_SEMANTICS
 234 $(SQLITE3_BINDINGS.NODE) :      CFLAGS += \
 235                                 $(NODE_CFLAGS) \
 236                                 $(SQLITE3_FLAGS)
 237 $(SQLITE3_BINDINGS.NODE) :      LDFLAGS += \
 238                                 $(NODE_LDFLAGS) \
 239                                 -Wl,-soname=node_sqlite3.node
 240 $(SQLITE3_BINDINGS.NODE) :      LIBS += -lpthread
 241 
 242 #
 243 # The libuuid Node add-on follows the same pattern as EXPAT.NODE.
 244 #
 245 UUID_OBJDIR =   node-libuuid/build/Release
 246 UUID_SRCDIR =   node-libuuid/src
 247 UUID.NODE =     $(UUID_OBJDIR)/uuid.node
 248 
 249 $(UUID.NODE) :  WARN_FLAGS +=   -Wno-unused -Wno-write-strings -Wno-sign-compare
 250 $(UUID.NODE) :  CPPFLAGS +=     $(NODE_CPPFLAGS)
 251 $(UUID.NODE) :  CXXFLAGS +=     $(NODE_CFLAGS)
 252 $(UUID.NODE) :  LDFLAGS +=      $(NODE_LDFLAGS)
 253 $(UUID.NODE) :  LIBS +=         -luuid
 254 
 255 #
 256 # The zsock add-on places its single source file in a subdirectory.
 257 #
 258 ZSOCK_OBJDIR =  node-zsock/build/Release
 259 ZSOCK_SRCDIR =  node-zsock/src
 260 ZSOCK_BINDINGS.NODE =   $(ZSOCK_OBJDIR)/zsock_bindings.node
 261 
 262 $(ZSOCK_BINDINGS.NODE) :        WARN_FLAGS =    -Wall -Werror
 263 $(ZSOCK_BINDINGS.NODE) :        CPPFLAGS += \
 264                                 $(NODE_CPPFLAGS) \
 265                                 -D_REENTRANT \
 266                                 -D_POSIX_PTHREAD_SEMANTICS \
 267                                 -D_XOPEN_SOURCE_EXTENDED=1 \
 268                                 -D__EXTENSIONS__ \
 269                                 -DSunOS
 270 $(ZSOCK_BINDINGS.NODE) :        CXXFLAGS += \
 271                                 $(NODE_CFLAGS) \
 272                                 -std=c++98
 273 $(ZSOCK_BINDINGS.NODE) :        LDFLAGS +=      $(NODE_LDFLAGS)
 274 $(ZSOCK_BINDINGS.NODE) :        LIBS +=         -lsocket -lnsl -lcontract
 275 
 276 #
 277 # The zutil add-on places its multiple source files in a subdirectory, and
 278 # builds them against some headers that it also supplies and needs to depend on.
 279 # Because we must build intermediate object files, this requires a
 280 # different target pattern as well; see below.
 281 #
 282 ZUTIL_OBJDIR =  node-zutil/build/Release
 283 ZUTIL_SRCDIR =  node-zutil/src
 284 ZUTIL_BINDINGS.NODE =   $(ZUTIL_OBJDIR)/zutil_bindings.node
 285 
 286 ZUTIL_SRCS += \
 287         zone.cc \
 288         zonecfg.cc \
 289         zutil_bindings.cc
 290 
 291 ZUTIL_HDRS += \
 292         zone.h \
 293         zonecfg.h \
 294         zutil_common.h
 295 
 296 ZUTIL_BINDINGS_OBJS =   $(ZUTIL_SRCS:%.cc=$(ZUTIL_OBJDIR)/%.o)
 297 ZUTIL_BINDINGS_HDRS =   $(ZUTIL_HDRS:%=$(ZUTIL_SRCDIR)/%)
 298 CLEANFILES +=           $(ZUTIL_BINDINGS_OBJS)
 299 
 300 $(ZUTIL_BINDINGS.NODE) :        WARN_FLAGS +=   -Wno-unused
 301 $(ZUTIL_BINDINGS.NODE) :        CPPFLAGS +=     $(NODE_CPPFLAGS) -DSunOS
 302 $(ZUTIL_BINDINGS.NODE) :        CXXFLAGS +=     $(NODE_CFLAGS)
 303 $(ZUTIL_BINDINGS.NODE) :        LDFLAGS +=      $(NODE_LDFLAGS)
 304 $(ZUTIL_BINDINGS.NODE) :        LIBS +=         -lzonecfg
 305 
 306 #
 307 # List of targets.  TARGETS, SMARTDC_TARGETS, and SMARTDC_LIB_TARGETS must
 308 # include only those files that are safe to remove when the clean target is
 309 # built.
 310 #
 311 TARGETS = \
 312         bootparams \
 313         diskinfo \
 314         disklayout \
 315         disklist \
 316         disk_size \
 317         mkzpool \
 318         removable_disk \
 319         vmunbundle \
 320         zfs_recv \
 321         zfs_send \
 322         zoneevent \
 323         $(EXPAT.NODE) \
 324         $(DTRACE_PROVIDER.NODE) \
 325         $(KSTAT.NODE) \
 326         $(LOCKFD_BINDING.NODE) \
 327         $(MICROTIME.NODE) \
 328         $(SYSLOG.NODE) \
 329         $(SQLITE3_BINDINGS.NODE) \
 330         $(UUID.NODE) \
 331         $(ZSOCK_BINDINGS.NODE) \
 332         $(ZUTIL_BINDINGS.NODE)
 333 
 334 USR_LIB_TARGETS = \
 335         measure_terminal
 336 
 337 SMARTDC_TARGETS = \
 338         qemu-exec
 339 
 340 SMARTDC_LIB_TARGETS = \
 341         sdc-on-tty
 342 
 343 all: $(TARGETS) $(USR_LIB_TARGETS) sysinfo nictagadm $(SMARTDC_TARGETS) \
 344         $(SMARTDC_LIB_TARGETS)
 345 
 346 install: all
 347         mkdir -p $(DESTDIR)/usr/bin
 348         cp -p $(TARGETS) sysinfo nictagadm $(DESTDIR)/usr/bin
 349         cp -p $(USR_LIB_TARGETS) $(DESTDIR)/usr/lib
 350         mkdir -p $(DESTDIR)/smartdc/bin
 351         cp -p $(SMARTDC_TARGETS) $(DESTDIR)/smartdc/bin
 352         mkdir -p $(DESTDIR)/smartdc/lib
 353         cp -p $(SMARTDC_LIB_TARGETS) $(DESTDIR)/smartdc/lib
 354         mkdir -m 0755 -p $(PREFIX_NODE)/node_modules
 355         cp -Pr node_modules/* $(PREFIX_NODE)/node_modules
 356         cp $(KSTAT.NODE) $(PREFIX_NODE)/node_modules/
 357         cp node-lockfd/lib/index.js $(PREFIX_NODE)/node_modules/lockfd.js
 358         cp $(LOCKFD_BINDING.NODE) $(PREFIX_NODE)/node_modules/lockfd_binding.node
 359         cp $(MICROTIME.NODE) $(PREFIX_NODE)/node_modules/
 360         rm -rf $(DESTDIR)/usr/vm
 361         cp -PR vm $(DESTDIR)/usr/
 362         mkdir -m 0755 -p $(DESTDIR)/usr/vm/node_modules
 363         mkdir -p $(PREFIX_NODE)/node_modules/{zsock,zutil}/build/Release
 364         mkdir -p $(DESTDIR)/usr/vm/test/tests
 365         cp -Pr vm/common $(DESTDIR)/usr/vm/test/
 366         cp -Pr vm/node-tap $(DESTDIR)/usr/vm/test/
 367         cp -Pr vm/tests $(DESTDIR)/usr/vm/test/
 368         cp vm/runtest $(DESTDIR)/usr/vm/test/
 369         cp vm/runtests $(DESTDIR)/usr/vm/test/
 370         cp -Pr node-zsock/{package.json,lib} \
 371             $(PREFIX_NODE)/node_modules/zsock
 372         cp -Pr node-zutil/{package.json,lib} \
 373             $(PREFIX_NODE)/node_modules/zutil
 374         cp $(SQLITE3_BINDINGS.NODE) \
 375             $(PREFIX_NODE)/node_modules
 376         (sed -e "s|var sqlite3.*;|var sqlite3 = module.exports = exports = require('./node_sqlite3');|" | \
 377             sed -e "s|var trace = require.*;|var trace = require('./sqlite3_trace')|") \
 378             < node-sqlite3/lib/sqlite3.js \
 379             > $(PREFIX_NODE)/node_modules/sqlite3.js
 380         cp node-sqlite3/lib/trace.js $(PREFIX_NODE)/node_modules/sqlite3_trace.js
 381         cp $(ZSOCK_BINDINGS.NODE) \
 382             $(PREFIX_NODE)/node_modules/zsock/build/Release
 383         cp $(ZUTIL_BINDINGS.NODE) \
 384             $(PREFIX_NODE)/node_modules/zutil/build/Release
 385         cp $(EXPAT.NODE) $(PREFIX_NODE)/node_modules/expat_binding.node
 386         cp $(UUID.NODE) $(PREFIX_NODE)/node_modules/uuid.node
 387         cp $(DTRACE_PROVIDER.NODE) $(PREFIX_NODE)/node_modules/dtrace-provider.node
 388         sed -e "s|require('./build.*DTraceProviderBindings')|require('/usr/node/node_modules/dtrace-provider.node')|" \
 389             < $(DTRACE_PROVIDER_SRCDIR)/dtrace-provider.js \
 390             > $(PREFIX_NODE)/node_modules/dtrace-provider.js
 391         sed -e "s|var expat.*;|var expat = require('./expat_binding');|" \
 392             < node-expat/lib/node-expat.js \
 393             > $(PREFIX_NODE)/node_modules/node-expat.js
 394         cp zoneevent $(DESTDIR)/usr/vm/sbin/zoneevent
 395         cp zfs_send $(DESTDIR)/usr/vm/sbin/zfs_send
 396         cp zfs_recv $(DESTDIR)/usr/vm/sbin/zfs_recv
 397         cp vmunbundle $(DESTDIR)/usr/vm/sbin/vmunbundle
 398         cp filewait.js $(DESTDIR)/usr/vm/sbin/filewait
 399         mkdir -p $(DESTDIR)/lib/svc/manifest/system
 400         cp vm/smf/system-vmadmd.xml \
 401             $(DESTDIR)/lib/svc/manifest/system/system-vmadmd.xml
 402         cp vm/smf/system-metadata.xml \
 403             $(DESTDIR)/lib/svc/manifest/system/system-metadata.xml
 404         mv $(DESTDIR)/usr/vm/sbin/vmadmd.js $(DESTDIR)/usr/vm/sbin/vmadmd
 405         mv $(DESTDIR)/usr/vm/sbin/vmadm.js $(DESTDIR)/usr/vm/sbin/vmadm
 406         mv $(DESTDIR)/usr/vm/sbin/add-userscript.js \
 407             $(DESTDIR)/usr/vm/sbin/add-userscript
 408         mv $(DESTDIR)/usr/vm/sbin/metadata.js $(DESTDIR)/usr/vm/sbin/metadata
 409         mkdir -p $(DESTDIR)/usr/share/man/man1
 410         sed -e "s|require('dtrace-provider')|require('/usr/node/node_modules/dtrace-provider')|" \
 411             < node-bunyan/lib/bunyan.js \
 412             > $(PREFIX_NODE)/node_modules/bunyan.js
 413         cp node-bunyan/docs/bunyan.1 $(DESTDIR)/usr/share/man/man1/bunyan.1
 414         mkdir -p $(DESTDIR)/usr/bin
 415         sed -e 's|^#!/usr/bin/env node.*$$|#!/usr/node/bin/node|' \
 416             < node-bunyan/bin/bunyan \
 417             > $(DESTDIR)/usr/bin/bunyan
 418         cp node-panic/lib/panic.js $(PREFIX_NODE)/node_modules/panic.js
 419         cp node-panic/lib/subr.js $(PREFIX_NODE)/node_modules/subr.js
 420         rm -rf $(DESTDIR)/usr/img
 421         mkdir -m 0755 -p $(DESTDIR)/usr/img
 422         cp img/README.md $(DESTDIR)/usr/img/README.md
 423         cp img/package.json $(DESTDIR)/usr/img/package.json
 424         cp -PR img/etc $(DESTDIR)/usr/img/
 425         cp -PR img/lib $(DESTDIR)/usr/img/
 426         cp -PR img/man $(DESTDIR)/usr/img/
 427         cp -PR img/node_modules $(DESTDIR)/usr/img/
 428         cp -PR img/sbin $(DESTDIR)/usr/img/
 429         cp -PR img/test $(DESTDIR)/usr/img/
 430         rm -rf $(DESTDIR)/usr/fw
 431         mkdir -m 0755 -p $(DESTDIR)/usr/fw
 432         cp -PR fw/etc $(DESTDIR)/usr/fw/
 433         cp -PR fw/lib $(DESTDIR)/usr/fw/
 434         cp -PR fw/node_modules $(DESTDIR)/usr/fw/
 435         cp -PR fw/sbin $(DESTDIR)/usr/fw/
 436 
 437 check: $(JSLINT)
 438         @echo "==> Running cstyle..."
 439         @# cstyle doesn't echo as it goes so we add an echo to each line below
 440         @(for file in $(C_CHECK_TARGETS); do \
 441                 echo $(PWD)/$$file; \
 442                 $(CSTYLE) $$file; \
 443         done)
 444         @printf "\nC files ok!\n"
 445         @printf "\n==> Running JavaScriptLint...\n"
 446         @$(JSLINT) --nologo --conf=$(ROOT)/tools/jsl.node.conf \
 447             $(JS_CHECK_TARGETS) $(JS_CHECK_OLDSKOOL_TARGETS)
 448         @printf "\n==> Running jsstyle...\n"
 449         @# jsstyle doesn't echo as it goes so we add an echo to each line below
 450         (for file in $(JS_CHECK_TARGETS); do \
 451                 echo $(PWD)/$$file; \
 452                 $(JSSTYLE) $(JSSTYLE_OPTS) $$file; \
 453                 [[ $$? == "0" ]] || exit 1; \
 454         done)
 455         (for file in $(JS_CHECK_OLDSKOOL_TARGETS); do \
 456                 echo $(PWD)/$$file; \
 457                 $(JSSTYLE) $(JSSTYLE_OLDSKOOL_OPTS) $$file; \
 458                 [[ $$? == "0" ]] || exit 1; \
 459         done)
 460         @printf "\nJS style ok!\n"
 461 
 462 .PHONY: manifest
 463 manifest:
 464         (cat manifest && cd vm && \
 465             echo "# list of tests is autogenerated by smartos-live/src/Makefile" && \
 466             find tests/ -type f -exec echo "{}" "0444 root bin" \;) \
 467             | sed -e "s|^tests/|f usr/vm/test/tests/|" \
 468             > $(DESTDIR)/$(DESTNAME) \
 469 
 470 $(JSLINT):
 471         (cd $(ROOT); $(MAKE) jsl)
 472 
 473 clean:
 474         -rm -f $(TARGETS) $(SMARTDC_TARGETS) $(SMARTDC_LIB_TARGETS) *.o \
 475             $(CLEANFILES)
 476         -rm -rf node-sqlite3/build
 477         cd $(LOCKFD_SRC_DIR) && $(MAKE) clean
 478 
 479 include Makefile.targ
 480 
 481 #
 482 # Custom rules for building our various real targets follow.  Generic rules
 483 # belong in Makefile.targ.
 484 #
 485 disklayout: disklayout.js
 486         cp disklayout.js disklayout
 487         chmod 0755 disklayout
 488 
 489 disklist: disklist.sh
 490         cp disklist.sh disklist
 491         chmod 0755 disklist
 492 
 493 mkzpool: mkzpool.js
 494         cp mkzpool.js mkzpool
 495         chmod 0755 mkzpool
 496 
 497 sysinfo:
 498         touch sysinfo
 499 
 500 nictagadm:
 501         touch nictagadm
 502 
 503 #
 504 # Node native add-on target patterns.  Follow these patterns when adding a new
 505 # add-on and see the comment and definitions for EXPAT.NODE above as well.
 506 #
 507 $(EXPAT.NODE): node-expat/node-expat.cc
 508         @mkdir -p $(EXPAT_OBJDIR)
 509         $(GXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@ $< $(LIBS)
 510 
 511 #
 512 # node-lockfd is built using the v8plus-based Makefile contained within the
 513 # project.  We use LD_OPTIONS, here, to induce the linker to include libc,
 514 # which gcc as configured in proto.strap does not, but which other C compilers
 515 # generally do.
 516 #
 517 $(LOCKFD_BINDING.NODE): FRC
 518         cd $(LOCKFD_SRC_DIR) && \
 519         LD_OPTIONS=-lc \
 520         $(MAKE) \
 521                 CC=$(GCC) CXX=$(GXX) \
 522                 PREFIX_NODE=$(PREFIX_NODE) \
 523                 NODE_EXEC=$(NODE_EXEC) \
 524                 V8PLUS=$(LOCKFD_V8PLUS_DIR) \
 525                 CTFCONVERT=$(CTFCONVERT) \
 526                 CTFMERGE=$(CTFMERGE)
 527 
 528 #
 529 # The next two are used to build libusdt files into
 530 # $(DTRACE_PROVIDER_OBJDIR)/libusdt/*.o, instead of building libusdt.a
 531 #
 532 $(DTRACE_PROVIDER_OBJDIR)/%.o: $(DTRACE_PROVIDER_SRCDIR)/%.c \
 533             $(DTRACE_PROVIDER_HDRS)
 534         @mkdir -p $(DTRACE_PROVIDER_OBJDIR)/libusdt
 535         $(GCC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $<
 536 
 537 $(DTRACE_PROVIDER_OBJDIR)/%.o: $(DTRACE_PROVIDER_SRCDIR)/%.s
 538         @mkdir -p $(DTRACE_PROVIDER_OBJDIR)/libusdt
 539         $(GCC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $<
 540 
 541 $(DTRACE_PROVIDER_OBJDIR)/%.o: $(DTRACE_PROVIDER_SRCDIR)/%.cc \
 542             $(DTRACE_PROVIDER_HDRS)
 543         @mkdir -p $(DTRACE_PROVIDER_OBJDIR)
 544         $(GXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@ -c $<
 545 
 546 $(DTRACE_PROVIDER.NODE): $(DTRACE_PROVIDER_OBJS)
 547         @mkdir -p $(DTRACE_PROVIDER_OBJDIR)
 548         $(GXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@ $(DTRACE_PROVIDER_OBJS) $(LIBS)
 549 
 550 $(KSTAT.NODE): node-kstat/kstat.cc
 551         @mkdir -p $(KSTAT_OBJDIR)
 552         $(GXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@ $< $(LIBS)
 553 
 554 $(MICROTIME.NODE): node-microtime/src/microtime.cc
 555         @mkdir -p $(MICROTIME_OBJDIR)
 556         $(GXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@ $< $(LIBS)
 557 
 558 $(SQLITE3_OBJDIR)/%.o: $(SQLITE3_SRCDIR)/%.cc $(SQLITE3_HDRS)
 559         @mkdir -p $(SQLITE3_OBJDIR)
 560         $(GXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ -c $<
 561 
 562 $(SQLITE3_OBJDIR)/%.o: $(SQLITE3_LIBSRCDIR)/%.c $(SQLITE3_HDRS)
 563         @mkdir -p $(SQLITE3_OBJDIR)
 564         $(GCC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $<
 565 
 566 $(SQLITE3_BINDINGS.NODE): $(SQLITE3_OBJS)
 567         $(GXX) $(LDFLAGS) -o $@ $(SQLITE3_OBJS) $(LIBS)
 568 
 569 $(UUID.NODE): $(UUID_SRCDIR)/uuid.cc
 570         @mkdir -p $(UUID_OBJDIR)
 571         $(GXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@ $< $(LIBS)
 572 
 573 $(ZSOCK_BINDINGS.NODE): $(ZSOCK_SRCDIR)/zsock.cc
 574         @mkdir -p $(ZSOCK_OBJDIR)
 575         $(GXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@ $< $(LIBS)
 576 
 577 #
 578 # The zutil add-on requires a slightly more complex 2-phase build.
 579 #
 580 $(ZUTIL_OBJDIR)/%.o: $(ZUTIL_SRCDIR)/%.cc $(ZUTIL_BINDINGS_HDRS)
 581         @mkdir -p $(ZUTIL_OBJDIR)
 582         $(GXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ -c $<
 583 
 584 $(ZUTIL_BINDINGS.NODE): $(ZUTIL_BINDINGS_OBJS)
 585         $(GXX) $(LDFLAGS) -o $@ $(ZUTIL_BINDINGS_OBJS) $(LIBS)
 586 
 587 FRC: