# Copyright (C) 2001-2009 by David Capello		-*-Makefile-*-

######################################################################
# ASE

ASE = aseprite$(EXE)

COMMON_SOURCES =					\
	src/commands/cmd_about.cpp			\
	src/commands/cmd_advanced_mode.cpp		\
	src/commands/cmd_background_from_layer.cpp	\
	src/commands/cmd_canvas_size.cpp		\
	src/commands/cmd_cel_properties.cpp		\
	src/commands/cmd_change_image_type.cpp		\
	src/commands/cmd_clear.cpp			\
	src/commands/cmd_close_file.cpp			\
	src/commands/cmd_configure_screen.cpp		\
	src/commands/cmd_configure_tools.cpp		\
	src/commands/cmd_copy.cpp			\
	src/commands/cmd_copy_cel.cpp			\
	src/commands/cmd_crop.cpp			\
	src/commands/cmd_cut.cpp			\
	src/commands/cmd_deselect_mask.cpp		\
	src/commands/cmd_duplicate_layer.cpp		\
	src/commands/cmd_duplicate_sprite.cpp		\
	src/commands/cmd_exit.cpp			\
	src/commands/cmd_eyedropper.cpp			\
	src/commands/cmd_film_editor.cpp		\
	src/commands/cmd_flatten_layers.cpp		\
	src/commands/cmd_flip.cpp			\
	src/commands/cmd_frame_properties.cpp		\
	src/commands/cmd_goto_frame.cpp			\
	src/commands/cmd_goto_layer.cpp			\
	src/commands/cmd_grid.cpp			\
	src/commands/cmd_invert_mask.cpp		\
	src/commands/cmd_layer_from_background.cpp	\
	src/commands/cmd_layer_properties.cpp		\
	src/commands/cmd_load_mask.cpp			\
	src/commands/cmd_mask_all.cpp			\
	src/commands/cmd_mask_by_color.cpp		\
	src/commands/cmd_merge_down_layer.cpp		\
	src/commands/cmd_move_cel.cpp			\
	src/commands/cmd_new_file.cpp			\
	src/commands/cmd_new_frame.cpp			\
	src/commands/cmd_new_layer.cpp			\
	src/commands/cmd_new_layer_set.cpp		\
	src/commands/cmd_open_file.cpp			\
	src/commands/cmd_options.cpp			\
	src/commands/cmd_palette_editor.cpp		\
	src/commands/cmd_paste.cpp			\
	src/commands/cmd_play_animation.cpp		\
	src/commands/cmd_preview.cpp			\
	src/commands/cmd_record_screen.cpp		\
	src/commands/cmd_redo.cpp			\
	src/commands/cmd_refresh.cpp			\
	src/commands/cmd_remove_cel.cpp			\
	src/commands/cmd_remove_frame.cpp		\
	src/commands/cmd_remove_layer.cpp		\
	src/commands/cmd_reselect_mask.cpp		\
	src/commands/cmd_rotate_canvas.cpp		\
	src/commands/cmd_save_file.cpp			\
	src/commands/cmd_save_mask.cpp			\
	src/commands/cmd_screen_shot.cpp		\
	src/commands/cmd_select_file.cpp		\
	src/commands/cmd_sprite_editor.cpp		\
	src/commands/cmd_sprite_properties.cpp		\
	src/commands/cmd_sprite_size.cpp		\
	src/commands/cmd_switch_colors.cpp		\
	src/commands/cmd_tips.cpp			\
	src/commands/cmd_undo.cpp			\
	src/commands/command.cpp			\
	src/commands/commands.cpp			\
	src/commands/fx/cmd_color_curve.cpp		\
	src/commands/fx/cmd_convolution_matrix.cpp	\
	src/commands/fx/cmd_despeckle.cpp		\
	src/commands/fx/cmd_invert_color.cpp		\
	src/commands/fx/cmd_replace_color.cpp		\
	src/commands/fx/effectbg.cpp			\
	src/core/app.cpp				\
	src/core/cfg.cpp				\
	src/core/color.cpp				\
	src/core/config.cpp				\
	src/core/core.cpp				\
	src/core/dirs.cpp				\
	src/core/drop_files.cpp				\
	src/core/file_system.cpp			\
	src/core/job.cpp				\
	src/core/modules.cpp				\
	src/dialogs/aniedit.cpp				\
	src/dialogs/drawtext.cpp			\
	src/dialogs/filesel.cpp				\
	src/dialogs/maskcol.cpp				\
	src/dialogs/options.cpp				\
	src/dialogs/playfli.cpp				\
	src/dialogs/repo.cpp				\
	src/dialogs/tips.cpp				\
	src/dialogs/vectmap.cpp				\
	src/effect/colcurve.cpp				\
	src/effect/convmatr.cpp				\
	src/effect/effect.cpp				\
	src/effect/invrtcol.cpp				\
	src/effect/median.cpp				\
	src/effect/replcol.cpp				\
	src/file/ase_format.cpp				\
	src/file/bmp_format.cpp				\
	src/file/file.cpp				\
	src/file/fli/fli.cpp				\
	src/file/fli_format.cpp				\
	src/file/format_options.cpp			\
	src/file/gif/format.cpp				\
	src/file/gif/lzw.cpp				\
	src/file/gif_format.cpp				\
	src/file/ico_format.cpp				\
	src/file/jpeg_format.cpp			\
	src/file/pcx_format.cpp				\
	src/file/png_format.cpp				\
	src/file/tga_format.cpp				\
	src/intl/intl.cpp				\
	src/intl/msgids.cpp				\
	src/jinete/jaccel.cpp				\
	src/jinete/jalert.cpp				\
	src/jinete/jbox.cpp				\
	src/jinete/jbutton.cpp				\
	src/jinete/jclipboard.cpp			\
	src/jinete/jcombobox.cpp			\
	src/jinete/jdraw.cpp				\
	src/jinete/jentry.cpp				\
	src/jinete/jgrid.cpp				\
	src/jinete/jfile.cpp				\
	src/jinete/jfilesel.cpp				\
	src/jinete/jfont.cpp				\
	src/jinete/jfontbmp.cpp				\
	src/jinete/jhook.cpp				\
	src/jinete/jimage.cpp				\
	src/jinete/jinete.cpp				\
	src/jinete/jintern.cpp				\
	src/jinete/jlabel.cpp				\
	src/jinete/jlist.cpp				\
	src/jinete/jlistbox.cpp				\
	src/jinete/jmanager.cpp				\
	src/jinete/jmem.cpp				\
	src/jinete/jmenu.cpp				\
	src/jinete/jmessage.cpp				\
	src/jinete/jmutex.cpp				\
	src/jinete/jpanel.cpp				\
	src/jinete/jquickmenu.cpp			\
	src/jinete/jrect.cpp				\
	src/jinete/jregion.cpp				\
	src/jinete/jsep.cpp				\
	src/jinete/jslider.cpp				\
	src/jinete/jstream.cpp				\
	src/jinete/jstring.cpp				\
	src/jinete/jsystem.cpp				\
	src/jinete/jtextbox.cpp				\
	src/jinete/jtheme.cpp				\
	src/jinete/jthread.cpp				\
	src/jinete/jtooltips.cpp			\
	src/jinete/jview.cpp				\
	src/jinete/jwidget.cpp				\
	src/jinete/jwindow.cpp				\
	src/jinete/jxml.cpp				\
	src/jinete/themes/jstandard_theme.cpp		\
	src/modules/editors.cpp				\
	src/modules/gfx.cpp				\
	src/modules/gui.cpp				\
	src/modules/palettes.cpp			\
	src/modules/recent.cpp				\
	src/modules/rootmenu.cpp			\
	src/modules/tools.cpp				\
	src/raster/algo.cpp				\
	src/raster/algofill.cpp				\
	src/raster/blend.cpp				\
	src/raster/brush.cpp				\
	src/raster/cel.cpp				\
	src/raster/dirty.cpp				\
	src/raster/gfxobj.cpp				\
	src/raster/image.cpp				\
	src/raster/layer.cpp				\
	src/raster/mask.cpp				\
	src/raster/palette.cpp				\
	src/raster/path.cpp				\
	src/raster/quant.cpp				\
	src/raster/rotate.cpp				\
	src/raster/sprite.cpp				\
	src/raster/stock.cpp				\
	src/raster/undo.cpp				\
	src/util/autocrop.cpp				\
	src/util/boundary.cpp				\
	src/util/celmove.cpp				\
	src/util/clipboard.cpp				\
	src/util/col_file.cpp				\
	src/util/filetoks.cpp				\
	src/util/hash.cpp				\
	src/util/images_ref.cpp				\
	src/util/misc.cpp				\
	src/util/msk_file.cpp				\
	src/util/pic_file.cpp				\
	src/util/quantize.cpp				\
	src/util/recscr.cpp				\
	src/util/render.cpp				\
	src/util/thmbnail.cpp				\
	src/widgets/colbar.cpp				\
	src/widgets/colbut.cpp				\
	src/widgets/colsel.cpp				\
	src/widgets/colview.cpp				\
	src/widgets/curvedit.cpp			\
	src/widgets/editor/click.cpp			\
	src/widgets/editor/cursor.cpp			\
	src/widgets/editor/editor.cpp			\
	src/widgets/editor/keys.cpp			\
	src/widgets/fileview.cpp			\
	src/widgets/groupbut.cpp			\
	src/widgets/menuitem.cpp			\
	src/widgets/paledit.cpp				\
	src/widgets/preview.cpp				\
	src/widgets/statebar.cpp			\
	src/widgets/tabs.cpp				\
	src/widgets/target.cpp				\
	src/widgets/toolbar.cpp

