#
#  Rules for building the Allegro library on Unix. This file is processed
#  by the configure script, to produce the real makefile that does the work.

INSTALL_TARGETS = full-install
DEFAULT_TARGETS = full-build

srcdir = .
builddir = .

include $(srcdir)/makefile.ver

SHELL = /bin/sh

prefix = /opt/BCallegro
exec_prefix = ${prefix}
bindir = ${exec_prefix}/bin
includedir = ${prefix}/include
infodir = ${prefix}/info
mandir = ${prefix}/man
libdir = ${exec_prefix}/lib
modulebasedir = $(libdir)/allegro
moduledir = $(modulebasedir)/$(shared_major_minor)

EXE =
OBJ = .o
OBJDIR = obj/unix
LIBDIR = lib/unix
INFO_DIR = $(infodir)/dir
DESTDIR =

ACLOCAL = aclocal
AUTOCONF = autoconf
AUTOHEADER = autoheader

INSTALL = /bc/cbe/bin/install -c
INSTALL_PROGRAM = ${INSTALL}
INSTALL_DATA = ${INSTALL} -m 644
INSTALL_INFO = /usr/sfw/bin/install-info

transform = s,x,x,

CC = /usr/sfw/bin/gcc
CPP = /usr/sfw/bin/gcc -E
CXX = /usr/sfw/bin/gcc
MAKEINFO = /usr/sfw/bin/makeinfo
AR = ar rvs
LIBS = -lm -lpthread -lXxf86vm -lXpm -lXext -lX11 -L/usr/lib -lesd -laudiofile -lm -lrt -lresolv -lnsl -lsocket -lposix4 

LDCONFIG = echo ought to run ldconfig

mkinstalldirs = $(SHELL) $(srcdir)/misc/mkdirs.sh

CONFIG_H = include/allegro/platform/alunixac.h
CONFIG_H_IN = include/allegro/platform/alunixac.hin
CONFIGURE = configure
CONFIGURE_IN = configure.in
ACLOCAL_M4 = aclocal.m4

INCLUDES = -I. -Iinclude -Iinclude/allegro -I$(srcdir)/include -I$(srcdir)/include/allegro
DEFS = -DHAVE_CONFIG_H
CPPFLAGS = -I/usr/X11/include -I/usr/lib/oss/include
override LDFLAGS += -R/usr/X11/lib -L/usr/X11/lib -R/usr/sfw/lib -L/usr/sfw/lib -R/opt/BCallegro/lib
PROG_LDFLAGS = -s $(LDFLAGS)
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
LINK = $(CC) $(PROG_LDFLAGS)

override CFLAGS +=   -DALLEGRO_LIB_BUILD  -mtune=pentium -O2 -funroll-loops -ffast-math -fomit-frame-pointer -Wall -Wno-unused 
ALLEGRO_DEBUG_CFLAGS =   -DALLEGRO_LIB_BUILD  -g -Wall -Wno-unused  -DDEBUGMODE
ALLEGRO_PROFILE_CFLAGS =   -DALLEGRO_LIB_BUILD  -pg -mtune=pentium -O2 -funroll-loops -ffast-math -Wall -Wno-unused 
ALLEGRO_SHAREDLIB_CFLAGS = -fPIC -DALLEGRO_SHARED
COMPILE_NORMAL = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS)
COMPILE_DEBUG = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(ALLEGRO_DEBUG_CFLAGS)
COMPILE_PROFILE = $(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(ALLEGRO_PROFILE_CFLAGS)

CXXFLAGS = -fno-exceptions   -DALLEGRO_LIB_BUILD  -mtune=pentium -O2 -funroll-loops -ffast-math -fomit-frame-pointer -Wall -Wno-unused 
ALLEGRO_DEBUG_CXXFLAGS = -fno-exceptions   -DALLEGRO_LIB_BUILD  -g -Wall -Wno-unused  -DDEBUGMODE
ALLEGRO_PROFILE_CXXFLAGS = -fno-exceptions   -DALLEGRO_LIB_BUILD  -pg -mtune=pentium -O2 -funroll-loops -ffast-math -Wall -Wno-unused 
COMPILE_CXX_NORMAL = $(CXX) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CXXFLAGS)
COMPILE_CXX_DEBUG = $(CXX) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(ALLEGRO_DEBUG_CXXFLAGS)
COMPILE_CXX_PROFILE = $(CXX) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(ALLEGRO_PROFILE_CXXFLAGS)

ALLEGRO_SFLAGS = -x assembler-with-cpp
COMPILE_S_NORMAL = $(COMPILE_NORMAL) $(ALLEGRO_SFLAGS)
COMPILE_S_DEBUG = $(COMPILE_DEBUG) $(ALLEGRO_SFLAGS)
COMPILE_S_PROFILE = $(COMPILE_PROFILE) $(ALLEGRO_SFLAGS)

