github.com/amacneil/dbmate@v1.16.3-0.20230225174651-ca89b10d75d7/Makefile (about)

     1  # enable cgo to build sqlite
     2  export CGO_ENABLED = 1
     3  
     4  # strip binaries
     5  FLAGS := -tags sqlite_omit_load_extension,sqlite_json -ldflags '-s'
     6  
     7  # default output file
     8  OUTPUT ?= dbmate
     9  
    10  # platform-specific settings
    11  GOOS := $(shell go env GOOS)
    12  ifeq ($(GOOS),linux)
    13  	# statically link binaries to support alpine linux
    14  	FLAGS := -tags netgo,osusergo,sqlite_omit_load_extension,sqlite_json  -ldflags '-s -extldflags "-static"'
    15  endif
    16  ifeq ($(GOOS),darwin)
    17  	export SDKROOT ?= $(shell xcrun --sdk macosx --show-sdk-path)
    18  endif
    19  ifeq ($(GOOS),windows)
    20  	ifneq ($(suffix $(OUTPUT)),.exe)
    21  		OUTPUT := $(addsuffix .exe,$(OUTPUT))
    22  	endif
    23  endif
    24  
    25  .PHONY: all
    26  all: fix build wait test
    27  
    28  .PHONY: clean
    29  clean:
    30  	rm -rf dist
    31  
    32  .PHONY: build
    33  build: clean
    34  	go build -o dist/$(OUTPUT) $(FLAGS) .
    35  
    36  .PHONY: ls
    37  ls:
    38  	ls -lh dist/$(OUTPUT)
    39  	file dist/$(OUTPUT)
    40  
    41  .PHONY: test
    42  test:
    43  	go test -p 1 $(FLAGS) ./...
    44  
    45  .PHONY: lint
    46  lint:
    47  	golangci-lint run
    48  
    49  .PHONY: fix
    50  fix:
    51  	golangci-lint run --fix
    52  
    53  .PHONY: wait
    54  wait:
    55  	dist/dbmate -e CLICKHOUSE_TEST_URL wait
    56  	dist/dbmate -e MYSQL_TEST_URL wait
    57  	dist/dbmate -e POSTGRES_TEST_URL wait
    58  
    59  .PHONY: docker-all
    60  docker-all:
    61  	docker-compose pull
    62  	docker-compose build
    63  	docker-compose run --rm dev make all
    64  
    65  .PHONY: docker-sh
    66  docker-sh:
    67  	-docker-compose run --rm dev