github.com/cellofellow/gopkg@v0.0.0-20140722061823-eec0544a62ad/image/webp/libwebp/makefile.unix (about)

     1  # This makefile is a simpler alternative to the autoconf-based build
     2  # system, for simple local building of the libraries and tools.
     3  # It will not install the libraries system-wide, but just create the 'cwebp'
     4  # and 'dwebp' tools in the examples/ directory, along with the static
     5  # libraries 'src/libwebp.a', 'src/libwebpdecoder.a', 'src/mux/libwebpmux.a' and
     6  # 'src/demux/libwebpdemux.a'.
     7  #
     8  # To build the library and examples, use:
     9  #    make -f makefile.unix
    10  # from this top directory.
    11  
    12  #### Customizable part ####
    13  
    14  # These flags assume you have libpng, libjpeg, libtiff and libgif installed. If
    15  # not, either follow the install instructions below or just comment out the next
    16  # four lines.
    17  EXTRA_FLAGS= -DWEBP_HAVE_PNG -DWEBP_HAVE_JPEG -DWEBP_HAVE_TIFF
    18  DWEBP_LIBS= -lpng -lz
    19  CWEBP_LIBS= $(DWEBP_LIBS) -ljpeg -ltiff
    20  GIF_LIBS = -lgif
    21  
    22  ifeq ($(strip $(shell uname)), Darwin)
    23    # Work around a problem linking tables marked as common symbols,
    24    # cf., src/enc/yuv.[hc]
    25    # Failure observed with: gcc 4.2.1 and 4.0.1.
    26    EXTRA_FLAGS += -fno-common
    27    EXTRA_FLAGS += -DHAVE_GLUT_GLUT_H
    28    EXTRA_FLAGS += -I/opt/local/include
    29    EXTRA_LIBS  += -L/opt/local/lib
    30    GL_LIBS = -framework GLUT -framework OpenGL
    31  else
    32    GL_LIBS = -lglut -lGL
    33  endif
    34  
    35  
    36  # To install libraries on Mac OS X:
    37  # 1. Install MacPorts (http://www.macports.org/install.php)
    38  # 2. Run "sudo port install jpeg"
    39  # 3. Run "sudo port install libpng"
    40  # 4. Run "sudo port install tiff"
    41  # 5. Run "sudo port install giflib"
    42  
    43  # To install libraries on Linux:
    44  # 1. Run "sudo apt-get install libjpeg62-dev"
    45  # 2. Run "sudo apt-get install libpng12-dev"
    46  # 3. Run "sudo apt-get install libtiff4-dev"
    47  # 4. Run "sudo apt-get install libgif-dev"
    48  
    49  # Uncomment for build for 32bit platform
    50  # Alternatively, you can just use the command
    51  # 'make -f makefile.unix EXTRA_FLAGS=-m32' to that effect.
    52  # EXTRA_FLAGS += -m32
    53  
    54  # Extra flags to enable experimental features and code
    55  # EXTRA_FLAGS += -DWEBP_EXPERIMENTAL_FEATURES
    56  
    57  # Extra flags to enable byte swap for 16 bit colorspaces.
    58  # EXTRA_FLAGS += -DWEBP_SWAP_16BIT_CSP
    59  
    60  # Extra flags to enable multi-threading
    61  EXTRA_FLAGS += -DWEBP_USE_THREAD
    62  EXTRA_LIBS += -lpthread
    63  
    64  # Extra flags to emulate C89 strictness with the full ANSI
    65  EXTRA_FLAGS += -Wextra -Wold-style-definition
    66  EXTRA_FLAGS += -Wmissing-prototypes
    67  EXTRA_FLAGS += -Wmissing-declarations
    68  EXTRA_FLAGS += -Wdeclaration-after-statement
    69  EXTRA_FLAGS += -Wshadow
    70  # EXTRA_FLAGS += -Wvla
    71  
    72  #### Nothing should normally be changed below this line ####
    73  
    74  AR = ar
    75  ARFLAGS = r
    76  CC = gcc
    77  CPPFLAGS = -Isrc/ -Wall
    78  CFLAGS = -O3 -DNDEBUG $(EXTRA_FLAGS)
    79  INSTALL = install
    80  GROFF = /usr/bin/groff
    81  COL = /usr/bin/col
    82  LDFLAGS = $(EXTRA_LIBS) $(EXTRA_FLAGS) -lm
    83  
    84  DEC_OBJS = \
    85      src/dec/alpha.o \
    86      src/dec/buffer.o \
    87      src/dec/frame.o \
    88      src/dec/idec.o \
    89      src/dec/io.o \
    90      src/dec/layer.o \
    91      src/dec/quant.o \
    92      src/dec/tree.o \
    93      src/dec/vp8.o \
    94      src/dec/vp8l.o \
    95      src/dec/webp.o \
    96  
    97  DEMUX_OBJS = \
    98      src/demux/demux.o \
    99  
   100  DSP_DEC_OBJS = \
   101      src/dsp/cpu.o \
   102      src/dsp/dec.o \
   103      src/dsp/dec_neon.o \
   104      src/dsp/dec_sse2.o \
   105      src/dsp/lossless.o \
   106      src/dsp/upsampling.o \
   107      src/dsp/upsampling_neon.o \
   108      src/dsp/upsampling_sse2.o \
   109      src/dsp/yuv.o \
   110  
   111  DSP_ENC_OBJS = \
   112      src/dsp/enc.o \
   113      src/dsp/enc_neon.o \
   114      src/dsp/enc_sse2.o \
   115  
   116  ENC_OBJS = \
   117      src/enc/alpha.o \
   118      src/enc/analysis.o \
   119      src/enc/backward_references.o \
   120      src/enc/config.o \
   121      src/enc/cost.o \
   122      src/enc/filter.o \
   123      src/enc/frame.o \
   124      src/enc/histogram.o \
   125      src/enc/iterator.o \
   126      src/enc/layer.o \
   127      src/enc/picture.o \
   128      src/enc/quant.o \
   129      src/enc/syntax.o \
   130      src/enc/token.o \
   131      src/enc/tree.o \
   132      src/enc/vp8l.o \
   133      src/enc/webpenc.o \
   134  
   135  EX_FORMAT_DEC_OBJS = \
   136      examples/jpegdec.o \
   137      examples/metadata.o \
   138      examples/pngdec.o \
   139      examples/tiffdec.o \
   140  
   141  EX_UTIL_OBJS = \
   142      examples/example_util.o \
   143  
   144  GIF2WEBP_UTIL_OBJS = \
   145      examples/gif2webp_util.o \
   146  
   147  MUX_OBJS = \
   148      src/mux/muxedit.o \
   149      src/mux/muxinternal.o \
   150      src/mux/muxread.o \
   151  
   152  UTILS_DEC_OBJS = \
   153      src/utils/alpha_processing.o \
   154      src/utils/bit_reader.o \
   155      src/utils/color_cache.o \
   156      src/utils/filters.o \
   157      src/utils/huffman.o \
   158      src/utils/quant_levels_dec.o \
   159      src/utils/random.o \
   160      src/utils/rescaler.o \
   161      src/utils/thread.o \
   162      src/utils/utils.o \
   163  
   164  UTILS_ENC_OBJS = \
   165      src/utils/bit_writer.o \
   166      src/utils/huffman_encode.o \
   167      src/utils/quant_levels.o \
   168  
   169  LIBWEBPDECODER_OBJS = $(DEC_OBJS) $(DSP_DEC_OBJS) $(UTILS_DEC_OBJS)
   170  LIBWEBP_OBJS = $(LIBWEBPDECODER_OBJS) $(ENC_OBJS) $(DSP_ENC_OBJS) \
   171                 $(UTILS_ENC_OBJS)
   172  LIBWEBPMUX_OBJS = $(MUX_OBJS)
   173  LIBWEBPDEMUX_OBJS = $(DEMUX_OBJS)
   174  
   175  HDRS_INSTALLED = \
   176      src/webp/decode.h \
   177      src/webp/demux.h \
   178      src/webp/encode.h \
   179      src/webp/mux.h \
   180      src/webp/mux_types.h \
   181      src/webp/types.h \
   182  
   183  HDRS = \
   184      src/dec/alphai.h \
   185      src/dec/decode_vp8.h \
   186      src/dec/vp8i.h \
   187      src/dec/vp8li.h \
   188      src/dec/webpi.h \
   189      src/dsp/dsp.h \
   190      src/dsp/lossless.h \
   191      src/dsp/yuv.h \
   192      src/enc/cost.h \
   193      src/enc/vp8enci.h \
   194      src/utils/alpha_processing.h \
   195      src/utils/bit_reader.h \
   196      src/utils/bit_writer.h \
   197      src/utils/color_cache.h \
   198      src/utils/filters.h \
   199      src/utils/huffman.h \
   200      src/utils/huffman_encode.h \
   201      src/utils/quant_levels.h \
   202      src/utils/quant_levels_dec.h \
   203      src/utils/random.h \
   204      src/utils/rescaler.h \
   205      src/utils/thread.h \
   206      src/webp/format_constants.h \
   207      $(HDRS_INSTALLED) \
   208  
   209  OUT_LIBS = examples/libexample_util.a src/libwebpdecoder.a src/libwebp.a
   210  OUT_EXAMPLES = examples/cwebp examples/dwebp
   211  EXTRA_EXAMPLES = examples/gif2webp examples/vwebp examples/webpmux
   212  
   213  OUTPUT = $(OUT_LIBS) $(OUT_EXAMPLES)
   214  ifeq ($(MAKECMDGOALS),clean)
   215    OUTPUT += $(EXTRA_EXAMPLES)
   216    OUTPUT += src/demux/libwebpdemux.a src/mux/libwebpmux.a
   217    OUTPUT += examples/libgif2webp_util.a
   218  endif
   219  
   220  ex: $(OUT_EXAMPLES)
   221  all: ex $(EXTRA_EXAMPLES)
   222  
   223  $(EX_FORMAT_DEC_OBJS): %.o: %.h
   224  
   225  %.o: %.c $(HDRS)
   226  	$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@
   227  
   228  examples/libexample_util.a: $(EX_UTIL_OBJS)
   229  examples/libgif2webp_util.a: $(GIF2WEBP_UTIL_OBJS)
   230  src/libwebpdecoder.a: $(LIBWEBPDECODER_OBJS)
   231  src/libwebp.a: $(LIBWEBP_OBJS)
   232  src/mux/libwebpmux.a: $(LIBWEBPMUX_OBJS)
   233  src/demux/libwebpdemux.a: $(LIBWEBPDEMUX_OBJS)
   234  
   235  %.a:
   236  	$(AR) $(ARFLAGS) $@ $^
   237  
   238  examples/cwebp: examples/cwebp.o $(EX_FORMAT_DEC_OBJS)
   239  examples/dwebp: examples/dwebp.o
   240  examples/gif2webp: examples/gif2webp.o
   241  examples/vwebp: examples/vwebp.o
   242  examples/webpmux: examples/webpmux.o
   243  
   244  examples/cwebp: src/libwebp.a
   245  examples/cwebp: EXTRA_LIBS += $(CWEBP_LIBS)
   246  examples/dwebp: examples/libexample_util.a src/libwebpdecoder.a
   247  examples/dwebp: EXTRA_LIBS += $(DWEBP_LIBS)
   248  examples/gif2webp: examples/libexample_util.a examples/libgif2webp_util.a
   249  examples/gif2webp: src/mux/libwebpmux.a src/libwebp.a
   250  examples/gif2webp: EXTRA_LIBS += $(GIF_LIBS)
   251  examples/gif2webp: EXTRA_FLAGS += -DWEBP_HAVE_GIF
   252  examples/vwebp: examples/libexample_util.a src/demux/libwebpdemux.a
   253  examples/vwebp: src/libwebp.a
   254  examples/vwebp: EXTRA_LIBS += $(GL_LIBS)
   255  examples/vwebp: EXTRA_FLAGS += -DWEBP_HAVE_GL
   256  examples/webpmux: examples/libexample_util.a src/mux/libwebpmux.a
   257  examples/webpmux: src/libwebpdecoder.a
   258  
   259  $(OUT_EXAMPLES) $(EXTRA_EXAMPLES):
   260  	$(CC) -o $@ $^ $(LDFLAGS)
   261  
   262  dist: DESTDIR := dist
   263  dist: OUT_EXAMPLES += $(EXTRA_EXAMPLES)
   264  dist: all
   265  	$(INSTALL) -m755 -d $(DESTDIR)/include/webp \
   266  	           $(DESTDIR)/bin $(DESTDIR)/doc $(DESTDIR)/lib
   267  	$(INSTALL) -m755 -s $(OUT_EXAMPLES) $(DESTDIR)/bin
   268  	$(INSTALL) -m644 $(HDRS_INSTALLED) $(DESTDIR)/include/webp
   269  	$(INSTALL) -m644 src/libwebp.a $(DESTDIR)/lib
   270  	$(INSTALL) -m644 src/demux/libwebpdemux.a $(DESTDIR)/lib
   271  	$(INSTALL) -m644 src/mux/libwebpmux.a $(DESTDIR)/lib
   272  	umask 022; \
   273  	for m in man/[cd]webp.1 man/gif2webp.1 man/webpmux.1; do \
   274  	  basenam=$$(basename $$m .1); \
   275  	  $(GROFF) -t -e -man -T utf8 $$m \
   276  	    | $(COL) -bx >$(DESTDIR)/doc/$${basenam}.txt; \
   277  	  $(GROFF) -t -e -man -T html $$m \
   278  	    | $(COL) -bx >$(DESTDIR)/doc/$${basenam}.html; \
   279  	done
   280  
   281  clean:
   282  	$(RM) $(OUTPUT) *~ \
   283                examples/*.o examples/*~ \
   284                src/dec/*.o src/dec/*~ \
   285                src/demux/*.o src/demux/*~ \
   286                src/dsp/*.o src/dsp/*~ \
   287                src/enc/*.o src/enc/*~ \
   288                src/mux/*.o src/mux/*~ \
   289                src/utils/*.o src/utils/*~ \
   290                src/webp/*~ man/*~ doc/*~ swig/*~ \
   291  
   292  superclean: clean
   293  	$(RM) -r .git *.log *.cache *~
   294  	$(RM) -r .deps */.deps */*/.deps
   295  	$(RM) -r .libs */.libs */*/.libs
   296  	$(RM) */*.lo */*/*.lo
   297  	$(RM) */*.la */*/*.la
   298  	$(RM) Makefile */Makefile */*/Makefile
   299  	$(RM) Makefile.in */Makefile.in */*/Makefile.in
   300  	$(RM) config.log autom4te.cache libtool config.h stamp-h1
   301  	$(RM) aclocal.m4 compile
   302  	$(RM) config.guess config.h.in config.sub config.status
   303  	$(RM) configure depcomp install-sh ltmain.sh missing src/libwebp.pc
   304  	$(RM) m4/*
   305  
   306  .PHONY: all clean dist ex superclean
   307  .SUFFIXES: