github.com/stackdocker/rkt@v0.10.1-0.20151109095037-1aa827478248/makelib/build_go_bin.mk (about)

     1  # inputs cleared after including this file:
     2  # BGB_STAMP
     3  # BGB_BINARY
     4  # BGB_GO_FLAGS
     5  # BGB_PKG_IN_REPO
     6  # BGB_ADDITIONAL_GO_ENV
     7  
     8  # inputs left alone:
     9  # DEPSDIR
    10  # DEPSGENTOOL
    11  # GOPATH
    12  # GO_ENV
    13  # MAKEFILE_LIST
    14  # REPO_PATH
    15  
    16  _BGB_PATH_ := $(lastword $(MAKEFILE_LIST))
    17  
    18  $(call setup-stamp-file,_BGB_GO_DEPMK_STAMP_,$(BGB_BINARY)/bgb-go-depmk)
    19  $(call setup-stamp-file,_BGB_KV_DEPMK_STAMP_,$(BGB_BINARY)/bgb-kv-depmk)
    20  
    21  # the gopath symlink creation rule should be generated only once, even
    22  # if we include this file multiple times.
    23  ifeq ($(_BGB_RKT_SYMLINK_STAMP_),)
    24  
    25  # the symlink stamp wasn't yet generated, do it now.
    26  
    27  _BGB_RKT_BASE_SYMLINK_ := src/$(REPO_PATH)
    28  _BGB_RKT_SYMLINK_NAME_ := $(GOPATH)/$(_BGB_RKT_BASE_SYMLINK_)
    29  
    30  $(call setup-custom-stamp-file,_BGB_RKT_SYMLINK_STAMP_,$(_BGB_PATH_)/rkt-symlink)
    31  
    32  $(call generate-stamp-rule,$(_BGB_RKT_SYMLINK_STAMP_),,$(_BGB_RKT_SYMLINK_NAME_))
    33  
    34  INSTALL_SYMLINKS += $(MK_TOPLEVEL_ABS_SRCDIR):$(_BGB_RKT_SYMLINK_NAME_)
    35  CREATE_DIRS += $(call dir-chain,$(GOPATH),$(call to-dir,$(_BGB_RKT_BASE_SYMLINK_)))
    36  
    37  endif
    38  
    39  _BGB_PKG_NAME_ := $(REPO_PATH)/$(BGB_PKG_IN_REPO)
    40  
    41  $(call setup-dep-file,_BGB_GO_DEPMK,$(_BGB_PKG_NAME_))
    42  $(call setup-dep-file,_BGB_KV_DEPMK,$(_BGB_PKG_NAME_)/kv)
    43  
    44  $(call forward-vars,$(BGB_BINARY), \
    45  	BGB_ADDITIONAL_GO_ENV GO_ENV GO BGB_GO_FLAGS _BGB_PKG_NAME_)
    46  $(BGB_BINARY): $(_BGB_PATH_) $(_BGB_RKT_SYMLINK_STAMP_)
    47  	$(VQ) \
    48  	$(call vb,vt,GO,$(call vsg,$(_BGB_PKG_NAME_))) \
    49  	$(BGB_ADDITIONAL_GO_ENV) $(GO_ENV) "$(GO)" build -o "$@" $(BGB_GO_FLAGS) "$(_BGB_PKG_NAME_)"
    50  
    51  $(call generate-go-deps,$(_BGB_GO_DEPMK_STAMP_),$(BGB_BINARY),$(_BGB_GO_DEPMK),$(BGB_PKG_IN_REPO))
    52  $(call generate-kv-deps,$(_BGB_KV_DEPMK_STAMP_),$(BGB_BINARY),$(_BGB_KV_DEPMK),BGB_GO_FLAGS)
    53  
    54  $(BGB_STAMP): $(BGB_BINARY) $(_BGB_GO_DEPMK_STAMP_) $(_BGB_KV_DEPMK_STAMP_)
    55  
    56  # _BGB_RKT_SYMLINK_STAMP_ is deliberately not cleared - it needs to
    57  # stay defined to make sure that the gopath symlink rule is generated
    58  # only once.
    59  $(call undefine-namespaces,BGB _BGB,_BGB_RKT_SYMLINK_STAMP_)