# This file is part of "5_6_5", a filter plugin for Adobe Photoshop # Copyright (C) 2004-2011 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 = quantise_rgb VARIANTS = 565 555 666 777 VERSION := $(shell perl -n -e 'm/^\#.+VERSION_STR\s+\"([^"]*)\"/ && print $$1;' version.h) MINGW_CC = i386-mingw32msvc-gcc DLLWRAP = i386-mingw32msvc-dllwrap WINDRES = i386-mingw32msvc-windres PSAPI = "../adobe_photoshop_cs5_sdk_mac/photoshopapi" CFLAGS += -O2 -W -Wall -Wno-main -Wno-unused-parameter CPPFLAGS += -I$(PSAPI)/pica_sp -I$(PSAPI)/photoshop -I$(PSAPI)/general \ -I../common/adobeplugin -I../common/tt # ---------- source & object files ---------- # where to find .c source files vpath %.c ../common/tt ../common/adobeplugin vpath %.m cocoa # object files, separate for each platform OBJ_OSX := $(addprefix obj/, \ ui_mac.o ui_compat_mac.o ui_cocoa.o dbg_mac.o str.o ) OBJ_W32 := $(addprefix obj_w32/, \ ui_win.o ui_compat_win.o dbg_win.o compat_win.o dllmain.o str.o ) # ---------- executables ---------- # parts of Mac OS X plugin bundle to build # Adobe's plugs use .plugin extension BUNDLE := $(addsuffix .plugin, $(VARIANTS)) PLUGIN_OSX := $(addsuffix .plugin/Contents/MacOS/$(EXEC), $(VARIANTS)) PLUGIN_RSRC := $(addsuffix .plugin/Contents/Resources/$(EXEC).rsrc, $(VARIANTS)) PLUGIN_PLIST := $(addsuffix .plugin/Contents/Info.plist, $(VARIANTS)) PLUGIN_PKGINFO := $(addsuffix .plugin/Contents/PkgInfo, $(VARIANTS)) PLUGIN_PARTS = $(PLUGIN_OSX) $(PLUGIN_RSRC) $(PLUGIN_PLIST) $(PLUGIN_PKGINFO) DISTDMG = dist/$(EXEC)-$(VERSION).dmg $(PLUGIN_OSX) : CFLAGS += $(ARCH) $(PLUGIN_OSX) : LDFLAGS += $(ARCH) $(PLUGIN_OSX) : CPPFLAGS += -DMAC_ENV -DMACMACHO -Dmacintosh \ -I/Developer/Headers/FlatCarbon # Win32 plugin DLL to build PLUGIN_W32 := $(addsuffix .8bf, $(VARIANTS)) DISTZIP = dist/$(EXEC)-$(VERSION)-win.zip $(PLUGIN_W32) : CPPFLAGS += -DWIN_ENV # ---------- targets ---------- .PHONY : thin cs2 cs3 cs5 clean dmg dll zip # targets for OS X Mach-O (bundle) format runtimes: # 'thin' - single architecture, of build host # 'cs2' - PowerPC only # 'cs3' - Universal (PPC & Intel architectures; CS3 and CS4) # 'cs5' - 32-bit and 64-bit Intel thin cs2 cs3 cs5 : $(PLUGIN_PARTS) # Min system for CS2: Mac OS X v.10.2.8 cs2 : ARCH = -arch ppc cs2 : CFLAGS += -isysroot /Developer/SDKs/MacOSX10.2.8.sdk -mmacosx-version-min=10.2 cs2 : LDFLAGS += -Wl,-syslibroot,/Developer/SDKs/MacOSX10.2.8.sdk -mmacosx-version-min=10.2 # See: http://developer.apple.com/documentation/Porting/Conceptual/PortingUnix/compiling/chapter_4_section_3.html#//apple_ref/doc/uid/TP40002850-BAJCFEBA # gcc 4.2 (OS X 10.6) has trouble building the universal plugin: # Min system for CS3: Mac OS X v.10.4.8 cs3 : CC = /usr/bin/gcc-4.0 cs3 : ARCH = -arch ppc -arch i386 cs3 : CFLAGS += -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4 cs3 : LDFLAGS += -Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4 cs5 : ARCH = -arch i386 -arch x86_64 cs5 : CFLAGS += -isysroot /Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 cs5 : LDFLAGS += -Wl,-syslibroot,/Developer/SDKs/MacOSX10.5.sdk -mmacosx-version-min=10.5 REZFLAGS += $(ARCH) $(BUNDLE) : mkdir -p $@ /Developer/Tools/SetFile -a B $@ # insert correct executable name and version string in bundle's Info.plist $(PLUGIN_PLIST) : Info.plist version.h mkdir -p $(dir $@) sed -e s/VERSION_STR/$(VERSION)/ -e s/EXEC/$(EXEC)/ $< > $@ $(PLUGIN_PKGINFO) : mkdir -p $(dir $@) printf 8BFM8BIM > $@ clean : rm -fr *.[ox] obj/*.o obj_w32/*.o $(PLUGIN_W32) $(BUNDLE) temp dmg : $(DISTDMG) # create an Apple disk image (dmg) archive of the distribution kit $(DISTDMG) : $(PLUGIN_PARTS) dist/README dist/COPYING @ DIR=`mktemp -d $(EXEC)-XXXX`; \ cp -Rp dist/README dist/COPYING $(BUNDLE) $$DIR; \ hdiutil create -srcfolder $$DIR -ov -volname "$(EXEC) $(VERSION)" \ -imagekey zlib-level=9 -fs HFS+ $@; \ rm -fr $$DIR @ ls -l $@ dll : $(PLUGIN_W32) zip : $(DISTZIP) $(DISTZIP) : $(PLUGIN_W32) dist/README dist/COPYING zip -j -9 -r $@ $^ ls -l $@ 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/%.o : %.m ; $(CC) -o $@ -c $< $(CFLAGS) $(CPPFLAGS) obj/main_%.o : main.c ; $(CC) -o $@ -c $< $(CFLAGS) $(CPPFLAGS) obj_w32/%.o : %.c $(MINGW_CC) -o $@ -c $< $(CFLAGS) $(CPPFLAGS) obj_w32/main_%.o : main.c $(MINGW_CC) -o $@ -c $< $(CFLAGS) $(CPPFLAGS) # note dependencies on version.h: obj_w32/res_%.o : PiPL_%.rc version.h $(WINDRES) -o $@ -i $< $(CPPFLAGS) obj/main_565.o obj_w32/main_565.o : CPPFLAGS += -DRBITS=5 -DGBITS=6 -DBBITS=5 obj/main_555.o obj_w32/main_555.o : CPPFLAGS += -DRBITS=5 -DGBITS=5 -DBBITS=5 obj/main_666.o obj_w32/main_666.o : CPPFLAGS += -DRBITS=6 -DGBITS=6 -DBBITS=6 obj/main_777.o obj_w32/main_777.o : CPPFLAGS += -DRBITS=7 -DGBITS=7 -DBBITS=7 565.plugin/Contents/Resources/$(EXEC).rsrc : REZFLAGS += -d PLUGIN_NAME=\"565\" 555.plugin/Contents/Resources/$(EXEC).rsrc : REZFLAGS += -d PLUGIN_NAME=\"555\" 666.plugin/Contents/Resources/$(EXEC).rsrc : REZFLAGS += -d PLUGIN_NAME=\"666\" 777.plugin/Contents/Resources/$(EXEC).rsrc : REZFLAGS += -d PLUGIN_NAME=\"777\" # compile Mac resources (into data fork of .rsrc file) $(PLUGIN_RSRC) : PiPL_macho.r ui_mac.r ui.h 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/Contents/MacOS/$(EXEC) : exports.exp obj/main_%.o $(OBJ_OSX) mkdir -p $(dir $@) $(CC) -bundle -o $@ $(filter %.o, $^) $(LDFLAGS) \ -exported_symbols_list exports.exp \ -framework Carbon -framework System -framework AppKit ls -l $@ file $@ # link Win32 DLL %.8bf : exports.def obj_w32/main_%.o $(OBJ_W32) obj_w32/res_%.o $(DLLWRAP) -o $@ -def $^ -mwindows -s ls -l $@ # --------------------