github.com/makyo/juju@v0.0.0-20160425123129-2608902037e9/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).*/golang/'), golang)
    13  	GO_C := golang
    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    juju-local
    28    zip
    29    $(GO_C)
    30  endef
    31  
    32  default: build
    33  
    34  # Start of GOPATH-dependent targets. Some targets only make sense -
    35  # and will only work - when this tree is found on the GOPATH.
    36  ifeq ($(CURDIR),$(PROJECT_DIR))
    37  
    38  ifeq ($(JUJU_MAKE_GODEPS),true)
    39  $(GOPATH)/bin/godeps:
    40  	go get launchpad.net/godeps
    41  
    42  godeps: $(GOPATH)/bin/godeps
    43  	$(GOPATH)/bin/godeps -u dependencies.tsv
    44  else
    45  godeps:
    46  	@echo "skipping godeps"
    47  endif
    48  
    49  build: godeps
    50  	go build $(PROJECT)/...
    51  
    52  check: godeps
    53  	go test -test.timeout=1200s $(PROJECT)/...
    54  
    55  install: godeps
    56  	go install $(INSTALL_FLAGS) -v $(PROJECT)/...
    57  
    58  clean:
    59  	go clean $(PROJECT)/...
    60  
    61  else # --------------------------------
    62  
    63  build:
    64  	$(error Cannot $@; $(CURDIR) is not on GOPATH)
    65  
    66  check:
    67  	$(error Cannot $@; $(CURDIR) is not on GOPATH)
    68  
    69  install:
    70  	$(error Cannot $@; $(CURDIR) is not on GOPATH)
    71  
    72  clean:
    73  	$(error Cannot $@; $(CURDIR) is not on GOPATH)
    74  
    75  endif
    76  # End of GOPATH-dependent targets.
    77  
    78  # Reformat source files.
    79  format:
    80  	gofmt -w -l .
    81  
    82  # Reformat and simplify source files.
    83  simplify:
    84  	gofmt -w -l -s .
    85  
    86  # Install packages required to develop Juju and run tests. The stable
    87  # PPA includes the required mongodb-server binaries.
    88  install-dependencies:
    89  ifeq ($(shell lsb_release -cs|sed -r 's/precise/old/'),old)
    90  	@echo Adding juju PPAs for golang and mongodb-server
    91  	@sudo apt-add-repository --yes ppa:juju/golang
    92  	@sudo apt-add-repository --yes ppa:juju/stable
    93  	@sudo apt-get update
    94  endif
    95  	@echo Installing dependencies
    96  	@sudo apt-get --yes install --no-install-recommends \
    97  	$(strip $(DEPENDENCIES)) \
    98  	$(shell apt-cache madison juju-mongodb mongodb-server | head -1 | cut -d '|' -f1)
    99  
   100  # Install bash_completion
   101  install-etc:
   102  	@echo Installing bash completion
   103  	@sudo install -o root -g root -m 644 etc/bash_completion.d/juju-core /etc/bash_completion.d
   104  
   105  GOCHECK_COUNT="$(shell go list -f '{{join .Deps "\n"}}' github.com/juju/juju/... | grep -c "gopkg.in/check.v*")"
   106  check-deps:
   107  	@echo "$(GOCHECK_COUNT) instances of gocheck not in test code"
   108  
   109  .PHONY: build check install
   110  .PHONY: clean format simplify
   111  .PHONY: install-dependencies
   112  .PHONY: check-deps