#!/usr/bin/make
#
# This makefile generated by LgiIde
# http://www.memecode.com/lgi.php
#

.SILENT :

CC = gcc
CPP = g++
Target = lgi-gtk3
ifndef Build
	Build = Debug
endif
BuildDir = $(Build)

Flags = -fPIC -w -fno-inline -fpermissive

ifeq ($(Build),Debug)
	Flags += -g -std=c++14
	Tag = d
	Defs = -D_DEBUG -DLINUX -D_REENTRANT -D_FILE_OFFSET_BITS=64 -DPOSIX
	Libs =  \
		-lmagic \
		-lappindicator3 \
		-static-libgcc  \
		`pkg-config --libs gtk+-3.0`
	Inc =  \
		`pkg-config --cflags gtk+-3.0` \
		-I/usr/include/libappindicator3-0.1 \
		-I/usr/include/gstreamer-1.0 \
		-I./private/linux \
		-I./private/common \
		-I./include/lgi/linux/Gtk \
		-I./include/lgi/linux \
		-I./include
else
	Flags += -s -Os -std=c++14
	Defs = -DLINUX -D_REENTRANT -D_FILE_OFFSET_BITS=64 -DPOSIX
	Libs =  \
		-lmagic \
		-lappindicator3 \
		-static-libgcc  \
		`pkg-config --libs gtk+-3.0`
	Inc =  \
		`pkg-config --cflags gtk+-3.0` \
		-I/usr/include/libappindicator3-0.1 \
		-I/usr/include/gstreamer-1.0 \
		-I./private/linux \
		-I./private/common \
		-I./include/lgi/linux/Gtk \
		-I./include/lgi/linux \
		-I./include
endif