ifdef USE_386_ASM
  COMMON_SOURCES += \
	src/raster/x86/blenders.s			\
	src/raster/x86/int_mult.s
endif

COMMON_OBJS = $(addprefix $(OBJ_DIR)/,				\
	        $(addsuffix $(OBJ),				\
	          $(notdir $(basename $(COMMON_SOURCES)))))

ASE_SOURCES = \
	src/console.cpp						\
	src/context.cpp						\
	src/main.cpp						\
	src/ui_context.cpp					\
	src/undoable.cpp					\
	$(COMMON_SOURCES)

ASE_OBJS = $(addprefix $(OBJ_DIR)/,				\
	     $(addsuffix $(OBJ),				\
	       $(notdir $(basename $(ASE_SOURCES)))))

######################################################################
# Libart

LIBART_LIB = $(OBJ_DIR)/libart$(LIB_EXT)
LIBART_DIR = third_party/libart_lgpl
LIBART_SOURCES =				\
	$(LIBART_DIR)/art_affine.c		\
	$(LIBART_DIR)/art_alphagamma.c		\
	$(LIBART_DIR)/art_bpath.c		\
	$(LIBART_DIR)/art_gray_svp.c		\
	$(LIBART_DIR)/art_misc.c		\
	$(LIBART_DIR)/art_pixbuf.c		\
	$(LIBART_DIR)/art_rect.c		\
	$(LIBART_DIR)/art_rect_svp.c		\
	$(LIBART_DIR)/art_rect_uta.c		\
	$(LIBART_DIR)/art_render.c		\
	$(LIBART_DIR)/art_render_gradient.c	\
	$(LIBART_DIR)/art_render_svp.c		\
	$(LIBART_DIR)/art_rgba.c		\
	$(LIBART_DIR)/art_rgb_affine.c		\
	$(LIBART_DIR)/art_rgb_affine_private.c	\
	$(LIBART_DIR)/art_rgb_bitmap_affine.c	\
	$(LIBART_DIR)/art_rgb.c			\
	$(LIBART_DIR)/art_rgb_pixbuf_affine.c	\
	$(LIBART_DIR)/art_rgb_rgba_affine.c	\
	$(LIBART_DIR)/art_rgb_svp.c		\
	$(LIBART_DIR)/art_svp.c			\
	$(LIBART_DIR)/art_svp_ops.c		\
	$(LIBART_DIR)/art_svp_point.c		\
	$(LIBART_DIR)/art_svp_render_aa.c	\
	$(LIBART_DIR)/art_svp_vpath.c		\
	$(LIBART_DIR)/art_svp_vpath_stroke.c	\
	$(LIBART_DIR)/art_svp_wind.c		\
	$(LIBART_DIR)/art_uta.c			\
	$(LIBART_DIR)/art_uta_ops.c		\
	$(LIBART_DIR)/art_uta_rect.c		\
	$(LIBART_DIR)/art_uta_svp.c		\
	$(LIBART_DIR)/art_uta_vpath.c		\
	$(LIBART_DIR)/art_vpath_bpath.c		\
	$(LIBART_DIR)/art_vpath.c		\
	$(LIBART_DIR)/art_vpath_dash.c		\
	$(LIBART_DIR)/art_vpath_svp.c		\
	$(LIBART_DIR)/libart-features.c

