Merge branch 'upstream'
[nativeclient.git] / tools / libnacl / Makefile
blob0f25b45a850e69fa344d7e6d88d2182ad1755325
1 # Copyright 2008, Google Inc.
2 # All rights reserved.
3 #
4 # Redistribution and use in source and binary forms, with or without
5 # modification, are permitted provided that the following conditions are
6 # met:
7 #
8 # * Redistributions of source code must retain the above copyright
9 # notice, this list of conditions and the following disclaimer.
10 # * Redistributions in binary form must reproduce the above
11 # copyright notice, this list of conditions and the following disclaimer
12 # in the documentation and/or other materials provided with the
13 # distribution.
14 # * Neither the name of Google Inc. nor the names of its
15 # contributors may be used to endorse or promote products derived from
16 # this software without specific prior written permission.
18 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 # The main target of this directory is the library libnacl.a
32 # This provides the low-level interface layer for newlib.
33 all: libnacl.a
35 # Building on Linux
36 include ../../include/linux/makeconfig
38 # The libraries are installed relative to NCCDIR.
40 # Set up paths for tools, etc.
41 NCCDIR ?= /usr/local/nacl-sdk/nacl
42 NCCC=$(NCCDIR)/../bin/nacl-gcc
43 NCAR=$(NCCDIR)/../bin/nacl-ar
45 NC_CFLAGS += -O3 -Werror -Wall -Wswitch-enum -g -fno-builtin \
46 -fno-stack-protector $(OSFLAGS) \
47 -DNACL_BLOCK_SHIFT=5
49 .S.o:
50 $(NCCC) -c $(NC_CFLAGS) -o $@ $<
52 %.o: %.c
53 $(NCCC) -c $(NC_CFLAGS) -o $@ $<
56 # C files defining runtime functions.
57 LIBNACL_C_FILES=close.c \
58 dup.c \
59 execve.c \
60 _execve.c \
61 fork.c \
62 fstat.c \
63 getdents.c \
64 gettimeofday.c \
65 imc_accept.c \
66 imc_connect.c \
67 imc_makeboundsock.c \
68 imc_mem_obj_create.c \
69 imc_recvmsg.c \
70 imc_sendmsg.c \
71 imc_socketpair.c \
72 isatty.c \
73 kill.c\
74 link.c \
75 lock.c \
76 lseek.c \
77 mmap.c \
78 munmap.c \
79 multimedia.c \
80 open.c \
81 pipe.c \
82 read.c \
83 sbrk.c \
84 sched_yield.c \
85 stacktrace.c \
86 stat.c \
87 sysconf.c \
88 times.c \
89 tls.c \
90 unlink.c \
91 wait.c \
92 write.c
95 LIBNACL_C_OBJS=$(LIBNACL_C_FILES:.c=.o)
97 # Asm files that wrap the entry points into the service runtime.
98 LIBNACL_ASM_FILES=nacl_clock.S \
99 nacl_close.S \
100 nacl_exit.S \
101 nacl_fstat.S \
102 nacl_getdents.S \
103 nacl_getpid.S \
104 nacl_gettimeofday.S \
105 nacl_imc_accept.S \
106 nacl_imc_connect.S \
107 nacl_imc_makeboundsock.S \
108 nacl_imc_mem_obj_create.S \
109 nacl_imc_recvmsg.S \
110 nacl_imc_sendmsg.S \
111 nacl_imc_socketpair.S \
112 nacl_lseek.S \
113 nacl_mmap.S \
114 nacl_multimedia.S \
115 nacl_null.S \
116 nacl_open.S \
117 nacl_read.S \
118 nacl_sched_yield.S \
119 nacl_srpc_get_fd.S \
120 nacl_stat.S \
121 nacl_sysbrk.S \
122 nacl_sysconf.S \
123 nacl_tls.S \
124 nacl_unmap.S \
125 nacl_write.S
127 LIBNACL_ASM_OBJS=$(LIBNACL_ASM_FILES:.S=.o)
129 ALL_SOURCES=$(LIBNACL_C_FILES) $(LIBNACL_ASM_FILES)
131 INTERNAL_HEADERS=nacl.h
132 SERVICE_RUNTIME_HEADERS=../../service_runtime/nacl_config.h \
133 ../../service_runtime/nacl_syscalls.h
135 # The files that make up the library.
136 $(APP_LIBC_OBJS): $(INTERNAL_HEADERS) $(SERVICE_RUNTIME_HEADERS)
138 libnacl.a: $(LIBNACL_C_OBJS) $(LIBNACL_ASM_OBJS)
139 $(NCAR) crs libnacl.a $(LIBNACL_C_OBJS) $(LIBNACL_ASM_OBJS)
141 # The headers for building IMC clients under NaCl.
142 LIBNACL_IMC_HEADERS=../../intermodule_comm/nacl_imc.h \
143 ../../intermodule_comm/nacl_imc_c.h
144 # The headers for building NPAPI plugins to run under NaCl.
145 LIBNACL_NPAPI_HEADER_DIR=../../../third_party/npapi/files/include
146 LIBNACL_NPAPI_HEADERS=../npapi_runtime/nacl_npapi.h \
147 $(LIBNACL_NPAPI_HEADER_DIR)/npapi.h \
148 $(LIBNACL_NPAPI_HEADER_DIR)/npruntime.h \
149 $(LIBNACL_NPAPI_HEADER_DIR)/nptypes.h \
150 $(LIBNACL_NPAPI_HEADER_DIR)/npupp.h \
151 # The headers that get installed in the SDK directory.
152 LIBNACL_HEADERS=tls.h\
153 $(LIBNACL_IMC_HEADERS) \
154 $(LIBNACL_NPAPI_HEADERS)
156 # Installing the library and header files in the SDK directory.
157 install: libnacl.a $(LIBNACL_HEADERS)
158 cp libnacl.a $(NCCDIR)/lib
159 mkdir -p $(NCCDIR)/include/nacl
160 cp -f $(LIBNACL_HEADERS) $(NCCDIR)/include/nacl
162 makedep: $(ALL_SOURCES)
163 $(NCCC) -M $(NC_CFLAGS) $(ALL_SOURCES) > makedep
165 clean:
166 rm -f libnacl.a *.o \
167 makedep \
168 *.i *~
170 .PHONY: all clean
172 -include makedep