| OLD | NEW |
| (Empty) |
| 1 # Copyright (c) 2011 The Native Client 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 # | |
| 6 # GNU Make based build file. For details on GNU Make see: | |
| 7 # http://www.gnu.org/software/make/manual/make.html | |
| 8 # | |
| 9 | |
| 10 # | |
| 11 # Project information | |
| 12 # | |
| 13 # These variables store project specific settings for the project name | |
| 14 # build flags, files to copy or install. In the examples it is typically | |
| 15 # only the list of sources and project name that will actually change and | |
| 16 # the rest of the makefile is boilerplate for defining build rules. | |
| 17 # | |
| 18 PROJECT:=hello_world_c | |
| 19 C_SOURCES:=hello_world_c.c | |
| 20 COPY_FILES:=hello_world_c.html hello_world_c.nmf | |
| 21 LDFLAGS:=-lppapi | |
| 22 | |
| 23 | |
| 24 # | |
| 25 # Get pepper directory for toolchain and includes. | |
| 26 # | |
| 27 # If PEPPER_ROOT is not set, then assume it can be found a two directories up, | |
| 28 # from the default example directory location. | |
| 29 # | |
| 30 THIS_MAKEFILE:=$(abspath $(lastword $(MAKEFILE_LIST))) | |
| 31 PEPPER_ROOT?=$(abspath $(dir $(THIS_MAKEFILE))../..) | |
| 32 | |
| 33 # Project Build flags | |
| 34 DEFINES:= | |
| 35 INCLUDES:= | |
| 36 WARNINGS:=-Wno-long-long -Wall -Wswitch-enum -pedantic -Werror | |
| 37 CFLAGS:=-pthread $(WARNINGS) $(DEFINES) $(INCLUDES) | |
| 38 | |
| 39 # | |
| 40 # Compute tool paths | |
| 41 # | |
| 42 # | |
| 43 OSNAME:=$(shell python $(PEPPER_ROOT)/tools/getos.py) | |
| 44 TC_PATH:=$(abspath $(PEPPER_ROOT)/toolchain/$(OSNAME)_x86_newlib) | |
| 45 CC:=$(TC_PATH)/bin/i686-nacl-gcc | |
| 46 CXX:=$(TC_PATH)/bin/i686-nacl-g++ | |
| 47 STRIP:=$(TC_PATH)/bin/i686-nacl-strip | |
| 48 | |
| 49 # | |
| 50 # Create shell aliases | |
| 51 # | |
| 52 # Create Python based aliases for common shell commands like copy or move. | |
| 53 # | |
| 54 COPY = python $(PEPPER_ROOT)/tools/oshelpers.py cp | |
| 55 MKDIR = python $(PEPPER_ROOT)/tools/oshelpers.py mkdir | |
| 56 RM = python $(PEPPER_ROOT)/tools/oshelpers.py rm | |
| 57 MV = python $(PEPPER_ROOT)/tools/oshelpers.py mv | |
| 58 | |
| 59 # | |
| 60 # Disable DOS PATH warning when using Cygwin based tools Windows | |
| 61 # | |
| 62 CYGWIN ?= nodosfilewarning | |
| 63 export CYGWIN | |
| 64 | |
| 65 # | |
| 66 # Define a macro for copying files to the configuration directory | |
| 67 # | |
| 68 # Copys a source file to the destination directory, removing the base path | |
| 69 # from the source. Adds a dependency to the destination directory in case it | |
| 70 # needs to be created. | |
| 71 # | |
| 72 # $(1) = Source file | |
| 73 # $(2) = Destination directory | |
| 74 define FILE_COPY | |
| 75 $(2)/$(notdir $(1)) : $(1) | $(2) | |
| 76 $(COPY) $(1) $(2) | |
| 77 $(2)_COPIES+=$(2)/$(notdir $(1)) | |
| 78 endef | |
| 79 | |
| 80 | |
| 81 # Declare the ALL target first, to make the 'all' target the default build | |
| 82 all: DEBUG RELEASE | |
| 83 | |
| 84 | |
| 85 # | |
| 86 # Debug Build rules. | |
| 87 # | |
| 88 DEBUG_x86_32_FLAGS:=-m32 -O0 -g | |
| 89 DEBUG_x86_64_FLAGS:=-m64 -O0 -g | |
| 90 DEBUG_x86_32_OBJS:=$(patsubst %.c,DBG/x86_32/%.o,$(C_SOURCES)) | |
| 91 DEBUG_x86_64_OBJS:=$(patsubst %.c,DBG/x86_64/%.o,$(C_SOURCES)) | |
| 92 | |
| 93 # Create DBG configuration directories | |
| 94 DBG: | |
| 95 $(MKDIR) -p $@ | |
| 96 | |
| 97 DBG/x86_32: | |
| 98 $(MKDIR) -p $@ | |
| 99 | |
| 100 DBG/x86_64: | |
| 101 $(MKDIR) -p $@ | |
| 102 | |
| 103 # Copy all files to that config | |
| 104 $(foreach src,$(COPY_FILES),$(eval $(call FILE_COPY,$(src),DBG))) | |
| 105 | |
| 106 # Include generated dependencies | |
| 107 -include DBG/x86_32/*.d | |
| 108 -include DBG/x86_64/*.d | |
| 109 | |
| 110 # Define compile rule for all 32 bit debug objects | |
| 111 DBG/x86_32/%.o : %.c $(THIS_MAKE) | DBG/x86_32 | |
| 112 $(CC) -o $@ -c $< $(DEBUG_x86_32_FLAGS) $(CFLAGS) -MMD -MF $@.d | |
| 113 | |
| 114 # Define compile rule for all 64 bit debug objects | |
| 115 DBG/x86_64/%.o : %.c $(THIS_MAKE) | DBG/x86_64 | |
| 116 $(CC) -o $@ -c $< $(DEBUG_x86_64_FLAGS) $(CFLAGS) | |
| 117 | |
| 118 # Define Link rule for 32 bit debug NEXE | |
| 119 DBG/$(PROJECT)_x86_32.nexe : $(DEBUG_x86_32_OBJS) | |
| 120 $(CC) -o $@ $^ $(DEBUG_x86_32_FLAGS) $(LDFLAGS) | |
| 121 | |
| 122 # Define Link rule for 64 bit debug NEXE | |
| 123 DBG/$(PROJECT)_x86_64.nexe : $(DEBUG_x86_64_OBJS) | |
| 124 $(CC) -o $@ $^ $(DEBUG_x86_64_FLAGS) $(LDFLAGS) | |
| 125 | |
| 126 # Define a DEBUG alias to build the debug version | |
| 127 .PHONY : DEBUG RUN_DEBUG | |
| 128 DEBUG : DBG/$(PROJECT)_x86_32.nexe DBG/$(PROJECT)_x86_64.nexe $(DBG_COPIES) | |
| 129 | |
| 130 # Define a RUN_DEBUG alias to build and server the DEBUG version | |
| 131 RUN_DEBUG: DEBUG | |
| 132 cd DBG && python ../../httpd.py | |
| 133 | |
| 134 | |
| 135 # | |
| 136 # Release build rules. | |
| 137 # | |
| 138 RELEASE_x86_32_FLAGS:=-m32 -O2 -g | |
| 139 RELEASE_x86_64_FLAGS:=-m64 -O2 -g | |
| 140 RELEASE_x86_32_OBJS:=$(patsubst %.c,REL/x86_32/%.o,$(C_SOURCES)) | |
| 141 RELEASE_x86_64_OBJS:=$(patsubst %.c,REL/x86_64/%.o,$(C_SOURCES)) | |
| 142 | |
| 143 REL: | |
| 144 $(MKDIR) -pv $@ | |
| 145 | |
| 146 REL/x86_32: | |
| 147 $(MKDIR) -pv $@ | |
| 148 | |
| 149 REL/x86_64: | |
| 150 $(MKDIR) -pv $@ | |
| 151 | |
| 152 # Copy all files to that config | |
| 153 $(foreach src,$(COPY_FILES),$(eval $(call FILE_COPY,$(src),REL))) | |
| 154 | |
| 155 # Include generated dependencies | |
| 156 -include REL/x86_32/*.d | |
| 157 -include REL/x86_64/*.d | |
| 158 | |
| 159 # Define compile rule for all 32 bit debug objects | |
| 160 REL/x86_32/%.o : %.c $(THIS_MAKE) | REL/x86_32 | |
| 161 $(CC) -o $@ -c $< $(RELEASE_x86_32_FLAGS) $(CFLAGS) -MMD -MF $@.d | |
| 162 | |
| 163 # Define compile rule for all 64 bit debug objects | |
| 164 REL/x86_64/%.o : %.c $(THIS_MAKE) | REL/x86_64 | |
| 165 $(CC) -o $@ -c $< $(RELEASE_x86_64_FLAGS) $(CFLAGS) | |
| 166 | |
| 167 # Define Link rule for 32 bit optimized and stripped NEXE | |
| 168 REL/$(PROJECT)_x86_32.nexe : $(RELEASE_x86_32_OBJS) | |
| 169 $(CC) -o $@.unstripped $^ $(RELEASE_x86_32_FLAGS) $(LDFLAGS) | |
| 170 $(STRIP) $< -o $@ | |
| 171 | |
| 172 # Define Link rule for 64 bit optimized and stripped NEXE | |
| 173 REL/$(PROJECT)_x86_64.nexe : $(RELEASE_x86_64_OBJS) | |
| 174 $(CC) -o $@.unstripped $^ $(RELEASE_x86_64_FLAGS) $(LDFLAGS) | |
| 175 $(STRIP) $@.unstripped -o $@ | |
| 176 | |
| 177 # Define a RELEASE alias to build the debug version | |
| 178 .PHONY : RELEASE RUN_RELEASE | |
| 179 RELEASE : REL/$(PROJECT)_x86_32.nexe REL/$(PROJECT)_x86_64.nexe $(REL_COPIES) | |
| 180 | |
| 181 # Define a RUN_RELEASE alias to build and server the RELEASE version | |
| 182 RUN_RELEASE: RELEASE | |
| 183 cd REL && python ../../httpd.py | |
| OLD | NEW |