LIBART_OBJS = $(addprefix $(OBJ_DIR)/art.,					\
			  $(addsuffix $(OBJ),					\
				      $(notdir $(basename $(LIBART_SOURCES)))))

######################################################################
# Freetype

LIBFREETYPE_LIB = $(OBJ_DIR)/libfreetype$(LIB_EXT)
LIBFREETYPE_DIR = third_party/freetype
LIBFREETYPE_SOURCES =					\
	$(LIBFREETYPE_DIR)/src/base/ftsystem.c		\
	$(LIBFREETYPE_DIR)/src/base/ftdebug.c		\
	$(LIBFREETYPE_DIR)/src/base/ftinit.c		\
	$(LIBFREETYPE_DIR)/src/base/ftbase.c		\
	$(LIBFREETYPE_DIR)/src/base/ftglyph.c		\
	$(LIBFREETYPE_DIR)/src/base/ftmm.c		\
	$(LIBFREETYPE_DIR)/src/base/ftbbox.c		\
	$(LIBFREETYPE_DIR)/src/autohint/autohint.c	\
	$(LIBFREETYPE_DIR)/src/cache/ftcache.c		\
	$(LIBFREETYPE_DIR)/src/cff/cff.c		\
	$(LIBFREETYPE_DIR)/src/cid/type1cid.c		\
	$(LIBFREETYPE_DIR)/src/pcf/pcf.c		\
	$(LIBFREETYPE_DIR)/src/psaux/psaux.c		\
	$(LIBFREETYPE_DIR)/src/pshinter/pshinter.c	\
	$(LIBFREETYPE_DIR)/src/psnames/psmodule.c	\
	$(LIBFREETYPE_DIR)/src/raster/raster.c		\
	$(LIBFREETYPE_DIR)/src/sfnt/sfnt.c		\
	$(LIBFREETYPE_DIR)/src/smooth/smooth.c		\
	$(LIBFREETYPE_DIR)/src/truetype/truetype.c	\
	$(LIBFREETYPE_DIR)/src/type1/type1.c		\
	$(LIBFREETYPE_DIR)/src/winfonts/winfnt.c

