libwebp/Makefile.vc
James Zern b2b0090b4c Simplify Visual Studio ifdefs
Use _MSC_VER as the intrinsics compile without /arch:SSE2 on x86.
Also avoids applying the same flag to all files which defeated the
purpose of the runtime cpu-detection.

Thanks to Frank B. for the suggestion!

Change-Id: Iae9933a3cee704e663d9bbd53d0fa68e8c025425
2011-06-03 11:40:15 -07:00

206 lines
5.3 KiB
Makefile

#
# Stem for static libs and DLLs
#
LIB_NAME = libwebp_a
LIB_NAME_DEBUG = libwebp_a_debug
#
# Stem for DLL import libs
#
IMPLIB_NAME = libwebp
IMPLIB_NAME_DEBUG = libwepb_debug
!IFNDEF DEP_PATH
DEPS_PATH = ../../deps
!ENDIF
!IFNDEF ARCH
!IF ! [ cl 2>&1 | find "x86" > NUL ]
ARCH = x86
!ELSE IF ! [ cl 2>&1 | find "x64" > NUL ]
ARCH = x64
!ELSE
!ERROR Unable to auto-detect toolchain architecture! \
If cl.exe is in your PATH rerun nmake with ARCH=<arch>.
!ENDIF
!ENDIF
!IF "$(ARCH)" == "x86"
PLATFORM_LDFLAGS = /SAFESEH
!ENDIF
#############################################################
## Nothing more to do below this line!
MT = mt.exe
CCNODBG = cl.exe /nologo /O2 /DNDEBUG
CCDEBUG = cl.exe /nologo /Od /Gm /Zi /D_DEBUG /RTC1
CFLAGS = /Isrc /nologo /W3 /EHsc /DWIN32 /FD /c /GS /D_CRT_SECURE_NO_WARNINGS
LDFLAGS = /LARGEADDRESSAWARE /MANIFEST /NXCOMPAT /DYNAMICBASE $(PLATFORM_LDFLAGS)
CFLAGSLIB = /DLIBWEBP_STATICLIB
LNKDLL = link.exe /DLL
LNKLIB = link.exe /lib
LNKEXE = link.exe
LFLAGS = /nologo /machine:$(ARCH)
CFGSET = FALSE
!IF "$(OBJDIR)" == ""
OUTDIR = ..\obj\
!ELSE
OUTDIR = $(OBJDIR)
!ENDIF
##############################################################
# Runtime library configuration
!IF "$(RTLIBCFG)" == "static"
RTLIB = /MT
RTLIBD = /MTd
!ELSE
RTLIB = /MD
RTLIBD = /MDd
!ENDIF
DIRBASE = $(OUTDIR)\$(CFG)\$(ARCH)
DIROBJ = $(DIRBASE)\obj
DIRLIB = $(DIRBASE)\lib
DIRINC = $(DIRBASE)\include
DIRBIN = $(DIRBASE)\bin
# release-static
!IF "$(CFG)" == "release-static"
TARGET = $(LIB_NAME).lib
LNK = $(LNKLIB) /out:$(DIRLIB)\$(TARGET)
CC = $(CCNODBG) $(RTLIB) $(CFLAGSLIB)
CFGSET = TRUE
!ENDIF
# debug-static
!IF "$(CFG)" == "debug-static"
TARGET = $(LIB_NAME_DEBUG).lib
LNK = $(LNKLIB) /out:$(DIRLIB)\$(TARGET)
CC = $(CCDEBUG) $(RTLIBD) $(CFLAGSLIB)
CFGSET = TRUE
!ENDIF
#######################
# Usage
#
!IF "$(CFGSET)" == "FALSE"
!MESSAGE Usage: nmake /f Makefile.vc [CFG=<config>] [OBJDIR=<path>] [RTLIBCFG=<rtlib>] [<target>]
!MESSAGE where <config> is one of:
!MESSAGE - release-static - release static library
!MESSAGE - debug-static - debug static library
!MESSAGE <target> may be:
!MESSAGE - clean - perform a clean for CFG
!MESSAGE
!MESSAGE <rtlibcfg> controls the runtime library linkage - can be 'static' or 'dynamic'.
!MESSAGE <target> can be left blank in which case all is assumed
!MESSAGE <path> is the path where you like to build (obj, bins, etc.)
!MESSAGE default to ..\obj\
!IF "$(CFG)" != ""
!MESSAGE
!ERROR please choose a valid configuration instead of "$(CFG)"
!ENDIF
!ENDIF
#######################
# Rules
#
!IF "$(CFGSET)" == "TRUE"
# A config was provided, so the library can be built.
#
X_OBJS= \
$(DIROBJ)\dec\bits.obj \
$(DIROBJ)\dec\dsp.obj \
$(DIROBJ)\dec\frame.obj \
$(DIROBJ)\dec\quant.obj \
$(DIROBJ)\dec\tree.obj \
$(DIROBJ)\dec\vp8.obj \
$(DIROBJ)\dec\webp.obj \
$(DIROBJ)\dec\yuv.obj \
$(DIROBJ)\dec\idec.obj \
$(DIROBJ)\dec\alpha.obj \
$(DIROBJ)\dec\layer.obj \
$(DIROBJ)\enc\analysis.obj \
$(DIROBJ)\enc\bit_writer.obj \
$(DIROBJ)\enc\config.obj \
$(DIROBJ)\enc\cost.obj \
$(DIROBJ)\enc\dsp.obj \
$(DIROBJ)\enc\dsp_sse2.obj \
$(DIROBJ)\enc\frame.obj \
$(DIROBJ)\enc\filter.obj \
$(DIROBJ)\enc\iterator.obj \
$(DIROBJ)\enc\picture.obj \
$(DIROBJ)\enc\quant.obj \
$(DIROBJ)\enc\syntax.obj \
$(DIROBJ)\enc\tree.obj \
$(DIROBJ)\enc\webpenc.obj \
$(DIROBJ)\enc\alpha.obj \
$(DIROBJ)\enc\layer.obj \
$(RESOURCE)
EXAMPLES_OBJS = \
$(DIROBJ)\examples\cwebp.obj \
$(DIROBJ)\examples\dwebp.obj
all: $(DIRLIB)\$(TARGET) $(DIRBIN)\dwebp.exe $(DIRBIN)\cwebp.exe
$(DIRLIB)\$(TARGET): $(X_OBJS)
$(LNK) $(LFLAGS) $(X_OBJS)
-xcopy $(DIROBJ)\$(LIB_NAME).dll $(DIRBIN) /y
-xcopy $(DIROBJ)\$(LIB_NAME).lib $(DIRLIB) /y
-xcopy $(DIROBJ)\$(LIB_NAME_DEBUG).dll $(DIRBIN) /y
-xcopy $(DIROBJ)\$(LIB_NAME_DEBUG).lib $(DIRLIB) /y
-xcopy $(DIROBJ)\$(IMPLIB_NAME).lib $(DIRLIB) /y
-xcopy $(DIROBJ)\$(IMPLIB_NAME_DEBUG).lib $(DIRLIB) /y
-xcopy $(DIROBJ)\*.exp $(DIRLIB) /y
-xcopy $(DIROBJ)\*.pdb $(DIRLIB) /y
$(X_OBJS): $(DIROBJ)\enc $(DIROBJ)\dec $(DIRLIB) $(DIRINC) $(DIRBIN)
$(EXAMPLES_OBJS): $(DIROBJ)\examples $(DIRLIB)\$(TARGET)
$(DIROBJ)\enc:
@if not exist "$(DIROBJ)\enc" mkdir $(DIROBJ)\enc
$(DIROBJ)\examples:
@if not exist "$(DIROBJ)\examples" mkdir $(DIROBJ)\examples
$(DIROBJ)\dec:
@if not exist "$(DIROBJ)\dec" mkdir $(DIROBJ)\dec
$(DIRLIB):
@if not exist "$(DIRLIB)" mkdir $(DIRLIB)
$(DIRINC):
@if not exist "$(DIRINC)" mkdir $(DIRINC)
$(DIRBIN):
@if not exist "$(DIRBIN)" mkdir $(DIRBIN)
.SUFFIXES: .c .obj .res .exe
{examples}.c{$(DIROBJ)\examples}.obj:
$(CC) $(CFLAGS) /Fo"$@" $<
{src\dec}.c{$(DIROBJ)\dec}.obj:
$(CC) $(CFLAGS) /Fo"$@" $<
{src\enc}.c{$(DIROBJ)\enc}.obj:
$(CC) $(CFLAGS) /Fo"$@" $<
{$(DIROBJ)\examples}.obj{$(DIRBIN)}.exe:
$(LNKEXE) $(LDFLAGS) /OUT:"$@" $< ole32.lib windowscodecs.lib shlwapi.lib $(DIRLIB)\$(TARGET)
$(MT) -manifest $@.manifest -outputresource:$@;1
del $@.manifest
clean:
@-erase /s $(DIROBJ)\*.dll 2> NUL
@-erase /s $(DIROBJ)\*.exp 2> NUL
@-erase /s $(DIROBJ)\*.idb 2> NUL
@-erase /s $(DIROBJ)\*.lib 2> NUL
@-erase /s $(DIROBJ)\*.obj 2> NUL
@-erase /s $(DIROBJ)\*.pch 2> NUL
@-erase /s $(DIROBJ)\*.pdb 2> NUL
@-erase /s $(DIROBJ)\*.res 2> NUL
!ENDIF # End of case where a config was provided.