netsurf/cocoa/Makefile.target
2011-01-26 10:52:13 +00:00

179 lines
5.4 KiB
Makefile

# ----------------------------------------------------------------------------
# Mac OS X target setup
# ----------------------------------------------------------------------------
POSTEXES += NetSurf.app
LDFLAGS += -L/usr/X11/lib
LDFLAGS += -lm -lxml2 -lcurl -liconv
LDFLAGS += -lssl -lcrypto -lhubbub -lcss -lparserutils -lwapcaplet
CFLAGS += -I. -O $(WARNFLAGS) -Dnscocoa \
-D_BSD_SOURCE -D_POSIX_C_SOURCE \
-std=c99
CFLAGS += -g -Os -Wno-uninitialized
# shut up zconf.h and zlib.h
#CFLAGS += -D_LARGEFILE64_SOURCE=1
# for timerisset()
CFLAGS += -D_DARWIN_C_SOURCE
MACOSX_VERSION := 10.5
SDK_PATH := /Developer/SDKs/MacOSX$(MACOSX_VERSION).sdk
SDK_FLAGS := -isysroot $(SDK_PATH) -mmacosx-version-min=$(MACOSX_VERSION)
CFLAGS := $(SDK_FLAGS) $(CFLAGS)
LDFLAGS := $(SDK_FLAGS) -Wl,-syslibroot,$(SDK_PATH) $(LDFLAGS)
CXXFLAGS := $(SDK_FLAGS) $(CXXFLAGS)
CFLAGS += -I/usr/X11/include
CFLAGS += -I/usr/include/libxml2
CFLAGS += -Icocoa/PSMTabBarControl
CFLAGS += -include cocoa/Prefix.pch
ifneq ($(wildcard /opt/local*),)
# libjpeg is there when installed from MacPort.
LDFLAGS += -L/opt/local/lib
CFLAGS += -I/opt/local/include
endif
VERSION_FULL := $(shell sed -n '/"/{s/.*"\(.*\)".*/\1/;p;}' desktop/version.c)
VERSION_MAJ := $(shell sed -n '/_major/{s/.* = \([0-9]*\).*/\1/;p;}' desktop/version.c)
VERSION_MIN := $(shell sed -n '/_minor/{s/.* = \([0-9]*\).*/\1/;p;}' desktop/version.c)
LDFLAGS += -Wl,-framework,Cocoa -Wl,-framework,Carbon $(NETLDFLAGS)
CFLAGS += -I$(PREFIX)/include
LDFLAGS += -L$(PREFIX)/lib
$(eval $(call feature_enabled,BMP,-DWITH_BMP,-lnsbmp,BMP (libnsbmp)))
$(eval $(call feature_enabled,GIF,-DWITH_GIF,-lnsgif,GIF (libnsgif)))
$(eval $(call feature_enabled,PNG,-DWITH_PNG,-lpng,PNG (libpng) ))
$(eval $(call feature_enabled,NSSVG,-DWITH_NS_SVG,-lsvgtiny,SVG (libsvgtiny)))
ifneq ($(UNIVERSAL),)
UNIVERSAL_FLAGS := $(foreach arch,$(UNIVERSAL),-arch $(arch) )
CFLAGS += $(UNIVERSAL_FLAGS)
LDFLAGS += $(UNIVERSAL_FLAGS)
CXXFLAGS += $(UNIVERSAL_FLAGS)
endif
# ----------------------------------------------------------------------------
# Source file setup
# ----------------------------------------------------------------------------
# S_COCOA are sources purely for the Mac OS X build
S_COCOA := \
BrowserView.m \
BrowserViewController.m \
BrowserWindowController.m \
DownloadWindowController.m \
NetSurfAppDelegate.m \
NetsurfApp.m \
ScrollableView.m \
URLFieldCell.m \
TreeView.m \
HistoryView.m \
FormSelectMenu.m \
bitmap.m \
fetch.m \
font.m \
gui.m \
plotter.m \
save.m \
schedule.m \
selection.m \
thumbnail.m \
url.m \
utf8.m \
utils.m
S_TABBAR := \
NSBezierPath_AMShading.m \
NSString_AITruncation.m \
PSMOverflowPopUpButton.m \
PSMProgressIndicator.m \
PSMRolloverButton.m \
PSMTabBarCell.m \
PSMTabBarControl.m \
PSMTabBarController.m \
PSMTabDragAssistant.m \
PSMTabDragView.m \
PSMTabDragWindow.m \
PSMTabDragWindowController.m \
PSMUnifiedTabStyle.m
S_COCOA := $(addprefix cocoa/,$(S_COCOA))
S_TABBAR := $(addprefix cocoa/PSMTabBarControl/,$(S_TABBAR))
# complete source file list
SOURCES := $(S_COMMON) $(S_IMAGE) $(S_BROWSER) $(S_COCOA) $(S_TABBAR)
EXETARGET := NetSurf
S_XIBS := MainMenu.xib Browser.xib BrowserWindow.xib DownloadWindow.xib
S_NIBS := $(S_XIBS:.xib=.nib)
S_XIBS := $(addprefix cocoa/res/,$(S_XIBS))
S_NIBS := $(addprefix $(OBJROOT)/,$(S_NIBS))
R_RESOURCES := default.css adblock.css quirks.css NetSurf.icns
R_RESOURCES := $(addprefix cocoa/res/,$(R_RESOURCES))
LANGUAGES := de en fr it nl
LOCALIZED_RESOURCES := Messages
TABBAR_RESOURCES := AquaTabClose_Front_Pressed.png \
AquaTabClose_Front_Rollover.png \
AquaTabClose_Front.png \
AquaTabCloseDirty_Front_Pressed.png \
AquaTabCloseDirty_Front_Rollover.png \
AquaTabCloseDirty_Front.png \
AquaTabNew.png \
AquaTabNewPressed.png \
AquaTabNewRollover.png \
overflowImage.png \
overflowImagePressed.png \
pi.png
R_RESOURCES += $(addprefix cocoa/PSMTabBarControl/Images/,$(TABBAR_RESOURCES))
define make_lproj
R_RESOURCES += $$(OBJROOT)/$(1).lproj
$$(OBJROOT)/$(1).lproj: $(2) $$(OBJROOT)/created
mkdir -p $$@
cp -pLR $(2) $$@
endef
$(foreach lang,$(LANGUAGES),$(eval $(call make_lproj,$(lang),$(addprefix cocoa/res/$(lang).lproj/,$(LOCALIZED_RESOURCES)))))
$(OBJROOT)/MainMenu.nib: cocoa/res/MainMenu.xib $(OBJROOT)/created
ibtool $< --compile $@
$(OBJROOT)/Browser.nib: cocoa/res/Browser.xib $(OBJROOT)/created
ibtool $< --compile $@
$(OBJROOT)/BrowserWindow.nib: cocoa/res/BrowserWindow.xib $(OBJROOT)/created
ibtool $< --compile $@
$(OBJROOT)/DownloadWindow.nib: cocoa/res/DownloadWindow.xib $(OBJROOT)/created
ibtool $< --compile $@
NetSurf.app: NetSurf cocoa/Makefile.target $(R_RESOURCES) $(S_NIBS) NetSurf.app/Contents/Info.plist
mkdir -p NetSurf.app/Contents/MacOS
cp NetSurf NetSurf.app/Contents/MacOS
mkdir -p NetSurf.app/Contents/Resources
cp -pLR $(R_RESOURCES) NetSurf.app/Contents/Resources
cp -pLR $(S_NIBS) NetSurf.app/Contents/Resources
echo 'APPL????' > NetSurf.app/Contents/PkgInfo
NetSurf.app/Contents/Info.plist: cocoa/res/NetSurf-Info.plist cocoa/Makefile.target
mkdir -p NetSurf.app/Contents
sed -e 's/$${EXECUTABLE_NAME}/$(EXETARGET)/' \
-e 's/$${PRODUCT_NAME.*}/$(EXETARGET)/' \
-e 's/$${MACOSX_DEPLOYMENT_TARGET}/$(MACOSX_VERSION)/' \
-e 's/$${NETSURF_VERSION}/$(VERSION_FULL)/' \
-e 's/$${NETSURF_SHORT_VERSION}/$(VERSION_MAJ).$(VERSION_MIN)/' \
< cocoa/res/NetSurf-Info.plist > NetSurf.app/Contents/Info.plist