TARGET    := lz4.library
VERSION   := 53
LZ4LIBDIR := lz4-r123

V ?= /V

CC      := ppc-amigaos-gcc
STRIP   := ppc-amigaos-strip -R.comment
AR      := ppc-amigaos-ar
RM      := rm -f

CFLAGS  := -O4 -fomit-frame-pointer -funroll-loops -g \
           -I../include -I./$(LZ4LIBDIR) \
           -Wall -Wwrite-strings -Werror
LINK    := -O4
LIBS    := 

LZ4LIB_SRCS := $(wildcard $(LZ4LIBDIR)/*.c)
LZ4LIB_OBJS := $(LZ4LIB_SRCS:.c=.o)

main_SRCS := $(wildcard main/*.c)
main_OBJS := $(main_SRCS:.c=.o)

OBJS := init.o malloc.o $(main_OBJS) $(LZ4LIB_OBJS)

.PHONY: all
all: $(TARGET)

init.o: $(TARGET)_rev.h lz4_vectors.c lz4_vectors.h
$(main_OBJS): lz4_vectors.h
$(LZ4LIB_OBJS): CFLAGS += -DNO_STREAM -DNO_OBSOLETE

$(TARGET): $(OBJS)
	$(CC) $(LINK) -nostartfiles -o $@.debug $^ $(LIBS)
	$(STRIP) -o $@ $@.debug

.PHONY: clean
clean:
	$(RM) $(TARGET) $(TARGET).debug *.o main/*.o $(LZ4LIBDIR)/*.o

.PHONY: revision
revision:
	bumprev $(VERSION) $(TARGET)

.PHONY: install
install:
	copy clone $(TARGET) SYS:Libs/

