# Copyright (C) 2012-2014  The Bochs Project
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser 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
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public
# License along with this library; if not, write to the Free Software
# Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA

# Makefile for the iodev/hdimage component of bochs


.SUFFIXES: .cc

prefix          = /usr/local
exec_prefix     = $(prefix)
srcdir          = .

bindir          = $(exec_prefix)/bin
libdir          = $(exec_prefix)/lib
datarootdir     = $(prefix)/share
mandir          = $(datarootdir)/man
man1dir         = $(mandir)/man1
man5dir         = $(mandir)/man5
docdir          = $(datarootdir)/doc/bochs
sharedir        = $(datarootdir)/bochs
top_builddir    = ..
top_srcdir      = ../..

SHELL = /bin/sh



CXX = cl
CXXFLAGS = $(BX_INCDIRS) /nologo /MT /W3 /DNDEBUG /DWIN32 /D_WINDOWS /D_CRT_SECURE_NO_WARNINGS /O2 /Gr /EHs-c- 

LDFLAGS = 
LIBS = 
RANLIB = echo
PLUGIN_PATH=$(exec_prefix)/lib
top_builddir    = ../..
LIBTOOL=
WIN32_DLL_IMPORT_LIBRARY=../../

CDROM_OBJS = cdrom.o cdrom_win32.o
HDIMAGE_EXTRA_OBJS = vmware3.o vmware4.o vbox.o vpc-img.o vvfat.o

HDIMAGE_LINK_OPTS =
HDIMAGE_LINK_OPTS_VCPP = user32.lib

BX_INCDIRS = -I.. -I../.. -I$(srcdir)/.. -I$(srcdir)/../.. -I../../instrument/stubs -I$(srcdir)/../../instrument/stubs
LOCAL_CXXFLAGS = $(MCH_CFLAGS)

OBJS_THAT_CAN_BE_PLUGINS = \
  hdimage.o

OBJS_THAT_SUPPORT_OTHER_PLUGINS = \
  $(HDIMAGE_EXTRA_OBJS) \
  $(CDROM_OBJS)

NONPLUGIN_OBJS = $(OBJS_THAT_CANNOT_BE_PLUGINS) $(OBJS_THAT_CAN_BE_PLUGINS) $(OBJS_THAT_SUPPORT_OTHER_PLUGINS)
PLUGIN_OBJS = 

all: libhdimage.a

plugins: 

plugins_gcc: $(PLUGIN_OBJS:%.o=libbx_%.la)

plugins_msvc: bx_hdimage.dll

libhdimage.a: $(NONPLUGIN_OBJS)
	-del libhdimage.a
	lib /nologo /subsystem:console,"5.01" /verbose /out:$@ $(NONPLUGIN_OBJS)
	$(RANLIB) libhdimage.a

# standard compile rule for C++ files
.cc.o:
	$(CXX) /c  $(CXXFLAGS) $(LOCAL_CXXFLAGS) /Tp$< /Fo$@

##### building plugins with libtool
%.lo: %.cc
	$(LIBTOOL) --mode=compile --tag CXX $(CXX) -c $(CXXFLAGS) $(LOCAL_CXXFLAGS) $< -o $@

libbx_%.la: %.lo
	$(LIBTOOL) --mode=link --tag CXX $(CXX) -module $< -o $@ -rpath $(PLUGIN_PATH)

# special link rules for plugins that require more than one object file
libbx_hdimage.la: hdimage.lo $(HDIMAGE_EXTRA_OBJS:.o=.lo) $(CDROM_OBJS:.o=.lo)
	$(LIBTOOL) --mode=link --tag CXX $(CXX) -module hdimage.lo $(HDIMAGE_EXTRA_OBJS:.o=.lo) $(CDROM_OBJS:.o=.lo) -o libbx_hdimage.la -rpath $(PLUGIN_PATH)

#### building DLLs for win32 (Cygwin and MinGW/MSYS)
bx_%.dll: %.o
	$(CXX) $(CXXFLAGS) -shared -o $@ $< $(WIN32_DLL_IMPORT_LIBRARY)

