changeset 35914:209180129a45

build: Split object files from link libraries in generic executable rule. This avoids a host of problems when GNU Make starts mucking with -l flags.
author diego
date Tue, 19 Mar 2013 10:42:26 +0000
parents 635f18a8e27d
children aff0f7d45872
files Makefile
diffstat 1 files changed, 10 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/Makefile	Tue Mar 19 10:42:23 2013 +0000
+++ b/Makefile	Tue Mar 19 10:42:26 2013 +0000
@@ -797,7 +797,7 @@
 	./$< `$(CC) -dumpversion`
 
 %$(EXESUF): %.c
-	$(CC) $(CC_DEPFLAGS) $(CFLAGS) -o $@ $^
+	$(CC) $(CC_DEPFLAGS) $(CFLAGS) -o $@ $^ $(LIBS)
 
 %.ho: %.h
 	$(CC) $(CFLAGS) -Wno-unused -c -o $@ -x c $<
@@ -1009,11 +1009,13 @@
 
 ###### tests / tools #######
 
-TEST_OBJS = mp_msg.o mp_fifo.o osdep/$(GETCH) osdep/$(TIMER) -ltermcap -lm
+MP_MSG_LIBS = -ltermcap -lm
+MP_MSG_OBJS = mp_msg.o mp_fifo.o osdep/$(GETCH) osdep/$(TIMER)
 
-libvo/aspecttest$(EXESUF): libvo/aspect.o libvo/geometry.o $(TEST_OBJS)
+libvo/aspecttest$(EXESUF): libvo/aspect.o libvo/geometry.o $(MP_MSG_OBJS)
+libvo/aspecttest$(EXESUF): LIBS = $(MP_MSG_LIBS)
 
-LOADER_TEST_OBJS = $(SRCS_WIN32_EMULATION:.c=.o) $(SRCS_QTX_EMULATION:.S=.o) ffmpeg/libavutil/libavutil.a osdep/mmap_anon.o cpudetect.o path.o $(TEST_OBJS)
+LOADER_TEST_OBJS = $(SRCS_WIN32_EMULATION:.c=.o) $(SRCS_QTX_EMULATION:.S=.o) ffmpeg/libavutil/libavutil.a osdep/mmap_anon.o cpudetect.o path.o $(MP_MSG_OBJS)
 
 loader/qtx/list$(EXESUF) loader/qtx/qtxload$(EXESUF): CFLAGS += -g
 loader/qtx/list$(EXESUF) loader/qtx/qtxload$(EXESUF): $(LOADER_TEST_OBJS)
@@ -1044,12 +1046,13 @@
 	-rm -f $(call ADD_ALL_EXESUFS,$(ALLTOOLS))
 	-rm -f TOOLS/realcodecs/*.so.6.0
 
-TOOLS/bmovl-test$(EXESUF): -lSDL_image
+TOOLS/bmovl-test$(EXESUF): LIBS = -lSDL_image
 
 TOOLS/subrip$(EXESUF): path.o sub/vobsub.o sub/spudec.o sub/unrar_exec.o \
-    ffmpeg/libswscale/libswscale.a ffmpeg/libavutil/libavutil.a $(TEST_OBJS)
+    ffmpeg/libswscale/libswscale.a ffmpeg/libavutil/libavutil.a $(MP_MSG_OBJS)
+TOOLS/subrip$(EXESUF): LIBS = $(MP_MSG_LIBS)
 
-TOOLS/vfw2menc$(EXESUF): -lwinmm -lole32
+TOOLS/vfw2menc$(EXESUF): LIBS = -lwinmm -lole32
 
 mplayer-nomain.o: mplayer.c
 	$(CC) $(CFLAGS) -DDISABLE_MAIN -c -o $@ $<