# Dependencies
Source =	src/linux/Lgi/Window.cpp \
			src/linux/Lgi/Widgets.cpp \
			src/linux/Lgi/View.cpp \
			src/linux/Lgi/Thread.cpp \
			src/linux/Lgi/Printer.cpp \
			src/linux/Lgi/Menu.cpp \
			src/linux/Lgi/Layout.cpp \
			src/linux/Lgi/General.cpp \
			src/linux/Lgi/DragAndDrop.cpp \
			src/linux/Lgi/ClipBoard.cpp \
			src/linux/Lgi/App.cpp \
			src/linux/Gtk/ScreenDC.cpp \
			src/linux/Gtk/PrintDC.cpp \
			src/linux/Gtk/MemDC.cpp \
			src/linux/Gtk/LgiWidget.cpp \
			src/linux/Gtk/Gdc2.cpp \
			src/linux/General/ShowFileProp_Linux.cpp \
			src/linux/General/Mem.cpp \
			src/linux/General/File.cpp \
			src/common/Widgets/Tree.cpp \
			src/common/Widgets/ToolBar.cpp \
			src/common/Widgets/TextLabel.cpp \
			src/common/Widgets/TabView.cpp \
			src/common/Widgets/TableLayout.cpp \
			src/common/Widgets/StatusBar.cpp \
			src/common/Widgets/Splitter.cpp \
			src/common/Widgets/Slider.cpp \
			src/common/Widgets/ScrollBar.cpp \
			src/common/Widgets/RadioGroup.cpp \
			src/common/Widgets/ProgressDlg.cpp \
			src/common/Widgets/Progress.cpp \
			src/common/Widgets/Popup.cpp \
			src/common/Widgets/Panel.cpp \
			src/common/Widgets/List.cpp \
			src/common/Widgets/ItemContainer.cpp \
			src/common/Widgets/Edit.cpp \
			src/common/Widgets/Combo.cpp \
			src/common/Widgets/CheckBox.cpp \
			src/common/Widgets/Button.cpp \
			src/common/Widgets/Box.cpp \
			src/common/Widgets/Bitmap.cpp \
			src/common/Text/XmlTree.cpp \
			src/common/Text/Utf8.cpp \
			src/common/Text/Unicode.cpp \
			src/common/Text/Token.cpp \
			src/common/Text/TextView3.cpp \
			src/common/Text/String.cpp \
			src/common/Text/DocView.cpp \
			src/common/Skins/Gel/Gel.cpp \
			src/common/Resource/Res.cpp \
			src/common/Resource/LgiRes.cpp \
			src/common/Net/Uri.cpp \
			src/common/Net/NetTools.cpp \
			src/common/Net/Net.cpp \
			src/common/Net/MDStringToDigest.cpp \
			src/common/Net/Base64.cpp \
			src/common/Lgi/WindowCommon.cpp \
			src/common/Lgi/ViewCommon.cpp \
			src/common/Lgi/Variant.cpp \
			src/common/Lgi/TrayIcon.cpp \
			src/common/Lgi/ToolTip.cpp \
			src/common/Lgi/ThreadEvent.cpp \
			src/common/Lgi/ThreadCommon.cpp \
			src/common/Lgi/SubProcess.cpp \
			src/common/Lgi/Stream.cpp \
			src/common/Lgi/Rand.cpp \
			src/common/Lgi/OptionsFile.cpp \
			src/common/Lgi/Object.cpp \
			src/common/Lgi/Mutex.cpp \
			src/common/Lgi/Mru.cpp \
			src/common/Lgi/MenuCommon.cpp \
			src/common/Lgi/MemStream.cpp \
			src/common/Lgi/LMsg.cpp \
			src/common/Lgi/Library.cpp \
			src/common/Lgi/LgiCommon.cpp \
			src/common/Lgi/Input.cpp \
			src/common/Lgi/GuiUtils.cpp \
			src/common/Lgi/FontSelect.cpp \
			src/common/Lgi/FindReplace.cpp \
			src/common/Lgi/FileSelect.cpp \
			src/common/Lgi/DragAndDropCommon.cpp \
			src/common/Lgi/DataDlg.cpp \
			src/common/Lgi/CssTools.cpp \
			src/common/Lgi/Css.cpp \
			src/common/Lgi/AppCommon.cpp \
			src/common/Lgi/Alert.cpp \
			src/common/Hash/sha1/sha1.c \
			src/common/Hash/md5/md5.c \
			src/common/General/Properties.cpp \
			src/common/General/Password.cpp \
			src/common/General/FileCommon.cpp \
			src/common/General/ExeCheck.cpp \
			src/common/General/DateTime.cpp \
			src/common/General/Containers.cpp \
			src/common/Gdc2/Tools/GdcTools.cpp \
			src/common/Gdc2/Tools/ColourReduce.cpp \
			src/common/Gdc2/Surface.cpp \
			src/common/Gdc2/Rect.cpp \
			src/common/Gdc2/Path/Path.cpp \
			src/common/Gdc2/GdcCommon.cpp \
			src/common/Gdc2/Font/TypeFace.cpp \
			src/common/Gdc2/Font/StringLayout.cpp \
			src/common/Gdc2/Font/FontType.cpp \
			src/common/Gdc2/Font/FontSystem.cpp \
			src/common/Gdc2/Font/Font.cpp \
			src/common/Gdc2/Font/DisplayString.cpp \
			src/common/Gdc2/Font/Charset.cpp \
			src/common/Gdc2/Filters/Filter.cpp \
			src/common/Gdc2/Colour.cpp \
			src/common/Gdc2/Alpha.cpp \
			src/common/Gdc2/8Bit.cpp \
			src/common/Gdc2/32Bit.cpp \
			src/common/Gdc2/24Bit.cpp \
			src/common/Gdc2/16Bit.cpp \
			src/common/Gdc2/15Bit.cpp

SourceLst := $(patsubst %.c,%.o,$(patsubst %.cpp,%.o,$(Source)))

Objects := $(addprefix $(BuildDir)/,$(SourceLst))

# Target
TargetFile = lib$(Target)$(Tag).so
$(TargetFile) : $(Objects)
	mkdir -p $(BuildDir)
	@echo Linking $(TargetFile) [$(Build)]...
	$(CPP)$s -shared \
		 \
		-o $(BuildDir)/$(TargetFile) \
		$(Objects) \
		$(Libs)
	@echo Done.

.SECONDEXPANSION:
$(Objects): $(BuildDir)/%.o: $$(wildcard %.c*)
	mkdir -p $(@D)
	@echo $(<F) [$(Build)]
ifeq "$(suffix $<)" ".cpp"
	$(CPP) -MMD -MP $(Inc) $(Flags) $(Defs) -c $< -o $@
else
	$(CC) -MMD -MP $(Inc) $(Flags) $(Defs) -c $< -o $@
endif

-include $(Objects:.o=.d)

# Clean out targets
clean :
	rm -rf $(BuildDir)/* $(BuildDir)/$(TargetFile)
	@echo Cleaned $(BuildDir)

VPATH=%.cpp \
	./src/common/Hash/sha1 \
	./src/common/Hash/md5 \
	./private/linux \
	./private/common \
	./include/lgi/mac/cocoa \
	./include/lgi/linux/Gtk \
	./include/lgi/linux \
	./include/lgi/common \
	./include \
	$(BuildDir)

