TARGET  := lzo.library
VERSION := 53

LZOLIBDIR := lzo-2.08

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

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

LZOLIB_SRCS := $(wildcard $(LZOLIBDIR)/src/*.c)
LZOLIB_OBJS := $(LZOLIB_SRCS:.c=.o)

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

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

.PHONY: all
all: $(TARGET)

init.o: $(TARGET)_rev.h lzo_vectors.c lzo_vectors.h
$(main_OBJS): lzo_vectors.h
$(LZOLIB_OBJS): CFLAGS += -DLZO_HAVE_CONFIG_H

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

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

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

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

