[gdal-dev] build system vs. libtool

Ivan Shmakov ivan at theory.asu.ru
Thu Dec 13 03:40:14 EST 2007


	I wonder, how the following is expected to work?

$ nl -ba GDALmake.opt 
...
     4	#
     5	# the library can be built by the native build or with the help of libtool
     6	#
     7	HAVE_LIBTOOL	=	yes
     8	LIBTOOL	=	$(SHELL) $(top_builddir)/libtool
     9	ifeq ($(HAVE_LIBTOOL),yes)
    10	LIBTOOL_COMPILE_CC =	$(LIBTOOL) --mode=compile --tag=CC
    11	LIBTOOL_COMPILE_CXX =	$(LIBTOOL) --mode=compile --tag=CXX
    12	LIBTOOL_LINK	=	$(LIBTOOL) --mode=link
    13	LIBTOOL_INSTALL	=	$(LIBTOOL) --mode=install
    14	LIBTOOL_FINISH	=	$(LIBTOOL) --mode=finish --silent
    15	LIBTOOL_CLEAN	=	$(LIBTOOL) --mode=clean
    16	else
    17	LIBTOOL_FINISH	=	/bin/true
    18	endif
...
    20	CC	=	$(LIBTOOL_COMPILE_CC) gcc
    21	CXX	=	$(LIBTOOL_COMPILE_CXX) g++
    22	LD	=	$(LIBTOOL_LINK)	g++
...
   345	#
   346	# gdal and ogr low level drivers use the following default rules in order to
   347	# populate the ../o/ directory with all object and library object files
   348	#
   349	
   350	O_OBJ =	$(foreach file,$(OBJ),../o/$(file))
   351	
   352	../o/%.o:	%.c
   353		$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
   354	
   355	../o/%.o:	%.cpp
   356		$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -o $@ $<
   357	
   358	%.o:	%.c
   359		$(CC) $(CFLAGS) $(CPPFLAGS) -c -o $@ $<
   360	
   361	%.o:	%.cpp
   362		$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c -o $@ $<
...
$ 

	IIUC, when using `libtool', the `.o' files are put into the
	`.libs/' subdirectory, and in the build directory the
	corresponding `.lo' are created instead.  Thus, Make ends up
	trying to build each of the `.o' files each time it's run.

	Moreover, Make fails to build most of the targets in the `apps'
	subdirectory:

--cut--
/bin/sh /[gdal-build-dir]/libtool --mode=compile --tag=CC gcc -g -O2  -Wall -Wdeclaration-after-statement  -I/[gdal-build-dir]/port -I/[gdal-build-dir]/gcore -I/[gdal-build-dir]/alg -I/[gdal-build-dir]/ogr -I/[gdal-build-dir]/ogr/ogrsf_frmts -I/[gdal-build-dir]/frmts -DOGR_ENABLED -I/[gdal-build-dir]/port  -c -o gdalinfo.o gdalinfo.c
libtool: compile:  gcc -g -O2 -Wall -Wdeclaration-after-statement -I/[gdal-build-dir]/port -I/[gdal-build-dir]/gcore -I/[gdal-build-dir]/alg -I/[gdal-build-dir]/ogr -I/[gdal-build-dir]/ogr/ogrsf_frmts -I/[gdal-build-dir]/frmts -DOGR_ENABLED -I/[gdal-build-dir]/port -c gdalinfo.c  -fPIC -DPIC -o .libs/gdalinfo.o
/bin/sh /[gdal-build-dir]/libtool --mode=link	g++  gdalinfo.o  \
		/[gdal-build-dir]/libgdal.la -o gdalinfo
libtool: link: g++ gdalinfo.o -o .libs/gdalinfo  /[gdal-build-dir]/.libs/libgdal.so -L/usr/lib /usr/lib/libsqlite3.so /usr/lib/libexpat.so /usr/lib/libhdf5.so -lm -lmfhdf -ldf /usr/lib/libjpeg.so -lpng -lnetcdf -lz -lpthread -lrt -ldl -Wl,-rpath -Wl,/var/home/ivan/lib
g++: gdalinfo.o: No such file or directory
make[1]: *** [gdalinfo] Error 1
--cut--

	May I suggest replacing `.o' in all the code with a kind of
	`.$(OBJEXT)' and setting `OBJEXT' to `lo' when Libtool is in
	use?



More information about the gdal-dev mailing list