VERSION = @VERSION@
HOSTOS  = @HOSTOS@
HOSTCPU = @HOSTCPU@

LIBDIR = @LIBDIR@
CFGDIR = @CFGDIR@
LOCDIR = @LOCDIR@
DOCDIR = @DOCDIR@

################################################################################

CXX =           @CXX@
HOSTCXX =       @HOSTCXX@
LD =            @CXX_LINK@
HOSTLD =        @HOSTCXX_LINK@
EXEEXT =        @EXEEXT@

DEBUG =         @DEBUG@
GCCDEP =        @GCCDEP@
DEFS =          @DEFS@ \
                -DLIBDIR='"$(LIBDIR)"' \
                -DCFGDIR='"$(CFGDIR)"' \
                -DLOCDIR='"$(LOCDIR)"' \
                -DKDEDIR='"$(KDEDIR)"' \
                -DPACKAGE='"icewm"' \
                -DVERSION='"$(VERSION)"' \
                -DHOSTOS='"$(HOSTOS)"' \
                -DHOSTCPU='"$(HOSTCPU)"' \
                -DEXEEXT='"$(EXEEXT)"' \
                -DICEWMEXE='"icewm$(EXEEXT)"' \
                -DICEWMTRAYEXE='"icewmtray$(EXEEXT)"' \
                -DICEWMBGEXE='"icewmbg$(EXEEXT)"' \
                -DICESMEXE='"icewm-session$(EXEEXT)"' \
                -DICEHELPEXE='"icehelp$(EXEEXT)"' \
                -DICEHELPIDX='"$(DOCDIR)/icewm-$(VERSION)/icewm.html"'

CXXFLAGS =      @CXXFLAGS@ $(DEBUG) $(DEFS) `pkg-config gdk-pixbuf-xlib-2.0 --cflags` \
	        @CORE_CFLAGS@ @IMAGE_CFLAGS@ @AUDIO_CFLAGS@ `pkg-config fontconfig --cflags`
LFLAGS =	@LDFLAGS@ 
LIBS =          @LIBS@ `pkg-config gdk-pixbuf-xlib-2.0 --libs` 

CORE_LIBS =     @CORE_LIBS@ `pkg-config fontconfig --libs`
IMAGE_LIBS =    @IMAGE_LIBS@
AUDIO_LIBS =    @AUDIO_LIBS@
GNOME2_LIBS =    @GNOME2_LIBS@

################################################################################

libice_OBJS = ref.o \
        mstring.o \
	upath.o \
        yapp.o yxapp.o ytimer.o ywindow.o ypaint.o ypopup.o \
        yworker.o \
        misc.o ycursor.o ysocket.o \
        ypaths.o ypixbuf.o ylocale.o yarray.o ypipereader.o \
        yxembed.o yconfig.o yprefs.o \
        yfont.o yfontcore.o yfontxft.o \
        ypixmap.o \
	yimage.o \
        yimage_gdk.o yimage_imlib.o yimage_xpm.o \
        ytooltip.o # FIXME
        
libitk_OBJS = \
	ymenu.o ylabel.o yscrollview.o \
        ymenuitem.o yscrollbar.o ybutton.o ylistbox.o yinput.o \
        yicon.o \
        wmconfig.o # FIXME

genpref_OBJS = \
	genpref.o

icewm_LIBS = \
	$(CORE_LIBS) $(IMAGE_LIBS)
icewm_OBJS = \
        ymsgbox.o ydialog.o yurl.o \
        wmsession.o wmwinlist.o wmtaskbar.o wmwinmenu.o \
        wmdialog.o wmabout.o wmswitch.o wmstatus.o \
        wmoption.o wmaction.o \
        wmcontainer.o wmclient.o \
        wmmgr.o wmapp.o \
        wmframe.o wmbutton.o wmminiicon.o wmtitle.o movesize.o \
        themes.o decorate.o browse.o \
        wmprog.o \
        atasks.o aworkspaces.o amailbox.o aclock.o acpustatus.o \
	apppstatus.o aaddressbar.o objbar.o aapm.o atray.o ysmapp.o \
        yxtray.o \
        $(libitk_OBJS) $(libice_OBJS)

icesh_LIBS = \
	$(CORE_LIBS)
icesh_OBJS = \
	icesh.o misc.o

icewm-session_LIBS = \
	$(CORE_LIBS) $(IMAGE_LIBS)
icewm-session_OBJS = \
	icesm.o $(libice_OBJS)

icewmhint_LIBS = \
	$(CORE_LIBS)
icewmhint_OBJS = \
	icewmhint.o

icewmbg_LIBS = \
	$(CORE_LIBS) $(IMAGE_LIBS)
icewmbg_OBJS = \
	icewmbg.o $(libice_OBJS)

icesound_LIBS = \
	$(CORE_LIBS) $(AUDIO_LIBS)
icesound_OBJS = \
	icesound.o misc.o ycmdline.o

icewm-menu-gnome2_LIBS = \
	$(CORE_LIBS) $(GNOME2_LIBS)
