##############################################################################
#                                                                            #
#                  FOX:  A Free C++ Class Library for X                      #
#                                                                            #
##############################################################################
# Contributed by: Andre Fornacon, updates from Jochen Rassler                #
##############################################################################
# $Id: Makefile.dmc,v 1.14.2.2 2006/08/08 23:17:35 fox Exp $                 #
##############################################################################
# This library is free software; you can redistribute it and/or              #
# modify it under the terms of the GNU Library General Public                #
# License as published by the Free Software Foundation; either               #
# version 2 of the License, or (at your option) any later version.           #
#                                                                            #
# This library is distributed in the hope that it will be useful,            #
# but WITHOUT ANY WARRANTY; without even the implied warranty of             #
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	See the GNU          #
# Library General Public License for more details.                           #
#                                                                            #
# You should have received a copy of the GNU Library General Public          #
# License along with this library; if not, write to the Free                 #
# Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.         #
##############################################################################

# Digital Mars C++ Compiler 8.x or later
CXX	  = dmc
CXXFLAGS  = -mn -5 -a8 -Ae -Ar
RM	  = del
TOPDIR	  = ..
DEFINES   = -DNDEBUG -DFOX_BIGENDIAN=0 -DWIN32 -D_WINDOWS
LD	  = link
LDFLAGS   = -noignorecase
LIBS	  = c:\dm\lib\advapi32.lib c:\dm\lib\shell32.lib c:\dm\lib\gdi32.lib c:\dm\lib\wsock32.lib c:\dm\lib\winspool.lib
GLLIBS	  = opengl32.lib glu32.lib
INCDIRS   = -I$(TOPDIR)\include
FOXLIB	  = $(TOPDIR)\src\FOX-1.6.lib
RESWRAP	  = $(TOPDIR)\utils\reswrap.exe

PROGRAMS  = adie.exe

SOURCES = \
	Adie.cpp \
	Commands.cpp \
	help.cpp \
	HelpWindow.cpp \
	Hilite.cpp \
	icons.cpp \
	main.cpp \
	parsesyntax.cpp \
	Preferences.cpp \
	TextWindow.cpp

OBJECTS   = \
	adie.obj \
	Commands.obj  \
	help.obj \
	HelpWindow.obj \
	TextWindow.obj \
	Preferences.obj \
	help.obj \
	Hilite.obj \
	icons.obj \
	parsesyntax.obj \
	main.obj

# splitted to avoid 'cmdline too long' errors
ICONS_1	= adie_gif.gif big_gif.gif bookset_gif.gif booknext_gif.gif \
          bookprev_gif.gif bookdel_gif.gif close_gif.gif colors_gif.gif \
          copy_gif.gif cut_gif.gif delete_gif.gif fonts_gif.gif help_gif.gif

ICONS_2 = indent_gif.gif info_gif.gif lang_gif.gif new_gif.gif open_gif.gif \
          palette_gif.gif pattern_gif.gif paste_gif.gif print_gif.gif \
          quit_gif.gif redo_gif.gif reload_gif.gif save_gif.gif saveall_gif.gif

ICONS_3 = saveas_gif.gif search_gif.gif searchnext_gif.gif searchprev_gif.gif \
          shiftleft_gif.gif shiftright_gif.gif styles_gif.gif small_gif.gif \
          syntax_gif.gif undo_gif.gif

ICONS = $(ICONS_1) $(ICONS_2) $(ICONS_3)


.cpp.obj:
	$(CXX) -c $(INCDIRS) $(CXXFLAGS) $(DEFINES) $*.cpp

all: $(PROGRAMS)

adie.exe: $(OBJECTS) $(FOXLIB)
	$(LD) $(LDFLAGS) $(OBJECTS) $(FOXLIB) $(LIBS)

adie.obj: icons.cpp

icons.h: $(ICONS)
	$(RM) $@
	$(RESWRAP) -i -oa $@ $(ICONS_1)
	$(RESWRAP) -i -oa $@ $(ICONS_2)
	$(RESWRAP) -i -oa $@ $(ICONS_2)

icons.cpp: $(ICONS)
	$(RM) $@
	echo ^#include "icons.h" > $@
	$(RESWRAP) -oa $@ $(ICONS_1)
	$(RESWRAP) -oa $@ $(ICONS_2)
	$(RESWRAP) -oa $@ $(ICONS_3)

clean:
	$(RM) *.obj *.exe *.tds *.map icons.cpp
