Added spec:commit task to commit changes to spec/ruby sources.
[rbx.git] / shotgun / lib / Makefile
blobd5a60607fce0a3c229ea2b9b684a94c3700dfdef
1 -include ../config.mk
2 include ../common.mk
4 CPPFLAGS += -I.. -I../.. -I../../.. \
5 -I../external_libs/libffi/include \
6 -I../external_libs/libev \
7 -I../external_libs/onig \
8 -I../external_libs/libgdtoa \
9 -I../external_libs/libtommath \
10 -I../external_libs/libltdl \
11 -I../external_libs/libbstring \
12 -I../external_libs/libcchash \
13 -I../external_libs/libmpa \
14 -I../external_libs/libmquark \
15 -D_GNU_SOURCE
17 LIBS= -lz \
18 ../external_libs/libffi/.libs/libffi.a \
19 ../external_libs/libgdtoa/libgdtoa.a \
20 ../external_libs/libtommath/libtommath.a \
21 ../external_libs/onig/.libs/libonig.a \
22 $(SINGLE_MODULE) \
23 ../external_libs/libev/.libs/libev.a \
24 ../external_libs/libltdl/.libs/libltdl.a \
25 -lm \
26 ../external_libs/libbstring/libbstring.a \
27 ../external_libs/libcchash/libcchash.a \
28 ../external_libs/libmpa/libptr_array.a \
29 ../external_libs/libmquark/libmquark.a
31 ifeq ($(UNAME),Linux)
32 CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
33 endif
35 ifeq ($(UNAME),Darwin)
36 CPPFLAGS += -D_XOPEN_SOURCE -D_DARWIN_USE_64_BIT_INODE
37 SINGLE_MODULE=-Wl,-single_module
38 else
39 SINGLE_MODULE=
40 endif
42 ifneq ($(findstring BSD,$(UNAME)),BSD)
43 # BSD do not require a separate libdl
44 LIBS+=-ldl
45 else
46 # BSD and Darwin comes with strlcat and strlcpy
47 CPPFLAGS+=-DHAVE_STRLCAT -DHAVE_STRLCPY
48 CPPFLAGS+=-I/usr/local/include
49 endif
51 ifeq ($(UNAME),Darwin)
52 # BSD and Darwin comes with strlcat and strlcpy
53 CPPFLAGS+=-DHAVE_STRLCAT -DHAVE_STRLCPY
54 endif
56 # Linux needs -lrt and -lcrypt
57 # FreeBSD only needs -lcrypt
58 # Darwin, OpenBSD and Solaris don't need any
59 ifeq ($(UNAME),Linux)
60 LIBS+= -lrt -lcrypt
61 endif
63 ifeq ($(UNAME),FreeBSD)
64 LIBS+= -lcrypt
65 endif
67 # BSD needs special PThread handling
68 ifeq ($(findstring BSD,$(UNAME)),BSD)
69 LIBS+=-lpthread
70 endif
72 ifeq ($(UNAME),SunOS)
73 CFLAGS+=-D__C99FEATURES__
74 LIBS+= -lsocket
75 endif
77 ifdef PROF
78 OPTIMIZATIONS=-O2
79 else
80 ifdef DEV
81 OPTIMIZATIONS=-O0
82 else
83 ifdef TURBO
84 OPTIMIZATIONS=-O3 -falign-loops -momit-leaf-frame-pointer -fno-tree-pre
85 else
86 OPTIMIZATIONS=-O2 -finline-functions
87 endif
88 endif
89 endif
91 ifeq ($(CPU), powerpc)
92 OPTIMIZATIONS+=-falign-loops=16
93 endif
95 CFLAGS += -fPIC $(CPPFLAGS)
96 DEPS=auto.h system_primitives.gen instruction_names.c instruction_names.h \
97 node_types.c node_types.h
99 SOURCES=$(sort \
100 $(wildcard *.c) \
101 $(wildcard subtend/*.c) \
102 grammar.c \
103 auto.c \
104 instruction_names.c \
105 node_types.c \
107 OBJS=$(SOURCES:.c=.o) subtend/PortableUContext_asm.o
109 # Explicitly require anything you need from kernel/ or lib/
110 RUBY=ruby
112 %.o: %.c
113 $(COMP) $(CFLAGS) $(OPTIMIZATIONS) -c $< -o $@
115 %.o: %.S
116 $(COMP) $(CFLAGS) $(OPTIMIZATIONS) -c $< -o $@
118 %.d: %.c $(DEPS)
119 @echo DEP $<
120 @set -e; rm -f $@; \
121 $(CC) -MM -MT '$(<:.c=.o)' $(CPPFLAGS) $< > $@.$$$$; \
122 sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
123 rm -f $@.$$$$
125 $(RBXLIB): $(RBXLIBLOCAL)
126 $(LINKER) -o $(RBXLIB) $(OBJS) $(SONAME) $(LIBS)
128 $(RBXLIBLOCAL): $(DEPS) $(OBJS)
129 $(LINKER) -o $(RBXLIBLOCAL) $(OBJS) $(SONAMELOCAL) $(LIBS)
131 library: $(RBXLIB)
133 .PHONY: library
135 cpu_instructions.o: instructions.gen instruction_names.c instruction_names.h
136 cpu_primitives.o: system_primitives.gen
137 object_memory.o: object_memory.h
139 instruction_names.c instruction_names.h instructions.gen: instructions.rb
140 $(RUBY) instructions.rb > instructions.gen
142 system_primitives.gen: primitives.rb
143 $(RUBY) primitives.rb > system_primitives.gen
145 auto.h auto.c: genheader.rb ../../lib/compiler/system_hints.rb
146 $(RUBY) genheader.rb > auto.c
148 node_types.c node_types.h: node_types.rb
149 $(RUBY) node_types.rb
151 grammar.o:
152 $(COMP) $(CFLAGS) -c grammar.c
154 subtend/ffi.o: subtend/ffi.c
155 $(COMP) $(CFLAGS) $(OPTIMIZATIONS) -Wno-unused-variable -Wno-unused-value -c $< -o $@
157 # In a perfect world, we'd only rebuild grammar.c if grammar.y changed.
158 # However, version control systems do not track file modify times, which will
159 # mess up make's dependency tracking. So don't depend on grammar.y here.
160 grammar.c: grammar.y
161 bison -o grammar.c grammar.y
163 clean:
164 rm -f *.o \
165 *.lo \
166 *.la \
167 subtend/*.o \
168 subtend/*.lo \
169 subtend/*.d \
170 *.gen \
171 *.a \
172 auto.c \
173 auto.h \
174 *.d \
175 .*.d \
176 *.d.* \
177 instruction_names.c \
178 instruction_names.h \
179 node_types.c \
180 node_types.h \
181 primitive_indexes.h \
182 primitive_util.h
184 rm -rf .libs \
185 subtend/.libs \
186 librubinius-* \
187 *.dylib
189 .PHONY: clean
191 ifneq ($(MAKECMDGOALS),clean)
192 -include $(SOURCES:%.c=%.d)
193 endif