1b03749
diff -pruN a/configure b/configure
1b03749
--- a/configure	1970-01-01 05:30:00.000000000 +0530
1b03749
+++ b/configure	2010-06-08 01:24:47.000000000 +0530
1b03749
@@ -0,0 +1,154 @@
1b03749
+#!/bin/sh
1b03749
+
1b03749
+######### Default options ############
1b03749
+CC="gcc"
1b03749
+CXX="g++"
1b03749
+enable_lcms="no"
1b03749
+enable_openmp="no"
1b03749
+CFLAGS="-O4 -I. -w"
1b03749
+LDFLAGS=
1b03749
+DESTDIR=""
1b03749
+PREFIX="/usr/local"
1b03749
+lcms_headers="/usr/local/include"
1b03749
+lcms_libs="/usr/local/lib"
1b03749
+######################################
1b03749
+
1b03749
+SRCFILE=
1b03749
+
1b03749
+cleanup() {
1b03749
+	echo "Aborted, cleaning up"
1b03749
+	if [ -n "$SRCFILE" ]; then
1b03749
+		rm -f $SRCFILE
1b03749
+		rm -f $SRCFILE.out
1b03749
+	fi
1b03749
+	echo "Done"
1b03749
+	exit 1
1b03749
+}
1b03749
+
1b03749
+check_lib() {
1b03749
+	fail=
1b03749
+	printf "Checking if lib$1 is present and can be linked against... "
1b03749
+	SRCFILE=$(mktemp --suffix=.c)
1b03749
+
1b03749
+	echo "extern int $2(void); int main() {$2();}" > $SRCFILE
1b03749
+
1b03749
+	$CC $SRCFILE -o $SRCFILE.out -L$3 -l$1 > /dev/null 2>&1
1b03749
+
1b03749
+	if [ $? -ne 0 ]; then
1b03749
+		echo "no"
1b03749
+		fail="yes"
1b03749
+	else
1b03749
+		echo "yes"
1b03749
+		LDFLAGS="$LDFLAGS -L$3 -l$1"
1b03749
+	fi
1b03749
+
1b03749
+	rm -f $SRCFILE
1b03749
+	rm -f $SRCFILE.out
1b03749
+
1b03749
+	if [ "$fail" = "yes" ]; then
1b03749
+		echo "Configuration failed. lib$1 is missing"
1b03749
+		exit 2
1b03749
+	fi
1b03749
+}
1b03749
+
1b03749
+usage() {
1b03749
+	printf >&2 "Usage: $0 [options]\n\n"
1b03749
+	printf >&2 "Where options are:\n"
1b03749
+	printf >&2 "\t-c\tC Compiler to use [gcc]\n"
1b03749
+	printf >&2 "\t-x\tC++ Compiler to use [g++]\n"
1b03749
+	printf >&2 "\t-P\tDefault installation prefix [/usr/local]\n"
1b03749
+	printf >&2 "\t-o\tBuild with OpenMP support [no]\n"
1b03749
+	printf >&2 "\t-l\tBuild with lcms support [no]\n"
1b03749
+	printf >&2 "\t-I\tlcms headers location [/usr/local/include]\n"
1b03749
+	printf >&2 "\t-L\tlcms library location [/usr/local/lib]\n"
1b03749
+	echo >&2
1b03749
+	printf >&2 "\t-h\tPrint this help text\n\n"
1b03749
+
1b03749
+	exit 1
1b03749
+}
1b03749
+
1b03749
+trap 'cleanup' SIGINT
1b03749
+
1b03749
+args=`getopt "c:x:lohL:I:P:" $*`
1b03749
+
1b03749
+if [ $? -ne 0 ]; then
1b03749
+	usage
1b03749
+fi
1b03749
+
1b03749
+set -- $args
1b03749
+
1b03749
+while [ $# -gt 0 ]; do
1b03749
+	case "$1" in
1b03749
+	-c)
1b03749
+		CC="$2"
1b03749
+		shift
1b03749
+		;;
1b03749
+	-x)
1b03749
+		CXX="$2"
1b03749
+		shift
1b03749
+		;;
1b03749
+	-l)	
1b03749
+		enable_lcms="yes"
1b03749
+		;;
1b03749
+	-I)
1b03749
+		lcms_headers="$2"
1b03749
+		shift
1b03749
+		;;
1b03749
+	-P)
1b03749
+		PREFIX="$2"
1b03749
+		shift
1b03749
+		;;
1b03749
+	-L)
1b03749
+		lcms_libs="$2"
1b03749
+		shift
1b03749
+		;;
1b03749
+	-o)	
1b03749
+		enable_openmp="yes"
1b03749
+		;;
1b03749
+	-h)
1b03749
+		usage
1b03749
+		;;
1b03749
+	--)	break
1b03749
+		;;
1b03749
+	esac
1b03749
+	shift
1b03749
+done
1b03749
+
1b03749
+echo "Using C compiler as $CC"
1b03749
+echo "Using C++ compiler as $CXX"
1b03749
+
1b03749
+printf "Enable lcms... "
1b03749
+if [ "$enable_lcms" = "yes" ]; then
1b03749
+	echo "yes"
1b03749
+	check_lib lcms cmsErrorAction $lcms_libs
1b03749
+	CFLAGS="$CFLAGS -DUSE_LCMS -I$lcms_headers"
1b03749
+else
1b03749
+	echo "no"
1b03749
+fi
1b03749
+
1b03749
+printf "Enable openmp support... "
1b03749
+if [ "$enable_openmp" = "yes" ]; then
1b03749
+	CFLAGS="$CFLAGS -fopenmp"
1b03749
+	echo "yes"
1b03749
+else
1b03749
+	echo "no"
1b03749
+fi
1b03749
+
1b03749
+# Generate makefile from Makefile.in
1b03749
+echo "Generating Makefile"
1b03749
+
1b03749
+echo "# Makefile generated from configure script. Do not edit" > Makefile
1b03749
+
1b03749
+echo "CC = $CC" >> Makefile
1b03749
+echo "CXX = $CXX" >> Makefile
1b03749
+echo "CFLAGS = $CFLAGS" >> Makefile
1b03749
+echo "CXXFLAGS = \$(CFLAGS)" >> Makefile
1b03749
+echo "LDFLAGS = $LDFLAGS" >> Makefile
1b03749
+echo "DESTDIR = $DESTDIR" >> Makefile
1b03749
+echo "PREFIX = $PREFIX" >> Makefile
1b03749
+echo "LIBDIR = lib" >> Makefile
1b03749
+echo "BINDIR = bin" >> Makefile
1b03749
+
1b03749
+cat Makefile.in >> Makefile
1b03749
+
1b03749
+echo "Done"
1b03749
diff -pruN a/Makefile b/Makefile
1b03749
--- a/Makefile	2010-03-28 23:40:18.000000000 +0530
1b03749
+++ b/Makefile	1970-01-01 05:30:00.000000000 +0530
1b03749
@@ -1,100 +0,0 @@
1b03749
-all: library all_samples 
1b03749
-
1b03749
-CFLAGS=-O4  -I. -w
1b03749
-
1b03749
-# OpenMP support
1b03749
-#CFLAGS=-O4  -I. -w -fopenmp
1b03749
-
1b03749
-# LCMS support
1b03749
-#LCMS_DEF=-DUSE_LCMS -I/usr/local/include
1b03749
-#LCMS_LIB=-L/usr/local/lib -llcms
1b03749
-
1b03749
-
1b03749
-DCRAW_LIB_OBJECTS=object/dcraw_common.o object/libraw_cxx.o object/libraw_c_api.o object/dcraw_fileio.o
1b03749
-DCRAW_LIB_MT_OBJECTS=object/dcraw_common_mt.o object/libraw_cxx_mt.o object/libraw_c_api_mt.o object/dcraw_fileio_mt.o
1b03749
-
1b03749
-library: lib/libraw.a lib/libraw_r.a
1b03749
-
1b03749
-all_samples: bin/raw-identify bin/simple_dcraw  bin/dcraw_emu bin/dcraw_half bin/half_mt bin/mem_image bin/unprocessed_raw bin/4channels
1b03749
-
1b03749
-install: library
1b03749
-	@if [ -d /usr/local/include ] ; then cp -R libraw /usr/local/include/ ; else echo 'no /usr/local/include' ; fi
1b03749
-	@if [ -d /usr/local/lib ] ; then cp lib/libraw.a lib/libraw_r.a /usr/local/lib/ ; else echo 'no /usr/local/lib' ; fi
1b03749
-
1b03749
-install-binaries: all_samples
1b03749
-	@if [ -d /usr/local/bin ] ; then cp bin/[a-z]* /usr/local/bin/ ; else echo 'no /usr/local/bin' ; fi
1b03749
-
1b03749
-
1b03749
-#binaries
1b03749
-
1b03749
-bin/raw-identify: lib/libraw.a samples/raw-identify.cpp
1b03749
-	g++ -DLIBRAW_NOTHREADS ${LCMS_DEF} ${CFLAGS} -o bin/raw-identify samples/raw-identify.cpp -L./lib -lraw  -lm ${LCMS_LIB}
1b03749
-
1b03749
-bin/unprocessed_raw: lib/libraw.a samples/unprocessed_raw.cpp
1b03749
-	g++ -DLIBRAW_NOTHREADS ${LCMS_DEF} ${CFLAGS} -o bin/unprocessed_raw samples/unprocessed_raw.cpp -L./lib -lraw  -lm  ${LCMS_LIB}
1b03749
-
1b03749
-bin/4channels: lib/libraw.a samples/4channels.cpp
1b03749
-	g++ -DLIBRAW_NOTHREADS ${LCMS_DEF} ${CFLAGS} -o bin/4channels samples/4channels.cpp -L./lib -lraw  -lm  ${LCMS_LIB}
1b03749
-
1b03749
-bin/simple_dcraw: lib/libraw.a samples/simple_dcraw.cpp
1b03749
-	g++ -DLIBRAW_NOTHREADS ${LCMS_DEF}  ${CFLAGS} -o bin/simple_dcraw samples/simple_dcraw.cpp -L./lib -lraw  -lm  ${LCMS_LIB}
1b03749
-
1b03749
-bin/mem_image: lib/libraw.a samples/mem_image.cpp
1b03749
-	g++ -DLIBRAW_NOTHREADS ${LCMS_DEF} ${CFLAGS} -o bin/mem_image samples/mem_image.cpp -L./lib -lraw  -lm  ${LCMS_LIB}
1b03749
-
1b03749
-bin/dcraw_half: lib/libraw.a object/dcraw_half.o
1b03749
-	gcc -DLIBRAW_NOTHREADS ${LCMS_DEF} ${CFLAGS} -o bin/dcraw_half object/dcraw_half.o -L./lib -lraw  -lm -lstdc++  ${LCMS_LIB}
1b03749
-
1b03749
-bin/half_mt: lib/libraw_r.a object/half_mt.o
1b03749
-	gcc ${LCMS_DEF}  -pthread ${CFLAGS} -o bin/half_mt object/half_mt.o -L./lib -lraw_r  -lm -lstdc++  ${LCMS_LIB}
1b03749
-
1b03749
-bin/dcraw_emu: lib/libraw.a samples/dcraw_emu.cpp
1b03749
-	g++ -DLIBRAW_NOTHREADS ${LCMS_DEF} ${CFLAGS} -o bin/dcraw_emu samples/dcraw_emu.cpp -L./lib -lraw  -lm  ${LCMS_LIB}
1b03749
-
1b03749
-#objects
1b03749
-
1b03749
-object/dcraw_common.o: internal/dcraw_common.cpp
1b03749
-	g++ -c -DLIBRAW_NOTHREADS ${LCMS_DEF} ${CFLAGS} -o object/dcraw_common.o internal/dcraw_common.cpp
1b03749
-
1b03749
-object/dcraw_fileio.o: internal/dcraw_fileio.cpp
1b03749
-	g++ -c -DLIBRAW_NOTHREADS ${CFLAGS} ${LCMS_DEF} -o object/dcraw_fileio.o internal/dcraw_fileio.cpp
1b03749
-
1b03749
-object/libraw_cxx.o: src/libraw_cxx.cpp
1b03749
-	g++ -c -DLIBRAW_NOTHREADS ${LCMS_DEF} ${CFLAGS} -o object/libraw_cxx.o src/libraw_cxx.cpp
1b03749
-
1b03749
-object/libraw_c_api.o: src/libraw_c_api.cpp
1b03749
-	g++ -c -DLIBRAW_NOTHREADS  ${LCMS_DEF} ${CFLAGS} -o object/libraw_c_api.o src/libraw_c_api.cpp
1b03749
-
1b03749
-object/dcraw_half.o: samples/dcraw_half.c
1b03749
-	gcc -c -DLIBRAW_NOTHREADS  ${LCMS_DEF} ${CFLAGS} -o object/dcraw_half.o samples/dcraw_half.c
1b03749
-
1b03749
-object/half_mt.o: samples/half_mt.c
1b03749
-	gcc -c -pthread ${LCMS_DEF}  ${CFLAGS} -o object/half_mt.o samples/half_mt.c
1b03749
-
1b03749
-
1b03749
-lib/libraw.a: ${DCRAW_LIB_OBJECTS}
1b03749
-	rm -f lib/libraw.a
1b03749
-	ar crv lib/libraw.a ${DCRAW_LIB_OBJECTS}
1b03749
-	ranlib lib/libraw.a
1b03749
-
1b03749
-lib/libraw_r.a: ${DCRAW_LIB_MT_OBJECTS}
1b03749
-	rm -f lib/libraw_r.a
1b03749
-	ar crv lib/libraw_r.a ${DCRAW_LIB_MT_OBJECTS}
1b03749
-	ranlib lib/libraw_r.a
1b03749
-
1b03749
-object/dcraw_common_mt.o: internal/dcraw_common.cpp
1b03749
-	g++ -c -pthread ${LCMS_DEF}  ${CFLAGS} -o object/dcraw_common_mt.o internal/dcraw_common.cpp
1b03749
-
1b03749
-object/dcraw_fileio_mt.o: internal/dcraw_fileio.cpp
1b03749
-	g++ -c -pthread ${LCMS_DEF} ${CFLAGS} -o object/dcraw_fileio_mt.o internal/dcraw_fileio.cpp
1b03749
-
1b03749
-object/libraw_cxx_mt.o: src/libraw_cxx.cpp
1b03749
-	g++ -c ${LCMS_DEF}  -pthread ${CFLAGS} -o object/libraw_cxx_mt.o src/libraw_cxx.cpp
1b03749
-
1b03749
-object/libraw_c_api_mt.o: src/libraw_c_api.cpp
1b03749
-	g++ -c ${LCMS_DEF}  -pthread ${CFLAGS} -o object/libraw_c_api_mt.o src/libraw_c_api.cpp
1b03749
-
1b03749
-clean:
1b03749
-	rm -fr bin/*.dSYM
1b03749
-	rm -f *.o *~ src/*~ samples/*~ internal/*~ libraw/*~ lib/lib*.a bin/[4a-z]* object/*o dcraw/*~ doc/*~ bin/*~
1b03749
-
1b03749
diff -pruN a/Makefile.in b/Makefile.in
1b03749
--- a/Makefile.in	1970-01-01 05:30:00.000000000 +0530
1b03749
+++ b/Makefile.in	2010-06-08 01:24:47.000000000 +0530
1b03749
@@ -0,0 +1,96 @@
1b03749
+all: library all_samples 
1b03749
+
1b03749
+
1b03749
+DCRAW_LIB_OBJECTS=object/dcraw_common.o object/libraw_cxx.o object/libraw_c_api.o object/dcraw_fileio.o
1b03749
+DCRAW_LIB_MT_OBJECTS=object/dcraw_common_mt.o object/libraw_cxx_mt.o object/libraw_c_api_mt.o object/dcraw_fileio_mt.o
1b03749
+
1b03749
+library: lib/libraw.a lib/libraw_r.a
1b03749
+
1b03749
+all_samples: bin/raw-identify bin/simple_dcraw  bin/dcraw_emu bin/dcraw_half bin/half_mt bin/mem_image bin/unprocessed_raw bin/4channels
1b03749
+
1b03749
+install: library
1b03749
+	mkdir -p $(DESTDIR)/$(PREFIX)/include
1b03749
+	mkdir -p $(DESTDIR)/$(PREFIX)/$(LIBDIR)
1b03749
+	cp -R -p libraw $(DESTDIR)/$(PREFIX)/include/
1b03749
+	cp -p lib/libraw.a lib/libraw_r.a $(DESTDIR)/$(PREFIX)/$(LIBDIR)/
1b03749
+
1b03749
+install-binaries: all_samples
1b03749
+	mkdir -p $(DESTDIR)/$(PREFIX)/$(BINDIR)
1b03749
+	cp -p bin/[a-z]* $(DESTDIR)/$(PREFIX)/$(BINDIR)/
1b03749
+
1b03749
+
1b03749
+#binaries
1b03749
+
1b03749
+bin/raw-identify: lib/libraw.a samples/raw-identify.cpp
1b03749
+	$(CXX) -DLIBRAW_NOTHREADS $(CFLAGS) -o bin/raw-identify samples/raw-identify.cpp -L./lib -lraw  -lm $(LDFLAGS)
1b03749
+
1b03749
+bin/unprocessed_raw: lib/libraw.a samples/unprocessed_raw.cpp
1b03749
+	$(CXX) -DLIBRAW_NOTHREADS $(CFLAGS) -o bin/unprocessed_raw samples/unprocessed_raw.cpp -L./lib -lraw  -lm  $(LDFLAGS)
1b03749
+
1b03749
+bin/4channels: lib/libraw.a samples/4channels.cpp
1b03749
+	$(CXX) -DLIBRAW_NOTHREADS $(CFLAGS) -o bin/4channels samples/4channels.cpp -L./lib -lraw  -lm  $(LDFLAGS)
1b03749
+
1b03749
+bin/simple_dcraw: lib/libraw.a samples/simple_dcraw.cpp
1b03749
+	$(CXX) -DLIBRAW_NOTHREADS $(CFLAGS) -o bin/simple_dcraw samples/simple_dcraw.cpp -L./lib -lraw  -lm  $(LDFLAGS)
1b03749
+
1b03749
+bin/mem_image: lib/libraw.a samples/mem_image.cpp
1b03749
+	$(CXX) -DLIBRAW_NOTHREADS $(CFLAGS) -o bin/mem_image samples/mem_image.cpp -L./lib -lraw  -lm  $(LDFLAGS)
1b03749
+
1b03749
+bin/dcraw_half: lib/libraw.a object/dcraw_half.o
1b03749
+	$(CC) -DLIBRAW_NOTHREADS $(CFLAGS) -o bin/dcraw_half object/dcraw_half.o -L./lib -lraw  -lm -lstdc++  $(LDFLAGS)
1b03749
+
1b03749
+bin/half_mt: lib/libraw_r.a object/half_mt.o
1b03749
+	$(CC) -pthread $(CFLAGS) -o bin/half_mt object/half_mt.o -L./lib -lraw_r  -lm -lstdc++  $(LDFLAGS)
1b03749
+
1b03749
+bin/dcraw_emu: lib/libraw.a samples/dcraw_emu.cpp
1b03749
+	$(CXX) -DLIBRAW_NOTHREADS $(CFLAGS) -o bin/dcraw_emu samples/dcraw_emu.cpp -L./lib -lraw  -lm  $(LDFLAGS)
1b03749
+
1b03749
+#objects
1b03749
+
1b03749
+object/dcraw_common.o: internal/dcraw_common.cpp
1b03749
+	$(CXX) -c -DLIBRAW_NOTHREADS $(CFLAGS) -o object/dcraw_common.o internal/dcraw_common.cpp
1b03749
+
1b03749
+object/dcraw_fileio.o: internal/dcraw_fileio.cpp
1b03749
+	$(CXX) -c -DLIBRAW_NOTHREADS $(CFLAGS) -o object/dcraw_fileio.o internal/dcraw_fileio.cpp
1b03749
+
1b03749
+object/libraw_cxx.o: src/libraw_cxx.cpp
1b03749
+	$(CXX) -c -DLIBRAW_NOTHREADS $(CFLAGS) -o object/libraw_cxx.o src/libraw_cxx.cpp
1b03749
+
1b03749
+object/libraw_c_api.o: src/libraw_c_api.cpp
1b03749
+	$(CXX) -c -DLIBRAW_NOTHREADS  $(CFLAGS) -o object/libraw_c_api.o src/libraw_c_api.cpp
1b03749
+
1b03749
+object/dcraw_half.o: samples/dcraw_half.c
1b03749
+	$(CC) -c -DLIBRAW_NOTHREADS  $(CFLAGS) -o object/dcraw_half.o samples/dcraw_half.c
1b03749
+
1b03749
+object/half_mt.o: samples/half_mt.c
1b03749
+	$(CC) -c -pthread  $(CFLAGS) -o object/half_mt.o samples/half_mt.c
1b03749
+
1b03749
+
1b03749
+lib/libraw.a: ${DCRAW_LIB_OBJECTS}
1b03749
+	rm -f lib/libraw.a
1b03749
+	ar crv lib/libraw.a ${DCRAW_LIB_OBJECTS}
1b03749
+	ranlib lib/libraw.a
1b03749
+
1b03749
+lib/libraw_r.a: ${DCRAW_LIB_MT_OBJECTS}
1b03749
+	rm -f lib/libraw_r.a
1b03749
+	ar crv lib/libraw_r.a ${DCRAW_LIB_MT_OBJECTS}
1b03749
+	ranlib lib/libraw_r.a
1b03749
+
1b03749
+object/dcraw_common_mt.o: internal/dcraw_common.cpp
1b03749
+	$(CXX) -c -pthread  $(CFLAGS) -o object/dcraw_common_mt.o internal/dcraw_common.cpp
1b03749
+
1b03749
+object/dcraw_fileio_mt.o: internal/dcraw_fileio.cpp
1b03749
+	$(CXX) -c -pthread $(CFLAGS) -o object/dcraw_fileio_mt.o internal/dcraw_fileio.cpp
1b03749
+
1b03749
+object/libraw_cxx_mt.o: src/libraw_cxx.cpp
1b03749
+	$(CXX) -c  -pthread $(CFLAGS) -o object/libraw_cxx_mt.o src/libraw_cxx.cpp
1b03749
+
1b03749
+object/libraw_c_api_mt.o: src/libraw_c_api.cpp
1b03749
+	$(CXX) -c  -pthread $(CFLAGS) -o object/libraw_c_api_mt.o src/libraw_c_api.cpp
1b03749
+
1b03749
+clean:
1b03749
+	rm -fr bin/*.dSYM
1b03749
+	rm -f *.o *~ src/*~ samples/*~ internal/*~ libraw/*~ lib/lib*.a bin/[4a-z]* object/*o dcraw/*~ doc/*~ bin/*~
1b03749
+
1b03749
+distclean: clean
1b03749
+	rm -f Makefile