LIBFREETYPE_OBJS = $(addprefix $(OBJ_DIR)/freetype.,					\
			  $(addsuffix $(OBJ),						\
				      $(notdir $(basename $(LIBFREETYPE_SOURCES)))))

######################################################################
# GD Library

LIBGD_LIB = $(OBJ_DIR)/libgd$(LIB_EXT)
LIBGD_DIR = third_party/gd
LIBGD_SOURCES =					\
	$(LIBGD_DIR)/gd				\
	$(LIBGD_DIR)/gdfx			\
	$(LIBGD_DIR)/gd_security		\
	$(LIBGD_DIR)/gd_gd			\
	$(LIBGD_DIR)/gd_gd2			\
	$(LIBGD_DIR)/gd_io			\
	$(LIBGD_DIR)/gd_io_dp			\
	$(LIBGD_DIR)/gd_gif_in			\
	$(LIBGD_DIR)/gd_gif_out			\
	$(LIBGD_DIR)/gd_io_file			\
	$(LIBGD_DIR)/gd_io_ss			\
	$(LIBGD_DIR)/gd_jpeg			\
	$(LIBGD_DIR)/gd_png			\
	$(LIBGD_DIR)/gd_ss			\
	$(LIBGD_DIR)/gd_topal			\
	$(LIBGD_DIR)/gd_wbmp			\
	$(LIBGD_DIR)/gdcache			\
	$(LIBGD_DIR)/gdfontg			\
	$(LIBGD_DIR)/gdfontl			\
	$(LIBGD_DIR)/gdfontmb			\
	$(LIBGD_DIR)/gdfonts			\
	$(LIBGD_DIR)/gdfontt			\
	$(LIBGD_DIR)/gdft			\
	$(LIBGD_DIR)/gdhelpers			\
	$(LIBGD_DIR)/gdkanji			\
	$(LIBGD_DIR)/gdtables			\
	$(LIBGD_DIR)/gdxpm			\
	$(LIBGD_DIR)/wbmp

