1compiler    := gcc
2extra_flags :=
3use_neon    := 0
4release	   := release
5DYLIB	      :=
6
7ifeq ($(platform),)
8platform = unix
9ifeq ($(shell uname -a),)
10   platform = win
11else ifneq ($(findstring MINGW,$(shell uname -a)),)
12   platform = win
13else ifneq ($(findstring Darwin,$(shell uname -a)),)
14   platform = osx
15   arch = intel
16ifeq ($(shell uname -p),powerpc)
17   arch = ppc
18endif
19else ifneq ($(findstring win,$(shell uname -a)),)
20   platform = win
21endif
22endif
23
24ifeq ($(platform),gcc)
25extra_rules_gcc := $(shell $(compiler) -dumpmachine)
26endif
27
28ifneq (,$(findstring armv7,$(extra_rules_gcc)))
29extra_flags += -mcpu=cortex-a9 -mtune=cortex-a9 -mfpu=neon
30use_neon := 1
31endif
32
33ifneq (,$(findstring hardfloat,$(extra_rules_gcc)))
34extra_flags += -mfloat-abi=hard
35endif
36
37ifeq (release,$(build))
38extra_flags += -O2
39endif
40
41ifeq (debug,$(build))
42extra_flags += -O0 -g
43endif
44
45ldflags := -shared -Wl,--version-script=link.T
46
47ifeq ($(platform), unix)
48DYLIB =
49else ifeq ($(platform), osx)
50compiler := $(CC)
51DYLIB =
52ldflags := -dynamiclib
53else
54extra_flags += -static-libgcc -static-libstdc++
55DYLIB = exe
56endif
57
58LIBRETRO_COMM_DIR := ../..
59CORE_DIR := $(LIBRETRO_COMM_DIR)/utils
60
61CC      := $(compiler)
62CXX     := $(subst CC,++,$(compiler))
63flags   := -fPIC $(extra_flags) -I$(LIBRETRO_COMM_DIR)/include
64asflags := -fPIC  $(extra_flags)
65LDFLAGS :=
66flags   += -std=c99 -DMD5_BUILD_UTILITY
67
68
69ifeq (1,$(use_neon))
70ASMFLAGS := -INEON/asm
71asflags += -mfpu=neon
72endif
73
74
75OBJS += $(CORE_DIR)/djb2.o \
76		  $(CORE_DIR)/md5.o \
77		  $(CORE_DIR)/sha1.o \
78		  $(CORE_DIR)/crc32.o
79UTILS += djb2$(DYLIB) md5$(DYLIB) sha1$(DYLIB) crc32$(DYLIB)
80
81all: djb2$(DYLIB) md5$(DYLIB) sha1$(DYLIB) crc32$(DYLIB)
82
83djb2$(DYLIB): $(CORE_DIR)/djb2.o
84
85md5$(DYLIB): $(CORE_DIR)/md5.o
86
87sha1$(DYLIB): $(CORE_DIR)/sha1.o
88
89crc32$(DYLIB): $(CORE_DIR)/crc32.o $(CORE_DIR)/../encodings/encoding_crc32.o
90
91%.o: %.S
92	$(CC) -c -o $@ $(asflags) $(LDFLAGS)  $(ASMFLAGS)  $<
93
94%.o: %.c
95	$(CC) -c -o $@ $(flags) $<
96
97%.$(DYLIB): %.o
98	$(CC) -o $@ $(ldflags) $(flags) $^
99
100clean:
101	rm -f *.o
102	rm -f djb2$(DYLIB) md5$(DYLIB) sha1$(DYLIB) crc32$(DYLIB)
103
104strip:
105	strip -s *.$(DYLIB)
106