| 1 | TARGET := rzip |
| 2 | |
| 3 | LIBRETRO_COMM_DIR := ../../.. |
| 4 | LIBRETRO_DEPS_DIR := ../../../../deps |
| 5 | |
| 6 | # Attempt to detect target platform |
| 7 | ifeq '$(findstring ;,$(PATH))' ';' |
| 8 | UNAME := Windows |
| 9 | else |
| 10 | UNAME := $(shell uname 2>/dev/null || echo Unknown) |
| 11 | UNAME := $(patsubst CYGWIN%,Cygwin,$(UNAME)) |
| 12 | UNAME := $(patsubst MSYS%,MSYS,$(UNAME)) |
| 13 | UNAME := $(patsubst MINGW%,MSYS,$(UNAME)) |
| 14 | endif |
| 15 | |
| 16 | # Add '.exe' extension on Windows platforms |
| 17 | ifeq ($(UNAME), Windows) |
| 18 | TARGET := rzip.exe |
| 19 | endif |
| 20 | ifeq ($(UNAME), MSYS) |
| 21 | TARGET := rzip.exe |
| 22 | endif |
| 23 | |
| 24 | SOURCES := \ |
| 25 | rzip.c \ |
| 26 | $(LIBRETRO_COMM_DIR)/compat/fopen_utf8.c \ |
| 27 | $(LIBRETRO_COMM_DIR)/compat/compat_strl.c \ |
| 28 | $(LIBRETRO_COMM_DIR)/compat/compat_strcasestr.c \ |
| 29 | $(LIBRETRO_COMM_DIR)/compat/compat_posix_string.c \ |
| 30 | $(LIBRETRO_COMM_DIR)/encodings/encoding_utf.c \ |
| 31 | $(LIBRETRO_COMM_DIR)/encodings/encoding_crc32.c \ |
| 32 | $(LIBRETRO_COMM_DIR)/file/file_path.c \ |
| 33 | $(LIBRETRO_COMM_DIR)/file/file_path_io.c \ |
| 34 | $(LIBRETRO_COMM_DIR)/string/stdstring.c \ |
| 35 | $(LIBRETRO_COMM_DIR)/streams/file_stream.c \ |
| 36 | $(LIBRETRO_COMM_DIR)/streams/file_stream_transforms.c \ |
| 37 | $(LIBRETRO_COMM_DIR)/streams/interface_stream.c \ |
| 38 | $(LIBRETRO_COMM_DIR)/streams/memory_stream.c \ |
| 39 | $(LIBRETRO_COMM_DIR)/streams/rzip_stream.c \ |
| 40 | $(LIBRETRO_COMM_DIR)/streams/stdin_stream.c \ |
| 41 | $(LIBRETRO_COMM_DIR)/streams/trans_stream.c \ |
| 42 | $(LIBRETRO_COMM_DIR)/streams/trans_stream_pipe.c \ |
| 43 | $(LIBRETRO_COMM_DIR)/streams/trans_stream_zlib.c \ |
| 44 | $(LIBRETRO_COMM_DIR)/vfs/vfs_implementation.c \ |
| 45 | $(LIBRETRO_COMM_DIR)/time/rtime.c |
| 46 | |
| 47 | ifneq ($(wildcard $(LIBRETRO_DEPS_DIR)/*),) |
| 48 | # If we are building from inside the RetroArch |
| 49 | # directory (i.e. if an 'external' deps directory |
| 50 | # is avaiable), bake in zlib support |
| 51 | SOURCES += \ |
| 52 | $(LIBRETRO_DEPS_DIR)/libz/adler32.c \ |
| 53 | $(LIBRETRO_DEPS_DIR)/libz/libz-crc32.c \ |
| 54 | $(LIBRETRO_DEPS_DIR)/libz/deflate.c \ |
| 55 | $(LIBRETRO_DEPS_DIR)/libz/gzclose.c \ |
| 56 | $(LIBRETRO_DEPS_DIR)/libz/gzlib.c \ |
| 57 | $(LIBRETRO_DEPS_DIR)/libz/gzread.c \ |
| 58 | $(LIBRETRO_DEPS_DIR)/libz/gzwrite.c \ |
| 59 | $(LIBRETRO_DEPS_DIR)/libz/inffast.c \ |
| 60 | $(LIBRETRO_DEPS_DIR)/libz/inflate.c \ |
| 61 | $(LIBRETRO_DEPS_DIR)/libz/inftrees.c \ |
| 62 | $(LIBRETRO_DEPS_DIR)/libz/trees.c \ |
| 63 | $(LIBRETRO_DEPS_DIR)/libz/zutil.c |
| 64 | INCLUDE_DIRS := -I$(LIBRETRO_COMM_DIR)/include/compat/zlib |
| 65 | else |
| 66 | # If this is a stand-alone libretro-common directory, |
| 67 | # rely on system zlib library (note: only likely to |
| 68 | # work on Unix-based platforms...) |
| 69 | LDFLAGS += -lz |
| 70 | endif |
| 71 | |
| 72 | OBJS := $(SOURCES:.c=.o) |
| 73 | INCLUDE_DIRS += -I$(LIBRETRO_COMM_DIR)/include |
| 74 | CFLAGS += -DHAVE_ZLIB -Wall -pedantic -std=gnu99 $(INCLUDE_DIRS) |
| 75 | |
| 76 | # Silence "ISO C does not support the 'I64' ms_printf length modifier" |
| 77 | # warnings when using MinGW |
| 78 | ifeq ($(UNAME), Windows) |
| 79 | CFLAGS += -Wno-format |
| 80 | endif |
| 81 | ifeq ($(UNAME), MSYS) |
| 82 | CFLAGS += -Wno-format |
| 83 | endif |
| 84 | |
| 85 | ifeq ($(DEBUG), 1) |
| 86 | CFLAGS += -O0 -g -DDEBUG -D_DEBUG |
| 87 | else |
| 88 | CFLAGS += -O2 -DNDEBUG |
| 89 | endif |
| 90 | |
| 91 | all: $(TARGET) |
| 92 | |
| 93 | %.o: %.c |
| 94 | $(CC) -c -o $@ $< $(CFLAGS) |
| 95 | |
| 96 | $(TARGET): $(OBJS) |
| 97 | $(CC) -o $@ $^ $(LDFLAGS) |
| 98 | |
| 99 | clean: |
| 100 | rm -f $(TARGET) $(OBJS) |
| 101 | |
| 102 | .PHONY: clean |