1# Copyright 2016 The Chromium OS Authors. All rights reserved. 2# Use of this source code is governed by a BSD-style license that can be 3# found in the LICENSE file. 4 5GRALLOC = gralloc.cros.so 6 7SRCS = $(wildcard *.cc) 8SRCS += $(wildcard ../*.c) 9 10SRCS += $(wildcard gralloc0/*.cc) 11 12SOURCES = $(filter-out ../gbm%, $(SRCS)) 13PKG_CONFIG ?= pkg-config 14 15VPATH = $(dir $(SOURCES)) 16LIBDRM_CFLAGS := $(shell $(PKG_CONFIG) --cflags libdrm) 17LIBDRM_LIBS := $(shell $(PKG_CONFIG) --libs libdrm) 18 19CPPFLAGS += -Wall -fPIC -Werror -flto $(LIBDRM_CFLAGS) -D_GNU_SOURCE=1 20CXXFLAGS += -std=c++14 21CFLAGS += -std=c99 -D_GNU_SOURCE=1 22LIBS += -shared -lcutils -lhardware -lsync $(LIBDRM_LIBS) 23 24OBJS = $(foreach source, $(SOURCES), $(addsuffix .o, $(basename $(source)))) 25 26OBJECTS = $(addprefix $(TARGET_DIR), $(notdir $(OBJS))) 27LIBRARY = $(addprefix $(TARGET_DIR), $(GRALLOC)) 28 29.PHONY: all clean 30 31all: $(LIBRARY) 32 33$(LIBRARY): $(OBJECTS) 34 35clean: 36 $(RM) $(LIBRARY) 37 $(RM) $(OBJECTS) 38 39$(LIBRARY): 40 $(CXX) $(CPPFLAGS) $(CXXFLAGS) $^ -o $@ $(LIBS) 41 42$(TARGET_DIR)%.o: %.cc 43 $(CXX) $(CPPFLAGS) $(CXXFLAGS) -c $^ -o $@ -MMD 44 45$(TARGET_DIR)%.o: %.c 46 $(CC) $(CPPFLAGS) $(CFLAGS) -c $^ -o $@ -MMD 47