Release/Makefile
author Evan Schoenberg
Thu Oct 09 23:44:30 2008 +0000 (2008-10-09)
branchadium-1.3
changeset 182 e41e547babce
parent 176 a9cdab1f5fb9
child 183 73b01abefcbf
permissions -rw-r--r--
Versioned to 1.3.2
     1 ###########
     2 # What to do before running this script:
     3 # - openUp needs to be installed.
     4 # - Set VERSION, BUILD_IN_DEBUG_MODE, BETA, and OFFICIAL_BUILD below.
     5 #    * The Adium plists will automatically updated to match these values.
     6 #    * BETA should be TRUE for all beta builds and FALSE for all releases.
     7 #      It primarily affects the appcast used by Adium for detecting updates.
     8 #    * BUILD_IN_DEBUG_MODE should be set to FALSE for the last beta
     9 #      in addition to the release itself. If FALSE, debug logging is disabled
    10 #      and certain space optimizations for nibs and strings are done which
    11 #      also prevent modification.
    12 #    * OFFICIAL_BUILD is TRUE for the benefit of our Adium build machine, which signs 
    13 #      official release builds. When building a release yourself, set this to FALSE, 
    14 #      since you don't have the Adium certificate on your machine.
    15 #
    16 # How to run this script:
    17 # - make all
    18 ###########
    19 
    20 VERSION=1.3.2
    21 BUILD_IN_DEBUG_MODE?=FALSE
    22 BETA?=FALSE
    23 OFFICIAL_BUILD?=TRUE
    24 
    25 # Always builds in debug mode.
    26 NIGHTLY?=FALSE
    27 
    28 ###########
    29 # To release!
    30 # Releasing requires cachefly access and adiumx.com access.
    31 #
    32 # First upload to cachefly. If you don't have access and need to do a release, get with Evan or Eric.
    33 # Triggering the version checker once the release is up:
    34 # 1) Build Adium
    35 # 2) Get the number out of the 'buildnum' file in Adium.app/Contents/Resources
    36 # 3) Paste that number into the appropriate place (adium version or adium-beta version, depending on which you're triggering) in the version.plist file in our public_html folder.  *** (2) and (3) are to support the old version checker, in Adium 0.8x and earlier ***
    37 # 4) Update and commit the appcast.xml file in the adium checkout root
    38 # 5) Run the appcast update php script.
    39 ###########
    40 
    41 ###########
    42 # No need for changes below this point
    43 ###########
    44 
    45 ###########
    46 # Variables
    47 ###########
    48 SRC_DIR=..
    49 BUILD_DIR=build
    50 ART_DIR=Artwork
    51 ADIUM_DIR=$(BUILD_DIR)/Adium
    52 RELEASE_NAME=Adium_$(VERSION)
    53 VERSION_ESCAPED=$(VERSION)
    54 RELEASE_NAME_ESCAPED=Adium_$(VERSION_ESCAPED)
    55 TARBALL_DIR=adium-$(VERSION)
    56 
    57 ifeq ($(NIGHTLY),TRUE)
    58 	VERSION_ESCAPED:=$(VERSION_ESCAPED)\`date +%Y%m%d\`
    59 	VERSION:=$(VERSION)`date +%Y%m%d`
    60 	BUILD_IN_DEBUG_MODE=TRUE
    61 	BUILDFLAGS+="ADIUM_CFLAGS=-DNIGHTLY_RELEASE"
    62 endif
    63 
    64 ifeq ($(BUILD_IN_DEBUG_MODE),TRUE)
    65     BUILDSTYLE=Deployment-Debug
    66 else
    67     BUILDSTYLE=Deployment
    68 endif
    69 
    70 BUILDFLAGS+="BUILDCONFIGURATION=$(BUILDSTYLE)"
    71 ifeq ($(BETA),TRUE)
    72 	BUILDFLAGS+="ADIUM_CFLAGS=-DBETA_RELEASE"
    73 endif
    74 
    75 PRODUCT_DIR=$(shell defaults read com.apple.Xcode PBXProductDirectory 2> /dev/null)
    76 
    77 ifeq ($(strip $(PRODUCT_DIR)),)
    78 	ADIUM_BUILD_DIR=$(SRC_DIR)/build/$(BUILDSTYLE)
    79 else
    80 	TARGET_BUILD_DIR=$(PRODUCT_DIR)/$(BUILDSTYLE)
    81 	ADIUM_BUILD_DIR=$(TARGET_BUILD_DIR)
    82 endif
    83 
    84 PLIST_DIR=`pwd`/../Plists
    85 ADIUM_PLIST=$(PLIST_DIR)/Info
    86 
    87 ###########
    88 # Targets
    89 ###########
    90 .PHONY: all all-withlocalchanges all-withlocalchanges-noclean all-nopackage-noclean all-nightly update assertnochanges assertnoconflicts version compile clean release source prepare-release-bundle createfolder diskimage nightly tarball
    91 
    92 all: update assertnochanges version clean compile release
    93 all-withlocalchanges: update assertnoconflicts version clean compile release
    94 all-withlocalchanges-noclean: update assertnoconflicts version compile release
    95 
    96 #doesn't bother putting things in a dmg
    97 #useful for builds not intended for distribution
    98 all-nopackage-noclean: update assertnoconflicts version compile createfolder prepare-release-bundle
    99 
   100 update:
   101 	svn update $(SRC_DIR)
   102 
   103 assertnochanges: assertnoconflicts
   104 	if [[ 0 -ne `svn st $(SRC_DIR) | egrep --invert-match '\?|Info\.plist' | wc -l` ]]; then \
   105 		echo 'You have local changes. Please do not build releases from an unclean checkout. You must revert the changes, commit them, or check out another working copy and build from that.' 1>&2; \
   106 		exit 1; \
   107 	fi
   108 assertnoconflicts:
   109 	if [[ 0 -ne `svn st $(SRC_DIR) | egrep '^C' | wc -l` ]]; then \
   110 		echo 'You have conflicts in your checkout. You will not be able to build until these are resolved. Also, remember that even after you have fixed all conflict marks, you must use "svn resolved"; otherwise, svn will still believe the files are conflicted.' 1>&2; \
   111 		exit 2; \
   112 	fi
   113 
   114 version:
   115 	@# update the plists
   116 	defaults write $(ADIUM_PLIST) CFBundleGetInfoString "$(VERSION), Copyright 2001-2008 The Adium Team"
   117 	defaults write $(ADIUM_PLIST) CFBundleVersion "$(VERSION)"
   118 	defaults write $(ADIUM_PLIST) CFBundleShortVersionString "$(VERSION)"
   119 	plutil -convert xml1 $(ADIUM_PLIST).plist
   120 
   121 compile:
   122 	$(MAKE) $(BUILDFLAGS) -C $(SRC_DIR)
   123 
   124 testcompile:
   125 	$(MAKE) $(BUILDFLAGS) -C $(SRC_DIR)
   126 
   127 clean:
   128 	rm -rf $(BUILD_DIR)
   129 	$(MAKE) $(BUILDFLAGS) -C $(SRC_DIR) clean
   130 
   131 release: createfolder prepare-release-bundle diskimage
   132 
   133 prepare-release-bundle:
   134 	@# Convert all nibs to the smaller binary format
   135 	@echo Converting nibs to binary format...
   136 	find $(BUILD_DIR) -name keyedobjects.nib -print0 | xargs -0 plutil -convert binary1
   137 
   138 	@# delete unneeded nib files for non-beta builds
   139 	@echo Cleaning Adium.app for release
   140 ifeq ($(BUILD_IN_DEBUG_MODE),FALSE)
   141 	find $(BUILD_DIR) \( -name classes.nib -or -name info.nib \) -type f -delete
   142 endif
   143 	
   144 	@# delete svn  and backup files
   145 	find $(BUILD_DIR) -name ".svn" -type d -exec rm -rf {} \; -prune
   146 	find $(BUILD_DIR) \( -name "*~" -or -name .DS_Store \) -type f -delete
   147 
   148 	@# sign the executable
   149 ifeq ($(OFFICIAL_BUILD),TRUE)
   150 	if [ -e ~/adium-password ]; then \
   151 		security unlock-keychain -p `cat ~/adium-password`; \
   152 	fi
   153 	codesign -v -s Adium $(ADIUM_DIR)/Adium.app/Contents/MacOS/Adium
   154 endif
   155 
   156 createfolder:
   157 	@# clean build directory
   158 	rm -rf $(BUILD_DIR)
   159 	mkdir $(BUILD_DIR)
   160 
   161 	mkdir $(ADIUM_DIR)
   162 	
   163 	@# copy the app
   164 	cp -R $(ADIUM_BUILD_DIR)/Adium.app $(ADIUM_DIR)
   165 
   166 	@# copy the text files
   167 	cp $(SRC_DIR)/ChangeLogs/Changes.txt $(ADIUM_DIR)
   168 	cp $(SRC_DIR)/License.txt $(ADIUM_DIR)
   169 	
   170 	@# symlink /Applications
   171 	./mkalias -r /Applications $(ADIUM_DIR)/Applications
   172 
   173 diskimage:
   174 	rm "$(BUILD_DIR)/$(RELEASE_NAME).dmg" || true
   175 	@# make Adium disk image
   176 	mkdir -p $(ADIUM_DIR)/.background
   177 	cp $(ART_DIR)/dmgBackground.png $(ADIUM_DIR)/.background
   178 
   179 	./ensureCustomIconsExtracted $(ART_DIR)
   180 	./make-diskimage.sh $(BUILD_DIR)/$(RELEASE_NAME).dmg $(ADIUM_DIR) "Adium X $(VERSION)" dmg_adium.scpt $(ART_DIR)
   181 	
   182 	@echo Build finished. `md5 $(BUILD_DIR)/$(RELEASE_NAME_ESCAPED).dmg`
   183 
   184 #This is what nightly builds use. Does not update because buildbot does.
   185 nightly: assertnochanges version clean compile release
   186 	echo $(RELEASE_NAME) > $(BUILD_DIR)/latest
   187 	(svn info | perl -nle 's/Revision: ([0-9]+)/$$1/g and print "r".$$_') >> $(BUILD_DIR)/latest
   188 	md5 -q $(BUILD_DIR)/$(RELEASE_NAME).dmg > $(BUILD_DIR)/$(RELEASE_NAME).dmg.md5sum
   189 
   190 tarball:
   191 	svn export -q --non-interactive $(SRC_DIR) $(TARBALL_DIR)
   192 	tar zcf $(TARBALL_DIR).tgz $(TARBALL_DIR)
   193 	rm -rf $(TARBALL_DIR)