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         node_modules/{system,onlyif}.js \
  64         vm/sbin/*.js \
  65         vm/node_modules/{qmp,VM,dladm}.js \
  66         img/lib/*.js \
  67         img/sbin/imgadm
  68 
  69 JS_CHECK_OLDSKOOL_TARGETS = \
  70         disklayout.js \
  71         mkzpool.js \
  72         node_modules/disklayout.js
  73 
  74 # These files will get run through cstyle on 'make check'
  75 C_CHECK_TARGETS=\
  76         qemu-exec.c \
  77         vmunbundle.c \
  78         zfs_recv.c \
  79         zfs_send.c \
  80         zoneevent.c
  81 
  82 #
  83 # Generic flags we apply by default to everything.
  84 #
  85 CFLAGS +=       $(WARN_FLAGS)
  86 CXXFLAGS =      $(CFLAGS)
  87 
  88 #
  89 # Node native add-on patterns.  For add-ons with a single source file in the
  90 # root of the add-on tree and no headers of its own, follow the EXPAT.NODE
  91 # pattern here and below in the targets.  More complex examples (source
  92 # subdirectory, headers, multiple C++ sources) follow; see associated comments
  93 # if you are looking for a pattern to copy.
  94 #
  95 EXPAT_OBJDIR =  node-expat/build/Release
  96 EXPAT.NODE =    $(EXPAT_OBJDIR)/node-expat.node
  97 
  98 $(EXPAT.NODE) : WARN_FLAGS +=   -Wno-unused
  99 $(EXPAT.NODE) : CPPFLAGS +=     $(NODE_CPPFLAGS)
 100 $(EXPAT.NODE) : CXXFLAGS +=     $(NODE_CFLAGS)
 101 $(EXPAT.NODE) : LDFLAGS +=      $(NODE_LDFLAGS)
 102 $(EXPAT.NODE) : LIBS +=         -lexpat
 103 
 104 #
 105 # The kstat Node add-on follows the same pattern as EXPAT.NODE.
 106 #
 107 KSTAT_OBJDIR =  node-kstat/build/Release
 108 KSTAT.NODE =    $(KSTAT_OBJDIR)/kstat.node
 109 
 110 $(KSTAT.NODE) : WARN_FLAGS +=   -Wno-unused -Wno-write-strings -Wno-sign-compare
 111 $(KSTAT.NODE) : CPPFLAGS +=     $(NODE_CPPFLAGS)
 112 $(KSTAT.NODE) : CXXFLAGS +=     $(NODE_CFLAGS)
 113 $(KSTAT.NODE) : LDFLAGS +=      $(NODE_LDFLAGS)
 114 $(KSTAT.NODE) : LIBS +=         -lkstat
 115 
 116 #
 117 # The dtrace-provider add-on uses a combination of C, assembly and C++ files in
 118 # multiple directories.
 119 #
 120 DTRACE_PROVIDER_OBJDIR =        node-dtrace-provider/build/Release
 121 DTRACE_PROVIDER_SRCDIR =        node-dtrace-provider
 122 DTRACE_PROVIDER.NODE =          $(DTRACE_PROVIDER_OBJDIR)/dtrace-provider.node
 123 
 124 DTRACE_PROVIDER_SRCS += \
 125                         dtrace_probe.cc \
 126                         dtrace_provider.cc
 127 
 128 DTRACE_PROVIDER_LIBUSDT_SRCS += \
 129                         libusdt/usdt.c \
 130                         libusdt/usdt_dof_file.c \
 131                         libusdt/usdt_probe.c \
 132                         libusdt/usdt_dof.c \
 133                         libusdt/usdt_dof_sections.c
 134 
 135 DTRACE_PROVIDER_LIBUSDT_ASM_SRCS += \
 136                         libusdt/usdt_tracepoints_i386.s
 137 
 138 DTRACE_PROVIDER_HDRS += \
 139                         node-dtrace-provider/dtrace_provider.h \
 140                         node-dtrace-provider/libusdt/usdt_internal.h \
 141                         node-dtrace-provider/libusdt/usdt.h
 142 
 143 DTRACE_PROVIDER_OBJS += \
 144                         $(DTRACE_PROVIDER_SRCS:%.cc=$(DTRACE_PROVIDER_OBJDIR)/%.o) \
 145                         $(DTRACE_PROVIDER_LIBUSDT_SRCS:%.c=$(DTRACE_PROVIDER_OBJDIR)/%.o) \
 146                         $(DTRACE_PROVIDER_LIBUSDT_ASM_SRCS:%.s=$(DTRACE_PROVIDER_OBJDIR)/%.o)
 147 
 148 $(DTRACE_PROVIDER.NODE) :       WARN_FLAGS +=   -Wno-unused -Wno-sign-compare
 149 $(DTRACE_PROVIDER.NODE) :       CFLAGS +=       $(NODE_CFLAGS)
 150 $(DTRACE_PROVIDER.NODE) :       CPPFLAGS +=     \
 151                                         $(NODE_CPPFLAGS) \
 152                                         -Inode-dtrace-provider/libusdt
 153 $(DTRACE_PROVIDER.NODE) :       CXXFLAGS +=     $(NODE_CFLAGS)
 154 $(DTRACE_PROVIDER.NODE) :       LDFLAGS +=      $(NODE_LDFLAGS)
 155 
 156 CLEANFILES +=   $(DTRACE_PROVIDER.NODE) $(DTRACE_PROVIDER_OBJS)
 157 
 158 #
 159 # The sqlite3 add-on uses a combination of C + C++ files in multiple
 160 # directories, and has multiple header directories as well.
 161 #
 162 SQLITE3_OBJDIR =        node-sqlite3/build/Release
 163 SQLITE3_SRCDIR =        node-sqlite3/src
 164 SQLITE3_LIBSRCDIR =     node-sqlite3/deps/sqlite3
 165 SQLITE3_BINDINGS.NODE = $(SQLITE3_OBJDIR)/node_sqlite3.node
 166 
 167 SQLITE3_SRCS += \
 168         database.cc \
 169         node_sqlite3.cc \
 170         statement.cc
 171 
 172 SQLITE3_LIBSRCS +=      sqlite3.c
 173 
 174 SQLITE3_NODEHDRS += \
 175         async.h \
 176         macros.h \
 177         statement.h \
 178         threading.h
 179 
 180 SQLITE3_LIBHDRS += \
 181         sqlite3.h \
 182         sqlite3ext.h
 183 
 184 SQLITE3_OBJS =          \
 185                         $(SQLITE3_SRCS:%.cc=$(SQLITE3_OBJDIR)/%.o) \
 186                         $(SQLITE3_LIBSRCS:%.c=$(SQLITE3_OBJDIR)/%.o)
 187 SQLITE3_HDRS =          \
 188                         $(SQLITE3_NODEHDRS:%=$(SQLITE3_SRCDIR)/%) \
 189                         $(SQLITE3_LIBHDRS:%=$(SQLITE3_LIBSRCDIR)/%)
 190 CLEANFILES +=           $(SQLITE3_OBJS)
 191 
 192 SQLITE3_FLAGS = \
 193                                 -fdata-sections \
 194                                 -ffunction-sections \
 195                                 -fno-omit-frame-pointer \
 196                                 -fno-strict-aliasing \
 197                                 -fno-exceptions
 198 
 199 $(SQLITE3_BINDINGS.NODE) :      WARN_FLAGS =    -Wall -Werror
 200 $(SQLITE3_BINDINGS.NODE) :      CPPFLAGS += \
 201                                 $(NODE_CPPFLAGS) \
 202                                 -I$(SQLITE3_LIBSRCDIR) \
 203                                 -D_SQLITE_THREADSAFE=1 \
 204                                 -D_SQLITE_ENABLE_FTS3 \
 205                                 -D_SQLITE_ENABLE_RTREE \
 206                                 -D_LARGEFILE_SOURCE \
 207                                 -D_FILE_OFFSET_BITS=64 \
 208                                 -D_REENTRANT \
 209                                 -D_NDEBUG \
 210                                 -D_POSIX_PTHREAD_SEMANTICS
 211 $(SQLITE3_BINDINGS.NODE) :      CFLAGS += \
 212                                 $(NODE_CFLAGS) \
 213                                 $(SQLITE3_FLAGS)
 214 $(SQLITE3_BINDINGS.NODE) :      LDFLAGS += \
 215                                 $(NODE_LDFLAGS) \
 216                                 -Wl,-soname=node_sqlite3.node
 217 $(SQLITE3_BINDINGS.NODE) :      LIBS += -lpthread
 218 
 219 #
 220 # The zsock add-on places its single source file in a subdirectory.
 221 #
 222 ZSOCK_OBJDIR =  node-zsock/build/Release
 223 ZSOCK_SRCDIR =  node-zsock/src
 224 ZSOCK_BINDINGS.NODE =   $(ZSOCK_OBJDIR)/zsock_bindings.node
 225 
 226 $(ZSOCK_BINDINGS.NODE) :        WARN_FLAGS =    -Wall -Werror
 227 $(ZSOCK_BINDINGS.NODE) :        CPPFLAGS += \
 228                                 $(NODE_CPPFLAGS) \
 229                                 -D_REENTRANT \
 230                                 -D_POSIX_PTHREAD_SEMANTICS \
 231                                 -D_XOPEN_SOURCE_EXTENDED=1 \
 232                                 -D__EXTENSIONS__ \
 233                                 -DSunOS
 234 $(ZSOCK_BINDINGS.NODE) :        CXXFLAGS += \
 235                                 $(NODE_CFLAGS) \
 236                                 -std=c++98
 237 $(ZSOCK_BINDINGS.NODE) :        LDFLAGS +=      $(NODE_LDFLAGS)
 238 $(ZSOCK_BINDINGS.NODE) :        LIBS +=         -lsocket -lnsl -lcontract
 239 
 240 #
 241 # The zutil add-on places its multiple source files in a subdirectory, and
 242 # builds them against some headers that it also supplies and needs to depend on.
 243 # Because we must build intermediate object files, this requires a
 244 # different target pattern as well; see below.
 245 #
 246 ZUTIL_OBJDIR =  node-zutil/build/Release
 247 ZUTIL_SRCDIR =  node-zutil/src
 248 ZUTIL_BINDINGS.NODE =   $(ZUTIL_OBJDIR)/zutil_bindings.node
 249 
 250 ZUTIL_SRCS += \
 251         zone.cc \
 252         zonecfg.cc \
 253         zutil_bindings.cc
 254 
 255 ZUTIL_HDRS += \
 256         zone.h \
 257         zonecfg.h \
 258         zutil_common.h
 259 
 260 ZUTIL_BINDINGS_OBJS =   $(ZUTIL_SRCS:%.cc=$(ZUTIL_OBJDIR)/%.o)
 261 ZUTIL_BINDINGS_HDRS =   $(ZUTIL_HDRS:%=$(ZUTIL_SRCDIR)/%)
 262 CLEANFILES +=           $(ZUTIL_BINDINGS_OBJS)
 263 
 264 $(ZUTIL_BINDINGS.NODE) :        WARN_FLAGS +=   -Wno-unused
 265 $(ZUTIL_BINDINGS.NODE) :        CPPFLAGS +=     $(NODE_CPPFLAGS) -DSunOS
 266 $(ZUTIL_BINDINGS.NODE) :        CXXFLAGS +=     $(NODE_CFLAGS)
 267 $(ZUTIL_BINDINGS.NODE) :        LDFLAGS +=      $(NODE_LDFLAGS)
 268 $(ZUTIL_BINDINGS.NODE) :        LIBS +=         -lzonecfg
 269 
 270 #
 271 # List of targets.  TARGETS, SMARTDC_TARGETS, and SMARTDC_LIB_TARGETS must
 272 # include only those files that are safe to remove when the clean target is
 273 # built.
 274 #
 275 TARGETS = \
 276         bootparams \
 277         diskinfo \
 278         disklayout \
 279         disklist \
 280         disk_size \
 281         mkzpool \
 282         removable_disk \
 283         vmunbundle \
 284         zfs_recv \
 285         zfs_send \
 286         zoneevent \
 287         $(EXPAT.NODE) \
 288         $(DTRACE_PROVIDER.NODE) \
 289         $(KSTAT.NODE) \
 290         $(SYSLOG.NODE) \
 291         $(SQLITE3_BINDINGS.NODE) \
 292         $(ZSOCK_BINDINGS.NODE) \
 293         $(ZUTIL_BINDINGS.NODE)
 294 
 295 SMARTDC_TARGETS = \
 296         qemu-exec
 297 
 298 SMARTDC_LIB_TARGETS = \
 299         sdc-on-tty
 300 
 301 all: $(TARGETS) sysinfo $(SMARTDC_TARGETS) $(SMARTDC_LIB_TARGETS)
 302 
 303 install: all
 304         mkdir -p $(DESTDIR)/usr/bin
 305         cp -p $(TARGETS) sysinfo $(DESTDIR)/usr/bin
 306         mkdir -p $(DESTDIR)/smartdc/bin
 307         cp -p $(SMARTDC_TARGETS) $(DESTDIR)/smartdc/bin
 308         mkdir -p $(DESTDIR)/smartdc/lib
 309         cp -p $(SMARTDC_LIB_TARGETS) $(DESTDIR)/smartdc/lib
 310         mkdir -m 0755 -p $(PREFIX_NODE)/node_modules
 311         cp -Pr node_modules/* $(PREFIX_NODE)/node_modules
 312         cp $(KSTAT.NODE) $(PREFIX_NODE)/node_modules/
 313         rm -rf $(DESTDIR)/usr/vm
 314         cp -PR vm $(DESTDIR)/usr/
 315         mkdir -m 0755 -p $(DESTDIR)/usr/vm/node_modules
 316         mkdir -p $(PREFIX_NODE)/node_modules/{zsock,zutil}/build/Release
 317         mkdir -p $(DESTDIR)/usr/vm/test/tests
 318         cp -Pr vm/common $(DESTDIR)/usr/vm/test/
 319         cp -Pr vm/node-tap $(DESTDIR)/usr/vm/test/
 320         cp -Pr vm/tests $(DESTDIR)/usr/vm/test/
 321         cp vm/runtest $(DESTDIR)/usr/vm/test/
 322         cp vm/runtests $(DESTDIR)/usr/vm/test/
 323         cp -Pr node-zsock/{package.json,lib} \
 324             $(PREFIX_NODE)/node_modules/zsock
 325         cp -Pr node-zutil/{package.json,lib} \
 326             $(PREFIX_NODE)/node_modules/zutil
 327         cp $(SQLITE3_BINDINGS.NODE) \
 328             $(PREFIX_NODE)/node_modules
 329         (sed -e "s|var sqlite3.*;|var sqlite3 = module.exports = exports = require('./node_sqlite3');|" | \
 330             sed -e "s|var trace = require.*;|var trace = require('./sqlite3_trace')|") \
 331             < node-sqlite3/lib/sqlite3.js \
 332             > $(PREFIX_NODE)/node_modules/sqlite3.js
 333         cp node-sqlite3/lib/trace.js $(PREFIX_NODE)/node_modules/sqlite3_trace.js
 334         cp $(ZSOCK_BINDINGS.NODE) \
 335             $(PREFIX_NODE)/node_modules/zsock/build/Release
 336         cp $(ZUTIL_BINDINGS.NODE) \
 337             $(PREFIX_NODE)/node_modules/zutil/build/Release
 338         cp $(EXPAT.NODE) $(PREFIX_NODE)/node_modules/expat_binding.node
 339         cp $(DTRACE_PROVIDER.NODE) $(PREFIX_NODE)/node_modules/dtrace-provider.node
 340         sed -e "s|require('./build.*DTraceProviderBindings')|require('/usr/node/node_modules/dtrace-provider.node')|" \
 341             < $(DTRACE_PROVIDER_SRCDIR)/dtrace-provider.js \
 342             > $(PREFIX_NODE)/node_modules/dtrace-provider.js
 343         sed -e "s|var expat.*;|var expat = require('./expat_binding');|" \
 344             < node-expat/lib/node-expat.js \
 345             > $(PREFIX_NODE)/node_modules/node-expat.js
 346         cp zoneevent $(DESTDIR)/usr/vm/sbin/zoneevent
 347         cp zfs_send $(DESTDIR)/usr/vm/sbin/zfs_send
 348         cp zfs_recv $(DESTDIR)/usr/vm/sbin/zfs_recv
 349         cp vmunbundle $(DESTDIR)/usr/vm/sbin/vmunbundle
 350         mkdir -p $(DESTDIR)/lib/svc/manifest/system
 351         cp vm/smf/system-vmadmd.xml \
 352             $(DESTDIR)/lib/svc/manifest/system/system-vmadmd.xml
 353         cp vm/smf/system-metadata.xml \
 354             $(DESTDIR)/lib/svc/manifest/system/system-metadata.xml
 355         mv $(DESTDIR)/usr/vm/sbin/vmadmd.js $(DESTDIR)/usr/vm/sbin/vmadmd
 356         mv $(DESTDIR)/usr/vm/sbin/vmadm.js $(DESTDIR)/usr/vm/sbin/vmadm
 357         mv $(DESTDIR)/usr/vm/sbin/add-userscript.js \
 358             $(DESTDIR)/usr/vm/sbin/add-userscript
 359         mv $(DESTDIR)/usr/vm/sbin/metadata.js $(DESTDIR)/usr/vm/sbin/metadata
 360         mkdir -p $(DESTDIR)/usr/share/man/man1
 361         sed -e "s|require('dtrace-provider')|require('/usr/node/node_modules/dtrace-provider')|" \
 362             < node-bunyan/lib/bunyan.js \
 363             > $(PREFIX_NODE)/node_modules/bunyan.js
 364         cp node-bunyan/docs/bunyan.1 $(DESTDIR)/usr/share/man/man1/bunyan.1
 365         mkdir -p $(DESTDIR)/usr/bin
 366         sed -e 's|^#!/usr/bin/env node.*$$|#!/usr/node/bin/node|' \
 367             < node-bunyan/bin/bunyan \
 368             > $(DESTDIR)/usr/bin/bunyan
 369         cp node-panic/lib/panic.js $(PREFIX_NODE)/node_modules/panic.js
 370         cp node-panic/lib/subr.js $(PREFIX_NODE)/node_modules/subr.js
 371         rm -rf $(DESTDIR)/usr/img
 372         mkdir -m 0755 -p $(DESTDIR)/usr/img
 373         cp img/README.md $(DESTDIR)/usr/img/README.md
 374         cp img/package.json $(DESTDIR)/usr/img/package.json
 375         cp -PR img/etc $(DESTDIR)/usr/img/
 376         cp -PR img/lib $(DESTDIR)/usr/img/
 377         cp -PR img/man $(DESTDIR)/usr/img/
 378         cp -PR img/node_modules $(DESTDIR)/usr/img/
 379         cp -PR img/sbin $(DESTDIR)/usr/img/
 380         cp -PR img/test $(DESTDIR)/usr/img/
 381         rm -rf $(DESTDIR)/usr/fw
 382         mkdir -m 0755 -p $(DESTDIR)/usr/fw
 383         cp -PR fw/etc $(DESTDIR)/usr/fw/
 384         cp -PR fw/lib $(DESTDIR)/usr/fw/
 385         cp -PR fw/node_modules $(DESTDIR)/usr/fw/
 386         cp -PR fw/sbin $(DESTDIR)/usr/fw/
 387 
 388 check: $(JSLINT)
 389         @echo "==> Running cstyle..."
 390         @# cstyle doesn't echo as it goes so we add an echo to each line below
 391         @(for file in $(C_CHECK_TARGETS); do \
 392                 echo $(PWD)/$$file; \
 393                 $(CSTYLE) $$file; \
 394         done)
 395         @printf "\nC files ok!\n"
 396         @printf "\n==> Running JavaScriptLint...\n"
 397         @$(JSLINT) --nologo --conf=$(ROOT)/tools/jsl.node.conf \
 398             $(JS_CHECK_TARGETS) $(JS_CHECK_OLDSKOOL_TARGETS)
 399         @printf "\n==> Running jsstyle...\n"
 400         @# jsstyle doesn't echo as it goes so we add an echo to each line below
 401         (for file in $(JS_CHECK_TARGETS); do \
 402                 echo $(PWD)/$$file; \
 403                 $(JSSTYLE) $(JSSTYLE_OPTS) $$file; \
 404                 [[ $$? == "0" ]] || exit 1; \
 405         done)
 406         (for file in $(JS_CHECK_OLDSKOOL_TARGETS); do \
 407                 echo $(PWD)/$$file; \
 408                 $(JSSTYLE) $(JSSTYLE_OLDSKOOL_OPTS) $$file; \
 409                 [[ $$? == "0" ]] || exit 1; \
 410         done)
 411         @printf "\nJS style ok!\n"
 412 
 413 .PHONY: manifest
 414 manifest:
 415         (cat manifest && cd vm && \
 416             echo "# list of tests is autogenerated by smartos-live/src/Makefile" && \
 417             find tests/ -type f -exec echo "{}" "0444 root bin" \;) \
 418             | sed -e "s|^tests/|f usr/vm/test/tests/|" \
 419             > $(DESTDIR)/$(DESTNAME) \
 420 
 421 $(JSLINT):
 422         (cd $(ROOT); $(MAKE) jsl)
 423 
 424 clean:
 425         -rm -f $(TARGETS) $(SMARTDC_TARGETS) $(SMARTDC_LIB_TARGETS) *.o \
 426             $(CLEANFILES)
 427         -rm -rf node-sqlite3/build
 428 
 429 include Makefile.targ
 430 
 431 #
 432 # Custom rules for building our various real targets follow.  Generic rules
 433 # belong in Makefile.targ.
 434 #
 435 disklayout: disklayout.js
 436         cp disklayout.js disklayout
 437         chmod 0755 disklayout
 438 
 439 disklist: disklist.sh
 440         cp disklist.sh disklist
 441         chmod 0755 disklist
 442 
 443 mkzpool: mkzpool.js
 444         cp mkzpool.js mkzpool
 445         chmod 0755 mkzpool
 446 
 447 sysinfo:
 448         touch sysinfo
 449 
 450 #
 451 # Node native add-on target patterns.  Follow these patterns when adding a new
 452 # add-on and see the comment and definitions for EXPAT.NODE above as well.
 453 #
 454 $(EXPAT.NODE): node-expat/node-expat.cc
 455         @mkdir -p $(EXPAT_OBJDIR)
 456         $(GXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@ $< $(LIBS)
 457 
 458 #
 459 # The next two are used to build libusdt files into
 460 # $(DTRACE_PROVIDER_OBJDIR)/libusdt/*.o, instead of building libusdt.a
 461 #
 462 $(DTRACE_PROVIDER_OBJDIR)/%.o: $(DTRACE_PROVIDER_SRCDIR)/%.c \
 463             $(DTRACE_PROVIDER_HDRS)
 464         @mkdir -p $(DTRACE_PROVIDER_OBJDIR)/libusdt
 465         $(GCC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $<
 466 
 467 $(DTRACE_PROVIDER_OBJDIR)/%.o: $(DTRACE_PROVIDER_SRCDIR)/%.s
 468         @mkdir -p $(DTRACE_PROVIDER_OBJDIR)/libusdt
 469         $(GCC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $<
 470 
 471 $(DTRACE_PROVIDER_OBJDIR)/%.o: $(DTRACE_PROVIDER_SRCDIR)/%.cc \
 472             $(DTRACE_PROVIDER_HDRS)
 473         @mkdir -p $(DTRACE_PROVIDER_OBJDIR)
 474         $(GXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@ -c $<
 475 
 476 $(DTRACE_PROVIDER.NODE): $(DTRACE_PROVIDER_OBJS)
 477         @mkdir -p $(DTRACE_PROVIDER_OBJDIR)
 478         $(GXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@ $(DTRACE_PROVIDER_OBJS) $(LIBS)
 479 
 480 $(KSTAT.NODE): node-kstat/kstat.cc
 481         @mkdir -p $(KSTAT_OBJDIR)
 482         $(GXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@ $< $(LIBS)
 483 
 484 $(SQLITE3_OBJDIR)/%.o: $(SQLITE3_SRCDIR)/%.cc $(SQLITE3_HDRS)
 485         @mkdir -p $(SQLITE3_OBJDIR)
 486         $(GXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ -c $<
 487 
 488 $(SQLITE3_OBJDIR)/%.o: $(SQLITE3_LIBSRCDIR)/%.c $(SQLITE3_HDRS)
 489         @mkdir -p $(SQLITE3_OBJDIR)
 490         $(GCC) $(CPPFLAGS) $(CFLAGS) -o $@ -c $<
 491 
 492 $(SQLITE3_BINDINGS.NODE): $(SQLITE3_OBJS)
 493         $(GXX) $(LDFLAGS) -o $@ $(SQLITE3_OBJS) $(LIBS)
 494 
 495 $(ZSOCK_BINDINGS.NODE): $(ZSOCK_SRCDIR)/zsock.cc
 496         @mkdir -p $(ZSOCK_OBJDIR)
 497         $(GXX) $(CPPFLAGS) $(CXXFLAGS) $(LDFLAGS) -o $@ $< $(LIBS)
 498 
 499 #
 500 # The zutil add-on requires a slightly more complex 2-phase build.
 501 #
 502 $(ZUTIL_OBJDIR)/%.o: $(ZUTIL_SRCDIR)/%.cc $(ZUTIL_BINDINGS_HDRS)
 503         @mkdir -p $(ZUTIL_OBJDIR)
 504         $(GXX) $(CPPFLAGS) $(CXXFLAGS) -o $@ -c $<
 505 
 506 $(ZUTIL_BINDINGS.NODE): $(ZUTIL_BINDINGS_OBJS)
 507         $(GXX) $(LDFLAGS) -o $@ $(ZUTIL_BINDINGS_OBJS) $(LIBS)