github.com/wallyworld/juju@v0.0.0-20161013125918-6cf1bc9d917a/Makefile (about)

     1  #
     2  # Makefile for juju-core.
     3  #
     4  
     5  ifndef GOPATH
     6  $(warning You need to set up a GOPATH.  See the README file.)
     7  endif
     8  
     9  PROJECT := github.com/juju/juju
    10  PROJECT_DIR := $(shell go list -e -f '{{.Dir}}' $(PROJECT))
    11  
    12  ifeq ($(shell uname -p | sed -r 's/.*(86|armel|armhf|aarch64|ppc64le|s390x).*/golang/'), golang)
    13  	GO_C := golang-1.[6-9]
    14  	INSTALL_FLAGS :=
    15  else
    16  	GO_C := gccgo-4.9  gccgo-go
    17  	INSTALL_FLAGS := -gccgoflags=-static-libgo
    18  endif
    19  
    20  define DEPENDENCIES
    21    ca-certificates
    22    bzip2
    23    bzr
    24    distro-info-data
    25    git-core
    26    mercurial
    27    zip
    28    $(GO_C)
    29  endef
    30  
    31  default: build
    32  
    33  # Start of GOPATH-dependent targets. Some targets only make sense -
    34  # and will only work - when this tree is found on the GOPATH.
    35  ifeq ($(CURDIR),$(PROJECT_DIR))
    36  
    37  ifeq ($(JUJU_MAKE_GODEPS),true)
    38  $(GOPATH)/bin/godeps:
    39  	go get github.com/rogpeppe/godeps
    40  
    41  godeps: $(GOPATH)/bin/godeps
    42  	$(GOPATH)/bin/godeps -u dependencies.tsv
    43  else
    44  godeps:
    45  	@echo "skipping godeps"
    46  endif
    47  
    48  build: godeps
    49  	go build $(PROJECT)/...
    50  
    51  check: godeps
    52  	go test -test.timeout=1200s $(PROJECT)/...
    53  
    54  install: godeps
    55  	go install $(INSTALL_FLAGS) -v $(PROJECT)/...
    56  
    57  clean:
    58  	go clean $(PROJECT)/...
    59  
    60  else # --------------------------------
    61  
    62  build:
    63  	$(error Cannot $@; $(CURDIR) is not on GOPATH)
    64  
    65  check:
    66  	$(error Cannot $@; $(CURDIR) is not on GOPATH)
    67  
    68  install:
    69  	$(error Cannot $@; $(CURDIR) is not on GOPATH)
    70  
    71  clean:
    72  	$(error Cannot $@; $(CURDIR) is not on GOPATH)
    73  
    74  endif
    75  # End of GOPATH-dependent targets.
    76  
    77  # Reformat source files.
    78  format:
    79  	gofmt -w -l .
    80  
    81  # Reformat and simplify source files.
    82  simplify:
    83  	gofmt -w -l -s .
    84  
    85  # Install packages required to develop Juju and run tests. The stable
    86  # PPA includes the required mongodb-server binaries.
    87  install-dependencies:
    88  ifeq ($(shell lsb_release -cs|sed -r 's/precise|wily/old/'),old)
    89  	@echo Adding juju PPAs for golang and mongodb-server
    90  	@sudo apt-add-repository --yes ppa:juju/golang
    91  	@sudo apt-add-repository --yes ppa:juju/stable
    92  	@sudo apt-get update
    93  endif
    94  	@echo Installing dependencies
    95  	@sudo apt-get --yes install --no-install-recommends \
    96  	$(strip $(DEPENDENCIES)) \
    97  	$(shell apt-cache madison juju-mongodb3.2 juju-mongodb mongodb-server | head -1 | cut -d '|' -f1)
    98  
    99  # Install bash_completion
   100  install-etc:
   101  	@echo Installing bash completion
   102  	@sudo install -o root -g root -m 644 etc/bash_completion.d/juju2 /etc/bash_completion.d
   103  
   104  setup-lxd:
   105  ifeq ($(shell ifconfig lxdbr0 2>&1 | grep -q "inet addr" && echo true),true)
   106  	@echo IPv4 networking is already setup for LXD.
   107  	@echo run "sudo scripts/setup-lxd.sh" to reconfigure IPv4 networking
   108  else
   109  	@echo Setting up IPv4 networking for LXD
   110  	@sudo scripts/setup-lxd.sh || true
   111  endif
   112  
   113  
   114  GOCHECK_COUNT="$(shell go list -f '{{join .Deps "\n"}}' github.com/juju/juju/... | grep -c "gopkg.in/check.v*")"
   115  check-deps:
   116  	@echo "$(GOCHECK_COUNT) instances of gocheck not in test code"
   117  
   118  .PHONY: build check install
   119  .PHONY: clean format simplify
   120  .PHONY: install-dependencies
   121  .PHONY: check-deps