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:=dlopen |
| 19 COPY_FILES:=dlopen.html |
| 20 LDFLAGS:=-ldl -lppapi_cpp -lppapi |
| 21 |
| 22 NEXES:=$(PROJECT)_x86_32.nexe $(PROJECT)_x86_64.nexe |
| 23 NEXES+=lib32/libeightball.so lib64/libeightball.so |
| 24 |
| 25 # |
| 26 # Get pepper directory for toolchain and includes. |
| 27 # |
| 28 # If PEPPER_ROOT is not set, then assume it can be found a two directories up, |
| 29 # from the default example directory location. |
| 30 # |
| 31 THIS_MAKEFILE:=$(abspath $(lastword $(MAKEFILE_LIST))) |
| 32 PEPPER_ROOT?=$(abspath $(dir $(THIS_MAKEFILE))../..) |
| 33 |
| 34 # Project Build flags |
| 35 DEFINES:= |
| 36 INCLUDES:= |
| 37 WARNINGS:=-Wno-long-long -Wall -Wswitch-enum |
| 38 CXXFLAGS:=-pthread $(WARNINGS) $(DEFINES) $(INCLUDES) |
| 39 |
| 40 # |
| 41 # Compute tool paths |
| 42 # |
| 43 # |
| 44 OSNAME:=$(shell python $(PEPPER_ROOT)/tools/getos.py) |
| 45 TC_PATH:=$(abspath $(PEPPER_ROOT)/toolchain/$(OSNAME)_x86_glibc) |
| 46 CC:=$(TC_PATH)/bin/i686-nacl-gcc |
| 47 CXX:=$(TC_PATH)/bin/i686-nacl-g++ |
| 48 STRIP:=$(TC_PATH)/bin/i686-nacl-strip |
| 49 |
| 50 # |
| 51 # Create shell aliases |
| 52 # |
| 53 # Create Python based aliases for common shell commands like copy or move. |
| 54 # |
| 55 COPY:= python $(PEPPER_ROOT)/tools/oshelpers.py cp |
| 56 MKDIR:= python $(PEPPER_ROOT)/tools/oshelpers.py mkdir |
| 57 RM:= python $(PEPPER_ROOT)/tools/oshelpers.py rm |
| 58 MV:= python $(PEPPER_ROOT)/tools/oshelpers.py mv |
| 59 |
| 60 # |
| 61 # NMF Manifiest generation |
| 62 # |
| 63 NMF:=python $(PEPPER_ROOT)/tools/create_nmf.py |
| 64 NMF+=-D $(TC_PATH)/x86_64-nacl/bin/objdump |
| 65 NMF_PATHS:=-L $(TC_PATH)/x86_64-nacl/lib32 -L $(TC_PATH)/x86_64-nacl/lib |
| 66 NMF_PATHS+=-L lib32 -L lib64 |
| 67 |
| 68 # |
| 69 # Disable DOS PATH warning when using Cygwin based tools Windows |
| 70 # |
| 71 CYGWIN ?= nodosfilewarning |
| 72 export CYGWIN |
| 73 |
| 74 # |
| 75 # Define a macro for copying files to the configuration directory |
| 76 # |
| 77 # Copys a source file to the destination directory, removing the base path |
| 78 # from the source. Adds a dependency to the destination directory in case it |
| 79 # needs to be created. |
| 80 # |
| 81 # $(1) = Source file |
| 82 # $(2) = Destination directory |
| 83 define FILE_COPY |
| 84 $(2)/$(notdir $(1)) : $(1) | $(2) |
| 85 $(COPY) $(1) $(2) |
| 86 $(2)_COPIES+=$(2)/$(notdir $(1)) |
| 87 endef |
| 88 |
| 89 |
| 90 # Declare the ALL target first, to make the 'all' target the default build |
| 91 all: DEBUG RELEASE |
| 92 |
| 93 |
| 94 |
| 95 # |
| 96 # Debug Build rules. |
| 97 # |
| 98 DEBUG_x86_32_FLAGS:=-m32 -O0 -g |
| 99 DEBUG_x86_64_FLAGS:=-m64 -O0 -g |
| 100 |
| 101 # Create DBG configuration directories |
| 102 DBG: |
| 103 $(MKDIR) -p $@ |
| 104 |
| 105 DBG/lib32: |
| 106 $(MKDIR) -p $@ |
| 107 |
| 108 DBG/lib64: |
| 109 $(MKDIR) -p $@ |
| 110 |
| 111 # Copy all files to that config |
| 112 $(foreach src,$(COPY_FILES),$(eval $(call FILE_COPY,$(src),DBG))) |
| 113 |
| 114 # Build debug version dlopen nexe and eightball.so for 32 and 64 bit. |
| 115 DBG/dlopen_x86_32.o: dlopen.cc $(THIS_MAKE) | DBG |
| 116 $(CXX) -o $@ -c $< $(DEBUG_x86_32_FLAGS) $(CXXFLAGS) |
| 117 |
| 118 DBG/dlopen_x86_32.nexe: DBG/dlopen_x86_32.o $(THIS_MAKE) | DBG |
| 119 $(CXX) -o $@ $< $(DEBUG_x86_32_FLAGS) $(LDFLAGS) |
| 120 |
| 121 DBG/dlopen_x86_64.o: dlopen.cc $(THIS_MAKE) | DBG |
| 122 $(CXX) -o $@ -c $< $(DEBUG_x86_64_FLAGS) $(CXXFLAGS) |
| 123 |
| 124 DBG/dlopen_x86_64.nexe: DBG/dlopen_x86_64.o $(THIS_MAKE) | DBG |
| 125 $(CXX) -o $@ $< $(DEBUG_x86_64_FLAGS) $(LDFLAGS) |
| 126 |
| 127 DBG/eightball_x86_32.o: eightball.cc $(THIS_MAKE) | DBG |
| 128 $(CXX) -o $@ -c $< $(DEBUG_x86_32_FLAGS) $(CXXFLAGS) -fPIC |
| 129 |
| 130 DBG/lib32/libeightball.so: DBG/eightball_x86_32.o $(THIS_MAKE) | DBG/lib32 |
| 131 $(CXX) -o $@ $< $(DEBUG_x86_32_FLAGS) $(LDFLAGS) -shared |
| 132 |
| 133 DBG/eightball_x86_64.o: eightball.cc $(THIS_MAKE) | DBG |
| 134 $(CXX) -o $@ -c $< $(DEBUG_x86_64_FLAGS) $(CXXFLAGS) -fPIC |
| 135 |
| 136 DBG/lib64/libeightball.so: DBG/eightball_x86_64.o $(THIS_MAKE) | DBG/lib64 |
| 137 $(CXX) -o $@ $< $(DEBUG_x86_64_FLAGS) $(LDFLAGS) -shared |
| 138 |
| 139 # Define rule for building NMF file and copying dependencies |
| 140 DBG_NEXES:=$(foreach src,$(NEXES),DBG/$(src)) |
| 141 |
| 142 DBG/$(PROJECT).nmf : $(DBG_NEXES) |
| 143 cd DBG && $(NMF) -o dlopen.nmf -s . $(NMF_PATHS) $(NEXES) |
| 144 |
| 145 # Define a DEBUG alias to build the debug version |
| 146 .PHONY : DEBUG RUN_DEBUG |
| 147 DEBUG : $(DBG_NEXES) DBG/$(PROJECT).nmf $(DBG_COPIES) |
| 148 |
| 149 # Define a RUN_DEBUG alias to build and server the DEBUG version |
| 150 RUN_DEBUG: DEBUG |
| 151 cd DBG && python ../../httpd.py |
| 152 |
| 153 |
| 154 # |
| 155 # Release build rules. |
| 156 # |
| 157 RELEASE_x86_32_FLAGS:=-m32 -O2 |
| 158 RELEASE_x86_64_FLAGS:=-m64 -O2 |
| 159 |
| 160 REL: |
| 161 $(MKDIR) -p $@ |
| 162 |
| 163 REL/lib32: |
| 164 $(MKDIR) -p $@ |
| 165 |
| 166 REL/lib64: |
| 167 $(MKDIR) -p $@ |
| 168 |
| 169 # Copy all files to that config |
| 170 $(foreach src,$(COPY_FILES),$(eval $(call FILE_COPY,$(src),REL))) |
| 171 |
| 172 # Build release version dlopen nexe and eightball.so for 32 and 64 bit. |
| 173 REL/dlopen_x86_32.o: dlopen.cc $(THIS_MAKE) | REL |
| 174 $(CXX) -o $@ -c $< $(RELEASE_x86_32_FLAGS) $(CXXFLAGS) |
| 175 |
| 176 REL/dlopen_x86_32.nexe: REL/dlopen_x86_32.o $(THIS_MAKE) | REL |
| 177 $(CXX) -o $@ $< $(RELEASE_x86_32_FLAGS) $(LDFLAGS) |
| 178 |
| 179 REL/dlopen_x86_64.o: dlopen.cc $(THIS_MAKE) | REL |
| 180 $(CXX) -o $@ -c $< $(RELEASE_x86_64_FLAGS) $(CXXFLAGS) |
| 181 |
| 182 REL/dlopen_x86_64.nexe: REL/dlopen_x86_64.o $(THIS_MAKE) | REL |
| 183 $(CXX) -o $@ $< $(RELEASE_x86_64_FLAGS) $(LDFLAGS) |
| 184 |
| 185 REL/eightball_x86_32.o: eightball.cc $(THIS_MAKE) | REL/lib32 |
| 186 $(CXX) -o $@ -c $< $(RELEASE_x86_32_FLAGS) $(CXXFLAGS) -fPIC |
| 187 |
| 188 REL/lib32/libeightball.so: REL/eightball_x86_32.o $(THIS_MAKE) | REL/lib32 |
| 189 $(CXX) -o $@ $< $(RELEASE_x86_32_FLAGS) $(LDFLAGS) -shared |
| 190 |
| 191 REL/eightball_x86_64.o: eightball.cc $(THIS_MAKE) | REL/lib64 |
| 192 $(CXX) -o $@ -c $< $(RELEASE_x86_64_FLAGS) $(CXXFLAGS) -fPIC |
| 193 |
| 194 REL/lib64/libeightball.so: REL/eightball_x86_64.o $(THIS_MAKE) | REL/lib64 |
| 195 $(CXX) -o $@ $< $(RELEASE_x86_64_FLAGS) $(LDFLAGS) -shared |
| 196 |
| 197 # Define rule for building NMF file and copying dependencies |
| 198 REL_NEXES:=$(foreach src,$(NEXES),REL/$(src)) |
| 199 |
| 200 REL/$(PROJECT).nmf : $(REL_NEXES) |
| 201 cd REL && $(NMF) -o dlopen.nmf -s . $(NMF_PATHS) $(NEXES) |
| 202 |
| 203 # Define a RELEASE alias to build the release version |
| 204 .PHONY : RELEASE RUN_RELEASE |
| 205 RELEASE : $(REL_NEXES) REL/$(PROJECT).nmf $(REL_COPIES) |
| 206 |
| 207 # Define a RUN_RELEASE alias to build and server the RELEASE version |
| 208 RUN_RELEASE: RELEASE |
| 209 cd REL && python ../../httpd.py |
OLD | NEW |