LIBGD_OBJS = $(addprefix $(OBJ_DIR)/gd.,			\
	       $(addsuffix $(OBJ),				\
		 $(notdir $(basename $(LIBGD_SOURCES)))))

######################################################################
# JPEG

LIBJPEG_LIB = $(OBJ_DIR)/libjpeg$(LIB_EXT)
LIBJPEG_DIR = third_party/jpeg
LIBJPEG_SOURCES =				\
	$(LIBJPEG_DIR)/jcapimin.c		\
	$(LIBJPEG_DIR)/jcapistd.c		\
	$(LIBJPEG_DIR)/jccoefct.c		\
	$(LIBJPEG_DIR)/jccolor.c		\
	$(LIBJPEG_DIR)/jcdctmgr.c		\
	$(LIBJPEG_DIR)/jchuff.c			\
	$(LIBJPEG_DIR)/jcinit.c			\
	$(LIBJPEG_DIR)/jcmainct.c		\
	$(LIBJPEG_DIR)/jcmarker.c		\
	$(LIBJPEG_DIR)/jcmaster.c		\
	$(LIBJPEG_DIR)/jcomapi.c		\
	$(LIBJPEG_DIR)/jcparam.c		\
	$(LIBJPEG_DIR)/jcphuff.c		\
	$(LIBJPEG_DIR)/jcprepct.c		\
	$(LIBJPEG_DIR)/jcsample.c		\
	$(LIBJPEG_DIR)/jctrans.c		\
	$(LIBJPEG_DIR)/jdapimin.c		\
	$(LIBJPEG_DIR)/jdapistd.c		\
	$(LIBJPEG_DIR)/jdatadst.c		\
	$(LIBJPEG_DIR)/jdatasrc.c		\
	$(LIBJPEG_DIR)/jdcoefct.c		\
	$(LIBJPEG_DIR)/jdcolor.c		\
	$(LIBJPEG_DIR)/jddctmgr.c		\
	$(LIBJPEG_DIR)/jdhuff.c			\
	$(LIBJPEG_DIR)/jdinput.c		\
	$(LIBJPEG_DIR)/jdmainct.c		\
	$(LIBJPEG_DIR)/jdmarker.c		\
	$(LIBJPEG_DIR)/jdmaster.c		\
	$(LIBJPEG_DIR)/jdmerge.c		\
	$(LIBJPEG_DIR)/jdphuff.c		\
	$(LIBJPEG_DIR)/jdpostct.c		\
	$(LIBJPEG_DIR)/jdsample.c		\
	$(LIBJPEG_DIR)/jdtrans.c		\
	$(LIBJPEG_DIR)/jerror.c			\
	$(LIBJPEG_DIR)/jfdctflt.c		\
	$(LIBJPEG_DIR)/jfdctfst.c		\
	$(LIBJPEG_DIR)/jfdctint.c		\
	$(LIBJPEG_DIR)/jidctflt.c		\
	$(LIBJPEG_DIR)/jidctfst.c		\
	$(LIBJPEG_DIR)/jidctint.c		\
	$(LIBJPEG_DIR)/jidctred.c		\
	$(LIBJPEG_DIR)/jmemansi.c		\
	$(LIBJPEG_DIR)/jmemmgr.c		\
	$(LIBJPEG_DIR)/jquant1.c		\
	$(LIBJPEG_DIR)/jquant2.c		\
	$(LIBJPEG_DIR)/jutils.c