COMPILE_PROGRAM = $(COMPILE_NORMAL)
COMPILE_CXX_PROGRAM = $(COMPILE_CXX_NORMAL)
COMPILE_S_PROGRAM = $(COMPILE_S_NORMAL)

LIBALLEG = lib/unix/liballeg-$(shared_version).so lib/unix/liballeg_unsharable.a
LINK_LIBALLEG = -Llib/unix -lalleg-$(shared_version) -lalleg_unsharable -lm
ALLEGRO_LIB_TARGETS =  lib/unix/liballeg-$(shared_version).so lib/unix/liballeg_unsharable.a
ALLEGRO_MODULE_TARGETS = 

PLUGIN_LIB = lib/unix/libaldat.a
obj_unix_plugins_h = $(OBJDIR)/plugins.h

default: $(DEFAULT_TARGETS)

.SUFFIXES:
makefile: $(srcdir)/makefile.in config.status
	CONFIG_FILES=$@ CONFIG_HEADERS= $(SHELL) ./config.status

config.status: $(srcdir)/$(CONFIGURE)
	$(SHELL) ./config.status --recheck
$(srcdir)/$(CONFIGURE): $(srcdir)/$(CONFIGURE_IN) $(srcdir)/$(ACLOCAL_M4) $(CONFIGURE_DEPENDENCIES)
	cd $(srcdir) && $(AUTOCONF) $(CONFIGURE_IN) >$(CONFIGURE)

$(CONFIG_H): stamp-h
stamp-h: $(srcdir)/$(CONFIG_H_IN) config.status
	CONFIG_FILES= CONFIG_HEADERS="$(CONFIG_H):$(CONFIG_H_IN)" \
	  $(SHELL) ./config.status
	@echo timestamp > stamp-h
$(srcdir)/$(CONFIG_H_IN): $(srcdir)/stamp-h.in
$(srcdir)/stamp-h.in: $(srcdir)/$(CONFIGURE_IN) $(srcdir)/$(ACLOCAL_M4)
	cd $(srcdir) && $(AUTOHEADER) $(CONFIGURE_IN) >$(CONFIG_H_IN)
	@echo timestamp > $(srcdir)/stamp-h.in





# -------- list of sources for libraries and programs --------

include $(srcdir)/makefile.lst

ifneq (,$(CXX))
   ALLEGRO_LIB_EXE_SOURCES += $(ALLEGRO_LIB_CPP_EXE_SOURCES)
   ALLEGRO_LIB_EXES += $(ALLEGRO_LIB_CPP_EXES)
endif

ALLEGRO_EMPTY_LIST =

ALLEGRO_LIBRARY_SOURCES = \
	$(ALLEGRO_SRC_FILES) \
	$(ALLEGRO_SRC_UNIX_FILES) \
	$(ALLEGRO_SRC_I386_FILES) \
	$(ALLEGRO_SRC_X_FILES) \
	$(ALLEGRO_EMPTY_LIST)

ALLEGRO_EXE_TARGETS = \
	$(ALLEGRO_LIB_EXES) \
	$(ALLEGRO_LIB_X_EXES) \
	$(ALLEGRO_DATAFILE_EXES) \
	$(ALLEGRO_EXAMPLE_EXES) \
	demo/demo

# Header files (look in makefile.dep for "Headers referred by symbols").
ALLEGRO_EXTRA_HEADER = $(srcdir)/include/allegro/platform/alunix.h
ALLEGRO_INTERNAL_HEADER = $(srcdir)/include/allegro/platform/aintunix.h
ALLEGRO_MMX_HEADER =
allegro_alconfig_h = $(srcdir)/include/allegro/internal/alconfig.h \
	$(srcdir)/include/allegro/platform/alucfg.h \
	$(CONFIG_H)
allegro_alinline_h = $(srcdir)/include/allegro/alinline.h \
	$(srcdir)/include/allegro/platform/al386gcc.h \
	$(srcdir)/include/allegro/platform/al386vc.h \
	$(srcdir)/include/allegro/platform/al386wat.h
