include ../Makefile.stub
IDIR=$(INSTALL_DIR)/asis
install: libasis$(arext)
	$(RMDIR) $(IDIR)
	$(MKDIR) $(IDIR)
	$(INSTALL_FILES) *.ali $(IDIR)
	$(CHMOD) a-w $(IDIR)/*.ali
	$(INSTALL_FILES) *$(arext) $(IDIR)
	$(INSTALL_FILES) $(GNAT_DIR)/*.ads  $(GNAT_DIR)/*.adb $(IDIR)
	$(INSTALL_FILES) $(ASIS_DIR)/*.ads  $(ASIS_DIR)/*.adb $(IDIR)
	$(MAKE) -e -C ../tools/asistant

libasis$(arext): bld-objs
	$(AR) $(AR_FLAGS) libasis$(arext) *$(objext)
ifneq "$(findstring OpenVMS, $(host))" "OpenVMS"
#	VMS doesn't understand Unix shell "if" commands
	if $(RANLIB_TEST) ; then $(RANLIB) libasis$(arext); else true; fi
endif

bld-objs:
	$(CC) -c $(GNATMAKE_FLAGS) -I$(GNAT_DIR) -I$(ASIS_DIR) install_asis.adb
#	install_asis.adb is not '-gnatg-compilable'
ifeq "$(findstring hppa, $(host))" "hppa"
# this file has problems when compiled with optimization see 7418-013
	$(CC) -c  -I$(GNAT_DIR)  $(CFLAGS) -O0 $(ASIS_DIR)/a4g-a_sinput.adb
endif
	gnatmake -c $(GNATMAKE_FLAGS) -aI$(GNAT_DIR) -aI$(ASIS_DIR) $(CFLAGS)\
	         install_asis.adb \
                 -cargs $(ADA_FLAGS_FOR_ASISLIB)
	$(RM) install_asis$(objext) install_asis.ali

libasis$(soext): clean
	$(MAKE) -e bld-objs CFLAGS="$(CFLAGS) -fPIC"
	$(CC) -shared -o libasis$(soext) *$(objext)

clean:
	$(RM) *$(objext)
	$(RM) *.ali
	$(RM) *$(arext)
	$(RM) *$(soext)
	$(RM) *~
