Add --gc-sections to LDFLAGS.
authorAndre Noll <maan@systemlinux.org>
Thu, 11 Oct 2007 12:35:28 +0000 (14:35 +0200)
committerAndre Noll <maan@systemlinux.org>
Thu, 11 Oct 2007 12:35:28 +0000 (14:35 +0200)
This, together with -fdata-sections and -ffunction-sections brought
nice size reductions. Before:

-rwxr-xr-x 1 maan fml  29K Oct 11 14:32 para_audioc*
-rwxr-xr-x 1 maan fml  42K Oct 11 14:32 para_client*
-rwxr-xr-x 1 maan fml  33K Oct 11 14:32 para_fade*
-rwxr-xr-x 1 maan fml  38K Oct 11 14:32 para_filter*
-rwxr-xr-x 1 maan fml  54K Oct 11 14:32 para_fsck*
-rwxr-xr-x 1 maan fml  52K Oct 11 14:32 para_gui*
-rwxr-xr-x 1 maan fml  42K Oct 11 14:32 para_recv*
-rwxr-xr-x 1 maan fml 216K Oct 11 14:32 para_server*
-rwxr-xr-x 1 maan fml  38K Oct 11 14:32 para_write*

After:

-rwxr-xr-x 1 maan fml  21K Oct 11 14:31 para_audioc*
-rwxr-xr-x 1 maan fml  33K Oct 11 14:31 para_client*
-rwxr-xr-x 1 maan fml  29K Oct 11 14:31 para_fade*
-rwxr-xr-x 1 maan fml  29K Oct 11 14:31 para_filter*
-rwxr-xr-x 1 maan fml  45K Oct 11 14:31 para_fsck*
-rwxr-xr-x 1 maan fml  47K Oct 11 14:31 para_gui*
-rwxr-xr-x 1 maan fml  30K Oct 11 14:31 para_recv*
-rwxr-xr-x 1 maan fml 208K Oct 11 14:31 para_server*
-rwxr-xr-x 1 maan fml  29K Oct 11 14:31 para_write*

Makefile.in

index c572100b0663f21cc4a5cef3309a4b64a62d3f63..f6df58e7c1677abd02092f76b52052ed70e795a1 100644 (file)
@@ -28,6 +28,8 @@ DEBUG_CPPFLAGS += -Wredundant-decls
 # many warnings about trivial stuff
 # CPPFLAGS += -Wconversion
 
+LDFLAGS += -Wl,--gc-sections
+
 CPPFLAGS += -Os
 CPPFLAGS += -Wall
 CPPFLAGS += -Wuninitialized
@@ -46,6 +48,7 @@ CPPFLAGS += -Wmissing-format-attribute
 CPPFLAGS += -Wunused-macros
 CPPFLAGS += -Wshadow
 CPPFLAGS += -Wbad-function-cast
+CPPFLAGS += -fdata-sections -ffunction-sections
 CPPFLAGS += -DMAIN_INPUT_FILE_IS_$(*F)
 CPPFLAGS += @SSL_CPPFLAGS@
 CPPFLAGS += @ncurses_cppflags@
@@ -221,43 +224,43 @@ mysql_selector.o: mysql_selector.c
        $(CC) -c $(CPPFLAGS) $(DEBUG_CPPFLAGS) $<
 
 para_recv: @recv_objs@
-       $(CC) @recv_objs@ -o $@ @recv_ldflags@
+       $(CC) $(LDFLAGS) @recv_objs@ -o $@ @recv_ldflags@
 
 para_filter: @filter_objs@
-       $(CC) @filter_objs@ -o $@ @filter_ldflags@
+       $(CC) $(LDFLAGS) @filter_objs@ -o $@ @filter_ldflags@
 
 para_slider: $(slider_objs)
-       $(CC) $(slider_objs) -o $@ @GTK_LIBS@ @GLIB_LIBS@ -lzmw
+       $(CC) $(LDFLAGS) $(slider_objs) -o $@ @GTK_LIBS@ @GLIB_LIBS@ -lzmw
 
 para_client: @client_objs@
-       $(CC) -o $@ @client_objs@ @client_ldflags@
+       $(CC) $(LDFLAGS) -o $@ @client_objs@ @client_ldflags@
 
 para_gui: @gui_objs@
-       $(CC) -o $@ @gui_objs@ -lncurses
+       $(CC) $(LDFLAGS) -o $@ @gui_objs@ -lncurses
 
 para_audiod: @audiod_objs@
-       $(CC) -o $@ @audiod_objs@ @audiod_ldflags@
+       $(CC) $(LDFLAGS) -o $@ @audiod_objs@ @audiod_ldflags@
 
 para_audioc: @audioc_objs@
-       $(CC) -o $@ @audioc_objs@ @audioc_ldflags@
+       $(CC) $(LDFLAGS) -o $@ @audioc_objs@ @audioc_ldflags@
 
 para_dbadm: $(dbadm_objs)
-       $(CC) -o $@ $(dbadm_objs) -lncurses -lmenu
+       $(CC) $(LDFLAGS) -o $@ $(dbadm_objs) -lncurses -lmenu
 
 para_fade: $(fade_objs)
-       $(CC) -o $@ $(fade_objs)
+       $(CC) $(LDFLAGS) -o $@ $(fade_objs)
 
 para_server: @server_objs@
-       $(CC) -o $@ @server_objs@  @server_ldflags@
+       $(CC) $(LDFLAGS) -o $@ @server_objs@  @server_ldflags@
 
 para_fsck: @fsck_objs@
-       $(CC) -o $@ @fsck_objs@ @fsck_ldflags@
+       $(CC) $(LDFLAGS) -o $@ @fsck_objs@ @fsck_ldflags@
 
 para_sdl_gui: $(sdl_gui_objs)
-       $(CC) -o $@ $(sdl_gui_objs) -lSDL_image
+       $(CC) $(LDFLAGS) -o $@ $(sdl_gui_objs) -lSDL_image
 
 para_write: @write_objs@
-       $(CC) -o $@ @write_objs@ @write_ldflags@
+       $(CC) $(LDFLAGS) -o $@ @write_objs@ @write_ldflags@
 
 para_krell.so: $(krell_objs)
        $(CC) -Wall -fPIC @GTK_CFLAGS@ krell.o -o $@ @GTK_LIBS@ -shared