2007-12-23 00:15:58 +03:00
|
|
|
#
|
|
|
|
# Makefile for NetSurf
|
|
|
|
#
|
|
|
|
# Copyright 2007 Daniel Silverstone <dsilvers@netsurf-browser.org>
|
|
|
|
#
|
|
|
|
#
|
|
|
|
|
|
|
|
# Trivially, invoke as:
|
2008-03-19 07:03:40 +03:00
|
|
|
# make
|
2007-12-23 00:15:58 +03:00
|
|
|
# to build native, or:
|
2008-03-19 07:03:40 +03:00
|
|
|
# make TARGET=riscos
|
2007-12-23 00:15:58 +03:00
|
|
|
# to cross-build for RO.
|
|
|
|
#
|
2008-03-19 06:25:05 +03:00
|
|
|
# Tested on unix platforms (building for GTK and cross-compiling for RO) and
|
|
|
|
# on RO (building for RO).
|
2007-12-23 00:15:58 +03:00
|
|
|
#
|
|
|
|
# To clean, invoke as above, with the 'clean' target
|
|
|
|
#
|
2008-03-09 20:06:45 +03:00
|
|
|
# To build developer Doxygen generated documentation, invoke as above,
|
|
|
|
# with the 'docs' target:
|
2008-03-19 07:03:40 +03:00
|
|
|
# make docs
|
2008-03-09 20:06:45 +03:00
|
|
|
#
|
2007-12-23 00:15:58 +03:00
|
|
|
|
|
|
|
all: all-program
|
|
|
|
|
|
|
|
# Determine host type
|
2008-04-08 03:13:06 +04:00
|
|
|
# NOTE: HOST determination on RISC OS could fail because of missing bug fixes
|
|
|
|
# in UnixLib which only got addressed in UnixLib 5 / GCCSDK 4.
|
2008-03-20 18:13:52 +03:00
|
|
|
# When you don't have 'uname' available, you will see:
|
|
|
|
# File 'uname' not found
|
2008-04-08 03:13:06 +04:00
|
|
|
# When you do and using a 'uname' compiled with a buggy UnixLib, you
|
|
|
|
# will see the following printed on screen:
|
2008-03-20 18:13:52 +03:00
|
|
|
# RISC OS
|
|
|
|
# In both cases HOST make variable is empty and we recover from that by
|
|
|
|
# assuming we're building on RISC OS.
|
2008-04-08 03:13:06 +04:00
|
|
|
# In case you don't see anything printed (including the warning), you
|
|
|
|
# have an update to date RISC OS build sytem. ;-)
|
2008-03-19 03:48:08 +03:00
|
|
|
HOST := $(shell uname -s)
|
2008-03-20 18:13:52 +03:00
|
|
|
ifeq ($(HOST),)
|
|
|
|
HOST := riscos
|
|
|
|
$(warning Build platform determination failed but that's a known problem for RISC OS so we're assuming a native RISC OS build.)
|
2008-03-23 03:59:09 +03:00
|
|
|
else
|
|
|
|
ifeq ($(HOST),RISC OS)
|
|
|
|
# Fixup uname -s returning "RISC OS"
|
|
|
|
HOST := riscos
|
|
|
|
endif
|
2008-03-20 18:13:52 +03:00
|
|
|
endif
|
2007-12-23 00:15:58 +03:00
|
|
|
|
2008-03-19 03:48:08 +03:00
|
|
|
ifeq ($(HOST),riscos)
|
|
|
|
# Build happening on RO platform, default target is RO backend
|
2007-12-23 00:15:58 +03:00
|
|
|
ifeq ($(TARGET),)
|
|
|
|
TARGET := riscos
|
|
|
|
endif
|
|
|
|
else
|
2008-03-19 03:48:08 +03:00
|
|
|
# Build happening on non-RO platform, default target is GTK backend
|
2007-12-23 00:15:58 +03:00
|
|
|
ifeq ($(TARGET),)
|
|
|
|
TARGET := gtk
|
|
|
|
endif
|
|
|
|
endif
|
2008-03-22 03:49:56 +03:00
|
|
|
SUBTARGET =
|
2007-12-23 00:15:58 +03:00
|
|
|
|
2008-03-22 01:40:11 +03:00
|
|
|
ifneq ($(TARGET),riscos)
|
|
|
|
ifneq ($(TARGET),gtk)
|
|
|
|
$(error Unknown TARGET "$(TARGET)", should either be "riscos" or "gtk")
|
|
|
|
endif
|
|
|
|
endif
|
|
|
|
|
2007-12-23 00:15:58 +03:00
|
|
|
Q=@
|
|
|
|
VQ=@
|
|
|
|
PERL=perl
|
|
|
|
MKDIR=mkdir
|
|
|
|
TOUCH=touch
|
|
|
|
|
|
|
|
ifeq ($(TARGET),riscos)
|
|
|
|
ifeq ($(HOST),riscos)
|
|
|
|
# Build for RO on RO
|
2008-03-19 18:54:07 +03:00
|
|
|
GCCSDK_INSTALL_ENV := <NSLibs$$Dir>
|
2007-12-23 00:15:58 +03:00
|
|
|
CC := gcc
|
2008-03-19 06:25:05 +03:00
|
|
|
EXEEXT :=
|
2008-03-19 18:54:07 +03:00
|
|
|
PKG_CONFIG :=
|
2007-12-23 00:15:58 +03:00
|
|
|
else
|
2008-03-22 03:49:56 +03:00
|
|
|
# Cross-build for RO (either using GCCSDK 3.4.6 - AOF,
|
|
|
|
# either using GCCSDK 4 - ELF)
|
2008-03-22 01:40:11 +03:00
|
|
|
GCCSDK_INSTALL_ENV ?= /home/riscos/env
|
|
|
|
GCCSDK_INSTALL_CROSSBIN ?= /home/riscos/cross/bin
|
2008-03-22 03:49:56 +03:00
|
|
|
CC := $(wildcard $(GCCSDK_INSTALL_CROSSBIN)/*gcc)
|
|
|
|
ifneq (,$(findstring arm-unknown-riscos-gcc,$(CC)))
|
|
|
|
SUBTARGET := -elf
|
|
|
|
EXEEXT := ,e1f
|
|
|
|
ELF2AIF := $(GCCSDK_INSTALL_CROSSBIN)/elf2aif
|
|
|
|
else
|
|
|
|
SUBTARGET := -aof
|
2008-03-19 06:25:05 +03:00
|
|
|
EXEEXT := ,ff8
|
2008-03-22 03:49:56 +03:00
|
|
|
endif
|
2008-03-19 18:54:07 +03:00
|
|
|
PKG_CONFIG := $(GCCSDK_INSTALL_ENV)/ro-pkg-config
|
2007-12-23 00:15:58 +03:00
|
|
|
endif
|
2008-03-19 03:48:08 +03:00
|
|
|
else
|
2008-03-19 18:54:07 +03:00
|
|
|
# Building for GTK
|
|
|
|
PKG_CONFIG := pkg-config
|
2007-12-23 00:15:58 +03:00
|
|
|
endif
|
|
|
|
|
2008-04-07 23:13:11 +04:00
|
|
|
OBJROOT := build-$(HOST)-$(TARGET)$(SUBTARGET)
|
|
|
|
|
2008-03-19 18:54:07 +03:00
|
|
|
ifeq ($(HOST),riscos)
|
2008-04-07 23:13:11 +04:00
|
|
|
LDFLAGS := -Xlinker -symbols=$(OBJROOT)/sym -lxml2 -lz -lm -lcurl -lssl -lcrypto -lmng -ljpeg
|
2008-03-19 18:54:07 +03:00
|
|
|
else
|
|
|
|
LDFLAGS := $(shell $(PKG_CONFIG) --libs libxml-2.0 libcurl openssl)
|
|
|
|
LDFLAGS += -lz -lm -lmng -ljpeg
|
2008-05-19 17:36:32 +04:00
|
|
|
|
|
|
|
CCACHE := $(shell which ccache)
|
|
|
|
|
|
|
|
ifneq ($(CCACHE),)
|
|
|
|
CC := $(CCACHE) $(CC)
|
|
|
|
endif
|
|
|
|
|
2008-03-19 18:54:07 +03:00
|
|
|
endif
|
2007-12-23 00:15:58 +03:00
|
|
|
|
|
|
|
ifeq ($(TARGET),gtk)
|
|
|
|
# Building for GTK, we need the GTK flags
|
|
|
|
|
|
|
|
GTKCFLAGS := -std=c99 -Dgtk -Dnsgtk \
|
|
|
|
-DGTK_DISABLE_DEPRECATED \
|
|
|
|
-D_BSD_SOURCE \
|
|
|
|
-D_XOPEN_SOURCE=600 \
|
|
|
|
-D_POSIX_C_SOURCE=200112L \
|
2008-03-13 00:16:15 +03:00
|
|
|
-D_NETBSD_SOURCE \
|
2008-03-29 16:30:04 +03:00
|
|
|
$(WARNFLAGS) -I. -I../../libsprite/trunk/ -g -O \
|
2008-03-19 18:54:07 +03:00
|
|
|
$(shell $(PKG_CONFIG) --cflags libglade-2.0 gtk+-2.0 librsvg-2.0) \
|
2008-03-29 16:30:04 +03:00
|
|
|
$(shell $(PKG_CONFIG) --cflags librosprite) \
|
2007-12-23 00:15:58 +03:00
|
|
|
$(shell xml2-config --cflags)
|
|
|
|
|
2008-03-29 16:30:04 +03:00
|
|
|
GTKLDFLAGS := $(shell $(PKG_CONFIG) --cflags --libs libglade-2.0 gtk+-2.0 gthread-2.0 gmodule-2.0 librsvg-2.0 librosprite)
|
2007-12-23 00:15:58 +03:00
|
|
|
CFLAGS += $(GTKCFLAGS)
|
2008-03-19 18:54:07 +03:00
|
|
|
LDFLAGS += $(GTKLDFLAGS) $(shell $(PKG_CONFIG) --libs lcms)
|
2007-12-23 00:15:58 +03:00
|
|
|
|
2008-03-19 03:48:08 +03:00
|
|
|
ifeq ($(HOST),Windows_NT)
|
2007-12-23 00:15:58 +03:00
|
|
|
CFLAGS += -U__STRICT_ANSI__
|
|
|
|
endif
|
|
|
|
|
|
|
|
endif
|
|
|
|
|
|
|
|
ifeq ($(TARGET),riscos)
|
2008-02-10 01:37:51 +03:00
|
|
|
CFLAGS += -I. -O $(WARNFLAGS) -Driscos \
|
|
|
|
-std=c99 -D_BSD_SOURCE -D_POSIX_C_SOURCE \
|
2008-03-19 07:23:13 +03:00
|
|
|
-mpoke-function-name
|
2007-12-23 00:15:58 +03:00
|
|
|
|
|
|
|
CFLAGS += -I$(GCCSDK_INSTALL_ENV)/include \
|
|
|
|
-I$(GCCSDK_INSTALL_ENV)/include/libxml2 \
|
|
|
|
-I$(GCCSDK_INSTALL_ENV)/include/libmng
|
2008-03-19 04:19:12 +03:00
|
|
|
ifeq ($(HOST),riscos)
|
2008-03-19 07:23:13 +03:00
|
|
|
CFLAGS += -I<OSLib$$Dir> -mthrowback
|
2008-03-19 04:19:12 +03:00
|
|
|
endif
|
2008-03-22 03:49:56 +03:00
|
|
|
ASFLAGS += -xassembler-with-cpp -I. -I$(GCCSDK_INSTALL_ENV)/include
|
2008-03-19 04:19:12 +03:00
|
|
|
LDFLAGS += -L$(GCCSDK_INSTALL_ENV)/lib -lcares -lrufl -lpencil \
|
2008-02-03 22:11:36 +03:00
|
|
|
-lsvgtiny
|
2008-03-19 04:19:12 +03:00
|
|
|
ifeq ($(HOST),riscos)
|
|
|
|
LDFLAGS += -LOSLib: -lOSLib32
|
|
|
|
else
|
|
|
|
LDFLAGS += -lOSLib32
|
2008-03-22 03:49:56 +03:00
|
|
|
ifeq ($(SUBTARGET),-elf)
|
|
|
|
# Go for static builds & AIF binary at the moment:
|
|
|
|
CFLAGS += -static
|
|
|
|
LDFLAGS += -static
|
|
|
|
EXEEXT := ,ff8
|
2008-03-19 04:19:12 +03:00
|
|
|
endif
|
2007-12-23 00:15:58 +03:00
|
|
|
endif
|
2008-03-22 03:49:56 +03:00
|
|
|
endif
|
|
|
|
|
|
|
|
$(OBJROOT)/created:
|
|
|
|
$(VQ)echo " MKDIR: $(OBJROOT)"
|
|
|
|
$(Q)$(MKDIR) $(OBJROOT)
|
|
|
|
$(Q)$(TOUCH) $(OBJROOT)/created
|
|
|
|
|
|
|
|
DEPROOT := $(OBJROOT)/deps
|
|
|
|
$(DEPROOT)/created: $(OBJROOT)/created
|
|
|
|
$(VQ)echo " MKDIR: $(DEPROOT)"
|
|
|
|
$(Q)$(MKDIR) $(DEPROOT)
|
|
|
|
$(Q)$(TOUCH) $(DEPROOT)/created
|
|
|
|
|
|
|
|
WARNFLAGS = -W -Wall -Wundef -Wpointer-arith \
|
|
|
|
-Wcast-align -Wwrite-strings -Wstrict-prototypes \
|
|
|
|
-Wmissing-prototypes -Wmissing-declarations -Wredundant-decls \
|
|
|
|
-Wnested-externs -Winline -Wno-unused-parameter -Wuninitialized
|
2007-12-23 00:15:58 +03:00
|
|
|
|
|
|
|
CLEANS := clean-target
|
|
|
|
|
|
|
|
include Makefile.sources
|
|
|
|
|
2008-03-05 15:30:29 +03:00
|
|
|
OBJECTS := $(sort $(addprefix $(OBJROOT)/,$(subst /,_,$(patsubst %.c,%.o,$(patsubst %.s,%.o,$(SOURCES))))))
|
2007-12-23 00:15:58 +03:00
|
|
|
|
|
|
|
$(EXETARGET): $(OBJECTS)
|
|
|
|
$(VQ)echo " LINK: $(EXETARGET)"
|
2008-03-22 03:49:56 +03:00
|
|
|
ifneq ($(TARGET)$(SUBTARGET),riscos-elf)
|
2008-03-20 16:21:53 +03:00
|
|
|
$(Q)$(CC) -o $(EXETARGET) $(OBJECTS) $(LDFLAGS)
|
2008-03-22 03:49:56 +03:00
|
|
|
else
|
|
|
|
$(Q)$(CC) -o $(EXETARGET:,ff8=,e1f) $(OBJECTS) $(LDFLAGS)
|
|
|
|
$(Q)$(ELF2AIF) $(EXETARGET:,ff8=,e1f) $(EXETARGET)
|
|
|
|
$(Q)$(RM) $(EXETARGET:,ff8=,e1f)
|
|
|
|
endif
|
2007-12-23 00:15:58 +03:00
|
|
|
|
|
|
|
clean-target:
|
|
|
|
$(VQ)echo " CLEAN: $(EXETARGET)"
|
|
|
|
$(Q)$(RM) $(EXETARGET)
|
|
|
|
|
|
|
|
clean-builddir:
|
|
|
|
$(VQ)echo " CLEAN: $(OBJROOT)"
|
|
|
|
$(Q)$(RM) -r $(OBJROOT)
|
|
|
|
CLEANS += clean-builddir
|
|
|
|
|
|
|
|
all-program: $(EXETARGET)
|
|
|
|
|
|
|
|
.SUFFIXES:
|
|
|
|
|
|
|
|
DEPFILES :=
|
|
|
|
# Now some macros which build the make system
|
|
|
|
|
|
|
|
# 1 = Source file
|
|
|
|
# 2 = dep filename, no prefix
|
|
|
|
# 3 = obj filename, no prefix
|
|
|
|
define dependency_generate_c
|
|
|
|
DEPFILES += $(2)
|
|
|
|
$$(DEPROOT)/$(2): $$(DEPROOT)/created $(1) css/css_enum.h css/parser.h
|
|
|
|
$$(VQ)echo " DEP: $(1)"
|
2008-03-05 15:30:29 +03:00
|
|
|
$$(Q)$$(RM) $$(DEPROOT)/$(2)
|
2008-03-19 03:48:08 +03:00
|
|
|
$$(Q)$$(CC) $$(CFLAGS) -MM -MT '$$(DEPROOT)/$2 $$(OBJROOT)/$(3)' \
|
2008-03-05 15:30:29 +03:00
|
|
|
-MF $$(DEPROOT)/$(2) $(1)
|
2007-12-23 00:15:58 +03:00
|
|
|
|
|
|
|
endef
|
|
|
|
|
|
|
|
# 1 = Source file
|
|
|
|
# 2 = dep filename, no prefix
|
|
|
|
# 3 = obj filename, no prefix
|
|
|
|
define dependency_generate_s
|
|
|
|
DEPFILES += $(2)
|
|
|
|
$$(DEPROOT)/$(2): $$(DEPROOT)/created $(1)
|
|
|
|
$$(VQ)echo " DEP: $(1)"
|
2008-03-05 15:30:29 +03:00
|
|
|
$$(Q)$$(RM) $$(DEPROOT)/$(2)
|
2008-03-19 03:48:08 +03:00
|
|
|
$$(Q)$$(CC) $$(CFLAGS) -MM -MT '$$(DEPROOT)/$2 $$(OBJROOT)/$(3)' \
|
2008-03-05 15:30:29 +03:00
|
|
|
-MF $$(DEPROOT)/$(2) $(1)
|
2007-12-23 00:15:58 +03:00
|
|
|
|
|
|
|
endef
|
|
|
|
|
|
|
|
# 1 = Source file
|
|
|
|
# 2 = obj filename, no prefix
|
|
|
|
# 3 = dep filename, no prefix
|
|
|
|
define compile_target_c
|
|
|
|
$$(OBJROOT)/$(2): $$(OBJROOT)/created $$(DEPROOT)/$(3)
|
|
|
|
$$(VQ)echo " COMPILE: $(1)"
|
|
|
|
$$(Q)$$(CC) $$(CFLAGS) -o $$@ -c $(1)
|
|
|
|
|
|
|
|
endef
|
|
|
|
|
|
|
|
# 1 = Source file
|
|
|
|
# 2 = obj filename, no prefix
|
|
|
|
# 3 = dep filename, no prefix
|
|
|
|
define compile_target_s
|
|
|
|
$$(OBJROOT)/$(2): $$(OBJROOT)/created
|
|
|
|
$$(VQ)echo " ASSEMBLE: $(1)"
|
|
|
|
$$(Q)$$(CC) $$(ASFLAGS) -o $$@ -c $(1)
|
|
|
|
|
|
|
|
endef
|
|
|
|
|
|
|
|
# Rules to construct dep lines for each object...
|
|
|
|
$(eval $(foreach SOURCE,$(filter %.c,$(SOURCES)), \
|
|
|
|
$(call dependency_generate_c,$(SOURCE),$(subst /,_,$(SOURCE:.c=.d)),$(subst /,_,$(SOURCE:.c=.o)))))
|
|
|
|
|
|
|
|
# Cannot currently generate dep files for S files because they're objasm
|
|
|
|
# when we move to gas format, we will be able to.
|
|
|
|
|
|
|
|
#$(eval $(foreach SOURCE,$(filter %.s,$(SOURCES)), \
|
|
|
|
# $(call dependency_generate_s,$(SOURCE),$(subst /,_,$(SOURCE:.s=.d)),$(subst /,_,$(SOURCE:.s=.o)))))
|
|
|
|
|
|
|
|
ifneq ($(MAKECMDGOALS),clean)
|
2008-03-05 15:30:29 +03:00
|
|
|
-include $(sort $(addprefix $(DEPROOT)/,$(DEPFILES)))
|
2007-12-23 00:15:58 +03:00
|
|
|
endif
|
|
|
|
|
|
|
|
# And rules to build the objects themselves...
|
|
|
|
|
|
|
|
$(eval $(foreach SOURCE,$(filter %.c,$(SOURCES)), \
|
|
|
|
$(call compile_target_c,$(SOURCE),$(subst /,_,$(SOURCE:.c=.o)),$(subst /,_,$(SOURCE:.c=.d)))))
|
|
|
|
|
|
|
|
$(eval $(foreach SOURCE,$(filter %.s,$(SOURCES)), \
|
|
|
|
$(call compile_target_s,$(SOURCE),$(subst /,_,$(SOURCE:.s=.o)),$(subst /,_,$(SOURCE:.s=.d)))))
|
|
|
|
|
2008-05-24 16:20:57 +04:00
|
|
|
.PHONY: all clean docs
|
2007-12-23 00:15:58 +03:00
|
|
|
|
|
|
|
clean: $(CLEANS)
|
2008-03-09 20:06:45 +03:00
|
|
|
|
|
|
|
docs:
|
|
|
|
doxygen Docs/Doxyfile
|