#
# This makefile is not expected to work in all situations.
# You may have to modify it.
#

ifeq ($(origin OS),undefined)
OS:=unknown
endif

CC:=gcc
CFLAGS:=-Wall -O2
LDFLAGS:=
INCLUDES:=-I.

ifeq ($(OS),Windows_NT)
TARGET:=pngrewrite.exe
else
TARGET:=pngrewrite
endif

all: $(TARGET)

.PHONY: all clean

OBJFILES:=pngrewrite.o libpngrewrite.o

$(TARGET): pngrewrite.o libpngrewrite.o
	$(CC) $(LDFLAGS) -o $@ $^ -lpng -lz -lm

pngrewrite.o: libpngrewrite.h
libpngrewrite.o: libpngrewrite.h

$(OBJFILES): %.o: %.c
	$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $<

clean:
	rm -f $(TARGET) $(OBJFILES)