# special link rules for plugins with Cygwin, MinGW/MSYS and MSVC nmake
bx_hdimage.dll: hdimage.o $(HDIMAGE_EXTRA_OBJS) $(CDROM_OBJS)
	 hdimage.o $(HDIMAGE_EXTRA_OBJS) $(CDROM_OBJS) $(WIN32_DLL_IMPORT_LIBRARY) $(HDIMAGE_LINK_OPTS)

##### end DLL section

clean:
	-del -rf .libs *.lo *.o *.la *.a *.dll *.exp *.lib

dist-clean: clean
	-del Makefile

###########################################
# dependencies generated by
#  gcc -MM -I.. -I../.. -I../../instrument/stubs *.cc | sed -e 's/\.cc/.cc/g'
#  gcc -MM -I.. -I../.. -I../../instrument/stubs *.cc | \
#     sed -e 's/\.cc/.cc/g' -e 's/\.o:/.lo:/g'
#
# This means that every source file is listed twice, once with a .o rule
# and then again with an identical .lo rule.  The .lo rules are used when
# building plugins.
###########################################
cdrom_amigaos.o: cdrom_amigaos.cc ../../bochs.h ../../config.h \
 ../../osdep.h ../../bx_debug/debug.h ../../config.h ../../osdep.h \
 ../../gui/siminterface.h ../../cpudb.h ../../gui/paramtree.h \
 ../../memory/memory.h ../../pc_system.h ../../gui/gui.h \
 ../../instrument/stubs/instrument.h scsi_commands.h cdrom.h \
 cdrom_amigaos.h
cdrom.o: cdrom.cc ../../bochs.h ../../config.h ../../osdep.h \
 ../../bx_debug/debug.h ../../config.h ../../osdep.h \
 ../../gui/siminterface.h ../../cpudb.h ../../gui/paramtree.h \
 ../../memory/memory.h ../../pc_system.h ../../gui/gui.h \
 ../../instrument/stubs/instrument.h cdrom.h
cdrom_misc.o: cdrom_misc.cc ../../bochs.h ../../config.h ../../osdep.h \
 ../../bx_debug/debug.h ../../config.h ../../osdep.h \
 ../../gui/siminterface.h ../../cpudb.h ../../gui/paramtree.h \
 ../../memory/memory.h ../../pc_system.h ../../gui/gui.h \
 ../../instrument/stubs/instrument.h cdrom.h cdrom_misc.h
cdrom_osx.o: cdrom_osx.cc ../../bochs.h ../../config.h ../../osdep.h \
 ../../bx_debug/debug.h ../../config.h ../../osdep.h \
 ../../gui/siminterface.h ../../cpudb.h ../../gui/paramtree.h \
 ../../memory/memory.h ../../pc_system.h ../../gui/gui.h \
 ../../instrument/stubs/instrument.h cdrom.h cdrom_osx.h
cdrom_win32.o: cdrom_win32.cc ../../bochs.h ../../config.h ../../osdep.h \
 ../../bx_debug/debug.h ../../config.h ../../osdep.h \
 ../../gui/siminterface.h ../../cpudb.h ../../gui/paramtree.h \
 ../../memory/memory.h ../../pc_system.h ../../gui/gui.h \
 ../../instrument/stubs/instrument.h cdrom.h cdrom_win32.h
hdimage.o: hdimage.cc ../iodev.h ../../bochs.h ../../config.h \
 ../../osdep.h ../../bx_debug/debug.h ../../config.h ../../osdep.h \
 ../../gui/siminterface.h ../../cpudb.h ../../gui/paramtree.h \
 ../../memory/memory.h ../../pc_system.h ../../gui/gui.h \
 ../../instrument/stubs/instrument.h ../../plugin.h ../../extplugin.h \
 ../../param_names.h cdrom.h cdrom_amigaos.h cdrom_misc.h cdrom_osx.h \
 cdrom_win32.h hdimage.h vmware3.h vmware4.h vvfat.h vpc-img.h vbox.h
