src/3rdparty/libpng/scripts/makefile.mingw
changeset 0 1918ee327afb
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     1 # makefile for mingw on x86
       
     2 #   Builds both dll (with import lib) and static lib versions
       
     3 #   of the library, and builds two copies of pngtest: one
       
     4 #   statically linked and one dynamically linked.
       
     5 #
       
     6 # Copyright (C) 2002, 2006, 2008 Soren Anderson, Charles Wilson,
       
     7 #    and Glenn Randers-Pehrson, based on makefile for linux-elf w/mmx by:
       
     8 # Copyright (C) 1998-2000, 2007 Greg Roelofs
       
     9 # Copyright (C) 1996, 1997 Andreas Dilger
       
    10 
       
    11 # This code is released under the libpng license.
       
    12 # For conditions of distribution and use, see the disclaimer
       
    13 # and license in png.h
       
    14 
       
    15 # Built from makefile.cygwin
       
    16 
       
    17 # This makefile intends to support building outside the src directory
       
    18 # if desired. When invoking it, specify an argument to SRCDIR on the
       
    19 # command line that points to the top of the directory where your source
       
    20 # is located.
       
    21 ifdef SRCDIR
       
    22 VPATH = $(SRCDIR)
       
    23 else
       
    24 SRCDIR = .
       
    25 endif
       
    26 
       
    27 # Override DESTDIR= on the make install command line to easily support
       
    28 # installing into a temporary location.  Example:
       
    29 #
       
    30 #    make install DESTDIR=/tmp/build/libpng
       
    31 #
       
    32 # If you're going to install into a temporary location
       
    33 # via DESTDIR, $(DESTDIR)$(prefix) must already exist before
       
    34 # you execute make install.
       
    35 DESTDIR=
       
    36 
       
    37 # If you're using a cross-compiler, add the appropriate prefix (e.g.,
       
    38 # "i386-mingw32msvc-") to the following three commands:
       
    39 CC=gcc
       
    40 AR=ar
       
    41 RANLIB=ranlib
       
    42 
       
    43 MKDIR_P=/bin/mkdir -pv
       
    44 
       
    45 # Where "make install" puts libpng*.a, *png*.dll, png.h, and pngconf.h
       
    46 ifndef prefix
       
    47 prefix=/usr
       
    48 $(warning "You haven't specified a 'prefix=' location. Defaulting to '/usr'")
       
    49 endif
       
    50 exec_prefix=$(prefix)
       
    51 
       
    52 # Where the zlib library and include files are located
       
    53 ZLIBLIB= /usr/lib
       
    54 ZLIBINC=
       
    55 
       
    56 ALIGN=
       
    57 # for i386:
       
    58 #ALIGN=-malign-loops=2 -malign-functions=2
       
    59 
       
    60 WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \
       
    61 	-Wmissing-declarations -Wtraditional -Wcast-align \
       
    62 	-Wstrict-prototypes -Wmissing-prototypes #-Wconversion
       
    63 
       
    64 ### if you don't need thread safety, but want the asm accel
       
    65 #CFLAGS= $(strip $(MINGW_CCFLAGS) -DPNG_THREAD_UNSAFE_OK \
       
    66 #	$(addprefix -I,$(ZLIBINC)) -W -Wall -O $(ALIGN) -funroll-loops \
       
    67 #	-fomit-frame-pointer)  # $(WARNMORE) -g -DPNG_DEBUG=5
       
    68 ### if you need thread safety and want (minimal) asm accel
       
    69 #CFLAGS= $(strip $(MINGW_CCFLAGS) $(addprefix -I,$(ZLIBINC)) \
       
    70 #	-W -Wall -O $(ALIGN) -funroll-loops \
       
    71 #	-fomit-frame-pointer)  # $(WARNMORE) -g -DPNG_DEBUG=5
       
    72 ### Normal (non-asm) compilation
       
    73 CFLAGS= $(strip $(MINGW_CCFLAGS) $(addprefix -I,$(ZLIBINC)) \
       
    74         -W -Wall -O3 $(ALIGN) -funroll-loops -DPNG_NO_MMX_CODE \
       
    75 	-fomit-frame-pointer) # $(WARNMORE) -g -DPNG_DEBUG=5
       
    76 
       
    77 LIBNAME = libpng12
       
    78 PNGMAJ = 0
       
    79 MINGDLL = 12
       
    80 PNGMIN = 1.2.40
       
    81 PNGVER = $(PNGMAJ).$(PNGMIN)
       
    82 
       
    83 SHAREDLIB=libpng$(MINGDLL).dll
       
    84 STATLIB=libpng.a
       
    85 IMPLIB=libpng.dll.a
       
    86 SHAREDDEF=libpng.def
       
    87 LIBS=$(SHAREDLIB) $(STATLIB)
       
    88 EXE=.exe
       
    89 
       
    90 LDFLAGS=$(strip -L. $(MINGW_LDFLAGS) -lpng $(addprefix -L,$(ZLIBLIB)) -lz)
       
    91 LDSFLAGS=$(strip -shared -L.  $(MINGW_LDFLAGS))
       
    92 LDEXTRA=-Wl,--out-implib=$(IMPLIB) $(addprefix -L,$(ZLIBLIB)) -lz
       
    93 
       
    94 INCPATH=$(prefix)/include
       
    95 LIBPATH=$(exec_prefix)/lib
       
    96 
       
    97 BINPATH=$(exec_prefix)/bin
       
    98 MANPATH=$(prefix)/man
       
    99 MAN3PATH=$(MANPATH)/man3
       
   100 MAN5PATH=$(MANPATH)/man5
       
   101 
       
   102 # cosmetic: shortened strings:
       
   103 S =$(SRCDIR)
       
   104 D =$(DESTDIR)
       
   105 DB =$(D)$(BINPATH)
       
   106 DI =$(D)$(INCPATH)
       
   107 DL =$(D)$(LIBPATH)
       
   108 
       
   109 OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \
       
   110 	pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \
       
   111 	pngwtran.o pngmem.o pngerror.o pngpread.o
       
   112 
       
   113 OBJSDLL = $(OBJS:.o=.pic.o)
       
   114 
       
   115 .SUFFIXES: .c .o .pic.o
       
   116 
       
   117 %.o : %.c
       
   118 	$(CC) -c $(CFLAGS) -o $@ $<
       
   119 %.pic.o : CFLAGS += -DPNG_BUILD_DLL
       
   120 %.pic.o : %.c
       
   121 	$(CC) -c $(CFLAGS) -o $@ $<
       
   122 
       
   123 all: all-static all-shared libpng.pc libpng-config libpng.pc libpng-config
       
   124 
       
   125 # Make this to verify that "make [...] install" will do what you want.
       
   126 buildsetup-tell:
       
   127 	@echo  VPATH is set to: \"$(VPATH)\"
       
   128 	@echo  prefix is set to: \"$(prefix)\"
       
   129 	@echo -e INCPATH,LIBPATH, etc. are set to:'\n' \
       
   130  $(addprefix $(D),$(INCPATH)'\n' $(LIBPATH)'\n' $(BINPATH)'\n' \
       
   131    $(MANPATH)'\n' $(MAN3PATH)'\n' $(MAN5PATH)'\n')'\n'
       
   132 
       
   133 libpng.pc: scripts/libpng.pc.in
       
   134 	@echo -e Making pkg-config file for this libpng installation..'\n' \
       
   135            using PREFIX=\"$(prefix)\"'\n'
       
   136 	cat scripts/libpng.pc.in | sed -e s!@prefix@!$(prefix)! \
       
   137 	-e s!@exec_prefix@!$(exec_prefix)! \
       
   138 	-e s!@libdir@!$(LIBPATH)! \
       
   139 	-e s!@includedir@!$(INCPATH)! \
       
   140 	-e s!@includedir@!$(INCPATH)! \
       
   141 	-e s!-lpng12!-lpng12\ -lz\ -lm! > libpng.pc
       
   142 
       
   143 libpng-config: scripts/libpng-config-head.in scripts/libpng-config-body.in
       
   144 	@echo -e Making $(LIBNAME) libpng-config file for this libpng \
       
   145  installation..'\n' using PREFIX=\"$(prefix)\"'\n'
       
   146 	( cat $(S)/scripts/libpng-config-head.in; \
       
   147 	echo prefix=\"$(prefix)\"; \
       
   148 	echo I_opts=\"-I$(INCPATH)/$(LIBNAME)\"; \
       
   149 	echo L_opts=\"-L$(LIBPATH)\"; \
       
   150 	echo libs=\"-lpng$(MINGDLL) -lz\"; \
       
   151 	cat $(S)/scripts/libpng-config-body.in ) > libpng-config
       
   152 	chmod +x libpng-config
       
   153 
       
   154 static: all-static
       
   155 shared: all-shared
       
   156 all-static: $(STATLIB) pngtest-stat$(EXE)
       
   157 all-shared: $(SHAREDLIB) pngtest$(EXE)
       
   158 
       
   159 $(STATLIB): $(OBJS)
       
   160 	$(AR) rc $@ $(OBJS)
       
   161 	$(RANLIB) $@
       
   162 
       
   163 $(SHAREDDEF): scripts/pngw32.def
       
   164 	cat $< | sed -e '1{G;s/^\(.*\)\(\n\)/EXPORTS/;};2,/^EXPORTS/d' | \
       
   165 	sed -e 's/\([^;]*\);/;/' > $@
       
   166 
       
   167 $(SHAREDLIB): $(OBJSDLL) $(SHAREDDEF)
       
   168 	$(CC) $(LDSFLAGS) -o $@ $(OBJSDLL) -L. $(LDEXTRA)
       
   169 
       
   170 pngtest$(EXE): pngtest.pic.o $(SHAREDLIB)
       
   171 	$(CC) $(CFLAGS) $< $(LDFLAGS) -o $@
       
   172 
       
   173 pngtest-stat$(EXE): pngtest.o $(STATLIB)
       
   174 	$(CC) -static $(CFLAGS) $< $(LDFLAGS) -o $@
       
   175 
       
   176 test: test-static test-shared
       
   177 
       
   178 test-static: pngtest-stat$(EXE)
       
   179 	./pngtest-stat $(S)/pngtest.png
       
   180 
       
   181 test-shared: pngtest$(EXE)
       
   182 	./pngtest $(S)/pngtest.png
       
   183 
       
   184 install-static: $(STATLIB) install-headers install-man
       
   185 	-@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
       
   186 	install -m 644 $(STATLIB) $(DL)/$(LIBNAME).a
       
   187 	-@rm -f $(DL)/$(STATLIB)
       
   188 	(cd $(DL); ln -sf $(LIBNAME).a $(STATLIB))
       
   189 
       
   190 install-shared: $(SHAREDLIB) libpng.pc libpng-config install-headers install-man
       
   191 	-@if [ ! -d $(DL) ]; then $(MKDIR_P) $(DL); fi
       
   192 	-@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi
       
   193 	-@if [ ! -d $(DL)/pkgconfig ]; then $(MKDIR_P) $(DL)/pkgconfig; fi
       
   194 	-@/bin/rm -f $(DL)/pkgconfig/$(LIBNAME).pc
       
   195 	-@/bin/rm -f $(DL)/pkgconfig/libpng.pc
       
   196 	install -m 644 $(IMPLIB) $(DL)/$(LIBNAME).dll.a
       
   197 	-@rm -f $(DL)/$(IMPLIB)
       
   198 	(cd $(DL); ln -sf $(LIBNAME).dll.a $(IMPLIB))
       
   199 	install -s -m 755 $(SHAREDLIB) $(DB)
       
   200 	install -m 644 libpng.pc $(DL)/pkgconfig/$(LIBNAME).pc
       
   201 	(cd $(DL)/pkgconfig; ln -sf $(LIBNAME).pc libpng.pc)
       
   202 
       
   203 install-headers:
       
   204 	-@if [ ! -d $(DI) ]; then $(MKDIR_P) $(DI); fi
       
   205 	-@if [ ! -d $(DI)/$(LIBNAME) ]; then $(MKDIR_P) $(DI)/$(LIBNAME); fi
       
   206 	-@rm -f $(DI)/png.h
       
   207 	-@rm -f $(DI)/pngconf.h
       
   208 	install -m 644 $(S)/png.h $(S)/pngconf.h $(DI)/$(LIBNAME)
       
   209 	-@rm -f $(DI)/libpng
       
   210 	(cd $(DI); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .)
       
   211 
       
   212 install-man:
       
   213 	-@if [ ! -d $(D)$(MAN3PATH) ]; then $(MKDIR_P) $(D)$(MAN3PATH); fi
       
   214 	-@if [ ! -d $(D)$(MAN5PATH) ]; then $(MKDIR_P) $(D)$(MAN5PATH); fi
       
   215 	install -m 644 $(S)/libpngpf.3 $(S)/libpng.3 $(D)$(MAN3PATH)
       
   216 	install -m 644 $(S)/png.5 $(D)$(MAN5PATH)
       
   217 
       
   218 install-config: libpng-config
       
   219 	-@if [ ! -d $(DB) ]; then $(MKDIR_P) $(DB); fi
       
   220 	-@/bin/rm -f $(DB)/libpng-config
       
   221 	-@/bin/rm -f $(DB)/$(LIBNAME)-config
       
   222 	cp libpng-config $(DB)/$(LIBNAME)-config
       
   223 	chmod 755 $(DB)/$(LIBNAME)-config
       
   224 	(cd $(DB); ln -sf $(LIBNAME)-config libpng-config)
       
   225 
       
   226 # Run this to verify that a future `configure' run will pick up the settings
       
   227 # you want.
       
   228 test-config-install: SHELL=/bin/bash
       
   229 test-config-install: $(DB)/libpng-config
       
   230 	@echo -e Testing libpng-config functions...'\n'
       
   231 	@ for TYRA in LDFLAGS CPPFLAGS CFLAGS LIBS VERSION; \
       
   232    do \
       
   233     printf "(%d)\t %10s =%s\n" $$(($$gytiu + 1)) $$TYRA \
       
   234     "$$($(DB)/libpng-config `echo --$$TYRA |tr '[:upper:]' '[:lower:]'`)"; \
       
   235     gytiu=$$(( $$gytiu + 1 )); \
       
   236    done
       
   237 
       
   238 install: install-static install-shared install-man install-config
       
   239 
       
   240 # If you installed in $(DESTDIR), test-installed won't work until you
       
   241 # move the library to its final location.  Use test-dd to test it
       
   242 # before then.
       
   243 
       
   244 test-dd:
       
   245 	echo
       
   246 	echo Testing installed dynamic shared library in $(DL).
       
   247 	$(CC) -I$(DI) $(CFLAGS) \
       
   248 	   `$(BINPATH)/libpng12-config --cflags` pngtest.c \
       
   249 	   -L$(DL) -L$(ZLIBLIB) \
       
   250 	   -o pngtestd `$(BINPATH)/libpng12-config --ldflags`
       
   251 	./pngtestd pngtest.png
       
   252 
       
   253 test-installed:
       
   254 	$(CC) $(CFLAGS) \
       
   255 	   `$(BINPATH)/libpng12-config --cflags` pngtest.c \
       
   256 	   -L$(ZLIBLIB) \
       
   257 	   -o pngtesti$(EXE) `$(BINPATH)/libpng12-config --ldflags`
       
   258 	./pngtesti$(EXE) pngtest.png
       
   259 
       
   260 clean:
       
   261 	/bin/rm -f *.pic.o *.o $(STATLIB) $(IMPLIB) $(SHAREDLIB) \
       
   262 	   pngtest-stat$(EXE) pngtest$(EXE) pngout.png $(SHAREDDEF) \
       
   263 	   libpng-config libpng.pc pngtesti$(EXE)
       
   264 
       
   265 DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO
       
   266 writelock:
       
   267 	chmod a-w *.[ch35] $(DOCS) scripts/*
       
   268 
       
   269 .PHONY: buildsetup-tell libpng.pc libpng-config test-config-install clean
       
   270 
       
   271 # DO NOT DELETE THIS LINE -- make depend depends on it.
       
   272 
       
   273 png.o png.pic.o:		png.h pngconf.h png.c
       
   274 pngerror.o pngerror.pic.o:	png.h pngconf.h pngerror.c
       
   275 pngrio.o pngrio.pic.o:		png.h pngconf.h pngrio.c
       
   276 pngwio.o pngwio.pic.o:		png.h pngconf.h pngwio.c
       
   277 pngmem.o pngmem.pic.o:		png.h pngconf.h pngmem.c
       
   278 pngset.o pngset.pic.o:		png.h pngconf.h pngset.c
       
   279 pngget.o pngget.pic.o:		png.h pngconf.h pngget.c
       
   280 pngread.o pngread.pic.o:	png.h pngconf.h pngread.c
       
   281 pngrtran.o pngrtran.pic.o:	png.h pngconf.h pngrtran.c
       
   282 pngrutil.o pngrutil.pic.o:	png.h pngconf.h pngrutil.c
       
   283 pngtrans.o pngtrans.pic.o:	png.h pngconf.h pngtrans.c
       
   284 pngwrite.o pngwrite.pic.o:	png.h pngconf.h pngwrite.c
       
   285 pngwtran.o pngwtran.pic.o:	png.h pngconf.h pngwtran.c
       
   286 pngwutil.o pngwutil.pic.o:	png.h pngconf.h pngwutil.c
       
   287 pngpread.o pngpread.pic.o:	png.h pngconf.h pngpread.c
       
   288 
       
   289 pngtest.o pngtest.pic.o:	png.h pngconf.h pngtest.c