Change soft-fail to use the config, rather than env
[rbx.git] / shotgun / external_libs / libmquark / Makefile
blobb14208b5917d1fb915f1c8a66678441dc9a4e909
1 -include ../../config.mk
3 # Respect the environment
4 ifeq ($(CC),)
5 CC=gcc
6 endif
8 UNAME=$(shell uname)
9 CPU=$(shell uname -p)
10 MARCH=$(shell uname -m)
11 OSVER=$(shell uname -r)
13 WARNINGS = -Wall
14 DEBUG = -g -ggdb3
16 CFLAGS = $(WARNINGS) $(DEBUG)
18 COMP=$(CC)
19 ifeq ($(UNAME),Darwin)
20 LDOPT=-dynamiclib
21 SUFFIX=dylib
22 SONAME=-current_version $(VERSION) -compatibility_version $(VERSION)
23 else
24 LDOPT=-shared
25 SUFFIX=so
26 ifneq ($(UNAME),SunOS)
27 SONAME=-Wl,-soname,libmquark-$(VERSION).$(SUFFIX)
28 endif
29 endif
31 BIN_RPATH=
32 LINKER=$(CC) $(LDOPT)
33 RANLIB = ranlib
35 ifndef VERBOSE
36 COMP=@echo CC $@;$(CC)
37 LINKER=@echo LINK $@;$(CC) $(LDOPT)
38 endif
40 VERSION=0.1
42 NAME=libmquark
43 OUTPUT_LIB=$(NAME).$(VERSION).$(SUFFIX)
44 OUTPUT_A=$(NAME).a
46 ifeq ($(UNAME),Darwin)
47 SINGLE_MODULE=-Wl,-single_module
48 ifeq ($(OSVER),9.1.0)
49 export MACOSX_DEPLOYMENT_TARGET=10.5
50 else
51 export MACOSX_DEPLOYMENT_TARGET=10.4
52 endif
53 else
54 SINGLE_MODULE=
55 endif
57 ifeq ($(UNAME),SunOS)
58 CFLAGS+=-D__C99FEATURES__
59 endif
61 ifdef DEV
62 OPTIMIZATIONS=
63 else
64 INLINE_OPTS=
65 OPTIMIZATIONS=-O2 -funroll-loops -finline-functions $(INLINE_OPTS)
66 endif
68 ifeq ($(CPU), powerpc)
69 OPTIMIZATIONS+=-falign-loops=16
70 endif
72 CPPFLAGS += -I../libcchash -I../libmpa -std=c99
73 CFLAGS += -fPIC $(CPPFLAGS)
74 DEPS=quark.h
76 SOURCES=quark.c
77 OBJS=$(SOURCES:.c=.o)
78 LIBS=-L../libcchash -L../libmpa -lcchash -lptr_array -lm
79 %.o: %.c
80 $(COMP) $(CFLAGS) $(OPTIMIZATIONS) -c $< -o $@
82 %.o: %.S
83 $(COMP) $(CFLAGS) $(OPTIMIZATIONS) -c $< -o $@
85 .%.d: %.c $(DEPS)
86 @echo DEP $<
87 @set -e; rm -f $@; \
88 $(CC) -MM $(CPPFLAGS) $< > $@.$$$$; \
89 sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
90 rm -f $@.$$$$
92 library: $(OUTPUT_LIB) $(OUTPUT_A)
94 $(OUTPUT_LIB): $(DEPS) $(OBJS)
95 $(LINKER) -o $(OUTPUT_LIB) $(OBJS) $(SONAME) $(LIBS)
97 $(OUTPUT_A): $(DEPS) $(OBJS)
98 $(AR) cru $(OUTPUT_A) $(OBJS)
99 $(RANLIB) $(OUTPUT_A)
101 .PHONY: library
103 clean:
104 rm -f *.o *.lo *.la *.so *.dylib *.a tester
106 test: tester
107 ./tester
109 tester: tester.o $(OUTPUT_A)
110 $(CC) -o tester $(OBJS) tester.o $(LIBS) $(OUTPUT_A)
112 .PHONY: clean
114 ifneq ($(MAKECMDGOALS),clean)
115 -include $(SOURCES:%.c=.%.d)
116 endif