• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright 2023 The ChromiumOS Authors
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file.
4
5prefix ?= /usr/local
6libdir = ${prefix}/lib
7includedir = ${prefix}/include/rutabaga_gfx
8
9UNAME := $(shell uname -s)
10
11GFXSTREAM_DEP = gfxstream_backend
12
13ifdef debug
14  release :=
15  target :=debug
16  extension :=debug
17  OUT = target/debug
18else
19  release :=--release
20  target :=release
21  extension :=
22  OUT = target/release
23endif
24
25# Remember to change ffi/build.rs if this changes.
26RUTABAGA_VERSION_MAJOR := 0
27SRC ?= src
28
29ifeq ($(UNAME), Linux)
30LIB_NAME := librutabaga_gfx_ffi.so
31endif
32
33ifeq ($(UNAME), Darwin)
34LIB_NAME := librutabaga_gfx_ffi.dylib
35endif
36
37gfxstream_feature :=
38ifeq ($(shell pkg-config --exists $(GFXSTREAM_DEP) && echo 1),1)
39    gfxstream_feature :=--features=gfxstream
40endif
41
42RUTABAGA_VERSION := $(RUTABAGA_VERSION_MAJOR).1.3
43
44all: build
45
46build:
47	cargo build $(gfxstream_feature) $(release)
48
49install: build
50ifeq ($(UNAME), Linux)
51	install -D -m 755 $(OUT)/$(LIB_NAME) $(DESTDIR)$(libdir)/$(LIB_NAME).$(RUTABAGA_VERSION)
52endif
53ifeq ($(UNAME), Darwin)
54	install_name_tool -id $(DESTDIR)$(libdir)/$(LIB_NAME).$(RUTABAGA_VERSION) $(DESTDIR)$(libdir)/$(LIB_NAME)
55endif
56
57	ln -sf $(LIB_NAME).$(RUTABAGA_VERSION) $(DESTDIR)$(libdir)/$(LIB_NAME).$(RUTABAGA_VERSION_MAJOR)
58	ln -sf $(LIB_NAME).$(RUTABAGA_VERSION) $(DESTDIR)$(libdir)/$(LIB_NAME)
59
60ifeq ($(UNAME), Linux)
61	install -D -m 0644 $(OUT)/rutabaga_gfx_ffi.pc $(DESTDIR)$(libdir)/pkgconfig/rutabaga_gfx_ffi.pc
62	install -D -m 0644 $(SRC)/include/rutabaga_gfx_ffi.h $(DESTDIR)$(includedir)/rutabaga_gfx_ffi.h
63endif
64ifeq ($(UNAME), Darwin)
65	install -m 0644 $(OUT)/rutabaga_gfx_ffi.pc $(DESTDIR)$(libdir)/pkgconfig/rutabaga_gfx_ffi.pc
66	install -m 0644 $(SRC)/include/rutabaga_gfx_ffi.h $(DESTDIR)$(includedir)/rutabaga_gfx_ffi.h
67endif
68
69clean:
70	cargo clean $(release)
71
72distclean:
73	cargo clean $(release)
74
75help:
76	@echo "usage: make $(prog) [debug=1]"
77