icewm-menu-gnome2_OBJS = \
	gnome2.o misc.o ycmdline.o yarray.o

icehelp_LIBS = \
	$(CORE_LIBS) $(IMAGE_LIBS)
icehelp_OBJS = \
	$(libitk_OBJS) $(libice_OBJS) icehelp.o

iceclock_OBJS = \
	$(libitk_OBJS) $(libice_OBJS) iceclock.o aclock.o
iceclock_LIBS = \
	$(CORE_LIBS) $(IMAGE_LIBS)
icebar_LIBS = \
	$(CORE_LIBS) $(IMAGE_LIBS)
icebar_OBJS = \
	$(libitk_OBJS) $(libice_OBJS) \
        icebar.o wmtaskbar.o \
        wmprog.o browse.o themes.o wmaction.o \
	amailbox.o aclock.o acpustatus.o apppstatus.o aaddressbar.o objbar.o
icewmtray_OBJS = \
	$(libitk_OBJS) $(libice_OBJS) yxtray.o icetray.o
icewmtray_LIBS = \
	$(CORE_LIBS) $(IMAGE_LIBS)
icesame_OBJS = \
	$(libitk_OBJS) $(libice_OBJS) icesame.o
icesame_LIBS = \
	$(CORE_LIBS) $(IMAGE_LIBS)
icelist_OBJS = \
	$(libitk_OBJS) $(libice_OBJS) icelist.o
icelist_LIBS = \
	$(CORE_LIBS) $(IMAGE_LIBS)
iceview_OBJS = \
	$(libitk_OBJS) $(libice_OBJS) iceview.o
iceview_LIBS = \
	$(CORE_LIBS) $(IMAGE_LIBS)
iceicon_OBJS = \
	$(libitk_OBJS) $(libice_OBJS) iceicon.o
iceicon_LIBS = \
	$(CORE_LIBS) $(IMAGE_LIBS)
icerun_OBJS = \
	$(libitk_OBJS) $(libice_OBJS) icerun.o
icerun_LIBS = \
	$(CORE_LIBS) $(IMAGE_LIBS)
iceskt_OBJS = \
	$(libitk_OBJS) $(libice_OBJS) iceskt.o
testmenus_LIBS = \
	$(CORE_LIBS) $(IMAGE_LIBS) 
testmenus_OBJS = \
	$(libitk_OBJS) $(libice_OBJS) testmenus.o wmprog.o wmaction.o themes.o browse.o
testwinhints_OBJS= \
        testwinhints.o
testwinhints_LIBS = \
        $(CORE_LIBS) $(IMAGE_LIBS)

testnetwmhints_OBJS= \
        testnetwmhints.o
testnetwmhints_LIBS = \
        $(CORE_LIBS) $(IMAGE_LIBS)

testmap_OBJS = \
        testmap.o
testmap_LIBS = \
        $(CORE_LIBS) $(IMAGE_LIBS)

testlocale_OBJS = \
	testlocale.o ylocale.o misc.o
testarray_OBJS = \
	testarray.o yarray.o misc.o

################################################################################

APPLICATIONS = @APPLICATIONS@
TESTCASES = @TESTCASES@
OBJECTS = @BASEOBJS@ @TESTOBJS@
BINARIES = @BASEBINS@ @TESTBINS@

################################################################################

all:	base
base:	@BASEBINS@ genpref$(EXEEXT) ../lib/preferences
tests:	@TESTBINS@
clean:
	rm -f $(BINARIES) genpref$(EXEEXT) *.o *.d *~

.PHONY: all base tests clean

################################################################################

%.o: %.cc
	@echo "  CXX     " $@
	@$(CXX) $(CXXFLAGS) $(GCCDEP) -c $<

$(BINARIES):
	@echo "  LD      " $@
	@$(LD) -o $@ $($(@:$(EXEEXT)=)_OBJS) $(LFLAGS) $($(@:$(EXEEXT)=)_LFLAGS) $(LIBS) $($(@:$(EXEEXT)=)_LIBS)

genpref.o: genpref.cc
	@echo "  HOSTCXX " $@
	@$(HOSTCXX) $(CXXFLAGS) $(GCCDEP) -c $<
	
genpref$(EXEEXT):
	@echo "  HOSTLD  " $@
	@$(HOSTLD) -o $@ $(genpref_OBJS)

################################################################################

gnome2.o: gnome2.cc
	@echo "  CXX     " $@
	@$(CXX) $(CXXFLAGS)  @GNOME2_CFLAGS@ $(GCCDEP) -c $<

################################################################################

#libice.so: $(libice_OBJS)
#	-@rm -f $@
#	ld -shared -o $@ $(libice_OBJS)

wmabout.o: ../VERSION

../lib/preferences: genpref$(EXEEXT)
	@echo "  GENPREF " $@
	@./genpref$(EXEEXT) >../lib/preferences

genpref$(EXEEXT): $(genpref_OBJS)

################################################################################

check:	all tests
	./icewm$(EXEEXT) --help >/dev/null
	./testarray$(EXEEXT)
	./testlocale$(EXEEXT)

################################################################################
#END

