
# This Makefile builds a shared version of the library, 
# libbz2.so.1.0.3, 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.

SHELL=/bin/sh

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.3 $(OBJS)
	$(CC) $(CFLAGS) -o bzip2-shared bzip2.c libbz2.so.1.0.3
	rm -f libbz2.so.1.0 libbz2.so
	ln -s libbz2.so.1.0.3 libbz2.so.1.0
	ln -s libbz2.so.1.0.3 libbz2.so

CFLAGS += -fPIC

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

blocksort.o: blocksort.c
	$(CC) $(CFLAGS) -c blocksort.c
huffman.o: huffman.c
	$(CC) $(CFLAGS) -c huffman.c
crctable.o: crctable.c
	$(CC) $(CFLAGS) -c crctable.c
randtable.o: randtable.c
	$(CC) $(CFLAGS) -c randtable.c
compress.o: compress.c
	$(CC) $(CFLAGS) -c compress.c
decompress.o: decompress.c
	$(CC) $(CFLAGS) -c decompress.c
bzlib.o: bzlib.c
	$(CC) $(CFLAGS) -c bzlib.c

romfs:
	$(ROMFSINST) libbz2.so.1.0.3 /lib/libbz2.so.1.0.3
	$(ROMFSINST) -s libbz2.so.1.0.3 /lib/libbz2.so.1.0
	$(ROMFSINST) -s libbz2.so.1.0.3 /lib/libbz2.so
	$(ROMFSINST) -e CONFIG_USER_BZIP2_BZIP2 bzip2-shared /bin/bzip2
	$(ROMFSINST) -e CONFIG_USER_BZIP2_BZIP2 -s bzip2 /bin/bunzip2
	$(ROMFSINST) -e CONFIG_USER_BZIP2_BZIP2 -s bzip2 /bin/bzcat
