makefile.cygwin-deluxe for building libpng-1.2.3 or higher. Download the UNIX-line-endings source file and the supplemental gmake include file (gzip-d tar archive). |
time of last modification:
Mon 20 May at 10:15:48 AM UTC
|
1 # makefile-deluxe for cygwin 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 # "Deluxe" enhancements (C) 2002 Soren Andersen: 7 # *-* Supports building outside the source directory. 8 # *-* Extensively tests post-install lib configuration mechanisms. 9 # *-* Automates cpu asm / mmx optimizations: 10 # --IMPORTANT! to use this feature you must either argue on the make commandline: 11 # 12 # $ make all [-f thismakefilename] HOST_CPU={x}86 [THREAD_RECKLESS=(1|0)] \ 13 # [... more stuff needed ...] 14 # where {x} is an Intel-compatible cpu version (3,4,5,6); OR you must make 15 # sure the special makefile include named "get-hostcpu-makefileinclude.gnu" 16 # is located where `make' can find it. 17 # 18 # Last modified: Monday, 20 May 2002, 05:55am 19 # 20 # -------------------------------------------------------------------- 21 # Copyright (C) 2002 Soren Andersen 22 # Derived from makefile.cygwin, based on the makefile for linux-elf w/mmx by: 23 # Copyright (C) 1998-2000 Greg Roelofs 24 # Copyright (C) 1996, 1997 Andreas Dilger 25 # For conditions of distribution and use, see copyright notice in png.h 26 # --------------------------------------------------------------------- 27 28 # A word to start with: some spurious noises may be issued by this makefile, 29 # some are truly informational and some are just side-effects of other things. 30 # Think of it like an old but cherished auto which shudders and belches a few 31 # times when you first start it up, but after it warms up and gets going, is 32 # a pleasure to ride in ;-). 33 34 35 # ********************************************************************* 36 # Leave all this stuff alone. It's here at the beginning for a reason. 37 all: build-setup-info 38 39 # begin host-cpu detection conditional makefile include --------------- 40 ifeq "$(filter clean,$(MAKECMDGOALS))" "" 41 ifeq "$(filter %86,$(HOST_CPU))" "" 42 include /cdv/g/src/common-vmk/get-hostcpu-makefileinclude.gnu 43 include $(CURDIR)/made_cpu_tool.tm~ 44 endif 45 endif 46 # end cpu-detection conditional makefile include ---------------------- 47 48 # OK, now you can look again. 49 # ********************************************************************* 50 51 # this makefile intends to support building outside the src directory 52 # if desired. when invoking it, specify an argument to SRCDIR on the 53 # command line that points to the top of the directory where your source 54 # is located. 55 56 ifdef SRCDIR 57 VPATH = $(SRCDIR) 58 else 59 SRCDIR = . 60 endif 61 62 # override DESTDIR= on the make install command line to easily support 63 # installing into a temporary location. Example: 64 # 65 # make install DESTDIR=/tmp/build/libpng 66 # 67 # If you're going to install into a temporary location 68 # via DESTDIR, that location must already exist before 69 # you execute make install. 70 71 DESTDIR = 72 73 # A given, on this platform: 74 CC=gcc 75 76 # where "make install" puts libpng*.a, *png*.dll, png.h, and pngconf.h 77 ifeq "$(filter clean,$(MAKECMDGOALS))" "" 78 ifndef prefix 79 prefix = /usr 80 ifneq "$(strip $(made_cpu_tool)$(HOST_CPU))" "" 81 $(warning You haven't specified a 'prefix=' location. Defaulting to "/usr") 82 endif 83 endif 84 endif 85 86 # Where the zlib library and include files are located. On my Cygwin, 87 # /usr/lib is required but the cpp finds the headers in /usr/include 88 # without any help. 89 ZLIBLIB = /usr/lib 90 ZLIBINC = 91 #ZLIBLIB=../zlib 92 #ZLIBINC=../zlib 93 94 ifdef MINGW 95 MINGW_CCFLAGS=-mno-cygwin -fnative-struct -I/usr/include/mingw 96 MINGW_LDFLAGS=-mno-cygwin -L/usr/lib/mingw 97 $(warning Be sure you are pointing "ZLIBINC" and "ZLIBLIB" towards \ 98 a non-Cygwin Zlib installation) 99 endif 100 101 WARNMORE=-Wwrite-strings -Wpointer-arith -Wshadow \ 102 -Wmissing-declarations -Wtraditional -Wcast-align \ 103 -Wstrict-prototypes -Wmissing-prototypes #-Wconversion 104 105 ### ********** NOTES ON CFLAGS *********** 106 ### if you don't need thread safety, and want the maximum asm accel, 107 ### argue in `make' invocation or uncomment here: 108 # THREAD_RECKLESS=1 109 ### else if you want thread-safe asm acceleration, use 110 # THREAD_RECKLESS=0 111 ASM_CODE = 112 ifdef THREAD_RECKLESS 113 ifeq "$(THREAD_RECKLESS)" "1" 114 ASM_CODE = -DPNG_THREAD_UNSAFE_OK -DPNG_USE_PNGGCCRD 115 endif 116 ifeq "$(THREAD_RECKLESS)" "0" 117 ASM_CODE = -DPNG_USE_PNGGCCRD 118 endif 119 endif 120 121 # most likely you don't need to mess with this, because you've read 122 # the instructions near the page top and know how to offer arguments 123 # when invoking make, to get it to do what you want -- haven't you?? 124 ifeq "$(filter clean,$(MAKECMDGOALS))" "" 125 HOST_CPU := $(strip $(shell ./makefile_hostcpu.exe 2>/dev/null)) 126 ifeq "$(HOST_CPU)" "" 127 HOST_CPU = 386 128 endif 129 endif 130 131 ALIGN ?= $(if $(filter 386,$(HOST_CPU)),-malign-loops=2 -malign-functions=2) 132 # for i386, we're told use: ALIGN=-malign-loops=2 -malign-functions=2 133 134 ### To get debugging, more CC warnings, etc. add the below to CFLAGS: 135 # $(WARNMORE) -g -DPNG_DEBUG=5 136 CFLAGS= $(strip $(MINGW_CCFLAGS) $(addprefix -I,$(ZLIBINC)) \ 137 -Wall -O3 $(ALIGN) -funroll-loops -fomit-frame-pointer \ 138 -DPNG_ZBUF_SIZE=32768 -mcpu=i$(HOST_CPU) $(ASM_CODE)) 139 140 MKDIR = /bin/mkdir -pv 141 RANLIB = ranlib 142 143 LIBNAME = libpng12 144 PNGMAJ = 0 145 PNGDLL = 12 146 PNGMIN = 1.2.3rc6 147 148 INCPATH =$(prefix)/include 149 LIBPATH =$(prefix)/lib 150 BINPATH =$(prefix)/bin 151 MANPATH =$(prefix)/man 152 MAN3PATH=$(MANPATH)/man3 153 MAN5PATH=$(MANPATH)/man5 154 155 # ******************************************************************** 156 # ********* NO USER-SERVICEABLE PARTS BELOW THIS POINT? ********** 157 # ******************************************************************** 158 159 160 PNGVER = $(PNGMAJ).$(PNGMIN) 161 # cosmetic: shortened strings: 162 S =$(SRCDIR) 163 D =$(DESTDIR) 164 165 SHAREDLIB = $(if $(filter undefined,$(origin MINGW)),cyg,lib)png$(PNGDLL).dll 166 STATLIB = libpng.a 167 IMPLIB = libpng.dll.a 168 LIBS = $(SHAREDLIB) $(STATLIB) 169 EXE = .exe 170 171 LDFLAGS = $(strip -L. $(MINGW_LDFLAGS) -lpng $(addprefix -L,$(ZLIBLIB)) -lz) 172 LDSFLAGS = $(strip -shared -L. $(MINGW_LDFLAGS)) 173 ifdef MINGW 174 LDSFLAGS += -Wl,--export-all 175 endif 176 LDEXTRA = -Wl,--warn-once $(addprefix -L,$(ZLIBLIB)) -lz 177 178 179 OBJS = png.o pngset.o pngget.o pngrutil.o pngtrans.o pngwutil.o \ 180 pngread.o pngrio.o pngwio.o pngwrite.o pngrtran.o \ 181 pngwtran.o pngmem.o pngerror.o pngpread.o 182 ifneq "$(findstring -DPNG_USE_PNGGCCRD,$(CFLAGS))" "" 183 OBJS += pnggccrd.o 184 endif 185 186 OBJSDLL = $(OBJS:.o=.pic.o) 187 188 # patterns ------------------------------------------------------------ 189 190 .SUFFIXES: .c .o .pic.o 191 192 %.o : %.c 193 $(CC) -c $(CFLAGS) -o $@ $< 194 %.pic.o : CFLAGS += -DPNG_BUILD_DLL 195 %.pic.o : %.c 196 $(CC) -c $(CFLAGS) -o $@ $< 197 198 # targets ------------------------------------------------------------- 199 200 201 all: build-setup-info all-static all-shared libpng.pc libpng-config 202 203 204 # make this target alone to verify that "make [...] install" 205 # will do what you want/expect before committing yourself. 206 build-setup-info: 207 @echo Building on host CPU: \"$(HOST_CPU)\" ; \ 208 echo VPATH is set to: \"$(VPATH)\"; \ 209 echo prefix is set to: \"$(prefix)\"; \ 210 echo -e INCPATH,LIBPATH, etc. are set to:'\n' \ 211 $(addprefix $(D),$(INCPATH)'\n' $(LIBPATH)'\n' \ $(BINPATH)'\n' $(MANPATH)'\n' $(MAN3PATH)'\n' $(MAN5PATH)'\n')'\n'; 212 213 libpng.pc: scripts/libpng.pc.in 214 @echo -e Making pkg-config file for this libpng installation..'\n' \ 215 using PREFIX=\"$(prefix)\"'\n' 216 cat $(S)/scripts/libpng.pc.in | sed -e s\!@PREFIX@!$(prefix)! | \ 217 sed -e s/-lm// > libpng.pc 218 219 libpng-config: scripts/libpng-config-head.in scripts/libpng-config-body.in 220 @echo -e Making $(LIBNAME) libpng-config file for this libpng \ 221 installation.. using PREFIX=\"$(prefix)\"'\n' 222 ( cat $(S)/scripts/libpng-config-head.in; \ 223 echo prefix=\"$(prefix)\"; \ 224 echo cppflags=\"-I$(INCPATH)/$(LIBNAME)\"; \ 225 echo cflags=\"\"; \ 226 echo ldflags=\"-L$(LIBPATH)\"; \ 227 echo libs=\"-lpng$(PNGDLL) -lz\"; \ 228 cat $(S)/scripts/libpng-config-body.in ) > libpng-config 229 chmod +x libpng-config 230 231 static: all-static 232 shared: all-shared 233 all-static: $(STATLIB) pngtest-stat$(EXE) 234 all-shared: $(SHAREDLIB) pngtest$(EXE) 235 236 pnggccrd.o: pnggccrd.c png.h pngconf.h 237 @echo "" 238 @echo ' You can ignore the single "control reaches end of non-void function"' 239 @echo ' warning and multiple "<variable> defined but not used" warnings:' 240 @echo "" 241 $(CC) -c $(CFLAGS) -o $@ $< 242 243 pnggccrd.pic.o: pnggccrd.c png.h pngconf.h 244 @echo "" 245 @echo ' You can ignore the single "control reaches end of non-void function"' 246 @echo ' warning and multiple "<variable> defined but not used" warnings:' 247 @echo "" 248 $(CC) -c $(CFLAGS) -DPNG_BUILD_DLL -o $@ $< 249 250 $(STATLIB): $(OBJS) 251 ar rc $@ $(OBJS) 252 $(RANLIB) $@ 253 254 $(SHAREDLIB): $(OBJSDLL) 255 $(strip $(CC) $(LDSFLAGS) -o $@ $(OBJSDLL) -L. $(LDEXTRA)) 256 257 pngtest$(EXE): pngtest.pic.o $(SHAREDLIB) 258 $(CC) $(CFLAGS) $< $(LDFLAGS) -o $@ 259 260 pngtest-stat$(EXE): pngtest.o $(STATLIB) 261 $(CC) -static $(CFLAGS) $< $(LDFLAGS) -o $@ 262 263 pngtest.pic.o: pngtest.c 264 $(CC) $(CFLAGS) -c $< -o $@ 265 266 pngtest.o: pngtest.c 267 $(CC) $(CFLAGS) -c $< -o $@ 268 269 test: test-static test-shared 270 271 test-static: pngtest-stat$(EXE) 272 ./pngtest-stat $(S)/pngtest.png 273 274 test-shared: pngtest$(EXE) 275 ./pngtest $(S)/pngtest.png 276 277 install-static: $(STATLIB) install-headers install-man 278 -@if [ ! -d $(D)$(LIBPATH) ]; then $(MKDIR) $(D)$(LIBPATH); fi 279 install -m 644 $(STATLIB) $(D)$(LIBPATH)/$(LIBNAME).a 280 -@rm -f $(D)$(LIBPATH)/$(STATLIB) 281 (cd $(D)$(LIBPATH); ln -sf $(LIBNAME).a $(STATLIB)) 282 283 install-shared: $(SHAREDLIB) libpng.pc libpng-config install-headers install-man 284 -@if [ ! -d $(D)$(LIBPATH) ]; then $(MKDIR) $(D)$(LIBPATH); fi 285 -@if [ ! -d $(D)$(BINPATH) ]; then $(MKDIR) $(D)$(BINPATH); fi 286 -@if [ ! -d $(D)$(LIBPATH)/pkgconfig ]; then \ 287 $(MKDIR) $(D)$(LIBPATH)/pkgconfig; fi 288 -@/bin/rm -f $(D)$(LIBPATH)/pkgconfig/$(LIBNAME).pc 289 -@/bin/rm -f $(D)$(LIBPATH)/pkgconfig/libpng.pc 290 install -m 644 $(IMPLIB) $(D)$(LIBPATH)/$(LIBNAME).dll.a 291 -@rm -f $(D)$(LIBPATH)/$(IMPLIB) 292 (cd $(D)$(LIBPATH); ln -sf $(LIBNAME).dll.a $(IMPLIB)) 293 install -s -m 755 $(SHAREDLIB) $(D)$(BINPATH) 294 install -m 644 libpng.pc $(D)$(LIBPATH)/pkgconfig/$(LIBNAME).pc 295 (cd $(D)$(LIBPATH)/pkgconfig; ln -sf $(LIBNAME).pc libpng.pc) 296 297 install-headers: 298 -@if [ ! -d $(D)$(INCPATH) ]; then \ 299 $(MKDIR) $(D)$(INCPATH); fi 300 -@if [ ! -d $(D)$(INCPATH)/$(LIBNAME) ]; then \ 301 $(MKDIR) $(D)$(INCPATH)/$(LIBNAME); fi 302 -@rm -f $(D)$(INCPATH)/png.h 303 -@rm -f $(D)$(INCPATH)/pngconf.h 304 install -m 644 $(S)/png.h $(S)/pngconf.h $(D)$(INCPATH)/$(LIBNAME) 305 -@rm -f $(D)$(INCPATH)/libpng 306 (cd $(D)$(INCPATH); ln -sf $(LIBNAME) libpng; ln -sf $(LIBNAME)/* .) 307 308 install-man: 309 -@if [ ! -d $(D)$(MAN3PATH) ]; then \ 310 $(MKDIR) $(D)$(MAN3PATH); fi 311 -@if [ ! -d $(D)$(MAN5PATH) ]; then \ 312 $(MKDIR) $(D)$(MAN5PATH); fi 313 install -m 644 $(S)/libpngpf.3 $(S)/libpng.3 $(D)$(MAN3PATH) 314 install -m 644 $(S)/png.5 $(D)$(MAN5PATH) 315 316 install-config: libpng-config 317 -@if [ ! -d $(D)$(BINPATH) ]; then \ 318 mkdir $(D)$(BINPATH); fi 319 -@/bin/rm -f $(D)$(BINPATH)/libpng-config 320 -@/bin/rm -f $(D)$(BINPATH)/$(LIBNAME)-config 321 cp libpng-config $(D)$(BINPATH)/$(LIBNAME)-config 322 chmod 755 $(D)$(BINPATH)/$(LIBNAME)-config 323 (cd $(D)$(BINPATH); ln -sf $(LIBNAME)-config libpng-config) 324 325 # run this to verify that a future `configure' run will pick up the settings 326 # you want. 327 test-config-install: SHELL=/bin/bash 328 test-config-install: 329 @echo -e '\n \ 330 ---------------------------------------------\n' Testing libpng-config functions...'\n' 331 @ for TYRA in LDFLAGS CPPFLAGS CFLAGS LIBS VERSION; \ 332 do \ 333 printf "(%d)\t %10s =%s\n" $$(($$gytiu + 1)) $$TYRA \ 334 "$$($(D)$(BINPATH)/libpng-config `echo --$$TYRA |tr '[:upper:]' '[:lower:]'`)"; \ 335 gytiu=$$(( $$gytiu + 1 )); \ 336 done 337 @echo -e ' \ 338 ---------------------------------------------\n' Testing pkg-config functions...'\n' 339 @if pkg-config --version >/dev/null; then \ 340 export PKG_CONFIG_PATH="`cygpath -au $(D)$(LIBPATH)/pkgconfig`"; \ 341 for TYRA in CFLAGS LIBS MODVERSION; \ 342 do \ 343 printf "(%d)\t %10s =%s\n" $$(($$gytiu + 1)) $$TYRA \ 344 "$$(pkg-config `echo --$$TYRA |tr '[:upper:]' '[:lower:]'` libpng)"; \ 345 gytiu=$$(( $$gytiu + 1 )); \ 346 done; \ 347 else \ 348 echo 'For your information: You do not seem to have "pkg-config" installed'; \ 349 echo 'on your system :-(. See http://www.freedesktop.org/software/pkgconfig/'; \ 350 echo or install "pkg-config" using the Cygwin "setup.exe" utility. ; \ 351 fi 352 @echo -e ' \ 353 ---------------------------------------------\n' \ 354 Finished testing library configuration-data installations. 355 356 357 install: install-static install-shared install-man install-config test-config-install 358 359 clean-o: 360 -@/bin/rm -f *.pic.o *.o 361 362 clean: clean-o 363 -/bin/rm -f $(STATLIB) $(IMPLIB) $(SHAREDLIB) pngtest-stat$(EXE) pngtest$(EXE) \ 364 pngout.png libpng-config libpng.pc makefile_hostcpu.exe TMP_hostcpu_DELETEME.c \ 365 made_cpu_tool.tm~ 366 367 DOCS = ANNOUNCE CHANGES INSTALL KNOWNBUG LICENSE README TODO Y2KINFO 368 writelock: 369 chmod a-w *.[ch35] $(DOCS) scripts/* 370 371 .PHONY: build-setup-info libpng.pc libpng-config test-config-install \ 372 clean clean-o 373 374 375 376 # DO NOT DELETE THIS LINE -- make depend depends on it. 377 378 png.o png.pic.o: png.h pngconf.h png.c 379 pngerror.o pngerror.pic.o: png.h pngconf.h pngerror.c 380 pngrio.o pngrio.pic.o: png.h pngconf.h pngrio.c 381 pngwio.o pngwio.pic.o: png.h pngconf.h pngwio.c 382 pngmem.o pngmem.pic.o: png.h pngconf.h pngmem.c 383 pngset.o pngset.pic.o: png.h pngconf.h pngset.c 384 pngget.o pngget.pic.o: png.h pngconf.h pngget.c 385 pngread.o pngread.pic.o: png.h pngconf.h pngread.c 386 pngrtran.o pngrtran.pic.o: png.h pngconf.h pngrtran.c 387 pngrutil.o pngrutil.pic.o: png.h pngconf.h pngrutil.c 388 pngtrans.o pngtrans.pic.o: png.h pngconf.h pngtrans.c 389 pngwrite.o pngwrite.pic.o: png.h pngconf.h pngwrite.c 390 pngwtran.o pngwtran.pic.o: png.h pngconf.h pngwtran.c 391 pngwutil.o pngwutil.pic.o: png.h pngconf.h pngwutil.c 392 pngpread.o pngpread.pic.o: png.h pngconf.h pngpread.c 393 394 pngtest.o: png.h pngconf.h pngtest.c 395 pngtest-stat.o: png.h pngconf.h pngtest.c 396