SRC = zlib-1.2.3

TARGETS = $(SRC)/libz.so.1.2.3
HEADERS := $(SRC)/zlib.h $(SRC)/zconf.h

.PHONY: clean install dist_install

all: install

$(SRC)/Makefile: 
	cd $(SRC); INSTALL='install -p' CC='$(CC) -s' CFLAGS='-Os' LDFLAGS='-s' ./configure \
                --prefix=$(PREFIX) \
                --libdir=$(PREFIX)/lib \
                --includedir=$(PREFIX)/include \
                --shared

$(TARGETS): $(SRC)/Makefile
	$(MAKE) -C $(SRC)

install: $(TARGETS)
	$(MAKE) -C $(SRC) install

	$(INSTALL) -d -m 755 $(SHADOW-DIR)/lib/
	$(INSTALL) -p $(TARGETS) $(INITRD-DIR)/lib/

clean:
	if [ -f $(SRC)/Makefile ]; then \
		make -C $(SRC) clean;       \
	fi
	rm -f $(SRC)/Makefile

dist_install: $(TARGETS)
	$(MAKE) -C $(SRC) install