vbox.o: vbox.cc ../iodev.h ../../bochs.h ../../config.h ../../osdep.h \
 ../../bx_debug/debug.h ../../config.h ../../osdep.h \
 ../../gui/siminterface.h ../../cpudb.h ../../gui/paramtree.h \
 ../../memory/memory.h ../../pc_system.h ../../gui/gui.h \
 ../../instrument/stubs/instrument.h ../../plugin.h ../../extplugin.h \
 ../../param_names.h hdimage.h vbox.h
vmware3.o: vmware3.cc ../iodev.h ../../bochs.h ../../config.h \
 ../../osdep.h ../../bx_debug/debug.h ../../config.h ../../osdep.h \
 ../../gui/siminterface.h ../../cpudb.h ../../gui/paramtree.h \
 ../../memory/memory.h ../../pc_system.h ../../gui/gui.h \
 ../../instrument/stubs/instrument.h ../../plugin.h ../../extplugin.h \
 ../../param_names.h hdimage.h vmware3.h
vmware4.o: vmware4.cc ../iodev.h ../../bochs.h ../../config.h \
 ../../osdep.h ../../bx_debug/debug.h ../../config.h ../../osdep.h \
 ../../gui/siminterface.h ../../cpudb.h ../../gui/paramtree.h \
 ../../memory/memory.h ../../pc_system.h ../../gui/gui.h \
 ../../instrument/stubs/instrument.h ../../plugin.h ../../extplugin.h \
 ../../param_names.h hdimage.h vmware4.h
vpc-img.o: vpc-img.cc ../iodev.h ../../bochs.h ../../config.h \
 ../../osdep.h ../../bx_debug/debug.h ../../config.h ../../osdep.h \
 ../../gui/siminterface.h ../../cpudb.h ../../gui/paramtree.h \
 ../../memory/memory.h ../../pc_system.h ../../gui/gui.h \
 ../../instrument/stubs/instrument.h ../../plugin.h ../../extplugin.h \
 ../../param_names.h hdimage.h vpc-img.h
vvfat.o: vvfat.cc ../iodev.h ../../bochs.h ../../config.h ../../osdep.h \
 ../../bx_debug/debug.h ../../config.h ../../osdep.h \
 ../../gui/siminterface.h ../../cpudb.h ../../gui/paramtree.h \
 ../../memory/memory.h ../../pc_system.h ../../gui/gui.h \
 ../../instrument/stubs/instrument.h ../../plugin.h ../../extplugin.h \
 ../../param_names.h hdimage.h vvfat.h
cdrom_amigaos.lo: cdrom_amigaos.cc ../../bochs.h ../../config.h \
 ../../osdep.h ../../bx_debug/debug.h ../../config.h ../../osdep.h \
 ../../gui/siminterface.h ../../cpudb.h ../../gui/paramtree.h \
 ../../memory/memory.h ../../pc_system.h ../../gui/gui.h \
 ../../instrument/stubs/instrument.h scsi_commands.h cdrom.h \
 cdrom_amigaos.h
cdrom.lo: cdrom.cc ../../bochs.h ../../config.h ../../osdep.h \
 ../../bx_debug/debug.h ../../config.h ../../osdep.h \
 ../../gui/siminterface.h ../../cpudb.h ../../gui/paramtree.h \
 ../../memory/memory.h ../../pc_system.h ../../gui/gui.h \
 ../../instrument/stubs/instrument.h cdrom.h
cdrom_misc.lo: cdrom_misc.cc ../../bochs.h ../../config.h ../../osdep.h \
 ../../bx_debug/debug.h ../../config.h ../../osdep.h \
 ../../gui/siminterface.h ../../cpudb.h ../../gui/paramtree.h \
 ../../memory/memory.h ../../pc_system.h ../../gui/gui.h \
 ../../instrument/stubs/instrument.h cdrom.h cdrom_misc.h
