summaryrefslogtreecommitdiff
path: root/nacl/GNUmakefile.in
blob: 1fffcee898db1173797d53b7eeb3648bff90a15a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
# Copyright 2012 Google Inc. All Rights Reserved.
# Author: yugui@google.com (Yugui Sonoda)

include Makefile
-include uncommon.mk

NACL_SDK_ROOT=@NACL_SDK_ROOT@
NACL_TOOLCHAIN=@NACL_TOOLCHAIN@
NACL_TOOLCHAIN_DIR=$(NACL_SDK_ROOT)/toolchain/$(NACL_TOOLCHAIN)
CXX=@CXX@

# Don't override CC/LD/etc if they are already set to absolute
# paths (this is the case when building in the naclports tree).
ifeq ($(dir $(CC)),./)
CC:=$(NACL_TOOLCHAIN_DIR)/bin/$(CC)
endif
ifeq ($(dir $(CXX)),./)
CXX:=$(NACL_TOOLCHAIN_DIR)/bin/$(CXX)
endif
ifeq ($(dir $(LD)),./)
LD:=$(NACL_TOOLCHAIN_DIR)/bin/$(LD)
endif
ifeq ($(dir $(NM)),./)
NM:=$(NACL_TOOLCHAIN_DIR)/bin/$(NM)
endif
ifeq ($(dir $(AR)),./)
AR:=$(NACL_TOOLCHAIN_DIR)/bin/$(AR)
endif
ifeq ($(dir $(AS)),./)
AS:=$(NACL_TOOLCHAIN_DIR)/bin/$(AS)
endif
ifeq ($(dir $(RANLIB)),./)
RANLIB:=$(NACL_TOOLCHAIN_DIR)/bin/$(RANLIB)
endif
ifeq ($(dir $(OBJDUMP)),./)
OBJDUMP:=$(NACL_TOOLCHAIN_DIR)/bin/$(OBJDUMP)
endif
ifeq ($(dir $(OBJCOPY)),./)
OBJCOPY:=$(NACL_TOOLCHAIN_DIR)/bin/$(OBJCOPY)
endif
PYTHON=@PYTHON@

PPROGRAM=pepper-$(PROGRAM)
PEPPER_LIBS=-lppapi -lnacl_io
PROGRAM_NMF=$(PROGRAM:$(EXEEXT)=.nmf)
PPROGRAM_NMF=$(PPROGRAM:$(EXEEXT)=.nmf)

GNUmakefile: $(srcdir)/nacl/GNUmakefile.in
$(PPROGRAM): $(PROGRAM) pepper_main.$(OBJEXT)
	$(Q)$(MAKE) $(MFLAGS) PROGRAM=$(PPROGRAM) MAINOBJ="pepper_main.$(OBJEXT)" LIBS="$(LIBS) $(PEPPER_LIBS)" CC="$(CXX)" program
$(PROGRAM_NMF) $(PPROGRAM_NMF): $(@:.nmf=$(EXEEXT)) nacl/create_nmf.rb

.PHONY: pprogram package show_naclflags
.SUFFIXES: $(EXEEXT) .nmf
$(EXEEXT).nmf:
	$(ECHO) generating manifest $@
	$(Q)$(MINIRUBY) $(srcdir)/nacl/create_nmf.rb --verbose=$(V) $(@:.nmf=$(EXEEXT)) $@

pepper_main.$(OBJEXT): $(srcdir)/nacl/pepper_main.c
	@$(ECHO) compiling nacl/pepper_main.c
	$(Q) $(CC) $(CFLAGS) $(XCFLAGS) $(CPPFLAGS) $(COUTFLAG)$@ -c $(srcdir)/nacl/pepper_main.c

.rbconfig.time:
	@$(MAKE) .rbconfig.raw.time RBCONFIG=.rbconfig.raw.time
	@sed \
	  -e 's!CONFIG\["CC"\] = .*!CONFIG\["CC"\] = "$(CC)"!' \
	  -e 's!CONFIG\["LD"\] = .*!CONFIG\["LD"\] = "$(LD)"!' \
	  -e 's!CONFIG\["NM"\] = .*!CONFIG\["NM"\] = "$(NM)"!' \
	  -e 's!CONFIG\["AR"\] = .*!CONFIG\["AR"\] = "$(AR)"!' \
	  -e 's!CONFIG\["AS"\] = .*!CONFIG\["AS"\] = "$(AS)"!' \
	  -e 's!CONFIG\["RANLIB"\] = .*!CONFIG\["RANLIB"\] = "$(RANLIB)"!' \
	  -e 's!CONFIG\["OBJDUMP"\] = .*!CONFIG\["OBJDUMP"\] = "$(OBJDUMP)"!' \
	  -e 's!CONFIG\["OBJCOPY"\] = .*!CONFIG\["OBJCOPY"\] = "$(OBJCOPY)"!' \
	-i.bak rbconfig.rb
	@touch .rbconfig.time

all: pprogram
main: $(PROGRAM_NMF)
pprogram: showflags $(PPROGRAM) $(PPROGRAM_NMF)
program: $(PROGRAM_NMF)
prog: pprogram

package: pprogram install-lib install-ext-comm install-ext-arch
	$(INSTALL_DATA) $(srcdir)/nacl/example.html $(prefix)
	$(ECHO) generating manifest $@
	$(Q)$(MINIRUBY) $(srcdir)/nacl/package.rb $(prefix)

showflags: show_naclflags

show_naclflags:
	@echo "        NACL_SDK_ROOT = $(NACL_SDK_ROOT)"
	@echo "        NM = $(NM)"
	@echo "        AR = $(AR)"
	@echo "        AS = $(AS)"
	@echo "        RANLIB = $(RANLIB)"
	@echo "        OBJDUMP = $(OBJDUMP)"
	@echo "        OBJCOPY = $(OBJCOPY)"

clean-local::
	-$(RM) $(PPROGRAM) pepper_main.$(OBJEXT) $(PROGRAM_NMF) $(PPRGORAM_NMF)