Home | History | Annotate | Download | only in src
      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 
      8 USE_X = $(filter X, $(USE))
      9 ifeq ($(GRAPHICS_BACKEND),OPENGLES)
     10     USE_GLES = y
     11 else
     12     USE_GLES = $(filter opengles, $(USE))
     13 endif
     14 
     15 ifneq ($(USE_X),)
     16     ifneq ($(USE_GLES),)
     17         PLATFORM = PLATFORM_X11_EGL
     18     else
     19         PLATFORM = PLATFORM_GLX
     20     endif
     21 else
     22     PLATFORM = PLATFORM_NULL
     23 endif
     24 
     25 SOURCES_GL_BENCH = main.cc yuvtest.cc testbase.cc
     26 SOURCES_GL_BENCH += glinterfacetest.cc contexttest.cc swaptest.cc
     27 SOURCES_GL_BENCH += readpixeltest.cc
     28 SOURCES_GL_BENCH += attributefetchtest.cc varyingsandddxytest.cc cleartest.cc
     29 SOURCES_GL_BENCH += texturetest.cc texturereusetest.cc textureupdatetest.cc
     30 SOURCES_GL_BENCH += textureuploadtest.cc trianglesetuptest.cc fillratetest.cc
     31 SOURCES_GL_BENCH += windowmanagercompositingtest.cc
     32 SOURCES_GL_BENCH += md5.cc png_helper.cc utils.cc waffle_stuff.cc
     33 
     34 SOURCES_WINDOWMANAGERTEST = windowmanagertest.cc utils.cc waffle_stuff.cc
     35 
     36 PKG_CONFIG ?= pkg-config
     37 BASE_VER ?= 369476
     38 PC_DEPS = libchrome-$(BASE_VER) libpng
     39 PC_CFLAGS := $(shell $(PKG_CONFIG) --cflags $(PC_DEPS))
     40 PC_LIBS := $(shell $(PKG_CONFIG) --libs $(PC_DEPS))
     41 
     42 CXXFLAGS = -g -Wall -Werror -std=gnu++11
     43 CPPFLAGS += $(PC_CFLAGS)
     44 LDLIBS = $(PC_LIBS) -lgflags
     45 # To compile outside of chroot or with newest libchrome, use the following two lines:
     46 #CPPFLAGS += -I$(HOME)/chromium/src -DWORKAROUND_CROSBUG14304
     47 #LDLIBS += -lbase_static -L$(HOME)/chromium/src/out/Release/obj.target/base
     48 
     49 GL_BENCH = ../glbench
     50 WINDOWMANAGERTEST = ../windowmanagertest
     51 
     52 PLATFORM_PKGS = waffle-1
     53 ifeq ($(PLATFORM),PLATFORM_GLX)
     54     PLATFORM_PKGS += x11
     55 endif
     56 PLATFORM_CFLAGS = -DPLATFORM=$(PLATFORM)
     57 PLATFORM_CFLAGS += $(shell $(PKG_CONFIG) --cflags $(PLATFORM_PKGS))
     58 PLATFORM_LIBS = $(shell $(PKG_CONFIG) --libs $(PLATFORM_PKGS))
     59 
     60 ifneq ($(USE_GLES),)
     61 CPPFLAGS += -DUSE_OPENGLES
     62 LDLIBS += -lGLESv2 -lEGL
     63 else
     64 CPPFLAGS += -DUSE_OPENGL
     65 LDLIBS += -lGL
     66 endif
     67 
     68 SOURCES_ALL = $(sort $(SOURCES_GL_BENCH) \
     69                      $(SOURCES_WINDOWMANAGERTEST))
     70 
     71 OBJS_GL_BENCH = $(SOURCES_GL_BENCH:.cc=.o)
     72 OBJS_WINDOWMANAGERTEST = $(SOURCES_WINDOWMANAGERTEST:.cc=.o)
     73 OBJS_ALL = $(SOURCES_ALL:.cc=.o)
     74 DEPS_ALL = $(SOURCES_ALL:.cc=.d)
     75 
     76 .PHONY: all clean
     77 
     78 EXE_PORTABLE = $(GL_BENCH) $(WINDOWMANAGERTEST)
     79 OBJ_PORTABLE = $(sort $(OBJS_GL_BENCH) $(OBJS_WINDOWMANAGERTEST))
     80 
     81 all:: $(EXE_PORTABLE)
     82 ifneq ($(USE_X),)
     83 all:: $(EXE_X_ONLY)
     84 endif
     85 
     86 $(GL_BENCH): $(OBJS_GL_BENCH)
     87 $(WINDOWMANAGERTEST): $(OBJS_WINDOWMANAGERTEST)
     88 
     89 clean:
     90 	$(RM) $(GL_BENCH) $(WINDOWMANAGERTEST)
     91 	$(RM) $(OBJS_ALL) $(DEPS_ALL)
     92 	$(RM) *.o *.d .version
     93 
     94 $(EXE_PORTABLE):
     95 	$(CXX) $(CXXFLAGS) $(LDFLAGS) $^ -o $@ $(LDLIBS) $(PLATFORM_LIBS)
     96 
     97 $(EXE_X_ONLY):
     98 	$(CXX) $(CXXFLAGS) $(LDFLAGS) $^ -o $@ $(LDLIBS) -lX11 -lrt
     99 
    100 $(OBJ_PORTABLE): %.o: %.cc
    101 	$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(PLATFORM_CFLAGS) -c $< -o $@ -MMD
    102 
    103 $(OBJS_X_ONLY): %.o: %.cc
    104 	$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@ -MMD
    105 
    106 -include $(DEPS_ALL)
    107