92 lines
1.7 KiB
Makefile
Raw Normal View History

compiler := gcc
extra_flags :=
use_neon := 0
2014-05-20 13:32:34 +02:00
build = release
DYLIB := so
ifeq ($(platform),)
2014-05-20 13:32:34 +02:00
platform = unix
ifeq ($(shell uname -a),)
platform = win
else ifneq ($(findstring MINGW,$(shell uname -a)),)
platform = win
else ifneq ($(findstring Darwin,$(shell uname -a)),)
platform = osx
arch = intel
ifeq ($(shell uname -p),powerpc)
arch = ppc
endif
else ifneq ($(findstring win,$(shell uname -a)),)
platform = win
endif
endif
ifeq ($(platform),gcc)
2014-05-20 13:32:34 +02:00
extra_rules_gcc := $(shell $(compiler) -dumpmachine)
endif
ifneq (,$(findstring armv7,$(extra_rules_gcc)))
2014-05-20 13:32:34 +02:00
extra_flags += -mcpu=cortex-a9 -mtune=cortex-a9 -mfpu=neon
use_neon := 1
endif
ifneq (,$(findstring hardfloat,$(extra_rules_gcc)))
2014-05-20 13:32:34 +02:00
extra_flags += -mfloat-abi=hard
endif
ifeq (release,$(build))
2014-05-20 13:32:34 +02:00
extra_flags += -O2
endif
ifeq (debug,$(build))
2014-05-20 13:32:34 +02:00
extra_flags += -O0 -g
endif
2014-05-20 13:32:34 +02:00
ldflags := -shared -lm -Wl,--version-script=link.T
ifeq ($(platform), unix)
2014-05-20 13:32:34 +02:00
DYLIB = so
else ifeq ($(platform), osx)
2014-05-20 13:32:34 +02:00
compiler := $(CC)
DYLIB = dylib
ldflags := -dynamiclib
else
2014-05-20 13:32:34 +02:00
extra_flags += -static-libgcc -static-libstdc++
DYLIB = dll
endif
2014-05-25 16:06:19 +02:00
CC := $(compiler) -Wall
CXX := $(subst CC,++,$(compiler)) -std=gnu++0x -Wall
flags := -fPIC $(extra_flags)
asflags := -fPIC $(extra_flags)
objects :=
ifeq (1,$(use_neon))
2014-05-20 13:32:34 +02:00
ASMFLAGS := -INEON/asm
asflags += -mfpu=neon
endif
2014-05-20 13:32:34 +02:00
plugs := $(wildcard *.c)
objects := $(plugs:.c=.o)
targets := $(objects:.o=.$(DYLIB))
all: build;
%.o: %.S
$(CC) -c -o $@ $(asflags) $(ASMFLAGS) $<
%.o: %.c
$(CC) -c -o $@ $(flags) $<
%.$(DYLIB): %.o
$(CC) -o $@ $(ldflags) $(flags) $^
2014-05-20 13:32:34 +02:00
build: $(targets)
clean:
rm -f *.o
rm -f *.$(DYLIB)
strip:
strip -s *.$(DYLIB)