Put similar target in Makefile together.
authorDaniel Carl <danielcarl@gmx.de>
Mon, 29 Jul 2013 16:40:02 +0000 (18:40 +0200)
committerDaniel Carl <danielcarl@gmx.de>
Mon, 29 Jul 2013 16:40:02 +0000 (18:40 +0200)
Added LDFLAG -s to strip symbol table to build smaller binary.

Makefile
config.mk

index 484a85e..0a9ca1a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -3,6 +3,7 @@ include config.mk
 -include $(DEPS)
 
 all: $(TARGET)
+debug: $(DTARGET)
 
 options:
        @echo "$(PROJECT) build options:"
@@ -12,16 +13,23 @@ options:
        @echo "CC      = $(CC)"
 
 src/hints.o: src/hints.js.h
+src/hints.do: src/hints.js.h
+
 src/hints.js.h: src/hints.js
        @echo "minify $<"
        @cat $< | src/js2h.sh > $@
 
 $(OBJ): src/config.h config.mk
+$(DOBJ): src/config.h config.mk
 
 $(TARGET): $(OBJ)
        @echo "$(CC) $@"
        @$(CC) $(OBJ) -o $(TARGET) $(LDFLAGS)
 
+$(DTARGET): $(DOBJ)
+       @echo "$(CC) $@"
+       @$(CC) $(DFLAGS) $(DOBJ) -o $(DTARGET) $(DLDFLAGS)
+
 src/config.h:
        @echo create $@ from src/config.def.h
        @cp src/config.def.h $@
@@ -30,12 +38,6 @@ src/config.h:
        @echo "${CC} $<"
        @$(CC) -c -o $@ $< $(CFLAGS)
 
-debug: $(DTARGET)
-
-$(DTARGET): $(DOBJ)
-       @echo "$(CC) $@"
-       @$(CC) $(DFLAGS) $(DOBJ) -o $(DTARGET) $(LDFLAGS)
-
 %.do: %.c %.h
        @echo "${CC} $<"
        @$(CC) -c -o $@ $< $(DFLAGS)
index 0f85b60..e11bf30 100644 (file)
--- a/config.mk
+++ b/config.mk
@@ -30,14 +30,19 @@ ifeq ($(USEGTK3), 1)
 CPPFLAGS += -DHAS_GTK3
 endif
 
-CFLAGS += $(shell pkg-config --cflags $(LIBS))
-CFLAGS += -Wall -pipe -ansi -std=c99 -pedantic
-CFLAGS += -Wmissing-declarations -Wmissing-parameter-type -Wno-overlength-strings
-CFLAGS += ${CPPFLAGS}
-
-LDFLAGS += $(shell pkg-config --libs $(LIBS)) -lX11 -lXext -lm
-
-DFLAGS += $(CFLAGS) -DDEBUG -ggdb -g
+# prepare the lib flags used for the linker
+LIBFLAGS = $(shell pkg-config --libs $(LIBS)) -lX11 -lXext -lm
+
+# normal compiler flags
+CFLAGS  += $(shell pkg-config --cflags $(LIBS))
+CFLAGS  += -Wall -pipe -ansi -std=c99 -pedantic
+CFLAGS  += -Wmissing-declarations -Wmissing-parameter-type -Wno-overlength-strings
+CFLAGS  += ${CPPFLAGS}
+LDFLAGS += -s ${LIBFLAGS}
+
+# compiler flags for the debug target
+DFLAGS   += $(CFLAGS) -DDEBUG -ggdb -g
+DLDFLAGS += ${LIBFLAGS}
 
 OBJ       = $(patsubst %.c, %.o, $(wildcard src/*.c))
 DOBJ      = $(patsubst %.c, %.do, $(wildcard src/*.c))