$NetBSD: patch-ab,v 1.10 2009/02/03 08:44:15 obache Exp $

--- Makefile.orig	2008-12-17 21:45:13.000000000 +0000
+++ Makefile
@@ -40,9 +40,9 @@ endif
 ifdef ARCH_X86
 ASFLAGS += -Icommon/x86/
 SRCS   += common/x86/mc-c.c common/x86/predict-c.c
-OBJASM  = $(ASMSRC:%.asm=%.o)
+OBJASM  = $(ASMSRC:%.asm=%.lo)
 $(OBJASM): common/x86/x86inc.asm common/x86/x86util.asm
-checkasm: tools/checkasm-a.o
+checkasm: tools/checkasm-a.lo
 endif
 endif
 
@@ -52,44 +52,49 @@ ALTIVECSRC += common/ppc/mc.c common/ppc
               common/ppc/quant.c common/ppc/deblock.c \
               common/ppc/predict.c
 SRCS += $(ALTIVECSRC)
-$(ALTIVECSRC:%.c=%.o): CFLAGS += $(ALTIVECFLAGS)
+$(ALTIVECSRC:%.c=%.lo): CFLAGS += $(ALTIVECFLAGS)
 endif
 
 # VIS optims
 ifeq ($(ARCH),UltraSparc)
 ASMSRC += common/sparc/pixel.asm
-OBJASM  = $(ASMSRC:%.asm=%.o)
+OBJASM  = $(ASMSRC:%.asm=%.lo)
 endif
 
 ifneq ($(HAVE_GETOPT_LONG),1)
 SRCS += extras/getopt.c
 endif
 
-OBJS = $(SRCS:%.c=%.o)
-OBJCLI = $(SRCCLI:%.c=%.o)
+OBJS = $(SRCS:%.c=%.lo)
+OBJCLI = $(SRCCLI:%.c=%.lo)
 DEP  = depend
 
 .PHONY: all default fprofiled clean distclean install uninstall dox test testclean
 
 default: $(DEP) x264$(EXE)
 
-libx264.a: .depend $(OBJS) $(OBJASM)
-	ar rc libx264.a $(OBJS) $(OBJASM)
-	ranlib libx264.a
+%.lo: %.c
+	${LIBTOOL} --mode=compile ${CC} -c ${CFLAGS} ${PICFLAGS} -o $@ $<
+
+libx264.la: .depend $(OBJS) $(OBJASM)
+	${LIBTOOL} --mode=link \
+	${CC} -o libx264.la -rpath ${PREFIX}/lib -version-info 0 \
+	$(OBJS) $(OBJASM) ${LDFLAGS}
 
 $(SONAME): .depend $(OBJS) $(OBJASM)
 	$(CC) -shared -o $@ $(OBJS) $(OBJASM) $(SOFLAGS) $(LDFLAGS)
 
-x264$(EXE): $(OBJCLI) libx264.a 
-	$(CC) -o $@ $+ $(LDFLAGS)
+x264$(EXE): $(OBJCLI) libx264.la 
+	${LIBTOOL} --mode=link $(CC) -o $@ $+ $(LDFLAGS)
 
-checkasm: tools/checkasm.o libx264.a
-	$(CC) -o $@ $+ $(LDFLAGS)
+checkasm: tools/checkasm.lo libx264.la
+	${LIBTOOL} --mode=link $(CC) -o $@ $+ $(LDFLAGS)
 
-%.o: %.asm
-	$(AS) $(ASFLAGS) -o $@ $<
+%.lo: %.asm
+	${LIBTOOL} --mode=compile --tag=CC \
+		./strip_fopt.sh $(AS) $(ASFLAGS) -o $@ $<
 # delete local/anonymous symbols, so they don't show up in oprofile
-	-@ strip -x $@
+	-@ strip -x $(@:.lo=.o)
 
 .depend: config.mak
 	rm -f .depend
@@ -144,21 +149,16 @@ distclean: clean
 	rm -f config.mak config.h x264.pc
 	rm -rf test/
 
-install: x264$(EXE) $(SONAME)
+install: x264$(EXE) libx264.la
 	install -d $(DESTDIR)$(bindir) $(DESTDIR)$(includedir)
 	install -d $(DESTDIR)$(libdir) $(DESTDIR)$(libdir)/pkgconfig
 	install -m 644 x264.h $(DESTDIR)$(includedir)
-	install -m 644 libx264.a $(DESTDIR)$(libdir)
+	${LIBTOOL} --mode=install ${BSD_INSTALL_LIB} libx264.la $(DESTDIR)$(libdir)
 	install -m 644 x264.pc $(DESTDIR)$(libdir)/pkgconfig
-	install x264$(EXE) $(DESTDIR)$(bindir)
-	ranlib $(DESTDIR)$(libdir)/libx264.a
+	${LIBTOOL} --mode=install ${BSD_INSTALL_PROGRAM} x264$(EXE) $(DESTDIR)$(bindir)
 ifeq ($(SYS),MINGW)
 	$(if $(SONAME), install -m 755 $(SONAME) $(DESTDIR)$(bindir))
-else
-	$(if $(SONAME), ln -sf $(SONAME) $(DESTDIR)$(libdir)/libx264.$(SOSUFFIX))
-	$(if $(SONAME), install -m 755 $(SONAME) $(DESTDIR)$(libdir))
 endif
-	$(if $(IMPLIBNAME), install -m 644 $(IMPLIBNAME) $(DESTDIR)$(libdir))
 
 uninstall:
 	rm -f $(DESTDIR)$(includedir)/x264.h $(DESTDIR)$(libdir)/libx264.a
