$NetBSD: patch-ab,v 1.13 2011/01/17 16:46:42 drochner Exp $

--- Makefile.orig	2011-01-01 21:45:05.000000000 +0000
+++ Makefile
@@ -86,9 +86,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
 
@@ -108,7 +108,7 @@ ASMSRC += common/arm/cpu-a.S common/arm/
           common/arm/dct-a.S common/arm/quant-a.S common/arm/deblock-a.S \
           common/arm/predict-a.S
 SRCS   += common/arm/mc-c.c common/arm/predict-c.c
-OBJASM  = $(ASMSRC:%.S=%.o)
+OBJASM  = $(ASMSRC:%.S=%.lo)
 endif
 endif
 
@@ -116,7 +116,7 @@ endif
 ifeq ($(ARCH),UltraSPARC)
 ifeq ($(findstring HIGH_BIT_DEPTH, $(CONFIG)),)
 ASMSRC += common/sparc/pixel.asm
-OBJASM  = $(ASMSRC:%.asm=%.o)
+OBJASM  = $(ASMSRC:%.asm=%.lo)
 endif
 endif
 
@@ -130,8 +130,8 @@ SRCSO += x264dll.c
 endif
 endif
 
-OBJS = $(SRCS:%.c=%.o)
-OBJCLI = $(SRCCLI:%.c=%.o)
+OBJS = $(SRCS:%.c=%.lo)
+OBJCLI = $(SRCCLI:%.c=%.lo)
 OBJSO = $(SRCSO:%.c=%.o)
 DEP  = depend
 
@@ -139,22 +139,26 @@ DEP  = depend
 
 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) $(OBJSO)
 	$(CC) -shared -o $@ $(OBJS) $(OBJASM) $(OBJSO) $(SOFLAGS) $(LDFLAGS)
 
-x264$(EXE): $(OBJCLI) libx264.a
-	$(CC) -o $@ $+ $(LDFLAGSCLI) $(LDFLAGS)
+x264$(EXE): $(OBJCLI) libx264.la
+	${LIBTOOL} --mode=link $(CC) -o $@ $+ $(LDFLAGSCLI) $(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 $@ $<
-	-@ $(STRIP) -x $@ # delete local/anonymous symbols, so they don't show up in oprofile
+%.lo: %.asm
+	${LIBTOOL} --mode=compile --tag=CC \
+		./strip_fopt.sh $(AS) $(ASFLAGS) -o $@ $<
 
 %.o: %.S
 	$(AS) $(ASFLAGS) -o $@ $<
@@ -212,24 +216,17 @@ distclean: clean
 	rm -f config.mak x264_config.h config.h config.log x264.pc
 	rm -rf test/
 
-install: x264$(EXE) $(SONAME)
-	install -d $(DESTDIR)$(bindir)
-	install -d $(DESTDIR)$(includedir)
-	install -d $(DESTDIR)$(libdir)
-	install -d $(DESTDIR)$(libdir)/pkgconfig
+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 x264_config.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 -f -s $(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)$(includedir)/x264_config.h $(DESTDIR)$(libdir)/libx264.a
