1# Copyright (c) 2013 The Chromium 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# GNU Makefile based on shared rules provided by the Native Client SDK.
6# See README.Makefiles for more details.
7
8VALID_TOOLCHAINS := pnacl
9
10# NACL_SDK_ROOT ?= $(abspath $(CURDIR)/../../..)
11include $(NACL_SDK_ROOT)/tools/common.mk
12
13
14TARGET = sdl_app
15DEPS = ppapi_simple nacl_io
16# ppapi_simple and SDL2 end up being listed twice due to dependency solving issues -- Gabriel
17LIBS = SDL2_test SDL2 ppapi_simple SDL2main SDL2 $(DEPS) ppapi_gles2 ppapi_cpp ppapi pthread
18
19CFLAGS := -Wall
20SOURCES ?= testgles2.c
21
22# Build rules generated by macros from common.mk:
23# Overriden macro from NACL SDK to be able to customize the library search path -- Gabriel
24# Specific Link Macro
25#
26# $1 = Target Name
27# $2 = List of inputs
28# $3 = List of libs
29# $4 = List of deps
30# $5 = List of lib dirs
31# $6 = Other Linker Args
32#
33# For debugging, we translate the pre-finalized .bc file.
34#
35define LINKER_RULE
36all: $(1).pexe
37$(1)_x86_32.nexe : $(1).bc
38	$(call LOG,TRANSLATE,$$@,$(PNACL_TRANSLATE) --allow-llvm-bitcode-input -arch x86-32 $$^ -o $$@)
39
40$(1)_x86_64.nexe : $(1).bc
41	$(call LOG,TRANSLATE,$$@,$(PNACL_TRANSLATE) --allow-llvm-bitcode-input -arch x86-64 $$^ -o $$@)
42
43$(1)_arm.nexe : $(1).bc
44	$(call LOG,TRANSLATE,$$@,$(PNACL_TRANSLATE) --allow-llvm-bitcode-input -arch arm $$^ -o $$@)
45
46$(1).pexe: $(1).bc
47	$(call LOG,FINALIZE,$$@,$(PNACL_FINALIZE) -o $$@ $$^)
48
49$(1).bc: $(2) $(foreach dep,$(4),$(STAMPDIR)/$(dep).stamp)
50	$(call LOG,LINK,$$@,$(PNACL_LINK) -o $$@ $(2) $(PNACL_LDFLAGS) $(foreach path,$(5),-L$(path)/pnacl/$(CONFIG)) -L./lib $(foreach lib,$(3),-l$(lib)) $(6))
51endef
52
53$(foreach dep,$(DEPS),$(eval $(call DEPEND_RULE,$(dep))))
54$(foreach src,$(SOURCES),$(eval $(call COMPILE_RULE,$(src),$(CFLAGS))))
55
56ifeq ($(CONFIG),Release)
57$(eval $(call LINK_RULE,$(TARGET)_unstripped,$(SOURCES),$(LIBS),$(DEPS)))
58$(eval $(call STRIP_RULE,$(TARGET),$(TARGET)_unstripped))
59else
60$(eval $(call LINK_RULE,$(TARGET),$(SOURCES),$(LIBS),$(DEPS)))
61endif
62
63$(eval $(call NMF_RULE,$(TARGET),))
64