Skip to content

Commit

Permalink
build: Use lib.exe, genlib or dlltool to generate lsmash.lib when ava…
Browse files Browse the repository at this point in the history
…ilable on mingw.
  • Loading branch information
nak5124 authored and VFR-maniac committed Jul 30, 2016
1 parent 089d607 commit 830eb1a
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*.dll*
*.dylib
*.exe
*.exp
*.lib
*.o
*.orig
Expand Down
9 changes: 8 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ $(STATICLIBNAME): $(OBJS)
$(SHAREDLIBNAME): $(OBJS)
$(LD) $(SO_LDFLAGS) $(LDFLAGS) -o $@ $^ $(LIBS)
-@ $(if $(STRIP), $(STRIP) -x $@)
ifneq ($(SLIB_CMD),)
$(SLIB_CMD)
endif
ifeq ($(SHAREDLIBNAME), liblsmash.so.$(MAJVER))
ln -sf $(SHAREDLIBNAME) liblsmash.so
endif
Expand Down Expand Up @@ -56,6 +59,10 @@ ifneq ($(IMPLIB),)
install -m 644 $(IMPLIB) $(DESTDIR)$(libdir)
install -d $(DESTDIR)$(bindir)
install -m 755 $(SHAREDLIB) $(DESTDIR)$(bindir)
ifneq ($(SLIB_CMD),)
install -m 644 $(DEFNAME) $(DESTDIR)$(libdir)
install -m 644 lsmash.lib $(DESTDIR)$(bindir)
endif
else
install -m 644 $(SHAREDLIB) $(DESTDIR)$(libdir)
ifeq ($(SHAREDLIB), liblsmash.so.$(MAJVER))
Expand All @@ -71,7 +78,7 @@ uninstall:
$(RM) $(addprefix $(DESTDIR)$(bindir)/, $(TOOLS_ALL) $(TOOLS_ALL:%=%.exe) liblsmash.dll cyglsmash.dll)

clean:
$(RM) */*.o *.a *.so* *.dll *.dylib $(addprefix cli/, *.exe $(TOOLS_ALL)) .depend *.ver
$(RM) */*.o *.a *.so* *.def *.exp *.lib *.dll *.dylib $(addprefix cli/, *.exe $(TOOLS_ALL)) .depend *.ver

distclean: clean
$(RM) config.* *.pc
Expand Down
34 changes: 33 additions & 1 deletion configure
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ cc_check()
return $ret
}

is_64bit()
{
echo 'int main(void){int a[2*(sizeof(void *)>4)-1]; return 0;}' > conftest.c
$CC conftest.c -o conftest 2> /dev/null
ret=$?
rm -f conftest*
return $ret
}

#-----------------------------------------------------------------------------

rm -f config.* .depend conftest* liblsmash.pc *.ver
Expand Down Expand Up @@ -200,9 +209,29 @@ case "$TARGET_OS" in
EXT=".exe"
SHARED_NAME="liblsmash-$MAJVER"
SHARED_EXT=".dll"
DEFNAME="${SHARED_NAME}.def"
IMPLIB="liblsmash.dll.a"
SO_LDFLAGS="-shared -Wl,--out-implib,$IMPLIB -Wl,--version-script,liblsmash.ver"
SO_LDFLAGS="-shared -Wl,--output-def,$DEFNAME -Wl,--out-implib,$IMPLIB -Wl,--version-script,liblsmash.ver"
CFLAGS="$CFLAGS -D__USE_MINGW_ANSI_STDIO=1"
LIBARCH=i386
if lib.exe --list > /dev/null 2>&1 ; then
if is_64bit ; then
LIBARCH=x64
fi
SLIB_CMD='sed -i "s/ @[^ ]*//" $(DEFNAME); lib.exe -machine:$(LIBARCH) -def:$(DEFNAME) -out:lsmash.lib'
elif genlib -V > /dev/null 2>&1 ; then
if is_64bit ; then
LIBARCH=x86_64
else
LIBARCH=x86
fi
SLIB_CMD='sed -i "s/ @[^ ]*//" $(DEFNAME); genlib -a $(LIBARCH) -o lsmash.lib -d $(SHAREDLIBNAME) $(DEFNAME)'
elif ${CROSS}dlltool --version > /dev/null 2>&1 ; then
if is_64bit ; then
LIBARCH="i386:x86-64"
fi
SLIB_CMD="sed -i \"s/ @[^ ]*//\" \$(DEFNAME); ${CROSS}dlltool -m \$(LIBARCH) -d \$(DEFNAME) -l lsmash.lib -D \$(SHAREDLIBNAME)"
fi
;;
*cygwin*)
EXT=".exe"
Expand Down Expand Up @@ -429,6 +458,9 @@ CFLAGS = $CFLAGS
LDFLAGS = $LDFLAGS
SO_LDFLAGS = $SO_LDFLAGS
LIBS = $LIBS
LIBARCH = $LIBARCH
DEFNAME = $DEFNAME
SLIB_CMD = $SLIB_CMD
EOF

cat config.mak
Expand Down

0 comments on commit 830eb1a

Please sign in to comment.