Updated MSpec source to 46e80081.
[rbx.git] / shotgun / external_libs / libcchash / Makefile
blobe4706a2d7c63b5912cf496ab96ab92e2ae4cc5b1
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)
17 VERSION = 1
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,libcchash-$(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 NAME=libcchash
41 OUTPUT_LIB = $(NAME).$(VERSION).$(SUFFIX)
42 OUTPUT_A = $(NAME).a
44 ifeq ($(UNAME),Darwin)
45 SINGLE_MODULE=-Wl,-single_module
46 ifeq ($(OSVER),9.1.0)
47 export MACOSX_DEPLOYMENT_TARGET=10.5
48 else
49 export MACOSX_DEPLOYMENT_TARGET=10.4
50 endif
51 else
52 SINGLE_MODULE=
53 endif
55 ifeq ($(UNAME),SunOS)
56 CFLAGS+=-D__C99FEATURES__
57 endif
59 ifdef DEV
60 OPTIMIZATIONS=
61 else
62 INLINE_OPTS=
63 OPTIMIZATIONS=-O2 -funroll-loops -finline-functions $(INLINE_OPTS)
64 endif
66 ifeq ($(CPU), powerpc)
67 OPTIMIZATIONS+=-falign-loops=16
68 endif
70 CFLAGS += -fPIC $(CPPFLAGS)
72 DEPS = hashtable.h hashtable_itr.h hashtable_utility.h
73 OBJS = hashtable.o hashtable_itr.o hashtable_utility.o
75 all: library
77 tester: hashtable.o tester.o hashtable_itr.o
78 $(CC) $(CFLAGS) -o tester hashtable.o hashtable_itr.o tester.o
80 %.o: %.c
81 $(COMP) $(CFLAGS) $(OPTIMIZATIONS) -c $< -o $@
83 %.o: %.S
84 $(COMP) $(CFLAGS) $(OPTIMIZATIONS) -c $< -o $@
86 .%.d: %.c $(DEPS)
87 @echo DEP $<
88 @set -e; rm -f $@; \
89 $(CC) -MM $(CPPFLAGS) $< > $@.$$$$; \
90 sed 's,\($*\)\.o[ :]*,\1.o $@ : ,g' < $@.$$$$ > $@; \
91 rm -f $@.$$$$
93 library: $(OUTPUT_LIB) $(OUTPUT_A)
95 $(OUTPUT_LIB): $(DEPS) $(OBJS)
96 $(LINKER) -o $(OUTPUT_LIB) $(OBJS) $(SONAME) $(LIBS)
98 $(OUTPUT_A): $(DEPS) $(OBJS)
99 $(AR) cru $(OUTPUT_A) $(OBJS)
100 $(RANLIB) $(OUTPUT_A)
102 .PHONY: library
104 clean:
105 rm -f *.o *.lo *.la *.so *.dylib *.a tester
107 .PHONY: clean
109 ifneq ($(MAKECMDGOALS),clean)
110 -include $(SOURCES:%.c=.%.d)
111 endif