• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# Copyright (c) 2011 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# TODO(ihf): When X on Nyan is gone, simplify this makefile,
6#            specifically the *_PORTABLE and *_X_ONLY bits.
7
8USE_X = $(filter X, $(USE))
9ifeq ($(GRAPHICS_BACKEND),OPENGLES)
10    USE_GLES = y
11else
12    USE_GLES = $(filter opengles, $(USE))
13endif
14
15ifneq ($(USE_X),)
16    ifneq ($(USE_GLES),)
17        PLATFORM = PLATFORM_X11_EGL
18    else
19        PLATFORM = PLATFORM_GLX
20    endif
21else
22    PLATFORM = PLATFORM_NULL
23endif
24
25SOURCES_GL_BENCH = main.cc yuvtest.cc testbase.cc
26SOURCES_GL_BENCH += glinterfacetest.cc contexttest.cc swaptest.cc
27SOURCES_GL_BENCH += readpixeltest.cc
28SOURCES_GL_BENCH += attributefetchtest.cc varyingsandddxytest.cc cleartest.cc
29SOURCES_GL_BENCH += texturetest.cc texturereusetest.cc textureupdatetest.cc
30SOURCES_GL_BENCH += textureuploadtest.cc trianglesetuptest.cc fillratetest.cc
31SOURCES_GL_BENCH += windowmanagercompositingtest.cc drawsizetest.cc
32SOURCES_GL_BENCH += texturerebind.cc
33SOURCES_GL_BENCH += md5.cc png_helper.cc utils.cc waffle_stuff.cc filepath.cc
34SOURCES_GL_BENCH += bufferuploadtest.cc bufferuploadsubtest.cc
35
36SOURCES_WINDOWMANAGERTEST = windowmanagertest.cc utils.cc waffle_stuff.cc filepath.cc
37
38PKG_CONFIG ?= pkg-config
39PC_DEPS = libpng
40PC_CFLAGS := $(shell $(PKG_CONFIG) --cflags $(PC_DEPS))
41PC_LIBS := $(shell $(PKG_CONFIG) --libs $(PC_DEPS))
42
43CXXFLAGS = -g -Wall -Werror -std=gnu++11
44CPPFLAGS += $(PC_CFLAGS)
45LDLIBS = $(PC_LIBS) -lgflags
46
47GL_BENCH = ../glbench
48WINDOWMANAGERTEST = ../windowmanagertest
49
50PLATFORM_PKGS = waffle-1
51ifeq ($(PLATFORM),PLATFORM_GLX)
52    PLATFORM_PKGS += x11
53endif
54PLATFORM_CFLAGS = -DPLATFORM=$(PLATFORM)
55PLATFORM_CFLAGS += $(shell $(PKG_CONFIG) --cflags $(PLATFORM_PKGS))
56PLATFORM_LIBS = $(shell $(PKG_CONFIG) --libs $(PLATFORM_PKGS))
57
58ifneq ($(USE_GLES),)
59CPPFLAGS += -DUSE_OPENGLES
60LDLIBS += -lGLESv2 -lEGL
61else
62CPPFLAGS += -DUSE_OPENGL
63LDLIBS += -lGL
64endif
65
66SOURCES_ALL = $(sort $(SOURCES_GL_BENCH) \
67                     $(SOURCES_WINDOWMANAGERTEST))
68
69OBJS_GL_BENCH = $(SOURCES_GL_BENCH:.cc=.o)
70OBJS_WINDOWMANAGERTEST = $(SOURCES_WINDOWMANAGERTEST:.cc=.o)
71OBJS_ALL = $(SOURCES_ALL:.cc=.o)
72DEPS_ALL = $(SOURCES_ALL:.cc=.d)
73
74.PHONY: all clean
75
76EXE_PORTABLE = $(GL_BENCH) $(WINDOWMANAGERTEST)
77OBJ_PORTABLE = $(sort $(OBJS_GL_BENCH) $(OBJS_WINDOWMANAGERTEST))
78
79all:: $(EXE_PORTABLE)
80ifneq ($(USE_X),)
81all:: $(EXE_X_ONLY)
82endif
83
84$(GL_BENCH): $(OBJS_GL_BENCH)
85$(WINDOWMANAGERTEST): $(OBJS_WINDOWMANAGERTEST)
86
87clean:
88	$(RM) $(GL_BENCH) $(WINDOWMANAGERTEST)
89	$(RM) $(OBJS_ALL) $(DEPS_ALL)
90	$(RM) *.o *.d .version
91
92$(EXE_PORTABLE):
93	$(CXX) $(CXXFLAGS) $(LDFLAGS) $^ -o $@ $(LDLIBS) $(PLATFORM_LIBS)
94
95$(EXE_X_ONLY):
96	$(CXX) $(CXXFLAGS) $(LDFLAGS) $^ -o $@ $(LDLIBS) -lX11 -lrt
97
98$(OBJ_PORTABLE): %.o: %.cc
99	$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(PLATFORM_CFLAGS) -c $< -o $@ -MMD
100
101$(OBJS_X_ONLY): %.o: %.cc
102	$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@ -MMD
103
104-include $(DEPS_ALL)
105