include ../Makefile.common

LIBNAME       = libgnomeada$(SO_EXT)
SONAME        = libgnomeada-$(MAJOR).$(MINOR)$(SO_EXT).$(MICRO)
ARCHIVENAME   = libgnomeada.a
GNOME_LIBS    = @GNOME_LIBS@
HAVE_GNOME    = @HAVE_GNOME@
INSTALL       = @INSTALL@
INSTALL_DATA  = @INSTALL_DATA@

ifeq ($(HAVE_GNOME),True)
all: $(ARCHIVENAME) $(LIBNAME)
install: all
	$(INSTALL_DATA) $(ARCHIVENAME) $(libdir)
	$(INSTALL_DATA) $(SONAME) $(libdir)
	$(RM) $(libdir)/$(LIBNAME)
	$(LN) $(SONAME) $(libdir)/$(LIBNAME)
	$(CP) gnome*.ads gnome*.adb bonobo*.ads bonobo*.adb $(incdir)
	$(CP) gnome*.ali bonobo*.ali $(alidir)
	$(CHMOD) -w $(alidir)/*.ali

else
all:
install:
endif

gnome:
	@if [ -f ../.devel ]; then \
	  $(GNATMAKE) -c $(GNATFLAGS_DEVEL) $(FPIC) -I.. -aO../lib-obj make_gnome; \
	else \
	  $(GNATMAKE) -c $(GNATFLAGS) $(FPIC) -I.. -aO../lib-obj make_gnome; \
	fi

$(LIBNAME): gnome
ifeq ($(BUILD_SHARED),yes)
	$(CC) -shared $(FPIC) $(OS_SPECIFIC_LINK_OPTIONS) -o $(SONAME) \
	  $(SO_OPTS)$(SONAME) gnome.o gnome-*.o bonobo*.o \
	  $(GTK_LIBS) $(GNOME_LIBS)
	$(RM) $(LIBNAME)
	$(LN) $(SONAME) $(LIBNAME)
	-@if [ ! -f ../.devel ]; then \
	  strip $(LIBNAME); \
	  $(CHMOD) +x $(LIBNAME); \
	fi
endif

$(ARCHIVENAME): gnome
	$(AR) $(ARFLAGS) $(ARCHIVENAME) gnome.o gnome-*.o bonobo*.o
	if [ -f /usr/bin/$(RANLIB) -o -f /bin/$(RANLIB) ]; then \
	  $(RANLIB) $(ARCHIVENAME); \
	fi

link: $(LIBNAME)
	gnatmake -gnaty make_gnome `gtkada-config` -largs -lgnomeada

clean:
	-$(RM) *.o *.ali *~ core

distclean: clean
	-$(RM) Makefile
	-$(RM) libgnomeada*.so*
