1compiler := gcc 2extra_flags := 3use_neon := 0 4release := release 5DYLIB := so 6PREFIX := /usr 7INSTALLDIR := $(PREFIX)/lib/retroarch/filters/video 8 9ifeq ($(platform),) 10 platform = unix 11 ifeq ($(shell uname -s),) 12 platform = win 13 else ifneq ($(findstring Darwin,$(shell uname -s)),) 14 platform = osx 15 arch = intel 16 ifeq ($(shell uname -p),powerpc) 17 arch = ppc 18 endif 19 else ifneq ($(findstring MINGW,$(shell uname -s)),) 20 platform = win 21 endif 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 := $(LDFLAGS) -shared -Wl,--version-script=link.T 46 47ifeq ($(platform), unix) 48DYLIB = so 49else ifeq ($(platform), osx) 50compiler := $(CC) 51DYLIB = dylib 52ldflags := -dynamiclib 53 ARCHFLAGS= 54 MINVERFLAGS= 55 ifeq ($(shell uname -p),arm) 56 MINVERFLAGS = -mmacosx-version-min=10.15 -stdlib=libc++ # macOS (Metal, ARM 64bit) 57 MINVERFLAGS += -DDONT_WANT_ARM_OPTIMIZATIONS 58 else ifeq ($(HAVE_METAL),1) 59 MINVERFLAGS = -mmacosx-version-min=10.13 -stdlib=libc++ # macOS (Metal, x86 64bit) 60 else ifeq ($(shell uname -p),powerpc) 61 MINVERFLAGS = -mmacosx-version-min=10.5 # macOSX (PowerPC 32-bit) 62 else ifeq ($(shell uname -m),i386) 63 MINVERFLAGS = -mmacosx-version-min=10.6 # macOSX (OpenGL, x86 32bit) 64 else 65 MINVERFLAGS = -mmacosx-version-min=10.7 -stdlib=libc++ # macOSX (OpenGL, x86 64bit) 66 endif 67 68 # Build for a specific architecture when ARCH is defined as a switch 69 ifeq ($(ARCH),arm64) 70 MINVERFLAGS = -mmacosx-version-min=10.15 -stdlib=libc++ # macOS (Metal, ARM 64bit) 71 MINVERFLAGS += -DDONT_WANT_ARM_OPTIMIZATIONS 72 ARCHFLAGS = -arch arm64 73 else ifeq ($(ARCH),x86_64) 74 ifeq ($(HAVE_METAL),1) 75 MINVERFLAGS = -mmacosx-version-min=10.13 -stdlib=libc++ 76 else 77 MINVERFLAGS = -mmacosx-version-min=10.7 -stdlib=libc++ 78 endif 79 ARCHFLAGS = -arch x86_64 80 else ifeq ($(ARCH),x86) 81 MINVERFLAGS = -mmacosx-version-min=10.6 82 ARCHFLAGS = -arch x86 83 else ifeq ($(ARCH),ppc) 84 MINVERFLAGS = -mmacosx-version-min=10.5 85 ARCHFLAGS = -arch ppc 86 endif 87 ifeq ($(BUILDBOT),1) 88 ARCHFLAGS = -target $(LIBRETRO_APPLE_PLATFORM) -isysroot $(LIBRETRO_APPLE_ISYSROOT) 89 endif 90 extraflags += $(MINVERFLAGS) $(ARCHFLAGS) 91 ldflags += $(MINVERFLAGS) $(ARCHFLAGS) 92else 93extra_flags += -static-libgcc -static-libstdc++ 94DYLIB = dll 95endif 96 97CC := $(compiler) 98CXX := $(subst CC,++,$(compiler)) 99flags := $(CPPFLAGS) $(CFLAGS) -fPIC $(extra_flags) -I../../libretro-common/include 100asflags := $(ASFLAGS) -fPIC $(extra_flags) 101objects := 102flags += -std=c99 103 104ifeq (1,$(use_neon)) 105ASMFLAGS := -INEON/asm 106asflags += -mfpu=neon 107endif 108 109objects += blargg_ntsc_snes.$(DYLIB) \ 110 phosphor2x.$(DYLIB) \ 111 epx.$(DYLIB) \ 112 lq2x.$(DYLIB) \ 113 2xsai.$(DYLIB) \ 114 super2xsai.$(DYLIB) \ 115 supereagle.$(DYLIB) \ 116 2xbr.$(DYLIB) \ 117 darken.$(DYLIB) \ 118 scale2x.$(DYLIB) \ 119 normal2x.$(DYLIB) \ 120 normal2x_width.$(DYLIB) \ 121 normal2x_height.$(DYLIB) \ 122 normal4x.$(DYLIB) \ 123 scanline2x.$(DYLIB) \ 124 grid2x.$(DYLIB) \ 125 grid3x.$(DYLIB) \ 126 gameboy3x.$(DYLIB) \ 127 gameboy4x.$(DYLIB) \ 128 dot_matrix_3x.$(DYLIB) \ 129 dot_matrix_4x.$(DYLIB) \ 130 upscale_1_5x.$(DYLIB) \ 131 upscale_256x_320x240.$(DYLIB) 132 133all: build; 134 135%.o: %.S 136 $(CC) -c -o $@ $(asflags) $(ASMFLAGS) $< 137 138%.o: %.c 139 $(CC) -c -o $@ $(flags) $< 140 141%.$(DYLIB): %.o 142 $(CC) -o $@ $(ldflags) $(flags) $^ 143 144build: $(objects) 145 146clean: 147 rm -f *.o 148 rm -f *.$(DYLIB) 149 150strip: 151 strip -s *.$(DYLIB) 152 153install: 154 mkdir -p $(DESTDIR)$(INSTALLDIR) 155 cp -t $(DESTDIR)$(INSTALLDIR) $(objects) *.filt 156 157test-install: 158 DESTDIR=/tmp/build $(MAKE) install 159