allegro_h = $(srcdir)/include/allegro.h \
	$(allegro_alconfig_h) \
	$(allegro_alinline_h) \
	$(srcdir)/include/allegro/3d.h \
	$(srcdir)/include/allegro/3dmaths.h \
	$(srcdir)/include/allegro/alcompat.h \
	$(srcdir)/include/allegro/alinline.h \
	$(srcdir)/include/allegro/base.h \
	$(srcdir)/include/allegro/color.h \
	$(srcdir)/include/allegro/compiled.h \
	$(srcdir)/include/allegro/config.h \
	$(srcdir)/include/allegro/datafile.h \
	$(srcdir)/include/allegro/debug.h \
	$(srcdir)/include/allegro/digi.h \
	$(srcdir)/include/allegro/draw.h \
	$(srcdir)/include/allegro/file.h \
	$(srcdir)/include/allegro/fix.h \
	$(srcdir)/include/allegro/fixed.h \
	$(srcdir)/include/allegro/fli.h \
	$(srcdir)/include/allegro/fmaths.h \
	$(srcdir)/include/allegro/gfx.h \
	$(srcdir)/include/allegro/gui.h \
	$(srcdir)/include/allegro/joystick.h \
	$(srcdir)/include/allegro/keyboard.h \
	$(srcdir)/include/allegro/matrix.h \
	$(srcdir)/include/allegro/midi.h \
	$(srcdir)/include/allegro/mouse.h \
	$(srcdir)/include/allegro/palette.h \
	$(srcdir)/include/allegro/quat.h \
	$(srcdir)/include/allegro/rle.h \
	$(srcdir)/include/allegro/sound.h \
	$(srcdir)/include/allegro/stream.h \
	$(srcdir)/include/allegro/system.h \
	$(srcdir)/include/allegro/text.h \
	$(srcdir)/include/allegro/timer.h \
	$(srcdir)/include/allegro/unicode.h \
	$(srcdir)/include/allegro/graphics.h \
	$(srcdir)/include/allegro/inline/3dmaths.inl \
	$(srcdir)/include/allegro/inline/asm.inl \
	$(srcdir)/include/allegro/inline/color.inl \
	$(srcdir)/include/allegro/inline/draw.inl \
	$(srcdir)/include/allegro/inline/file.inl \
	$(srcdir)/include/allegro/inline/fix.inl \
	$(srcdir)/include/allegro/inline/fmaths.inl \
	$(srcdir)/include/allegro/inline/gfx.inl \
	$(srcdir)/include/allegro/inline/matrix.inl \
	$(srcdir)/include/allegro/inline/rle.inl \
	$(srcdir)/include/allegro/inline/system.inl \
	$(ALLEGRO_EXTRA_HEADER)
allegro_internal_aintern_h = $(srcdir)/include/allegro/internal/aintern.h
allegro_aintdos_h = $(srcdir)/include/allegro/platform/aintdos.h \
	$(srcdir)/include/allegro/internal/aintvga.h
obj_unix_asmdef_inc = $(OBJDIR)/asmdef.inc
xalleg_h = $(srcdir)/include/xalleg.h

ifdef CROSSCOMPILE

$(OBJDIR)/asmdef.s: src/i386/asmdef.c include/*.h include/allegro/*.h
	$(CC) $(INCLUDES) `echo $(CFLAGS) | sed -e "s/.*\(-DALLEGRO_USE_C\).*/\1/"` -S -o $(OBJDIR)/asmdef.s src/i386/asmdef.c

$(obj_unix_asmdef_inc): $(OBJDIR)/asmdef.s
	@if [ ! -x misc/asmdef.sh ]; then chmod a+x misc/asmdef.sh; fi
	misc/asmdef.sh $(OBJDIR)/asmdef.s $(obj_unix_asmdef_inc)

else

$(obj_unix_asmdef_inc): $(OBJDIR)/asmdef$(EXE)
	$(OBJDIR)/asmdef$(EXE) $(obj_unix_asmdef_inc)

$(OBJDIR)/asmdef$(EXE): $(srcdir)/src/i386/asmdef.c $(ALLEGRO_ASMCAPA_HEADER) $(allegro_h)
	$(COMPILE_PROGRAM) $(srcdir)/src/i386/asmdef.c -o $(OBJDIR)/asmdef$(EXE)

endif



# -------- documentation --------

DOCBASEFILES = ahack changes faq help thanks allegro const abi api packfile \
               readme makedoc datafile grabber dat dat2c dat2s license
DOCBUILDFILES = bcc32 beos darwin djgpp linux macosx mingw32 msvc qnx unix watcom
DOCTXTBUILDFILES = $(addprefix docs/build/,$(addsuffix .txt,$(DOCBUILDFILES)))

DOCS  = $(addprefix docs/txt/,$(addsuffix .txt,$(filter-out changes thanks readme, $(DOCBASEFILES))))
DOCS += $(addprefix docs/rtf/,$(addsuffix .rtf,$(DOCBASEFILES)))
DOCS += $(addprefix docs/html/,$(addsuffix .html,index $(DOCBASEFILES)))
DOCS += $(addprefix docs/html/build/,$(addsuffix .html,$(DOCBUILDFILES)))
DOCS += docs/texi/allegro.texi docs/info/allegro.info docs/man/install_allegro.3
DOCS += CHANGES AUTHORS THANKS readme.txt
DOCS += docs/scite/allegro.api

DEVHELPDOCS  = $(addprefix docs/devhelp/,$(addsuffix .html,$(DOCBASEFILES)))
DEVHELPDOCS += $(addprefix docs/devhelp/build/,$(addsuffix .html,$(DOCBUILDFILES)))

