github.com/cloudbase/juju-core@v0.0.0-20140504232958-a7271ac7912f/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 := launchpad.net/juju-core
    10  PROJECT_DIR := $(shell go list -e -f '{{.Dir}}' $(PROJECT))
    11  
    12  ifeq ($(shell uname -p | sed -r 's/.*(x86|armel|armhf).*/golang/'), golang)
    13  	GO_C := golang
    14  else
    15  	GO_C := gccgo-4.9  gccgo-go
    16  endif
    17  
    18  define DEPENDENCIES
    19    build-essential
    20    bzr
    21    distro-info-data
    22    git-core
    23    mercurial
    24    rsyslog-gnutls
    25    zip
    26    $(GO_C)
    27  endef
    28  
    29  default: build
    30  
    31  # Start of GOPATH-dependent targets. Some targets only make sense -
    32  # and will only work - when this tree is found on the GOPATH.
    33  ifeq ($(CURDIR),$(PROJECT_DIR))
    34  
    35  build:
    36  	go build $(PROJECT)/...
    37  
    38  check:
    39  	go test $(PROJECT)/...
    40  
    41  install:
    42  	go install -v $(PROJECT)/...
    43  
    44  clean:
    45  	go clean $(PROJECT)/...
    46  
    47  else # --------------------------------
    48  
    49  build:
    50  	$(error Cannot $@; $(CURDIR) is not on GOPATH)
    51  
    52  check:
    53  	$(error Cannot $@; $(CURDIR) is not on GOPATH)
    54  
    55  install:
    56  	$(error Cannot $@; $(CURDIR) is not on GOPATH)
    57  
    58  clean:
    59  	$(error Cannot $@; $(CURDIR) is not on GOPATH)
    60  
    61  endif
    62  # End of GOPATH-dependent targets.
    63  
    64  # Reformat source files.
    65  format:
    66  	gofmt -w -l .
    67  
    68  # Reformat and simplify source files.
    69  simplify:
    70  	gofmt -w -l -s .
    71  
    72  # Install packages required to develop Juju and run tests. The stable
    73  # PPA includes the required mongodb-server binaries. However, neither
    74  # PPA works on Saucy just yet.
    75  install-dependencies:
    76  ifeq ($(shell lsb_release -cs|sed -r 's/precise|quantal|raring/old/'),old)
    77  	@echo Adding juju PPAs for golang and mongodb-server
    78  	@sudo apt-add-repository --yes ppa:juju/golang
    79  	@sudo apt-add-repository --yes ppa:juju/stable
    80  	@sudo apt-get update
    81  endif
    82  	@echo Installing dependencies
    83  	@sudo apt-get --yes install $(strip $(DEPENDENCIES)) \
    84  	$(shell apt-cache madison juju-mongodb mongodb-server | head -1 | cut -d '|' -f1)
    85  
    86  # Install bash_completion
    87  install-etc:
    88  	@echo Installing bash completion
    89  	@sudo install -o root -g root -m 644 etc/bash_completion.d/juju-core /etc/bash_completion.d
    90  
    91  .PHONY: build check install
    92  .PHONY: clean format simplify
    93  .PHONY: install-dependencies