# This file is part of "scramble", a filter plugin for Adobe Photoshop # Copyright (C) 2006-2013 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 = Scramble VERSION := $(shell sed -n -E 's/^.*VERSION_STR[[:blank:]]+\"([^"]*)\"/\1/p' version.h) PSAPI = ../adobe_photoshop_cs5_sdk_mac/pluginsdk/photoshopapi CFLAGS += -O2 -W -Wall -Wno-main -Wno-unused-parameter CPPFLAGS += -I$(PSAPI)/pica_sp -I$(PSAPI)/photoshop \ -I../common/adobeplugin -I../common/tt # ---------- source & object files ---------- # where to find .c source files vpath %.c ../common/tt ../common/adobeplugin vpath %.m cocoa # list of source files OBJ_COMMON = main.o process.o ui.o str.o # derive lists of object files, separate for each platform OBJ_OSX := $(addprefix obj/, $(OBJ_COMMON) \ ui_mac.o ui_compat_mac.o ui_cocoa.o ScrambleSettingsController.o ) # ---------- 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 \ $(BUNDLE)/Contents/Resources/ScrambleSettings.nib DISTDMG = dist/$(EXEC)-$(VERSION).dmg $(PLUGIN_OSX) : CPPFLAGS += -DMAC_ENV -DMACMACHO -Dmacintosh \ -I/Developer/Headers/FlatCarbon $(PLUGIN_OSX) : CFLAGS += $(ARCH) $(PLUGIN_OSX) : LDFLAGS += $(ARCH) REZFLAGS = $(ARCH) # ---------- targets ---------- .PHONY : thin cs2 cs3 cs5 dll clean dmg zip # targets for OS X Mach-O (bundle) format runtimes: # 'thin' - single architecture, of build host. Won't build on any recent OS X. # 'cs2' - PowerPC only # 'cs3' - Universal (PPC & Intel architectures; CS3 and CS4) # 'cs5' - 32-bit and 64-bit Intel. Default target. cs5 cs2 cs3 thin : $(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 # 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 # Min system for CS5: Mac OS X v.10.5.8 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 $(BUNDLE) : mkdir -p $@ /Developer/Tools/SetFile -a B $@ $(BUNDLE)/Contents : $(BUNDLE) mkdir -p $@ $(BUNDLE)/Contents/Resources $(BUNDLE)/Contents/MacOS : $(BUNDLE)/Contents mkdir -p $@ # insert correct executable name and version string in bundle's Info.plist $(BUNDLE)/Contents/Info.plist : Info.plist.tmpl version.h $(BUNDLE)/Contents sed -e s/%VERSION_STR%/$(VERSION)/ -e s/%EXEC%/$(EXEC)/ $< > $@ $(BUNDLE)/Contents/PkgInfo : $(BUNDLE)/Contents printf 8BFM8BIM > $@ # Copy the nib folders, without Svn metadata $(BUNDLE)/Contents/Resources/%.nib : cocoa/%.nib mkdir -p $@ cp $% %' > $@ # ---------- compile rules ---------- obj/%.o : %.c ; $(CC) -o $@ -c $< $(CFLAGS) $(CPPFLAGS) obj/%.o : %.m ; $(CC) -o $@ -c $< $(CFLAGS) $(CPPFLAGS) # compile Mac resources (into data fork of .rsrc file) $(PLUGIN_RSRC) : PiPL_macho.r ui_mac.r ui.h version.h $(BUNDLE)/Contents/Resources /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) : exports.exp $(OBJ_OSX) $(BUNDLE)/Contents/MacOS $(CC) -bundle -o $@ $(OBJ_OSX) \ $(LDFLAGS) -exported_symbols_list exports.exp \ -framework Carbon -framework System -framework AppKit ls -l $@ file $@ # --------------------