cdrom_osx.lo: cdrom_osx.cc ../../bochs.h ../../config.h ../../osdep.h \
 ../../bx_debug/debug.h ../../config.h ../../osdep.h \
 ../../gui/siminterface.h ../../cpudb.h ../../gui/paramtree.h \
 ../../memory/memory.h ../../pc_system.h ../../gui/gui.h \
 ../../instrument/stubs/instrument.h cdrom.h cdrom_osx.h
cdrom_win32.lo: cdrom_win32.cc ../../bochs.h ../../config.h ../../osdep.h \
 ../../bx_debug/debug.h ../../config.h ../../osdep.h \
 ../../gui/siminterface.h ../../cpudb.h ../../gui/paramtree.h \
 ../../memory/memory.h ../../pc_system.h ../../gui/gui.h \
 ../../instrument/stubs/instrument.h cdrom.h cdrom_win32.h
hdimage.lo: hdimage.cc ../iodev.h ../../bochs.h ../../config.h \
 ../../osdep.h ../../bx_debug/debug.h ../../config.h ../../osdep.h \
 ../../gui/siminterface.h ../../cpudb.h ../../gui/paramtree.h \
 ../../memory/memory.h ../../pc_system.h ../../gui/gui.h \
 ../../instrument/stubs/instrument.h ../../plugin.h ../../extplugin.h \
 ../../param_names.h cdrom.h cdrom_amigaos.h cdrom_misc.h cdrom_osx.h \
 cdrom_win32.h hdimage.h vmware3.h vmware4.h vvfat.h vpc-img.h vbox.h
vbox.lo: vbox.cc ../iodev.h ../../bochs.h ../../config.h ../../osdep.h \
 ../../bx_debug/debug.h ../../config.h ../../osdep.h \
 ../../gui/siminterface.h ../../cpudb.h ../../gui/paramtree.h \
 ../../memory/memory.h ../../pc_system.h ../../gui/gui.h \
 ../../instrument/stubs/instrument.h ../../plugin.h ../../extplugin.h \
 ../../param_names.h hdimage.h vbox.h
vmware3.lo: vmware3.cc ../iodev.h ../../bochs.h ../../config.h \
 ../../osdep.h ../../bx_debug/debug.h ../../config.h ../../osdep.h \
 ../../gui/siminterface.h ../../cpudb.h ../../gui/paramtree.h \
 ../../memory/memory.h ../../pc_system.h ../../gui/gui.h \
 ../../instrument/stubs/instrument.h ../../plugin.h ../../extplugin.h \
 ../../param_names.h hdimage.h vmware3.h
vmware4.lo: vmware4.cc ../iodev.h ../../bochs.h ../../config.h \
 ../../osdep.h ../../bx_debug/debug.h ../../config.h ../../osdep.h \
 ../../gui/siminterface.h ../../cpudb.h ../../gui/paramtree.h \
 ../../memory/memory.h ../../pc_system.h ../../gui/gui.h \
 ../../instrument/stubs/instrument.h ../../plugin.h ../../extplugin.h \
 ../../param_names.h hdimage.h vmware4.h
vpc-img.lo: vpc-img.cc ../iodev.h ../../bochs.h ../../config.h \
 ../../osdep.h ../../bx_debug/debug.h ../../config.h ../../osdep.h \
 ../../gui/siminterface.h ../../cpudb.h ../../gui/paramtree.h \
 ../../memory/memory.h ../../pc_system.h ../../gui/gui.h \
 ../../instrument/stubs/instrument.h ../../plugin.h ../../extplugin.h \
 ../../param_names.h hdimage.h vpc-img.h
vvfat.lo: vvfat.cc ../iodev.h ../../bochs.h ../../config.h ../../osdep.h \
 ../../bx_debug/debug.h ../../config.h ../../osdep.h \
 ../../gui/siminterface.h ../../cpudb.h ../../gui/paramtree.h \
 ../../memory/memory.h ../../pc_system.h ../../gui/gui.h \
 ../../instrument/stubs/instrument.h ../../plugin.h ../../extplugin.h \
 ../../param_names.h hdimage.h vvfat.h