MAKEDOC = docs/makedoc$(EXE)

docs: $(DOCS) $(DOCTXTBUILDFILES)

docs-dvi: $(srcdir)/docs/allegro.dvi
	@echo "Device independant documentation generated: docs/allegro.dvi"
	@echo "Run make docs-ps if you wish to generate Postscript documentation (you need dvips)."

docs-ps: $(srcdir)/docs/allegro.ps
	@echo "Postscript documentation generated: docs/allegro.ps"
	@echo "You can compress it with gzip by running make docs-gzipped-ps,"
	@echo "or with bzip2 by running make docs-bzipped-ps."

docs-pdf: $(srcdir)/docs/allegro.pdf
	@echo "PDF documentation generated: docs/allegro.pdf"

docs-gzipped-ps: $(srcdir)/docs/allegro.ps
	gzip -9 docs/allegro.ps
	@echo "Compressed postscript documentation generated: docs/allegro.ps.gz"

docs-bzipped-ps: $(srcdir)/docs/allegro.ps
	bzip2 -9 docs/allegro.ps
	@echo "Compressed postscript documentation generated: docs/allegro.ps.bz2"

docs-devhelp: docs/devhelp/allegro.devhelp
	@echo "DevHelp documentation generated: docs/devhelp/allegro.devhelp"
	@echo "To use, please install the above file."

$(filter %.txt,$(filter-out readme.txt, $(DOCS))): docs/txt/%.txt: docs/src/%._tx $(MAKEDOC)
	$(MAKEDOC) -ascii $@ $<

$(DOCTXTBUILDFILES): docs/build/%.txt: docs/src/build/%._tx $(MAKEDOC)
	$(MAKEDOC) -ascii $@ $<

$(filter %.rtf,$(DOCS)): docs/rtf/%.rtf: docs/src/%._tx $(MAKEDOC)
	$(MAKEDOC) -rtf $@ $<

$(filter %.texi,$(DOCS)): docs/texi/%.texi: docs/src/%._tx $(MAKEDOC)
	$(MAKEDOC) -texi $@ $<

$(filter %.info,$(DOCS)): docs/info/%.info: docs/texi/%.texi $(MAKEDOC)
	$(MAKEINFO) --no-split -o $@ $<

$(filter %.html,$(DOCS)): docs/html/%.html: docs/src/%._tx $(MAKEDOC)
	$(MAKEDOC) -html $@ $<

$(filter %.html,$(DEVHELPDOCS)): docs/devhelp/%.html: docs/src/%._tx $(MAKEDOC)
	$(MAKEDOC) -odevhelp -html $@ $<

$(filter %.api,$(DOCS)): docs/scite/%.api: docs/src/%._tx $(MAKEDOC)
	$(MAKEDOC) -scite $@ $<

docs/man/install_allegro.3: docs/src/allegro._tx $(MAKEDOC)
	$(MAKEDOC) -man docs/man/dummyname.3 $<

AUTHORS: docs/src/thanks._tx $(MAKEDOC)
	$(MAKEDOC) -part -ascii $@ $<
	cp AUTHORS docs/txt/authors.txt 

THANKS: docs/src/thanks._tx $(MAKEDOC)
	$(MAKEDOC) -part -ascii $@ $<
	cp THANKS docs/txt/thanks.txt

CHANGES: docs/src/changes._tx $(MAKEDOC)
	$(MAKEDOC) -ascii $@ $<
	cp CHANGES docs/txt/changes.txt

readme.txt: docs/src/readme._tx $(MAKEDOC)
	$(MAKEDOC) -ascii $@ $<
	cp readme.txt docs/txt/readme.txt

docs/allegro.dvi: docs/texi/allegro.texi
	cd docs && texi2dvi -c texi/allegro.texi && cd ..

docs/allegro.ps: docs/allegro.dvi
	cd docs && dvips -o allegro.ps allegro.dvi && cd ..

docs/allegro.pdf: docs/texi/allegro.texi
	cd docs && texi2pdf --texinfo='@topandbottommargin=.75in' texi/allegro.texi && cd ..

docs/devhelp/allegro.devhelp: $(filter %.html,$(DEVHELPDOCS)) docs/src/allegro._tx $(MAKEDOC)
	$(MAKEDOC) -devhelp docs/devhelp/allegro.html docs/src/allegro._tx

info:
	@cat makefile.info



# -------- dependencies and rules for building libraries and simple programs --------

-include makefile.dep

ifdef CROSSCOMPILE

full-build: lib modules programs

else

full-build: lib modules programs docs

endif

lib: $(ALLEGRO_LIB_TARGETS)

modules: $(ALLEGRO_MODULE_TARGETS)

programs: $(ALLEGRO_EXE_TARGETS)

