# This file is part of TIFFlib Format, a File Format plugin for Adobe Photoshop # Copyright (C) 2005-6 Toby Thain, toby@telegraphics.com.au # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # GNU Makefile # builds Win32 DLL and CS2/Mac Mach-O plugin bundle # by Toby Thain # ---------- variables & flags ---------- EXEC = TIFFlib # uses OS X's sed (breaks on Linux): #VERSION = $(shell sed -n -E 's/^.*VERSION_STR[[:blank:]]+\"([^"]*)\"/\1/p' version.h) # uses Perl, so is portable between OS X and Linux: VERSION = $(shell perl -n -e 'm/^.*VERSION_STR[[:blank:]]+\"([^"]*)\"/ && print $$1;' version.h) MINGW_CC = i386-mingw32msvc-gcc DLLWRAP = i386-mingw32msvc-dllwrap WINDRES = i386-mingw32msvc-windres PSAPI = "../Adobe Photoshop CS3 Public Beta SDK/photoshopapi" # in CS3(CS2?), PiPL FormatFlags added a 'fmtCannotCreateThumbnail' bit # older SDKs don't have this, so comment out this define if using them REZFLAGS = -d CS3SDK LIBJPEG = ../jpeg-6b LIBJPEGSRC = \ jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c \ jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c \ jcphuff.c jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c \ jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c \ jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c jdphuff.c \ jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c \ jfdctint.c jidctflt.c jidctfst.c jidctint.c jidctred.c jquant1.c \ jquant2.c jutils.c jmemmgr.c \ jmemansi.c LIBTIFF = ../tiff-3.8.2/libtiff LIBTIFFSRC = \ tif_dirinfo.c tif_jpeg.c tif_predict.c \ tif_dirread.c tif_luv.c tif_print.c tif_warning.c \ tif_dirwrite.c tif_lzw.c tif_read.c \ tif_aux.c tif_dumpmode.c tif_strip.c \ tif_close.c tif_error.c tif_next.c tif_swab.c tif_write.c \ tif_codec.c tif_extension.c tif_thunder.c tif_zip.c \ tif_color.c tif_fax3.c tif_fax3sm.c tif_open.c tif_tile.c \ tif_compress.c tif_flush.c tif_packbits.c \ tif_dir.c tif_getimage.c tif_pixarlog.c tif_version.c ZLIB = ../zlib-1.2.3 ZLIBSRC = \ adler32.c deflate.c infback.c inftrees.c uncompr.c \ compress.c inffast.c zutil.c \ crc32.c inflate.c trees.c $(LIBTIFF)/tif_config.h : $(LIBTIFF)/../configure $(LIBJPEG)/libjpeg.a cd $(LIBTIFF)/..; \ CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" \ ./configure --disable-dependency-tracking \ --with-zlib-include-dir=$(ZLIB) \ --with-jpeg-include-dir=$(LIBJPEG) \ --with-jpeg-lib-dir=$(LIBJPEG) win32/tiffconf.h : win32/tif_config.h ln $< $@ CFLAGS += -Wall -O2 CPPFLAGS += -I$(PSAPI)/Pica_sp -I$(PSAPI)/Photoshop -I$(PSAPI)/General \ -I../common/adobeplugin -I../common/tt obj/tif_%.o : CPPFLAGS += -I$(LIBJPEG) -I$(ZLIB) obj_w32/tif_%.o : CPPFLAGS += -I$(LIBJPEG) -I$(ZLIB) # libtiff won't correctly configure unless an actual jpeg library # has been built: $(LIBJPEG)/libjpeg.a : $(LIBJPEG)/configure cd $(LIBJPEG); \ CFLAGS="$(CFLAGS)" LDFLAGS="$(LDFLAGS)" ./configure; \ $(MAKE) libjpeg.a #$(ZLIB)/libz.a : $(ZLIB)/configure # cd $(ZLIB) && ./configure && $(MAKE) # ---------- source & object files ---------- # where to find .c source files vpath %.c ../common/tt ../common/adobeplugin $(LIBTIFF) $(ZLIB) $(LIBJPEG) # list of source files SRC_COMMON = main.c read.c write.c str.c util.c tif_support.c options.c ui.c \ $(LIBTIFFSRC) $(LIBJPEGSRC) $(ZLIBSRC) SRC_OSX = dbg_mac.c ui_compat_mac.c ui_mac.c tif_support_mac.c SRC_W32 = dbg_win.c ui_compat_win.c ui_win.c tif_support_win.c dllmain.c # derive lists of object files, separate for each platform OBJ_OSX := $(patsubst %.c, obj/%.o, $(SRC_COMMON) $(SRC_OSX)) OBJ_W32 := $(patsubst %.c, obj_w32/%.o, $(SRC_COMMON) $(SRC_W32)) obj_w32/res.o # don't try to build anything that depends on TIFF library until its # headers are configured. $(OBJ_OSX) : $(LIBTIFF)/tif_config.h $(OBJ_W32) : win32/tiffconf.h # ---------- executables ---------- # parts of Mac OS X plugin bundle to build # Adobe's plugs use .plugin extension BUNDLE = $(EXEC).plugin PLUGIN_OSX = $(BUNDLE)/Contents/MacOS/$(EXEC) PLUGIN_RSRC = $(BUNDLE)/Contents/Resources/$(EXEC).rsrc PLUGIN_PARTS = $(PLUGIN_OSX) $(PLUGIN_RSRC) $(BUNDLE)/Contents/Info.plist $(BUNDLE)/Contents/PkgInfo DISTDMG = dist/$(EXEC)-$(VERSION).dmg $(PLUGIN_OSX) : CPPFLAGS += -DMAC_ENV -Dmacintosh \ -I/Developer/Headers/FlatCarbon -I$(LIBTIFF) $(PLUGIN_OSX) : CFLAGS += -isysroot /Developer/SDKs/MacOSX10.4u.sdk $(ARCH) $(PLUGIN_OSX) : LDFLAGS += -Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk $(ARCH) $(PLUGIN_RSRC) : REZFLAGS += $(ARCH) # Win32 plugin DLL to build PLUGIN_W32 = $(EXEC).8bi DISTZIP = dist/$(EXEC)-$(VERSION)-win.zip $(PLUGIN_W32) : CPPFLAGS += -DWIN_ENV -Iwin32 -I$(LIBTIFF) -I$(LIBJPEG) -I$(ZLIB) # ---------- targets ---------- # build everything all : dll osx dll : $(PLUGIN_W32) zip : $(DISTZIP) # create a ZIP file of the distribution kit $(DISTZIP) : $(PLUGIN_W32) dist/README.html dist/gpl.html zip -j -9 $@ $^ @ ls -l $@ PLUGIN_PARTS = $(PLUGIN_OSX) $(PLUGIN_RSRC) $(BUNDLE)/Contents/Info.plist $(BUNDLE)/Contents/PkgInfo fat osx : $(PLUGIN_PARTS) # See: http://developer.apple.com/documentation/Porting/Conceptual/PortingUnix/compiling/chapter_4_section_3.html#//apple_ref/doc/uid/TP40002850-BAJCFEBA fat : ARCH = -arch ppc -arch i386 dmg : $(DISTDMG) # create an Apple disk image (dmg) archive of the distribution kit $(DISTDMG) : $(PLUGIN_PARTS) dist/README.html dist/gpl.html @ DIR=`mktemp -d $(EXEC).XXXX`; \ cp -Rp dist/README.html dist/gpl.html $(BUNDLE) $$DIR; \ hdiutil create -srcfolder $$DIR -ov -volname "$(EXEC) $(VERSION)" $@; \ rm -fr $$DIR @ ls -l $@ $(BUNDLE) : mkdir -p $@ /Developer/Tools/SetFile -a B $@ $(BUNDLE)/Contents/PkgInfo : $(BUNDLE) mkdir -p $(dir $@) echo -n 8BIF8BIM > $@ # insert correct executable name and version string in bundle's Info.plist $(BUNDLE)/Contents/Info.plist : Info.plist $(BUNDLE) version.h mkdir -p $(dir $@) sed -e s/VERSION_STR/$(VERSION)/ -e s/EXEC/$(EXEC)/ $< > $@ clean : rm -fr $(OBJ_OSX) $(OBJ_W32) $(PLUGIN_W32) $(BUNDLE) \ $(LIBJPEG)/libjpeg.a $(LIBTIFF)/tif_config.h make -C $(LIBJPEG) clean make -C $(LIBTIFF) clean make -C $(ZLIB) clean dist/gpl.html : curl http://www.gnu.org/licenses/gpl.html \ | sed -e 's%% %' \ -e 's%% %' > $@ # ---------- compile rules ---------- obj/%.o : %.c $(CC) -o $@ -c $< $(CFLAGS) $(CPPFLAGS) obj_w32/%.o : %.c $(MINGW_CC) -o $@ -c $< $(CFLAGS) $(CPPFLAGS) # note dependencies on version.h: obj_w32/res.o : PiPL.rc ui_win.rc ui.h version.h $(WINDRES) -i $< -o $@ obj_w32/ui_win.o : ui.h version.h # compile Mac resources (into data fork of .rsrc file) # HACK: naughty case insensitive trick, to skip compiling PiPL_common.R # directly yet keep it as a prerequisite $(PLUGIN_RSRC) : $(BUNDLE) PiPL_macho.r PiPL_common.R ui_mac.r version.h mkdir -p $(dir $@) /Developer/Tools/Rez -o $@ -useDF $(REZFLAGS) $(filter %.r,$^) \ -i /Developer/Headers/FlatCarbon \ -i $(PSAPI)/Resources \ -i $(PSAPI)/Photoshop @ ls -l $@ # ---------- link rules ---------- # link OS X Mach-O executable $(PLUGIN_OSX) : $(BUNDLE) exports.exp $(OBJ_OSX) mkdir -p $(dir $@) $(CC) -bundle -o $@ $(OBJ_OSX) \ -exported_symbols_list exports.exp \ -framework Carbon -framework System @ ls -l $@ # link Win32 DLL $(PLUGIN_W32) : exports.def $(OBJ_W32) $(DLLWRAP) -o $@ -def $^ -mwindows -s @ ls -l $@ # --------------------