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 5 GRALLOC = gralloc.cros.so 6 7 SRCS = $(wildcard *.cc) 8 SRCS += $(wildcard ../*.c) 9 10 SRCS += $(wildcard gralloc0/*.cc) 11 12 SOURCES = $(filter-out ../gbm%, $(SRCS)) 13 PKG_CONFIG ?= pkg-config 14 15 VPATH = $(dir $(SOURCES)) 16 LIBDRM_CFLAGS := $(shell $(PKG_CONFIG) --cflags libdrm) 17 LIBDRM_LIBS := $(shell $(PKG_CONFIG) --libs libdrm) 18 19 CPPFLAGS += -Wall -fPIC -Werror -flto $(LIBDRM_CFLAGS) 20 CXXFLAGS += -std=c++14 21 CFLAGS += -std=c99 22 LIBS += -shared -lcutils -lhardware -lsync $(LIBDRM_LIBS) 23 24 OBJS = $(foreach source, $(SOURCES), $(addsuffix .o, $(basename $(source)))) 25 26 OBJECTS = $(addprefix $(TARGET_DIR), $(notdir $(OBJS))) 27 LIBRARY = $(addprefix $(TARGET_DIR), $(GRALLOC)) 28 29 .PHONY: all clean 30 31 all: $(LIBRARY) 32 33 $(LIBRARY): $(OBJECTS) 34 35 clean: 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