suid: $(ALLEGRO_EXE_TARGETS)
	chown root.allegro $?
	chmod 4750 $?
	touch suid



# -------- shortcuts for building various programs --------

demo: demo/demo$(EXE)
makedoc: docs/makedoc$(EXE)
keyconf: setup/keyconf$(EXE)
setup: setup/setup$(EXE)
afinfo: tests/afinfo$(EXE)
akaitest: tests/akaitest$(EXE)
digitest: tests/digitest$(EXE)
filetest: tests/filetest$(EXE)
gfxinfo: tests/gfxinfo$(EXE)
mathtest: tests/mathtest$(EXE)
miditest: tests/miditest$(EXE)
play: tests/play$(EXE)
playfli: tests/playfli$(EXE)
test: tests/test$(EXE)
vesainfo: tests/vesainfo$(EXE)
colormap: tools/colormap$(EXE)
dat: tools/dat$(EXE)
dat2c: tools/dat2c$(EXE)
dat2s: tools/dat2s$(EXE)
exedat: tools/exedat$(EXE)
grabber: tools/grabber$(EXE)
pack: tools/pack$(EXE)
pat2dat: tools/pat2dat$(EXE)
rgbmap: tools/rgbmap$(EXE)
textconv: tools/textconv$(EXE)
examples: $(EXAMPLE_FILES)



# -------- rules for deleting the generated files --------

clean:

   define RM_OBJ_CLEAN_FILES
      $(foreach file, $(OBJ_CLEAN_FILES), rm -f $(file)
      )
   endef

   define RM_OTHER_CLEAN_FILES
      $(foreach file, $(OTHER_CLEAN_FILES), rm -f $(file)
      )
   endef

	$(RM_OBJ_CLEAN_FILES)
	$(RM_OTHER_CLEAN_FILES)

distclean: clean

   define RM_DISTCLEAN_FILES
      $(foreach file, $(DISTCLEAN_FILES) $(ALLEGRO_LIB_X_EXES), rm -f $(file)
      )
   endef

	$(RM_DISTCLEAN_FILES)

veryclean: distclean

   define RM_VERYCLEAN_FILES
      $(foreach file, $(VERYCLEAN_FILES), rm -f $(file)
      )
   endef

	$(RM_VERYCLEAN_FILES)
	rm -f makefile

maintainer-clean: veryclean
	rm -f configure include/allegro/platform/alunixac.hin
	rm -rf autom4te*



# -------- rules for installing the files --------

install: $(INSTALL_TARGETS)

mini-install: install-headers install-lib
	@echo "Your end-user version of Allegro is now installed"

full-install: install-headers install-programs install-lib
	@echo ""
	@echo "Run make docs-dvi if you wish to generate dvi documentation (you need texi2dvi)."
	@echo "Run make docs-pdf if you wish to generate PDF documentation (you need texi2pdf)."
	@echo "Run make install-man if you wish to install the man pages."
	@echo "Run make install-info if you wish to install the info documentation."
	@echo "You may conserve space by instead running make install-gzipped-man"
	@echo "and/or make install-gzipped-info.  Or install-bzipped-man,"
	@echo "install-bzipped-info to use bzip2 instead of gzip."

install-lib: lib modules
	$(mkinstalldirs) $(DESTDIR)$(libdir)
	@for l in alleg alld allp; do \
	  if test -f $(LIBDIR)/lib$${l}.a; then \
	    echo Installing $(LIBDIR)/lib$${l}.a to $(DESTDIR)$(libdir); \
	    $(INSTALL_DATA) $(LIBDIR)/lib$${l}.a $(DESTDIR)$(libdir)/; \
	  fi; \
	done
	@for l in alleg alld allp; do \
	  if test -f $(LIBDIR)/lib$${l}-$(shared_version).so; then \
	    echo Installing $(LIBDIR)/lib$${l}-$(shared_version).so to $(DESTDIR)$(libdir); \
	    $(INSTALL_DATA) $(LIBDIR)/lib$${l}-$(shared_version).so $(DESTDIR)$(libdir)/; \
	    $(INSTALL_DATA) $(LIBDIR)/lib$${l}_unsharable.a $(DESTDIR)$(libdir)/; \
	  fi; \
	done
	@if test -n "$(ALLEGRO_MODULE_TARGETS)"; then \
	  $(mkinstalldirs) $(DESTDIR)$(moduledir); \
	  for m in $(ALLEGRO_MODULE_TARGETS) modules.lst; do \
	   echo Installing $$m to $(DESTDIR)$(moduledir); \
	   $(INSTALL_DATA) $$m $(DESTDIR)$(moduledir)/; \
	  done; \
	fi
	$(mkinstalldirs) $(DESTDIR)$(bindir)
	@echo Installing allegro-config to $(DESTDIR)$(bindir)
	@$(INSTALL_PROGRAM) allegro-config $(DESTDIR)$(bindir)
	@if test -n "$(LIBDIR)/liball*-$(shared_version).so"; then \
		(cat /etc/ld.so.conf | grep $(libdir) >/dev/null || \
		 test $(libdir) = /lib || test $(libdir) = /usr/lib) \
		&& ($(LDCONFIG) $(libdir) || true) || (\
			echo "" ; \
			echo "Warning: shared library destination $(libdir) is not in ldd search path." ; \
			echo "Unless you add it to /etc/ld.so.conf, you must set LD_LIBRARY_PATH to include"; \
			echo "$(libdir) each time you want to run an Allegro program." ; \
		) ; \
	fi
	@for l in alleg alld allp; do \
	  if test -f $(DESTDIR)$(libdir)/lib$${l}-$(shared_version).so -a \! -h $(DESTDIR)$(libdir)/lib$${l}.so.${shared_major_minor}; then \
	    (cd $(DESTDIR)$(libdir); ln -s lib$${l}-$(shared_version).so lib$${l}.so.${shared_major_minor}); \
	  fi; \
	done
	$(mkinstalldirs) $(DESTDIR)$(prefix)/share/aclocal
	@echo Installing allegro.m4 to $(DESTDIR)$(prefix)/share/aclocal
	@$(INSTALL_DATA) misc/allegro.m4 $(DESTDIR)$(prefix)/share/aclocal

