
# This Makefile builds a shared version of the library, 
# libbz2.so.1.0.4, with soname libbz2.so.1.0,
# at least on x86-Linux (RedHat 7.2), 
# with gcc-2.96 20000731 (Red Hat Linux 7.1 2.96-98).  
# Please see the README file for some important info 
# about building the library like this.

# ------------------------------------------------------------------
# This file is part of bzip2/libbzip2, a program and library for
# lossless, block-sorting data compression.
#
# bzip2/libbzip2 version 1.0.4 of 20 December 2006
# Copyright (C) 1996-2006 Julian Seward <jseward@bzip.org>
#
# Please read the WARNING, DISCLAIMER and PATENTS sections in the 
# README file.
#
# This program is released under the terms of the license contained
# in the file LICENSE.
# ------------------------------------------------------------------


SHELL=/bin/sh
CC=gcc
ifeq ("$(CFLAGS)", "")
    ENVCFLAGS:=-O2 -g
else
    ENVCFLAGS:=$(CFLAGS)
endif
BIGFILES=-D_FILE_OFFSET_BITS=64
CFLAGS=$(ENVCFLAGS) -fpic -fPIC -Wall -Winline $(BIGFILES)

# Where are the source files, allows building "out of tree"
SOURCE_DIR="."
	
vpath %.c $(SOURCE_DIR)

OBJS= blocksort.o  \
      huffman.o    \
      crctable.o   \
      randtable.o  \
      compress.o   \
      decompress.o \
      bzlib.o

all: $(OBJS)
	$(CC) -shared -Wl,-soname -Wl,libbz2.so.1.0 -o libbz2.so.1.0.4 $(OBJS)
	$(CC) $(CFLAGS) -o bzip2-shared $(SOURCE_DIR)/bzip2.c libbz2.so.1.0.4
	rm -f libbz2.so.1.0
	ln -s libbz2.so.1.0.4 libbz2.so.1.0

clean: 
	rm -f $(OBJS) bzip2.o libbz2.so.1.0.4 libbz2.so.1.0 bzip2-shared

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