LIBJPEG_OBJS = $(addprefix $(OBJ_DIR)/jpeg.,			\
		$(addsuffix $(OBJ),				\
		  $(notdir $(basename $(LIBJPEG_SOURCES)))))

######################################################################
# LibPNG

LIBPNG_LIB = $(OBJ_DIR)/libpng$(LIB_EXT)
LIBPNG_DIR = third_party/libpng
LIBPNG_SOURCES =				\
	$(LIBPNG_DIR)/png.c			\
	$(LIBPNG_DIR)/pngerror.c		\
	$(LIBPNG_DIR)/pngget.c			\
	$(LIBPNG_DIR)/pngmem.c			\
	$(LIBPNG_DIR)/pngpread.c		\
	$(LIBPNG_DIR)/pngread.c			\
	$(LIBPNG_DIR)/pngrio.c			\
	$(LIBPNG_DIR)/pngrtran.c		\
	$(LIBPNG_DIR)/pngrutil.c		\
	$(LIBPNG_DIR)/pngset.c			\
	$(LIBPNG_DIR)/pngtrans.c		\
	$(LIBPNG_DIR)/pngwio.c			\
	$(LIBPNG_DIR)/pngwrite.c		\
	$(LIBPNG_DIR)/pngwtran.c		\
	$(LIBPNG_DIR)/pngwutil.c

LIBPNG_OBJS = $(addprefix $(OBJ_DIR)/png.,			\
		$(addsuffix $(OBJ),				\
		  $(notdir $(basename $(LIBPNG_SOURCES)))))

######################################################################
# ZLib

ZLIB_LIB = $(OBJ_DIR)/libzlib$(LIB_EXT)
ZLIB_DIR = third_party/zlib
ZLIB_SOURCES =					\
	$(ZLIB_DIR)/adler32.c			\
	$(ZLIB_DIR)/compress.c			\
	$(ZLIB_DIR)/crc32.c			\
	$(ZLIB_DIR)/deflate.c			\
	$(ZLIB_DIR)/gzio.c			\
	$(ZLIB_DIR)/infback.c			\
	$(ZLIB_DIR)/inffast.c			\
	$(ZLIB_DIR)/inflate.c			\
	$(ZLIB_DIR)/inftrees.c			\
	$(ZLIB_DIR)/trees.c			\
	$(ZLIB_DIR)/uncompr.c			\
	$(ZLIB_DIR)/zutil.c

ZLIB_OBJS = $(addprefix $(OBJ_DIR)/zlib.,		\
	      $(addsuffix $(OBJ),			\
		$(notdir $(basename $(ZLIB_SOURCES)))))

######################################################################
# All objects and libraries

ALL_OBJS =					\
	$(ASE_OBJS)				\
	$(LIBFREETYPE_OBJS)			\
	$(LIBART_OBJS)				\
	$(LIBJPEG_OBJS)				\
	$(LIBPNG_OBJS)				\
	$(ZLIB_OBJS)

THIRD_PARTY_LIBS =				\
	$(LIBART_LIB)				\
	$(LIBFREETYPE_LIB)			\
	$(LIBJPEG_LIB)				\
	$(LIBPNG_LIB)				\
	$(ZLIB_LIB)

######################################################################
# Tests

TESTS = $(addsuffix $(EXE),						\
		$(basename						\
			$(wildcard src/tests/*.cpp)			\
			$(wildcard src/tests/raster/*.cpp)		\
			$(wildcard src/tests/jinete/*.cpp)))

AUTOTESTS = $(addsuffix $(EXE),						\
		$(basename						\
			$(wildcard src/tests/*.cpp)))