From cc045ec56e120ee0314730cdc9e34814f9deeb4b Mon Sep 17 00:00:00 2001 From: Louis-Guillaume Gagnon Date: Fri, 13 Dec 2013 21:38:17 -0500 Subject: [PATCH] Makefile && main.c: add 'debug' compilation mode Makefile: 'debug' target: same as default + #define DEBUG main.c: #define 'DEBUG_CMD(cmd) macro when DEBUG #defined --- Makefile | 3 +++ main.c | 10 ++++++++++ 2 files changed, 13 insertions(+) diff --git a/Makefile b/Makefile index 6087bca..4145764 100644 --- a/Makefile +++ b/Makefile @@ -11,6 +11,9 @@ $(TARGET): $(OBJS) %.o: %.c $(CC) $(CFLAGS) -c $< -o $@ +debug: CFLAGS += -DDEBUG +debug: $(TARGET) + clean: rm -f *.o rm -f $(TARGET) diff --git a/main.c b/main.c index 7e44d68..4ea307c 100644 --- a/main.c +++ b/main.c @@ -6,6 +6,12 @@ #include #include +#ifdef DEBUG + #define DEBUG_CMD(cmd) {puts("+ DEBUG"); cmd; puts("- DEBUG");} +#else + #define DEBUG_CMD(cmd) {} +#endif + const char *progname = "sh"; static char *callname; @@ -690,10 +696,14 @@ int main(int argc, char *argv[]) argv += 1; flags = parse_argv(&argc, argv); + DEBUG_CMD(print_flaglist(flags)); + /* now that we have a flag list, we can try to get our initial config */ init_config(flags, argc > 0); + DEBUG_CMD(dump_config()); + return 0; } -- 2.11.4.GIT