install-headers:
	$(mkinstalldirs) $(DESTDIR)$(includedir)/allegro
	$(mkinstalldirs) $(DESTDIR)$(includedir)/allegro/inline
	$(mkinstalldirs) $(DESTDIR)$(includedir)/allegro/internal
	$(mkinstalldirs) $(DESTDIR)$(includedir)/allegro/platform
	$(INSTALL_DATA) $(srcdir)/include/allegro.h $(DESTDIR)$(includedir)/
	$(INSTALL_DATA) $(srcdir)/include/xalleg.h $(DESTDIR)$(includedir)/
	$(INSTALL_DATA) $(srcdir)/include/linalleg.h $(DESTDIR)$(includedir)/
	$(INSTALL_DATA) $(CONFIG_H) $(DESTDIR)$(includedir)/allegro/
	@for file in $(srcdir)/include/allegro/*.h; do \
	  echo Installing $$file to $(DESTDIR)$(includedir)/allegro; \
	  $(INSTALL_DATA) $$file $(DESTDIR)$(includedir)/allegro/; \
	done
	@for file in $(srcdir)/include/allegro/inline/*.inl; do \
	  echo Installing $$file to $(DESTDIR)$(includedir)/allegro/inline; \
	  $(INSTALL_DATA) $$file $(DESTDIR)$(includedir)/allegro/inline/; \
	done
	@for file in $(srcdir)/include/allegro/internal/*.h; do \
	  echo Installing $$file to $(DESTDIR)$(includedir)/allegro/internal; \
	  $(INSTALL_DATA) $$file $(DESTDIR)$(includedir)/allegro/internal/; \
	done
	@for file in $(srcdir)/include/allegro/platform/*.h; do \
	  echo Installing $$file to $(DESTDIR)$(includedir)/allegro/platform; \
	  $(INSTALL_DATA) $$file $(DESTDIR)$(includedir)/allegro/platform/; \
	done

INSTALL_EXES = $(filter tools/%, $(ALLEGRO_LIB_EXES) $(ALLEGRO_DATAFILE_EXES))

install-programs: $(INSTALL_EXES)
	$(mkinstalldirs) $(DESTDIR)$(bindir)
	@for prog in $^; do \
	    echo Installing $$prog to $(DESTDIR)$(bindir); \
	    $(INSTALL_PROGRAM) $$prog $(DESTDIR)$(bindir); \
	done

install-info: docs
	@echo Installing Allegro info documentation...
	$(mkinstalldirs) $(DESTDIR)$(infodir)
	@$(INSTALL_DATA) docs/info/allegro.info $(DESTDIR)$(infodir)
	-@if $(SHELL) -c "$(INSTALL_INFO) --version" >/dev/null 2>&1; then \
	  if $(INSTALL_INFO) --version 2>&1 | grep "Debian" >/dev/null; then \
	    $(INSTALL_INFO) --section Development -- $(DESTDIR)$(infodir)/allegro.info; \
	  else \
	    $(INSTALL_INFO) $(DESTDIR)$(infodir)/allegro.info $(INFO_DIR); \
	  fi; \
	else \
	  true; \
	fi

install-gzipped-info: install-info
	@echo Compressing documentation...
	@gzip -9 -f $(DESTDIR)$(infodir)/allegro.info

install-bzipped-info: install-info
	@echo Compressing documentation...
	@bzip2 -9 -f $(DESTDIR)$(infodir)/allegro.info

install-man: docs
	$(mkinstalldirs) $(DESTDIR)$(mandir)/man3
	@for file in $(srcdir)/docs/man/*.3; do \
	  echo Installing $$file to $(DESTDIR)$(mandir)/man3; \
	  $(INSTALL_DATA) $$file $(DESTDIR)$(mandir)/man3/; \
	done

install-gzipped-man: docs
	$(mkinstalldirs) $(DESTDIR)$(mandir)/man3
	@for file in $(srcdir)/docs/man/*.3; do \
	  echo Installing $$file.gz to $(DESTDIR)$(mandir)/man3; \
	  $(INSTALL_DATA) $$file $(DESTDIR)$(mandir)/man3/; \
	  gzip -9 -f $(DESTDIR)$(mandir)/man3/`echo $$file | sed -e "s:.*/::"`; \
	done

