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