Permalink
Find file
Fetching contributors…
Cannot retrieve contributors at this time
165 lines (147 sloc) 6.96 KB
#
# Creation of bundles
#
# The revision is needed for the bundle name and creating an OSX application bundle.
# Detect the revision
VERSIONS := $(shell AWK="$(AWK)" "$(ROOT_DIR)/findversion.sh")
REV := $(shell echo "$(VERSIONS)" | cut -f 1 -d' ')
SETFILE := $(shell for f in /usr/bin/SetFile /Developer/Tools/SetFile /Developer/usr/bin/SetFile ` which SetFile ` ; do if [ -x "$$f" ] ; then echo "$$f" ; break ; fi ; done )
# Make sure we have something in REV
ifeq ($(REV),)
REV := norev000
endif
ifndef BUNDLE_NAME
BUNDLE_NAME = opendune-custom-$(REV)-$(OS)
endif
ifndef VOLUME_NAME
VOLUME_NAME = "OpenDUNE $(REV)"
MOUNT_DIR = /Volumes/$(VOLUME_NAME)
endif
# An OSX application bundle needs the data files, lang files and OpenDUNE executable in a different location.
ifdef OSXAPP
OPENDUNE_DIR= $(BUNDLE_DIR)/$(OSXAPP)/Contents/MacOS
else
OPENDUNE_DIR= $(BUNDLE_DIR)
endif
bundle: all
@echo '[BUNDLE] Constructing bundle'
$(Q)rm -rf "$(BUNDLE_DIR)"
$(Q)mkdir -p "$(BUNDLE_DIR)"
$(Q)mkdir -p "$(OPENDUNE_DIR)"
ifdef OSXAPP
$(Q)mkdir -p "$(BUNDLE_DIR)/$(OSXAPP)/Contents/Resources"
$(Q)echo "APPL????" > "$(BUNDLE_DIR)/$(OSXAPP)/Contents/PkgInfo"
$(Q)$(ROOT_DIR)/os/macosx/plistgen.sh "$(BUNDLE_DIR)/$(OSXAPP)" "$(REV)"
$(Q)cp "$(ROOT_DIR)/os/macosx/opendune.icns" "$(BUNDLE_DIR)/$(OSXAPP)/Contents/Resources"
endif
$(Q)cp "$(BIN_DIR)/$(OPENDUNE)" "$(OPENDUNE_DIR)/"
$(Q)cp "$(ROOT_DIR)/README.txt" "$(BUNDLE_DIR)/"
$(Q)cp "$(ROOT_DIR)/COPYING" "$(BUNDLE_DIR)/"
$(Q)cp "$(ROOT_DIR)/enhancement.txt" "$(BUNDLE_DIR)/"
$(Q)cp "$(BIN_DIR)/opendune.ini.sample" "$(BUNDLE_DIR)/"
ifeq ($(OS), UNIX)
$(Q)cp "$(ROOT_DIR)/os/png_icon/opendune_32x32.png" "$(BUNDLE_DIR)/$(BINARY_NAME).png"
endif
ifeq ($(OPENDUNE), opendune.exe)
$(Q)unix2dos "$(BUNDLE_DIR)/README.txt" "$(BUNDLE_DIR)/COPYING" "$(BUNDLE_DIR)/enhancement.txt"
$(Q)unix2dos "$(BUNDLE_DIR)/opendune.ini.sample"
endif
ifeq ($(OS), TOS)
$(Q)cp "$(ROOT_DIR)/README.atari" "$(BUNDLE_DIR)/"
$(Q)unix2dos "$(BUNDLE_DIR)/README.txt" "$(BUNDLE_DIR)/README.atari" "$(BUNDLE_DIR)/COPYING" "$(BUNDLE_DIR)/enhancement.txt"
$(Q)unix2dos "$(BUNDLE_DIR)/opendune.ini.sample"
endif
### Packing the current bundle into several compressed file formats ###
#
# Zips & dmgs do not contain a root folder, i.e. they have files in the root of the zip/dmg.
# gzip, bzip2 and lha archives have a root folder, with the same name as the bundle.
#
# One can supply a custom name by adding BUNDLE_NAME:=<name> to the make command.
#
bundle_zip: bundle
@echo '[BUNDLE] Creating $(BUNDLE_NAME).zip'
$(Q)mkdir -p "$(BUNDLES_DIR)"
$(Q)cd "$(BUNDLE_DIR)" && zip -r $(shell if test -z "$(VERBOSE)"; then echo '-q'; fi) "$(BUNDLES_DIR)/$(BUNDLE_NAME).zip" .
bundle_7z: bundle
@echo '[BUNDLE] Creating $(BUNDLE_NAME).7z'
$(Q)mkdir -p "$(BUNDLES_DIR)"
$(Q)cd "$(BUNDLE_DIR)" && 7z a "$(BUNDLES_DIR)/$(BUNDLE_NAME).7z" .
bundle_gzip: bundle
@echo '[BUNDLE] Creating $(BUNDLE_NAME).tar.gz'
$(Q)mkdir -p "$(BUNDLES_DIR)/.gzip/$(BUNDLE_NAME)"
$(Q)cp -R "$(BUNDLE_DIR)/"* "$(BUNDLES_DIR)/.gzip/$(BUNDLE_NAME)/"
$(Q)cd "$(BUNDLES_DIR)/.gzip" && tar -zc$(shell if test -n "$(VERBOSE)"; then echo 'v'; fi)f "$(BUNDLES_DIR)/$(BUNDLE_NAME).tar.gz" "$(BUNDLE_NAME)"
$(Q)rm -rf "$(BUNDLES_DIR)/.gzip"
bundle_bzip2: bundle
@echo '[BUNDLE] Creating $(BUNDLE_NAME).tar.bz2'
$(Q)mkdir -p "$(BUNDLES_DIR)/.bzip2/$(BUNDLE_NAME)"
$(Q)cp -R "$(BUNDLE_DIR)/"* "$(BUNDLES_DIR)/.bzip2/$(BUNDLE_NAME)/"
$(Q)cd "$(BUNDLES_DIR)/.bzip2" && tar -jc$(shell if test -n "$(VERBOSE)"; then echo 'v'; fi)f "$(BUNDLES_DIR)/$(BUNDLE_NAME).tar.bz2" "$(BUNDLE_NAME)"
$(Q)rm -rf "$(BUNDLES_DIR)/.bzip2"
bundle_lzma: bundle
@echo '[BUNDLE] Creating $(BUNDLE_NAME).tar.lzma'
$(Q)mkdir -p "$(BUNDLES_DIR)/.lzma/$(BUNDLE_NAME)"
$(Q)cp -R "$(BUNDLE_DIR)/"* "$(BUNDLES_DIR)/.lzma/$(BUNDLE_NAME)/"
$(Q)cd "$(BUNDLES_DIR)/.lzma" && tar --lzma -c$(shell if test -n "$(VERBOSE)"; then echo 'v'; fi)f "$(BUNDLES_DIR)/$(BUNDLE_NAME).tar.lzma" "$(BUNDLE_NAME)"
$(Q)rm -rf "$(BUNDLES_DIR)/.lzma"
bundle_xz: bundle
@echo '[BUNDLE] Creating $(BUNDLE_NAME).tar.xz'
$(Q)mkdir -p "$(BUNDLES_DIR)/.xz/$(BUNDLE_NAME)"
$(Q)cp -R "$(BUNDLE_DIR)/"* "$(BUNDLES_DIR)/.xz/$(BUNDLE_NAME)/"
$(Q)cd "$(BUNDLES_DIR)/.xz" && tar --xz -c$(shell if test -n "$(VERBOSE)"; then echo 'v'; fi)f "$(BUNDLES_DIR)/$(BUNDLE_NAME).tar.xz" "$(BUNDLE_NAME)"
$(Q)rm -rf "$(BUNDLES_DIR)/.xz"
bundle_lha: bundle
@echo '[BUNDLE] Creating $(BUNDLE_NAME).lha'
$(Q)mkdir -p "$(BUNDLES_DIR)/.lha/$(BUNDLE_NAME)"
$(Q)cp -R "$(BUNDLE_DIR)/"* "$(BUNDLES_DIR)/.lha/$(BUNDLE_NAME)/"
$(Q)cd "$(BUNDLES_DIR)/.lha" && lha ao6 "$(BUNDLES_DIR)/$(BUNDLE_NAME).lha" "$(BUNDLE_NAME)"
$(Q)rm -rf "$(BUNDLES_DIR)/.lha"
bundle_dmg: bundle
@echo '[BUNDLE] Creating $(BUNDLE_NAME).dmg'
$(eval TMP_DMG := $(shell mktemp -u -t opendunedmg).dmg)
$(Q)hdiutil create -srcfolder $(BUNDLE_DIR) -size 4m -ov -format UDRW -fs HFS+ -volname $(VOLUME_NAME) $(TMP_DMG)
$(Q)DEV_NAME=$$(hdiutil attach -readwrite -noverify -noautoopen "$(TMP_DMG)" | grep '/Volumes/' | egrep '^/dev/' | sed 1q | awk '{print $$1}') && \
echo "$(TMP_DMG) mounted as $${DEV_NAME}" && \
cp "$(ROOT_DIR)/os/macosx/opendune.icns" $(MOUNT_DIR)/.VolumeIcon.icns && \
$(SETFILE) -c icnC $(MOUNT_DIR)/.VolumeIcon.icns && \
$(SETFILE) -a C $(MOUNT_DIR) && \
bless --folder $(MOUNT_DIR) --openfolder $(MOUNT_DIR) && \
hdiutil detach $$DEV_NAME
$(Q)$(RM) $(BUNDLES_DIR)/$(BUNDLE_NAME).dmg
$(Q)mkdir -p $(BUNDLES_DIR)
$(Q)hdiutil convert $(TMP_DMG) -format UDZO -imagekey zlib-level=9 -o $(BUNDLES_DIR)/$(BUNDLE_NAME).dmg
$(Q)$(RM) "$(TMP_DMG)"
bundle_exe: all
@echo '[BUNDLE] Creating $(BUNDLE_NAME).exe'
$(Q)mkdir -p "$(BUNDLES_DIR)"
$(Q)unix2dos "$(ROOT_DIR)/docs/"*.txt "$(ROOT_DIR)/readme.txt" "$(ROOT_DIR)/COPYING" "$(ROOT_DIR)/changelog.txt" "$(ROOT_DIR)/known-bugs.txt"
$(Q)cd $(ROOT_DIR)/os/windows/installer && makensis.exe //DVERSION_INCLUDE=version_$(PLATFORM).txt install.nsi
$(Q)mv $(ROOT_DIR)/os/windows/installer/*$(PLATFORM).exe "$(BUNDLES_DIR)/$(BUNDLE_NAME).exe"
ifdef OSXAPP
install:
@echo '[INSTALL] Cannot install the OSX Application Bundle'
else
install: bundle
@echo '[INSTALL] Installing OpenDUNE'
$(Q)install -d "$(INSTALL_BINARY_DIR)"
$(Q)install -d "$(INSTALL_DATA_DIR)"
ifeq ($(OPENDUNE), opendune.exe)
$(Q)install -m 755 "$(BUNDLE_DIR)/$(OPENDUNE)" "$(INSTALL_BINARY_DIR)/${BINARY_NAME}.exe"
else
$(Q)install -m 755 "$(BUNDLE_DIR)/$(OPENDUNE)" "$(INSTALL_BINARY_DIR)/${BINARY_NAME}"
endif
ifndef DO_NOT_INSTALL_DOCS
$(Q)install -d "$(INSTALL_DOC_DIR)"
$(Q)install -m 644 "$(BUNDLE_DIR)/README.txt" "$(BUNDLE_DIR)/enhancement.txt" "$(INSTALL_DOC_DIR)"
endif
ifndef DO_NOT_INSTALL_LICENSE
$(Q)install -d "$(INSTALL_DOC_DIR)"
$(Q)install -m 644 "$(BUNDLE_DIR)/COPYING" "$(INSTALL_DOC_DIR)"
endif
ifndef DO_NOT_INSTALL_ICON
ifeq ($(OS), UNIX)
$(Q)install -d "$(INSTALL_ICON_DIR)"
$(Q)install -m 644 "$(BUNDLE_DIR)/$(BINARY_NAME).png" "$(INSTALL_ICON_DIR)"
endif
endif
endif # OSXAPP