install-bzipped-man: docs
	$(mkinstalldirs) $(DESTDIR)$(mandir)/man3
	@for file in $(srcdir)/docs/man/*.3; do \
	  echo Installing $$file.bz2 to $(DESTDIR)$(mandir)/man3; \
	  $(INSTALL_DATA) $$file $(DESTDIR)$(mandir)/man3/; \
	  bzip2 -9 -f $(DESTDIR)$(mandir)/man3/`echo $$file | sed -e "s:.*/::"`; \
	done



# -------- rules for uninstalling the files --------

uninstall: uninstall-lib uninstall-modules uninstall-headers uninstall-programs uninstall-info uninstall-man uninstall-misc
	@echo
	@echo "All gone. Don't you feel sad now?"
	@echo
	@echo "Well, almost.  Shared libraries are not uninstalled by default --"
	@echo "use \"make uninstall-shared\" to remove them."

uninstall-lib:
	@echo "Uninstalling libraries..."
	@for l in alleg alld allp; do \
	  rm -f $(libdir)/lib$${l}_unsharable.a; \
	  rm -f $(libdir)/lib$${l}.a; \
	done
	rm -f $(bindir)/allegro-config

uninstall-shared:
	@echo "Uninstalling shared libraries..."
	@for l in alleg alld allp; do \
	  rm -f $(libdir)/lib$${l}-${shared_version}.so; \
	  rm -f $(libdir)/lib$${l}.so.${shared_major_minor}; \
	done
	-$(LDCONFIG) $(libdir)       # update cache (only works if we're root)

uninstall-modules:
	rm -rf $(modulebasedir) $(moduledir)

uninstall-headers:
	rm -f $(includedir)/allegro.h
	rm -f $(includedir)/xalleg.h
	rm -f $(includedir)/linalleg.h
	rm -rf $(includedir)/allegro

uninstall-programs:
	@for prog in $(ALLEGRO_LIB_EXES) $(ALLEGRO_DATAFILE_EXES); do \
	  if test "X`echo $$prog | sed -e s,tools/.\*,,`" = X; then \
	    p=`echo $$prog | sed -e s,tools/,,`; \
	    echo rm -f $(bindir)/$$p; \
	    rm -f $(bindir)/$$p; \
	  fi; \
	done

uninstall-info:
	@if test -f $(infodir)/allegro.info.gz; then \
	  echo Decompressing documentation...; \
	  gunzip $(infodir)/allegro.info.gz; \
	fi;
	@if test -f $(infodir)/allegro.info.bz2; then \
	  echo Decompressing documentation...; \
	  bzip2 -d $(infodir)/allegro.info.bz2; \
	fi;
	-@if $(SHELL) -c "$(INSTALL_INFO) --version" >/dev/null 2>&1; then \
	  if $(INSTALL_INFO) --version 2>&1 | grep "Debian" >/dev/null; then \
	    $(INSTALL_INFO) --remove $(infodir)/allegro.info; \
	  else \
	    $(INSTALL_INFO) --remove $(infodir)/allegro.info $(INFO_DIR); \
	  fi; \
	else \
	  true; \
	fi
	rm -f $(infodir)/allegro.info

uninstall-man:
	sed -n -e "s,^@[@\\].*@\([a-zA-Z0-9_]*\)[^a-zA-Z0-9_*].*,$(mandir)/man3/\1.3,p" $(srcdir)/docs/src/allegro._tx \
	  | xargs -n 1 rm -f
	sed -n -e "s,^@[@\\].*@\([a-zA-Z0-9_]*\)[^a-zA-Z0-9_*].*,$(mandir)/man3/\1.3.gz,p" $(srcdir)/docs/src/allegro._tx \
	  | xargs -n 1 rm -f
	sed -n -e "s,^@[@\\].*@\([a-zA-Z0-9_]*\)[^a-zA-Z0-9_*].*,$(mandir)/man3/\1.3.bz2,p" $(srcdir)/docs/src/allegro._tx \
	  | xargs -n 1 rm -f
	sed -n -e "s,^@@Example.*@\(ex.*\),$(mandir)/man3/\1.3,p" $(srcdir)/docs/src/allegro._tx \
	  | xargs -n 1 rm -f
	sed -n -e "s,^@@\(struct\|typedef\).*@\([a-zA-Z0-9_]*\),$(mandir)/man3/\2.3,p" $(srcdir)/docs/src/allegro._tx \
	  | xargs -n 1 rm -f

