diff -ruN uppsrc/ide/ide.lay uppsrc/ide/ide.lay
--- uppsrc/ide/ide.lay	2014-11-23 10:43:14 +0400
+++ uppsrc/ide/ide.lay	2014-12-17 05:47:48 +0400
@@ -246,24 +246,49 @@
 END_LAYOUT
 
 LAYOUT(OutputModeLayout, 616, 480)
-	ITEM(Label, dv___0, SetLabel(t_("&Build method:")).LeftPosZ(10, 70).TopPosZ(4, 19))
-	ITEM(DropList, method, LeftPosZ(82, 184).TopPosZ(4, 19))
-	ITEM(Switch, mode, SetLabel(t_("Debug         \nOptimal\nOptimize speed\nOptimize size")).LeftPosZ(244, 356).TopPosZ(32, 18))
-	ITEM(LabelBox, dv___3, LeftPosZ(304, 4).TopPosZ(28, 360))
-	UNTYPED(debug, LeftPosZ(8, 288).TopPosZ(56, 332))
-	ITEM(LabelBox, dv___5, SetLabel(t_("Release")).LeftPosZ(320, 288).TopPosZ(16, 36))
-	UNTYPED(release, LeftPosZ(320, 288).TopPosZ(56, 332))
-	ITEM(LabelBox, dv___7, SetLabel(t_("Export project")).LeftPosZ(8, 600).TopPosZ(392, 48))
-	ITEM(Label, dv___8, SetLabel(t_("To directory")).LeftPosZ(12, 68).TopPosZ(408, 21))
+	ITEM(Label, dv___0, SetLabel(t_("Main configuration:")).LeftPosZ(4, 96).TopPosZ(4, 20))
+	ITEM(DropList, config, LeftPosZ(100, 184).TopPosZ(4, 19))
+	ITEM(Label, dv___2, SetLabel(t_("&Build method:")).LeftPosZ(288, 70).TopPosZ(4, 19))
+	ITEM(DropList, method, LeftPosZ(360, 184).TopPosZ(4, 19))
+	ITEM(Switch, mode, SetLabel(t_("Debug         \nOptimal\nOptimize speed\nOptimize size")).LeftPosZ(244, 356).TopPosZ(40, 18))
+	ITEM(LabelBox, dv___5, LeftPosZ(304, 4).TopPosZ(28, 360))
+	UNTYPED(debug, LeftPosZ(8, 288).TopPosZ(64, 324))
+	ITEM(LabelBox, dv___7, SetLabel(t_("Release")).LeftPosZ(320, 288).TopPosZ(24, 36))
+	UNTYPED(release, LeftPosZ(320, 288).TopPosZ(64, 324))
+	ITEM(LabelBox, dv___9, SetLabel(t_("Export project")).LeftPosZ(8, 600).TopPosZ(392, 48))
+	ITEM(Label, dv___10, SetLabel(t_("To directory")).LeftPosZ(12, 68).TopPosZ(408, 21))
 	ITEM(EditString, export_dir, LeftPosZ(80, 316).TopPosZ(409, 19))
 	ITEM(Button, export_used, SetLabel(t_("Used")).LeftPosZ(400, 64).TopPosZ(407, 24))
 	ITEM(Button, export_all, SetLabel(t_("All")).LeftPosZ(468, 64).TopPosZ(407, 24))
 	ITEM(Button, export_makefile, SetLabel(t_("Makefile")).LeftPosZ(536, 64).TopPosZ(407, 24))
-	ITEM(Button, reset_blitz, SetLabel(t_("Reset BLITZ ")).LeftPosZ(8, 88).TopPosZ(448, 24))
+	ITEM(Button, reset_blitz, SetLabel(t_("Reset BLITZ")).LeftPosZ(8, 88).TopPosZ(448, 24))
+	ITEM(Button, cmd_options, SetLabel(t_("Command line &options..")).LeftPosZ(100, 124).TopPosZ(448, 24))
 	ITEM(Button, ok, SetLabel(t_("OK")).HCenterPosZ(64, 200).TopPosZ(448, 24))
 	ITEM(Button, cancel, SetLabel(t_("Cancel")).HCenterPosZ(64, 268).TopPosZ(448, 24))
 END_LAYOUT
 
+LAYOUT(CmdBuildOptionsLayout, 300, 368)
+	ITEM(DocEdit, cmd, HSizePosZ(4, 4).BottomPosZ(28, 44))
+	ITEM(Option, rebuild, SetLabel(t_("Rebuild all")).Tip(t_("a")).LeftPosZ(4, 72).TopPosZ(4, 16))
+	ITEM(Option, blitz, SetLabel(t_("Use BLITZ")).Tip(t_("b")).HSizePosZ(4, 220).TopPosZ(24, 16))
+	ITEM(Option, msgonfail, SetLabel(t_("If building fails, stop with message box")).Tip(t_("e (not umk compatible)")).LeftPosZ(4, 204).TopPosZ(44, 16))
+	ITEM(Option, silent, SetLabel(t_("Silent mode")).Tip(t_("l")).LeftPosZ(4, 76).TopPosZ(64, 16))
+	ITEM(Option, map, SetLabel(t_("Create a map file")).Tip(t_("m")).LeftPosZ(4, 104).TopPosZ(84, 16))
+	ITEM(Option, shared, SetLabel(t_("Use shared libraries")).Tip(t_("s")).LeftPosZ(4, 112).TopPosZ(104, 16))
+	ITEM(Option, sharedbuild, SetLabel(t_("Use shared libraries and build as shared libraries")).Tip(t_("S")).LeftPosZ(4, 248).TopPosZ(124, 16))
+	ITEM(Option, verbose, SetLabel(t_("Be verbose")).Tip(t_("v")).LeftPosZ(4, 76).TopPosZ(144, 16))
+	ITEM(Option, makefile, SetLabel(t_("Create makefile (to file out)")).Tip(t_("M")).LeftPosZ(4, 152).TopPosZ(164, 16))
+	ITEM(Option, savetargetdir, SetLabel(t_("Do not delete target directory out when exporting")).Tip(t_("k")).LeftPosZ(4, 256).TopPosZ(184, 16))
+	ITEM(LabelBox, dv___11, SetLabel(t_("Export project (to directory out): ")).HSizePosZ(4, 4).TopPosZ(204, 40))
+	ITEM(Switch, exportproject, SetLabel(t_("do not\nexport only files used\nexport all files")).HSizePosZ(8, 8).TopPosZ(216, 24))
+	ITEM(EditIntSpin, threads, Min(0).Tip(t_("Hn (umk compatible)")).HSizePosZ(252, 4).TopPosZ(248, 19))
+	ITEM(Label, dv___14, SetLabel(t_("Number of threads used for building (0 - default):")).HSizePosZ(4, 52).TopPosZ(248, 16))
+	ITEM(EditString, out, HSizePosZ(60, 4).TopPosZ(272, 19))
+	ITEM(Option, outoption, SetLabel(t_("Output:")).LeftPosZ(4, 52).TopPosZ(272, 20))
+	ITEM(Button, btnCopy, SetLabel(t_("Copy to clipboard")).RightPosZ(4, 100).BottomPosZ(4, 20))
+	ITEM(Option, umk, SetLabel(t_("Umk compatible")).LeftPosZ(4, 100).TopPosZ(344, 16))
+END_LAYOUT
+
 LAYOUT(InstallLayout, 400, 88)
 	ITEM(Label, dv___0, SetLabel(t_("MyApps directory")).LeftPosZ(8, 120).TopPosZ(8, 19))
 	ITEM(WithDropChoice<EditString>, myapps, LeftPosZ(8, 316).TopPosZ(28, 19))
diff -ruN uppsrc/ide/OutputMode.cpp uppsrc/ide/OutputMode.cpp
--- uppsrc/ide/OutputMode.cpp	2014-12-01 16:03:20 +0400
+++ uppsrc/ide/OutputMode.cpp	2014-12-17 07:14:17 +0400
@@ -130,9 +130,12 @@
 	void Save();
 	void Preset();
 	void SyncLock();
-	
+
 	void Export(int kind);
 
+	void ConfigChange();
+	void CmdOptions();
+
 	typedef OutMode CLASSNAME;
 
 	OutMode(Ide& ide);
@@ -140,6 +143,11 @@
 
 void OutMode::Load()
 {
+	config.Clear();
+	const DropList& list = ide.mainconfiglist;
+	for (int i = 0; i < list.GetCount(); ++i)
+		config.Add(list.GetKey(i), list[i]);
+	config <<= ide.mainconfigparam;
 	method.Clear();
 	FindFile ff(ConfigFile("*.bm"));
 	while(ff) {
@@ -184,6 +192,145 @@
 	Break(IDOK);
 }
 
+void OutMode::ConfigChange()
+{
+	if (config.GetIndex() < 0)
+		return;
+	ide.mainconfigparam = ~config;
+}
+
+class CmdBuildOptionsWindow : public WithCmdBuildOptionsLayout<TopWindow> {
+private:
+	String cmdAssembly, cmdBuildMode, cmdPackage, cmdMethod, cmdMainConfig;
+
+	struct PathConvert : ConvertString {
+		virtual int Filter(int chr) const
+		{
+			if (chr == '<' || chr == '>' || chr == '|' || chr == '*' || chr == '?' || chr == '\"') return Null;
+			return ConvertString::Filter(chr);
+		}
+	};
+
+public:
+	typedef CmdBuildOptionsWindow CLASSNAME;
+
+	CmdBuildOptionsWindow(const String& package, const String& method, const String& mainconfigparam, const String& output,
+		int targetmode, int hydra1_threads, int linkmode, bool blitzbuild, bool createmap, bool verbosebuild) :
+		cmdPackage(package), cmdMethod(method)
+	{
+		CtrlLayout(*this, t_("Command line options for building"));
+		MinimizeBox().CloseBoxRejects();
+		threads <<= hydra1_threads;
+		threads.NotNull(false);
+		cmdAssembly = GetVarsName();
+		cmdBuildMode = (targetmode == 1 ? "r" : targetmode == 2 ? "1" : targetmode == 3 ? "2" : "d");
+		if (mainconfigparam.GetCount()) {
+			cmdMainConfig = mainconfigparam;
+			cmdMainConfig.Replace(" ", ",");
+			cmdMainConfig.Insert(0, " +");
+		}
+		if (blitzbuild) blitz <<= true;
+		switch(linkmode) {
+			case 1: shared <<= true;  break;
+			case 2: sharedbuild <<= true; break;
+		}
+		exportproject <<= 0;
+		map <<= createmap;
+		verbose <<= verbosebuild;
+		out <<= output;
+		out.SetConvert(Single<PathConvert>());
+		outoption <<= true;
+
+		rebuild.WhenAction = blitz.WhenAction = msgonfail.WhenAction = silent.WhenAction =
+			map.WhenAction = verbose.WhenAction = makefile.WhenAction =
+			savetargetdir.WhenAction = exportproject.WhenAction = umk.WhenAction =
+			threads.WhenAction = out.WhenAction = outoption.WhenAction = THISBACK(GenerateCmd);
+		shared.WhenAction = THISBACK(OnShared);
+		sharedbuild.WhenAction << THISBACK(OnSharedBuild);
+		btnCopy.WhenPush = callback(&cmd, &TextCtrl::Copy);
+	}
+
+	void OnShared()      { if (shared && sharedbuild) sharedbuild <<= false; GenerateCmd(); }
+	void OnSharedBuild() { if (sharedbuild && shared) shared <<= false; GenerateCmd(); }
+
+	void GenerateCmd()
+	{
+		String cmdBuild("-");
+		if (rebuild) cmdBuild << 'a';
+		if (blitz) cmdBuild << 'b';
+		if (!umk && msgonfail) cmdBuild << 'e';
+		if (silent) cmdBuild << 'l';
+		if (map) cmdBuild << 'm';
+		cmdBuild << cmdBuildMode;
+		if (shared) cmdBuild << 's';
+		else if (sharedbuild) cmdBuild << 'S';
+		if (verbose) cmdBuild << 'v';
+		if (savetargetdir) cmdBuild << 'k';
+		switch (exportproject) {
+			case 1: cmdBuild << 'x'; break;
+			case 2: cmdBuild << 'X'; break;
+		}
+		if (makefile) cmdBuild << 'M';
+		int numThreads = ~threads;
+		if (umk && !IsNull(numThreads) && numThreads > 0)
+			cmdBuild << 'H' << numThreads;
+		String output;
+		if (outoption) {
+			output = TrimBoth(~out);
+			if (output.Find(" ") >= 0)
+				output = String().Cat() << "\"" << output << "\"";
+		}
+		cmd <<= TrimRight(Format("%s %s %s %s%s %s",
+			cmdAssembly, cmdPackage, cmdMethod, cmdBuild, cmdMainConfig, output));
+	}
+
+	virtual void Serialize(Stream& s)
+	{
+		s % rebuild % msgonfail % silent % verbose % makefile % savetargetdir % exportproject
+			% threads % outoption % umk ;
+	}
+
+	virtual bool Key(dword key, int count)
+	{
+		if (key == K_ESCAPE) {
+			Close();
+			return true;
+		}
+		return false;
+	}
+};
+
+void OutMode::CmdOptions()
+{
+	const Workspace& wspc = ide.IdeWorkspace();
+	int pi = wspc.GetCount() > 0 ? 0 : -1;
+	if (pi < 0) {
+		PromptOK("No main package");
+		return;
+	}
+	VectorMap<String, String> bm = ide.GetMethodVars(~method);
+	if (bm.GetCount() == 0) {
+		PromptOK("Invalid build method");
+		return;
+	}
+	One<Host> host = ide.CreateHost(false);
+	One<Builder> b = ide.CreateBuilder(~host);
+	const String& p = wspc[pi];
+	String output = NativePath(ide.OutDir(ide.PackageConfig(wspc, pi, bm, ~config, *host, *b), p, bm, true));
+	if (output.Right(1) == ".")
+		output = output.Left(output.GetCount() - 1);
+	const ModePane& pane = ~mode == 0 ? debug : release;
+	int blitzpackage = pane.package.Get(0, 2);
+	bool blitzbuild = !wspc.package[pi].noblitz && pane.blitz
+		&& (IsNull(blitzpackage) ? true : blitzpackage);
+	CmdBuildOptionsWindow window(p, ~method, ~config, output,
+		~mode, ide.hydra1_threads, pane.linkmode, blitzbuild, pane.map, ide.console.verbosebuild);
+	LoadFromGlobal(window, "CmdBuildOptionsWindow");
+	window.GenerateCmd();
+	window.Run();
+	StoreToGlobal(window, "CmdBuildOptionsWindow");
+}
+
 bool MapFlag(const VectorMap<String, String>& map, const char *key)
 {
 	return map.Get(key, "0") == "1";
@@ -242,7 +389,9 @@
 :	ide(ide)
 {
 	CtrlLayoutOKCancel(*this, "Output mode");
+	config <<= THISBACK(ConfigChange);
 	method <<= THISBACK(Preset);
+	cmd_options <<= THISBACK(CmdOptions);
 	SyncLock();
 	DirSel(export_dir, dsb);
 	export_all <<= THISBACK1(Export, 1);
@@ -253,12 +402,17 @@
 
 void Ide::SetupOutputMode()
 {
+	String prevmainconfig = mainconfigparam;
 	SetupDefaultMethod();
 	OutMode m(*this);
 	m.Load();
-	if(m.Execute() != IDOK)
+	if(m.Execute() != IDOK) {
+		mainconfigparam = prevmainconfig;
 		return;
+	}
 	m.Save();
+	if(prevmainconfig != mainconfigparam)
+		SetMainConfigList();
 	SyncBuildMode();
 	SetBar();
 }
