Index: libcfa/src/Makefile.am
===================================================================
--- libcfa/src/Makefile.am	(revision b3976bffdbe2eaf5064329ae5c0c09b3c7a4bb36)
+++ libcfa/src/Makefile.am	(revision dee1f892debc88dfe69449a54ea03dbb87f3f3d0)
@@ -26,9 +26,11 @@
 VPATH += :../prelude
 
+gdbwaittarget=""
+
 # AM_CFLAGS for all cfa source
 # AM_CFAFLAGS for only cfa source
 # use -no-include-stdhdr to prevent rebuild cycles
 # The built sources must not depend on the installed headers
-AM_CFAFLAGS = -quiet -in-tree -I$(srcdir)/stdhdr @CONFIG_CFAFLAGS@
+AM_CFAFLAGS = -quiet -in-tree -I$(srcdir)/stdhdr $(if $(findstring ${gdbwaittarget}, ${@}), -XCFA --gdb)  @CONFIG_CFAFLAGS@
 AM_CFLAGS = -g -Wall -Wno-unused-function -fPIC @ARCH_FLAGS@ @CONFIG_CFLAGS@
 AM_CCASFLAGS = -g -Wall -Wno-unused-function @ARCH_FLAGS@ @CONFIG_CFLAGS@
Index: libcfa/src/Makefile.in
===================================================================
--- libcfa/src/Makefile.in	(revision b3976bffdbe2eaf5064329ae5c0c09b3c7a4bb36)
+++ libcfa/src/Makefile.in	(revision dee1f892debc88dfe69449a54ea03dbb87f3f3d0)
@@ -435,4 +435,5 @@
 am__v_UPP_1 = 
 lib_LTLIBRARIES = libcfa.la libcfathread.la
+gdbwaittarget = ""
 
 # AM_CFLAGS for all cfa source
@@ -440,5 +441,5 @@
 # use -no-include-stdhdr to prevent rebuild cycles
 # The built sources must not depend on the installed headers
-AM_CFAFLAGS = -quiet -in-tree -I$(srcdir)/stdhdr @CONFIG_CFAFLAGS@
+AM_CFAFLAGS = -quiet -in-tree -I$(srcdir)/stdhdr $(if $(findstring ${gdbwaittarget}, ${@}), -XCFA --gdb)  @CONFIG_CFAFLAGS@
 AM_CFLAGS = -g -Wall -Wno-unused-function -fPIC @ARCH_FLAGS@ @CONFIG_CFLAGS@
 AM_CCASFLAGS = -g -Wall -Wno-unused-function @ARCH_FLAGS@ @CONFIG_CFLAGS@
Index: src/main.cc
===================================================================
--- src/main.cc	(revision b3976bffdbe2eaf5064329ae5c0c09b3c7a4bb36)
+++ src/main.cc	(revision dee1f892debc88dfe69449a54ea03dbb87f3f3d0)
@@ -17,8 +17,8 @@
 #include <execinfo.h>                       // for backtrace, backtrace_symbols
 #include <getopt.h>                         // for no_argument, optind, geto...
-#include <signal.h>                         // for signal, SIGABRT, SIGSEGV
 #include <cassert>                          // for assertf
 #include <cstdio>                           // for fopen, FILE, fclose, stdin
 #include <cstdlib>                          // for exit, free, abort, EXIT_F...
+#include <csignal>                         // for signal, SIGABRT, SIGSEGV
 #include <cstring>                          // for index
 #include <fstream>                          // for ofstream
@@ -96,4 +96,6 @@
 DeclarationNode * parseTree = nullptr;					// program parse tree
 
+static bool waiting_for_gdb = false; // flag to set cfa-cpp to wait for gdb on start
+
 static std::string PreludeDirector = "";
 
@@ -167,5 +169,4 @@
 } // sigAbortHandler
 
-
 int main( int argc, char * argv[] ) {
 	FILE * input;										// use FILE rather than istream because yyin is FILE
@@ -185,4 +186,11 @@
 	parse_cmdline( argc, argv, filename );				// process command-line arguments
 	CodeGen::FixMain::setReplaceMain( !nomainp );
+
+	if(waiting_for_gdb) {
+		std::cerr << "Waiting for gdb" << std::endl;
+		std::cerr << "run :" << std::endl;
+		std::cerr << "  gdb attach " << getpid() << std::endl;
+		raise(SIGSTOP);
+	}
 
 	try {
@@ -198,4 +206,5 @@
 		} else {										// no input file name
 			input = stdin;
+			std::cerr << "Input from stdin" << std::endl;
 			// if running cfa-cpp directly, might forget to pass -F option. Since this takes from stdin, pass
 			// a fake name along
@@ -438,5 +447,5 @@
 
 
-static const char optstring[] = ":hlLmNnpP:S:twW:D:F:";
+static const char optstring[] = ":hlLmNnpP:S:tgwW:D:F:";
 
 enum { PreludeDir = 128 };
@@ -453,4 +462,5 @@
 	{ "statistics", required_argument, nullptr, 'S' },
 	{ "tree", no_argument, nullptr, 't' },
+	{ "gdb", no_argument, nullptr, 'g' },
 	{ "", no_argument, nullptr, 0 },					// -w
 	{ "", no_argument, nullptr, 0 },					// -W
@@ -471,5 +481,6 @@
 	"<directory> prelude directory for debug/nodebug",	// no flag
 	"<option-list> enable profiling information:\n          counters,heap,time,all,none", // -S
-	"build in tree",									// -t
+	"building cfa standard lib",									// -t
+	"wait for gdb to attach",									// -g
 	"",													// -w
 	"",													// -W
@@ -582,6 +593,9 @@
 			Stats::parse_params( optarg );
 			break;
-		  case 't':										// build in tree
+		  case 't':										// building cfa stdlib
 			treep = true;
+			break;
+		  case 'g':										// wait for gdb
+			waiting_for_gdb = true;
 			break;
 		  case 'w':										// suppress all warnings, hidden