uninstall-misc:
	rm -f $(prefix)/share/aclocal/allegro.m4



# -------- generate automatic dependencies --------

depend:
	rm -f makefile.dep
	@echo "# Automatically generated." >makefile.dep
	@echo "Generating dependencies for libraries"
	$(SHELL) -c 'cd $(srcdir) && misc/deplib.sh $(ALLEGRO_LIBRARY_SOURCES)' >>makefile.dep
	@echo "Generating dependencies for dynamically loaded modules"
	$(SHELL) -c 'cd $(srcdir) && misc/depmod.sh vga -- $(ALLEGRO_MODULE_VGA_FILES)' >>makefile.dep
	$(SHELL) -c 'cd $(srcdir) && misc/depmod.sh svgalib -lvga $(ALLEGRO_MODULE_SVGALIB_FILES)' >>makefile.dep
	$(SHELL) -c 'cd $(srcdir) && misc/depmod.sh fbcon -- $(ALLEGRO_MODULE_FBCON_FILES)' >>makefile.dep
	$(SHELL) -c 'cd $(srcdir) && misc/depmod.sh dga2 -lXxf86dga $(ALLEGRO_MODULE_DGA2_FILES)' >> makefile.dep
	$(SHELL) -c 'cd $(srcdir) && misc/depmod.sh alsadigi -lasound $(ALLEGRO_MODULE_ALSADIGI_FILES)' >>makefile.dep
	$(SHELL) -c 'cd $(srcdir) && misc/depmod.sh alsamidi -lasound $(ALLEGRO_MODULE_ALSAMIDI_FILES)' >>makefile.dep
	$(SHELL) -c 'cd $(srcdir) && misc/depmod.sh esddigi "\`esd-config --libs\`" $(ALLEGRO_MODULE_ESD_FILES)' >>makefile.dep
	$(SHELL) -c 'cd $(srcdir) && misc/depmod.sh artsdigi "\`artsc-config --libs\`" $(ALLEGRO_MODULE_ARTS_FILES)' >>makefile.dep
	$(SHELL) -c 'cd $(srcdir) && misc/depmod.sh sgialdigi -laudio $(ALLEGRO_MODULE_SGIAL_FILES)' >>makefile.dep
	$(SHELL) -c 'cd $(srcdir) && misc/depmod.sh jackdigi "\`pkg-config --libs jack\`" $(ALLEGRO_MODULE_JACK_FILES)' >>makefile.dep
	@echo "Generating dependencies for simple programs"
	$(SHELL) -c 'cd $(srcdir) && misc/deplexe.sh -- $(ALLEGRO_LIB_EXE_SOURCES) $(ALLEGRO_EXAMPLE_FILES)' >>makefile.dep
	$(SHELL) -c 'cd $(srcdir) && misc/deplexe.sh -lX11 $(ALLEGRO_LIB_X_EXE_SOURCES) ' >>makefile.dep
	@echo "Generating dependencies for datafile plugins"
	$(SHELL) -c 'cd $(srcdir) && misc/depdlib.sh tools/datedit.c' >>makefile.dep
	@echo "Generating dependencies for datafile programs"
	$(SHELL) -c 'cd $(srcdir) && misc/depdexe.sh $(ALLEGRO_DATAFILE_EXE_SOURCES)' >>makefile.dep
	@echo "Generating dependencies for makedoc and demo"
	$(SHELL) -c 'cd $(srcdir) && misc/depmexe.sh docs/makedoc $(ALLEGRO_MAKEDOC_SOURCES)' >>makefile.dep
	$(SHELL) -c 'cd $(srcdir) && misc/depmexe.sh demo/demo $(ALLEGRO_DEMO_SOURCES)' >>makefile.dep
	@echo "Dependency generation completed!"

.PHONY: default full-build lib programs docs docs-dvi docs-ps docs-pdf \
docs-gzipped-ps docs-bzipped-ps \
clean distclean veryclean maintainer-clean \
install full-install mini-install \
install-lib install-headers install-programs install-info \
install-gzipped-info install-bzipped-info install-man install-gzipped-man \
install-bzipped-man depend \
uninstall uninstall-lib uninstall-modules uninstall-headers \
uninstall-programs uninstall-info uninstall-man

# Tell versions [3.59,3.63) of GNU make to not export all variables.
# Otherwise a system limit (for SysV at least) may be exceeded.
.NOEXPORT:
