Commit 4477e695 authored by Ben Avison's avatar Ben Avison
Browse files

Changes to facilitate platform independence.

Detail:
 CApp:
  * New variable CLEAN_DEPEND is now the preferred way to specify additional
    clean actions because GNU make doesn't have an equivalent to amu's :: rules
  * Can now indicate preference to use C++ linker options using LINK_TYPE
  * Gains install phase support:
    + INSTALLAPPFILES lists the files to be copied, effectively specified
      relative to LocalRes$Path
    + Adopted INSTTYPE concept from DDE makefiles for cases where executable
      and support files need to be installed to different locations
    + Unusual cases can override this implementation using CUSTOMINSTALLAPP
      and/or CUSTOMINSTALLTOOL

  CLibrary:
  * New variable CLEAN_DEPEND is now the preferred way to specify additional
    clean actions because GNU make doesn't have an equivalent to amu's :: rules
  * -o is no longer a mandatory argument to libfile - now in ARFLAGS rather
    than used explicitly

  DbgRules / StdRules:
  * Macroised some Norcroft-specific features

  HostTools:
  * Clean phase support was incomplete

  StdTools:
  * A few additional tool definitions
  * Added macro definitions for common C options
  * C's enable-warnings and suppress-function-name-embedding options now on by
    default because they're usually (maybe even universally?) used - it won't
    hurt if they're specified again by existing makefiles
  * C++ now has equivalent INCLUDES and DEFINES variables, and the standard C++
    headers are on the default include path
  * SEP is defined as the directory separator character and can be used from
    top-level makefiles in a platform-independent way

  Functionally equivalent versions of the following makefile fragments
  have been developed so far for executing on a Posix build host:
    AppLibs, CApp, CLibrary, DbgRules, HostTools, StdRules, StdTools
  These suport native compilers (when APCS=Host) and cross-compilers,
  and GCC (when TOOLCHAIN=GNU) and Norcroft toolchains - typically these
  environment variables would be selected by running an Env file.

Admin:
  Tested by building as many as possible of the DDE components on RISC OS
  and on Linux, using native and cross compilers, and using Norcroft and
  GNU toolchains.

Version 5.01. Tagged as 'BuildSys-5_01'
parent 9b73d9b9
# Makefile fragment for libraries linked against RAM applications
#
ANSILIB = ${LIBDIR}/CLib/ansilib.a
# Can't use ifeq (GNU,${TOOLCHAIN}) here, since we need to allow for host tools being built with GCC even on builds that otherwise use Norcroft
ifneq (,$(findstring gcc,${CC}))
CLIB =
else
CLIB = ${LIBDIR}/CLib/stubs.a
endif
RLIB = ${LIBDIR}/RISC_OSLib/risc_oslib.a
RSTUBS = ${LIBDIR}/RISC_OSLib/rstubs.a
ROMSTUBS = ${LIBDIR}/RISC_OSLib/romstubs.a
ROMCSTUBS = ${LIBDIR}/RISC_OSLib/romcstubs.a
ABSSYM = ${LIBDIR}/RISC_OSLib/abssym.a
C_ABSSYM = ${LIBDIR}/RISC_OSLib/c_abssym.a
A_ABSSYM = ${LIBDIR}/RISC_OSLib/a_abssym.a
ASMUTILS = ${LIBDIR}/AsmUtils/AsmUtils.a
CLXLIB = ${LIBDIR}/CLX/clxlib.a
# Can't use ifeq (GNU,${TOOLCHAIN}) here, since we need to allow for host tools being built with G++ even on builds that otherwise use Norcroft
ifneq (,$(findstring g++,${C++}))
C++LIB =
else
C++LIB = ${LIBDIR}/c++lib/c++lib.a
endif
TBOXLIB = ${LIBDIR}/tboxlibs/toolboxlib.a
FLEXLIB = ${LIBDIR}/tboxlibs/flexlib.a
EVENTLIB = ${LIBDIR}/tboxlibs/eventlib.a
WIMPLIB = ${LIBDIR}/tboxlibs/wimplib.a
RENDERLIB = ${LIBDIR}/tboxlibs/renderlib.a
TBOXLIBS = ${EVENTLIB} ${TBOXLIB} ${RENDERLIB} ${WIMPLIB}
SOCK4LIB = ${LIBDIR}/TCPIPLibs/socklib.a
SOCK5LIB = ${LIBDIR}/TCPIPLibs/socklib5.a
INETLIB = ${LIBDIR}/TCPIPLibs/inetlib.a
UNIXLIB = ${LIBDIR}/TCPIPLibs/unixlib.a
RPCLIB = ${LIBDIR}/TCPIPLibs/rpc/rpc_data.a ${LIBDIR}/TCPIPLibs/rpc/rpclib.a
CRYPTLIB = ${LIBDIR}/SSLeay/ssl.a ${LIBDIR}/SSLeay/libcrypto.a
NET4LIBS = ${UNIXLIB} ${INETLIB} ${SOCK4LIB}
NET5LIBS = ${UNIXLIB} ${INETLIB} ${SOCK5LIB}
ABCLIB = ${LIBDIR}/ABCLib/ABCLib.a
CALLXLIB = ${LIBDIR}/callx/callx.a
DDTLIB = ${LIBDIR}/DDTLib/DDTLib.a
DESKLIB = ${LIBDIR}/Desk/Desk.a
FETCHLIB = ${LIBDIR}/Fetchers/FetchLibZM.a
JSLIB = ${LIBDIR}/JSLib/JSLib.a
LDAPLIBS = ${LIBDIR}/LDAP/LDAP.a ${LIBDIR}/LDAP/LBER.a
MODMALLOCLIB = ${LIBDIR}/ModMalloc/Lib.a
NCMALIB = ${LIBDIR}/NCMALib/NCMALib.a
NSPRLIB = ${LIBDIR}/NSPRLib/NSPRLib.a
OSLIB = ${LIBDIR}/OSLib/OSLib.a
TGRLIB = ${LIBDIR}/TGRLib/tgrlib.a
WILDLIB = ${LIBDIR}/Wild/Wild.a
DEBUGLIB = ${LIBDIR}/DebugLib/DebugLib.a
DEBUGLIBS = # ${DEBUGLIB} ${MODMALLOCLIB} ${WILDLIB} ${DDTLIB} ${DESKLIB}
# EOF
# Makefile fragment for C and C++ applications
#
# This makefile provides the following phony targets:
#
# all install debug
#
#
# This fragment uses the following macros set by the master makefile.
#
#
# COMPONENT (the name of the component)
# TARGET (opt) (the leafname of the application - otherwise ${COMPONENT})
# DBG_TARGET (opt) (debug application leafname - otherwise ${TARGET}-D)
# INSTDIR (opt) (the target directory - otherwise ${INSTALLDIR}/${TARGET})
# DIRS (opt) (stamp object for directory creation - otherwise _dirs)
# OBJS (opt) (object files, no o. prefixes - otherwise ${TARGET})
# DBG_OBJS (opt) (debug build object files, no prefixes - otherwise ${OBJS})
# LIBS (opt) (extra libraries; CLib is always used)
# DBG_LIBS (opt) (extra debug libraries - otherwsie ${LIBS};
# CLib and DEBUGLIBS always used)
# APP_OBJS (opt) (object files for application version - otherwise derived
# from ${OBJS})
# APP_DBG_OBJS (opt) (object files for debug app version - otherwise derived
# from ${DBG_OBJS})
# CLEAN_DEPEND (opt) (phony target for additional clean actions)
# LINK_TYPE (opt) (variant of linking command, eg C++ - defaults to C)
# INSTTYPE (opt) (use "tool" or "app" to install executable vs application - defaults to "tool")
# INSTALLAPPFILES (opt) (list of files to be installed in application directory - use InstRes specification rules)
# INSTALLAPP_DEPEND (opt) (list of dependencies to be satisfied before doing application install - ${TARGET} assumed if in INSTALLAPPFILES)
# CUSTOMINSTALLAPP (opt) (set to "custom" to override the install rule for resource files)
# CUSTOMINSTALLTOOL (opt) (set to "custom" to override the install rule for target binary)
# SOURCES_TO_LINK (opt) (files which need be linked to by the link farm, in addition to contents of c and h directories)
#
#
# It relies on the following generic tool macros from the StdTools makefile
#
#
#C + CFLAGS (C compiler; CDFLAGS also used in debug builds; -g implicit)
# CP + CPFLAGS (copy, cp etc.)
# WIPE + WFLAGS (recursive delete)
# RM (non-recursive delete)
# AS + ASFLAGS (assembler)
# LD + LDFLAGS (linker; LDDFLAGS also used in debug builds; -d implicit)
# SQZ + SQZFLAGS (binary compressor)
# MKDIR (cdir/mkdir -p)
# ECHO
# TOUCH (create/touch)
#
#
# It relies on the following from the StdRules makefile
#
#
# .c.o .c++.o .cpp.o .s.o
#
#
# It relies on the following from the DbgRules makefile
#
#
# CDFLAGS C++DFLAGS ASDFLAGS LDDFLAGS
# .c.od .c++.od .cpp.od .s.od
#
#
TARGET ?= ${COMPONENT}
DBG_TARGET ?= ${TARGET}-D
INSTDIR ?= ${INSTALLDIR}/${TARGET}
DIRS ?= _dirs
OBJS ?= ${TARGET}
DBG_OBJS ?= ${OBJS}
DBG_LIBS ?= ${LIBS}
DBG_LIBS += ${DEBUGLIBS}
ifeq (C++,${LINK_TYPE})
LIBS += ${C++LIB}
DBG_LIBS += ${C++LIB}
endif
LIBS += ${CLIB}
DBG_LIBS += ${CLIB}
APP_OBJS ?= $(addsuffix .o,${OBJS})
APP_DBG_OBJS ?= $(addsuffix .od,${DBG_OBJS})
SOURCES_TO_SYMLINK += $(wildcard c/*) $(wildcard c++/*) $(wildcard h/*) $(wildcard s/*) VersionNum VersionASM
ifneq (objs,$(notdir ${CURDIR}))
# Makefile invoked from same directory
# Create link farm, then execute the makefile from within it
all install debug clean links: ${SYMLINK_DEPEND}
ifneq (clean,${MAKECMDGOALS})
$(foreach linksource,${SOURCES_TO_SYMLINK}, \
$(shell \
linkdest=`echo ${linksource} | sed -e 's,\([^/]*\)/\([^/]*\)$$,\2.\1,' -e 's,^,objs/,'`; \
linkdestdir=`echo $$linkdest | sed -e 's,/[^/]*$$,,'`; \
linkbackpath=`echo $$linkdestdir | sed -e 's,[^/]*,..,g'`; \
[ -d ${linksource} ] || [ -L $$linkdest ] || ${MKDIR} $$linkdestdir; \
[ -d ${linksource} ] || [ -L $$linkdest ] || ln -s $$linkbackpath/${linksource} $$linkdest; \
) \
)
@[ -L objs/Resources ] || ln -s ../Resources objs/Resources
endif
@[ -d objs ] || ${MKDIR} objs
ifneq (links,${MAKECMDGOALS})
@${MAKE} -C objs -f ../$(firstword ${MAKEFILE_LIST}) ${MAKECMDGOALS}
endif
else
# Makefile invoked from objs subdirectory
all: ${TARGET}${SUFFIX_ABSOLUTE}
@${ECHO} ${COMPONENT}: application built
${DIRS}:
${TOUCH} $@
clean :: ${CLEAN_DEPEND}
@${ECHO} Cleaning...
@cd .. && ${WIPE} objs ${WFLAGS}
@${ECHO} ${COMPONENT}: cleaned
install: install_${INSTTYPE}
install_: install_tool
INSTALLAPP_DEPEND += $(addsuffix ${SUFFIX_ABSOLUTE},$(filter ${TARGET},${INSTALLAPPFILES}))
install_app${CUSTOMINSTALLAPP}: ${INSTALLAPP_DEPEND}
${MKDIR} ${INSTAPP}
${INSTRES} -I Resources.${USERIF}.${LOCALE},Resources.${USERIF}.UK,Resources.${LOCALE},Resources.UK,Resources ${INSTAPP} ${INSTALLAPPFILES}
ifneq (,$(filter Desc,${INSTALLAPPFILES}))
${CPREPRO} -I. ${INSTAPP}/Desc > ${INSTAPP}/DescTmp
${TIDYDESC} ${INSTAPP}/Desc ${INSTAPP}/DescTmp
${RM} ${INSTAPP}/DescTmp
endif
@${ECHO} ${COMPONENT}: application installation complete
install_tool${CUSTOMINSTALLTOOL}: ${TARGET}${SUFFIX_ABSOLUTE}
${MKDIR} ${INSTDIR}
${CP} ${TARGET}${SUFFIX_ABSOLUTE} ${INSTDIR}/${TARGET}${SUFFIX_ABSOLUTE} ${CPFLAGS}
@${ECHO} ${COMPONENT}: tool installation complete
debug: ${DBG_TARGET}${SUFFIX_DEBIMAGE}
@${ECHO} ${COMPONENT}: debug application built
${TARGET}${SUFFIX_ABSOLUTE}: ${DIRS} ${APP_OBJS} ${LIBS}
${LD} ${LDFLAGS} -o $@ ${APP_OBJS} ${LIBS}
${STRIP} $@
${SQZ} ${SQZFLAGS} $@
${DBG_TARGET}${SUFFIX_DEBIMAGE}: ${DIRS} ${APP_DBG_OBJS} ${DBG_LIBS}
${LD} ${LDFLAGS} ${LDDFLAGS} -o $@ ${APP_DBG_OBJS} ${DBG_LIBS}
endif
# EOF
# Makefile fragment for C and C++ libraries for applications and modules
#
# This makefile provides the following phony targets:
#
# all_libs export_hdrs export_libs
#
#
# This fragment uses the following macros set by the master makefile.
#
#
# COMPONENT (the name of the component)
# TARGET (opt) (the leafname of the primary target - otherwise ${COMPONENT})
# LIBRARY (opt) (the leafname of the application library - otherwise ${TARGET})
# LIBRARYZM (opt) (the leafname of the module library - otherwise ${LIBRARY}zm)
# LIBRARYD (opt) (the leafname of the debug app library - otherwise ${LIBRARY}d)
# LIBRARYDZM (opt) (the leafname of the debug module library - otherwise ${LIBRARY}dzm)
# LIBRARIES (opt) (libraries to build/export - otherwise ${LIBRARY} and ${LIBRARYZM})
# LIBEXT (opt) (subdir or filename extension for library files - otherwise a)
# EXPDIR (opt) (the target directory - otherwise ${LIBDIR}/${TARGET})
# DIRS (opt) (stamp object for directory creation - otherwise _dirs)
# HDRS (opt) (header files to export, no h. prefix - otherwise ${TARGET})
# ASMHDRS (opt) (assembly header files to export, no Hdr. prefix - otherwise none)
# OBJS (object files, no o. or oz. prefixes)
# DBG_OBJS (opt) (debug build object files, no o. or oz. prefixes - otherwise ${OBJS})
# APP_OBJS (opt) (object files for application version - otherwise derived from ${OBJS})
# APP_DBG_OBJS (opt) (object files for debug app version - otherwise derived from ${DBG_OBJS})
# MOD_OBJS (opt) (object files for module version - otherwise derived from ${OBJS})
# MOD_DBG_OBJS (opt) (object files for debug module version - otherwise derived from ${DBG_OBJS})
# CLEAN_DEPEND (opt) (phony target for additional clean actions)
# CUSTOMLIB (opt) (set to "custom" to override the application library rule)
# CUSTOMLIBZM (opt) (set to "custom" to override the module library rule)
# CUSTOMLIBD (opt) (set to "custom" to override the debug application library rule)
# CUSTOMLIBDZM (opt) (set to "custom" to override the debug module library rule)
# SOURCES_TO_LINK (opt) (files which need be linked to by the link farm, in addition to contents of c and h directories)
#
#
# It relies on the following from the build system:
#
#
# PHASE (export phase discriminator)
#
#
# It relies on the following generic tool macros from the StdTools makefile
#
#
# CP + CPFLAGS (copy, cp etc.)
# WIPE + WFLAGS (recursive delete)
# RM (non-recursive delete)
# AS + ASFLAGS (assembler)
# MKDIR (cdir/mkdir -p)
# ECHO
# AR + ARFLAGS (libfile/ar)
# TOUCH (create/touch)
# NOP
#
#
# It relies on the following from the StdRules makefile
#
#
# .c.o .c.oz .c++.o .cpp.o .c++.oz .c++.oz .s.o .s.oz
#
#
# It relies on the following from the DbgRules makefile
#
#
# CDFLAGS C++DFLAGS ASDFLAGS
# .c.od .c.odz .c++.od .cpp.od .c++.odz .cpp.odz .s.od .s.odz
#
#
LIBDIR = ${BUILDDIR}/Export/${APCS}/Lib
TARGET ?= ${COMPONENT}
LIBRARY ?= ${TARGET}
LIBRARYZM ?= ${LIBRARY}zm
LIBRARYD ?= ${LIBRARY}d
LIBRARYDZM ?= ${LIBRARY}dzm
LIBRARIES ?= ${LIBRARYZM} ${LIBRARY}
LIBEXT ?= a
EXPDIR ?= ${LIBDIR}/${TARGET}
DIRS ?= _dirs
HDRS ?= ${TARGET}
ASMHDRS ?=
DBG_OBJS ?= ${OBJS}
APP_OBJS ?= $(addsuffix .o,${OBJS})
APP_DBG_OBJS ?= $(addsuffix .od,${DBG_OBJS})
MOD_OBJS ?= $(addsuffix .oz,${OBJS})
MOD_DBG_OBJS ?= $(addsuffix .odz,${DBG_OBJS})
EXPORTING_HDRS = $(addsuffix .exphdr,${HDRS})
EXPORTING_ASMHDRS = $(addsuffix .expasm,${ASMHDRS})
EXPORTING_LIBS = $(addsuffix .explib,${LIBRARIES})
TARGET_LIBS = $(addsuffix .${LIBEXT},${LIBRARIES})
SOURCES_TO_SYMLINK += $(wildcard c/*) $(wildcard h/*) $(wildcard s/*)
ifneq (objs,$(notdir ${CURDIR}))
# Makefile invoked from same directory
# Create link farm, then execute the makefile from within it
all_libs export_hdrs export_libs clean links: ${SYMLINK_DEPEND}
ifneq (clean,${MAKECMDGOALS})
$(foreach linksource,${SOURCES_TO_SYMLINK}, \
$(shell \
linkdest=`echo ${linksource} | sed -e 's,\([^/]*\)/\([^/]*\)$$,\2.\1,' -e 's,^,objs/,'`; \
linkdestdir=`echo $$linkdest | sed -e 's,/[^/]*$$,,'`; \
linkbackpath=`echo $$linkdestdir | sed -e 's,[^/]*,..,g'`; \
[ -d ${linksource} ] || [ -L $$linkdest ] || ${MKDIR} $$linkdestdir; \
[ -d ${linksource} ] || [ -L $$linkdest ] || ln -s $$linkbackpath/${linksource} $$linkdest; \
) \
)
endif
@[ -d objs ] || ${MKDIR} objs
ifneq (links,${MAKECMDGOALS})
@${MAKE} -C objs -f ../$(firstword ${MAKEFILE_LIST}) ${MAKECMDGOALS}
endif
else
# Makefile invoked from objs subdirectory
all_libs: ${TARGET_LIBS}
@${ECHO} ${COMPONENT}: library built
${DIRS}:
${TOUCH} $@
clean :: ${CLEAN_DEPEND}
@${ECHO} Cleaning...
@cd .. && ${WIPE} objs ${WFLAGS}
@${ECHO} ${COMPONENT}: cleaned
export: export_${PHASE}
${NOP}
export_: export_libs export_hdrs
${NOP}
create_exp_hdr_dirs:
${MKDIR} ${EXPDIR}
create_exp_lib_dir:
${MKDIR} ${EXPDIR}
.SUFFIXES: .exphdr .expasm .explib .h .Hdr .${LIBEXT}
.h.exphdr:; ${CP} $< ${EXPDIR}/$< ${CPFLAGS}
.Hdr.expasm:; ${CP} $< ${EXPDIR}/$< ${CPFLAGS}
.${LIBEXT}.explib:; ${CP} $< ${EXPDIR}/$< ${CPFLAGS}
export_hdrs: create_exp_hdr_dirs ${DIRS} ${EXPORTING_ASMHDRS} ${EXPORTING_HDRS}
[ ! -f ../VersionNum ] || ${CP} ../VersionNum ${EXPDIR}/LibVersion ${CPFLAGS}
@${ECHO} ${COMPONENT}: header export complete
export_libs: create_exp_lib_dir ${DIRS} ${EXPORTING_LIBS} ${TARGET_LIBS}
[ ! -f ../VersionNum ] || ${CP} ../VersionNum ${EXPDIR}/LibVersion ${CPFLAGS}
@${ECHO} ${COMPONENT}: library export complete
${LIBRARY}${CUSTOMLIB}.${LIBEXT}: ${DIRS} ${APP_OBJS}
${AR} ${ARFLAGS} ${LIBRARY}.${LIBEXT} ${APP_OBJS}
${LIBRARYZM}${CUSTOMLIBZM}.${LIBEXT}: ${DIRS} ${MOD_OBJS}
${AR} ${ARFLAGS} ${LIBRARYZM}.${LIBEXT} ${MOD_OBJS}
${LIBRARYD}${CUSTOMLIBD}.${LIBEXT}: ${DIRS} ${APP_DBG_OBJS}
${AR} ${ARFLAGS} ${LIBRARYD}.${LIBEXT} ${APP_DBG_OBJS}
${LIBRARYDZM}${CUSTOMLIBDZM}.${LIBEXT}: ${DIRS} ${MOD_DBG_OBJS}
${AR} ${ARFLAGS} ${LIBRARYDZM}.${LIBEXT} ${MOD_DBG_OBJS}
include $(wildcard *.d)
include $(wildcard *.dz)
include $(wildcard *.dd)
include $(wildcard *.ddz)
endif
# EOF
# Makefile fragment for defining standard debug rules for various tools
#
ifeq (GNU,${TOOLCHAIN})
CDFLAGS += -g -O0
C++DFLAGS += -g -O0
ASDFLAGS +=
LDDFLAGS +=
else
CDFLAGS += -gflv
C++DFLAGS += +g
ASDFLAGS += -G
LDDFLAGS += -d
endif
.SUFFIXES: .i .od .odz .s .c .h .c++ .cpp
# C source files -> object files
.c.od:
${CC} $(filter-out ${C_NO_FNAMES},${CFLAGS}) ${CDFLAGS} -o $@ $<
$(call make-depend,$<,$@,$(subst .od,.dd,$@))
.c.odz:
${CC} $(filter-out ${C_NO_FNAMES},${CFLAGS}) ${CDFLAGS} ${C_MODULE} -o $@ $<
$(call make-depend,$<,$@,$(subst .odz,.ddz,$@))
.c.i:
${CPREPRO} ${CFLAGS} -C $< > $@
# C++ source files -> object files
.c++.od:
${C++} $(filter-out ${C_NO_FNAMES},${C++FLAGS}) ${C++DFLAGS} -o $@ $<
$(call make-depend,$<,$@,$(subst .od,.dd,$@))
.cpp.od:
${C++} $(filter-out ${C_NO_FNAMES},${C++FLAGS}) ${C++DFLAGS} -o $@ $<
$(call make-depend,$<,$@,$(subst .od,.dd,$@))
.c++.odz:
${C++} $(filter-out ${C_NO_FNAMES},${C++FLAGS}) ${C++DFLAGS} ${C_MODULE} -o $@ $<
$(call make-depend,$<,$@,$(subst .odz,.ddz,$@))
.cpp.odz:
${C++} $(filter-out ${C_NO_FNAMES},${C++FLAGS}) ${C++DFLAGS} ${C_MODULE} -o $@ $<
$(call make-depend,$<,$(subst .odz,.ddz,$@))
.c++.i:
${CPREPRO} ${C++FLAGS} -C $< > $@
.cpp.i:
${CPREPRO} ${C++FLAGS} -C $< > $@
# Assembler source files -> object files
.s.od:
${AS} ${ASFLAGS} ${ASDFLAGS} -depend $(subst .od,.dd,$@) -o $@ $<
.s.odz:
${AS} ${ASFLAGS} ${ASDFLAGS} -depend $(subst .odz,.ddz,$@) -pd "zM SETL {TRUE}" -o $@ $<
.s.i:
@${NOP}
# EOF
# Makefile fragment for C applications that run on the build host but which
# are built during the main build
#
#
# These are the tool definitions for Posix hosted builds.
#
#
#
# Tool definitions.
#
CC = gcc
DO =
ECHO = echo
LD = g++
MAKE = make
MKDIR = mkdir -p
SED = sed
SQZ = @echo > /dev/null
STRIP = strip
TOUCH = touch
#
# Options.
#
STDTOOLOPTIONS = ${THROWBACK}
C_WARNINGS := -Wall -Wextra
C_OPTSIZE := -Os
C_OPTSPEED := -O3
CFLAGS += -c ${STDTOOLOPTIONS} ${CDEFINES} ${CINCLUDES} ${C_WARNINGS} -I. -O2 -std=c99
# EOF
# Makefile fragment for defining standard rules for various tools
#
# $(call make-depend,source,object,depend)
define make-depend
@${CC} ${CFLAGS} -M $1 > $3 2> /dev/null
@${SED} -i -e 's,$(basename $2).o *:,$2:,' $3
endef
# $(call make-depend,source,object,depend)
ifeq (GNU,${TOOLCHAIN})
define make-cpp-depend
@${C++} ${C++FLAGS} -M $1 > $3 2> /dev/null
@${SED} -i -e 's,$(basename $2).o *:,$2:,' $3
endef
else
define make-cpp-depend
endef
endif
.SUFFIXES: .o .oz .s .c .h .c++ .cpp
# C source files -> object files
.c.o:
${CC} ${CFLAGS} -o $@ $<
$(call make-depend,$<,$@,$(subst .o,.d,$@))
.c.oz:
${CC} ${CFLAGS} ${C_MODULE} -o $@ $<
$(call make-depend,$<,$@,$(subst .oz,.dz,$@))
# C++ source files -> object files
.c++.o:
${C++} ${C++FLAGS} -o $@ $<
$(call make-cpp-depend,$<,$@,$(subst .o,.d,$@))
.cpp.o:
${C++} ${C++FLAGS} -o $@ $<
$(call make-cpp-depend,$<,$@,$(subst .o,.d,$@))
.c++.oz:
${C++} ${C++FLAGS} ${C_MODULE} -o $@ $<
$(call make-cpp-depend,$<,$@,$(subst .oz,.dz,$@))
.cpp.oz:
${C++} ${C++FLAGS} ${C_MODULE} -o $@ $<
$(call make-cppp-depend,$<,$@,$(subst .oz,.dz,$@))
# Assembler source files -> object files
.s.o:
${AS} ${ASFLAGS} -depend $(subst .o,.d,$@) -o $@ $<
.s.oz:
${AS} ${ASFLAGS} -depend $(subst .oz,.dz,$@) -pd "zM SETL {TRUE}" -o $@ $<
# EOF
# Makefile fragment for defining the various tools and their options
#
# These are the tool definitions for builds using the GNU toolchain in a POSIX environment.
#
ifneq (Host,${APCS})
GNUTOOLPREFIX = arm-unknown-riscos-
SUFFIX_ABSOLUTE = ,ff8
SUFFIX_DEBIMAGE = ,fd3
endif
#
# Core toolset.
#
ifeq (GNU,${TOOLCHAIN})
AOFASM = asasm -aof
AR = ${GNUTOOLPREFIX}ar
AS = asasm
CC = ${GNUTOOLPREFIX}gcc
C++ = ${GNUTOOLPREFIX}g++
CMHG = cmunge
CPREPRO = gcc -E -x c
ELF2AIF = elf2aif
ifeq (C++,${LINK_TYPE})
LD = ${GNUTOOLPREFIX}g++
else
LD = ${GNUTOOLPREFIX}gcc
endif
ifneq (Host,${APCS})
STRIP = @echo > /dev/null
else
STRIP = strip
endif
else
AOFASM = armasm
AR = armlib
AS = armasm
CC = armcc
C++ = armcpp
CMHG = armcmhg
CPREPRO = armcc -C++ -E
ELF2AIF = @echo > /dev/null
ifeq (C++,${LINK_TYPE})
LD = armlink -c++
else
LD = armlink
endif
STRIP = @echo > /dev/null
endif
BINAOF = binaof
CAT = cat
#DATA2AOF = datatoaof
#DEFMOD = defmod
DO =
ECHO = echo
FILTERCOMP = FilterComp,102
FILTERCOMP2 = FilterComp2,102
GETVERSION = GetVersion,102
HDR2H = Hdr2H,102
INSTRES = InstRes,102
MAKE = make
MODGEN = modgen
MODSQZ = modsqz
NOP = @#
PERL = perl
RESGEN = resgen
RM = rm
#SETTYPE = settype
#SQUASH = squash
ifneq (Host,${APCS})
SQZ = armsqueeze
else
SQZ = @echo > /dev/null
endif
#STRIPDEPEND = stripdepnd
TIDYDESC = TidyDesc,102
#TLINK = tlink
#TOGPA = ToGPA
#TOKENCHECK = tokencheck
#TOKENISE = tokenise
TOUCH = touch
#TRANSLATE = translate
#UNMODSQZ = unmodsqz
AWK = awk
CD = cd
CHMOD = chmod
DF = df
DIFF = diff
EGREP = egrep
FIND = find
GAWK = gawk
#IDENT = GNU.ident
LEX = flex
LS = ls
MKDIR = mkdir -p
PWD = pwd
RPCGEN = rpcgen
SED = sed
WC = wc
YACC = bison
ZIP = zip -9qr
UNZIP = unzip
#
# Standard options. These can be added to or overridden in the
# including makefile.
#
STDTOOLOPTIONS = ${THROWBACK}
ASFLAGS += ${STDTOOLOPTIONS} ${ASMDEFINES} ${ASMINCLUDES}
ifeq (GNU,${TOOLCHAIN})
ifeq (Host,${APCS})
CINCLUDES += -I${LIBDIR}/CLib
C++INCLUDES += -I${LIBDIR}/CLib
else
# GCCSDK seems to use the CLib headers instead of its own ones, which is a bad thing unless/until they gain GCC compatibility
endif
else
CINCLUDES += -I${LIBDIR}/CLib
C++INCLUDES += -I${LIBDIR}/CLib
endif
CINCLUDES += -I${LIBDIR}/RISC_OSLib \
-I${CEXPORTDIR} \
-I${LIBDIR} \
-I.
C++INCLUDES += -I${LIBDIR}/RISC_OSLib \
-I${CEXPORTDIR} \
-I${LIBDIR} \
-I.
ifeq (GNU,${TOOLCHAIN})
ifeq (Host,${APCS})
C++INCLUDES += -I${LIBDIR}/c++lib
else
# GCCSDK seems to use the C++Lib headers instead of its own ones, which is a bad thing unless/until they gain GCC compatibility
endif
else
C++INCLUDES += -I${LIBDIR}/c++lib
endif
CFLAGS += -c ${STDTOOLOPTIONS} ${CDEFINES} ${CINCLUDES} ${C_NO_FNAMES} ${C_WARNINGS}
C++FLAGS += -c ${STDTOOLOPTIONS} ${C++DEFINES} ${C++INCLUDES}
CMHGFLAGS += -p ${STDTOOLOPTIONS} ${CMHGDEFINES} ${CMHGINCLUDES}
ifeq (GNU,${TOOLCHAIN})
ARFLAGS := r
ASFLAGS += ${ASASM_TOOLOPTIONS}
CFLAGS += ${GCC_TOOLOPTIONS} -O2 -std=c99
C++FLAGS += -O2
CMHGFLAGS += ${CMUNGE_TOOLOPTIONS}
C_WARNINGS := -Wall -Wextra
C_OPTSIZE := -Os
C_OPTSPEED := -O3
C_NO_ZI := -fno-zero-initialized-in-bss
ifeq (Host,${APCS})
GCC_TOOLOPTIONS :=
else
C_NO_STKCHK := -mno-apcs-stack-check
C_STKCHK := -mapcs-stack-check
C_NO_FNAMES := -mno-poke-function-name
C_MODULE := -mmodule
CFLAGS += -mlibscl
C++FLAGS += -mlibscl
LDFLAGS += -mlibscl
endif
else
ARFLAGS := -c -o
ASFLAGS += ${OBJASM_TOOLOPTIONS} -Stamp -quit
CFLAGS += ${NCC_TOOLOPTIONS}
CMHGFLAGS += ${TOOLOPTIONS}
C_WARNINGS := -fah
C_OPTSIZE := -Ospace
C_OPTSPEED := -Otime
C_NO_ZI := -zz100000
C_NO_STKCHK := -zps1
C_STKCHK := -zps0
C_NO_FNAMES := -ff
C_MODULE := -zM
endif
#
# Recursive forced copying options.
#
# CPFLAGS go after the arguments
# CPPREFLAGS go before the arguments
#
CPFLAGS =
CPPREFLAGS = -afL
CP = cp ${CPPREFLAGS}
#
# Recursive forced deletion with no errors.
#
# WFLAGS go after the arguments
# WPREFLAGS go before the arguments
#
WFLAGS =
WPREFLAGS = -rf
WIPE = rm ${WPREFLAGS}
# Alternative version (implementation differs on RISC OS).
XWIPE = rm ${WPREFLAGS}
# Directory separator character
SEP = /
# EOF
......@@ -38,6 +38,13 @@
# from ${OBJS})
# APP_DBG_OBJS (opt) (object files for debug app version - otherwise derived
# from ${DBG_OBJS})
# CLEAN_DEPEND (opt) (phony target for additional clean actions)
# LINK_TYPE (opt) (variant of linking command, eg C++ - defaults to C)
# INSTTYPE (opt) (use "tool" or "app" to install executable vs application - defaults to "tool")
# INSTALLAPPFILES (opt) (list of files to be installed in application directory - use InstRes specification rules)
# INSTALLAPP_DEPEND (opt) (list of dependencies to be satisfied before doing application install - ${TARGET} assumed if in INSTALLAPPFILES)
# CUSTOMINSTALLAPP (opt) (set to "custom" to override the install rule for resource files)
# CUSTOMINSTALLTOOL (opt) (set to "custom" to override the install rule for target binary)
#
#
# It relies on the following generic tool macros from the StdTools makefile
......@@ -78,6 +85,10 @@ DIRS ?= o._dirs
OBJS ?= ${TARGET}
DBG_OBJS ?= ${OBJS}
DBG_LIBS ?= ${LIBS}
ifeq (C++,${LINK_TYPE})
LIBS += ${C++LIB}
DBG_LIBS += ${C++LIB}
endif
LIBS += ${CLIB}
DBG_LIBS += ${DEBUGLIBS} ${CLIB}
APP_OBJS ?= $(addprefix o.,${OBJS})
......@@ -91,7 +102,7 @@ ${DIRS} ::
${MKDIR} od
${TOUCH} $@
clean ::
clean :: ${CLEAN_DEPEND}
@IfThere o Then ${ECHO} ${WIPE} o ${WFLAGS}
@IfThere o Then ${WIPE} o ${WFLAGS}
@IfThere od Then ${ECHO} ${WIPE} od ${WFLAGS}
......@@ -100,10 +111,26 @@ clean ::
${RM} ${DBG_TARGET}
@${ECHO} ${COMPONENT}: cleaned
install: ${TARGET}
install: install_${INSTTYPE}
install_: install_tool
INSTALLAPP_DEPEND += $(filter ${TARGET},${INSTALLAPPFILES})
install_app${CUSTOMINSTALLAPP}: ${INSTALLAPP_DEPEND}
${MKDIR} ${INSTAPP}
${INSTRES} -I Resources.${USERIF}.${LOCALE},Resources.${USERIF}.UK,Resources.${LOCALE},Resources.UK,Resources ${INSTAPP} ${INSTALLAPPFILES}
ifneq (,$(filter Desc,${INSTALLAPPFILES}))
${CPREPRO} -I. ${INSTAPP}.Desc > ${INSTAPP}.DescTmp
${TIDYDESC} ${INSTAPP}.Desc ${INSTAPP}.DescTmp
${RM} ${INSTAPP}.DescTmp
endif
@${ECHO} ${COMPONENT}: application installation complete
install_tool${CUSTOMINSTALLTOOL}: ${TARGET}
${MKDIR} ${INSTDIR}
${CP} ${TARGET} ${INSTDIR}.${TARGET} ${CPFLAGS}
@${ECHO} ${COMPONENT}: application installation complete
@${ECHO} ${COMPONENT}: tool installation complete
debug: ${DBG_TARGET}
@${ECHO} ${COMPONENT}: debug application built
......
......@@ -42,6 +42,7 @@
# APP_DBG_OBJS (opt) (object files for debug app version - otherwise derived from ${DBG_OBJS})
# MOD_OBJS (opt) (object files for module version - otherwise derived from ${OBJS})
# MOD_DBG_OBJS (opt) (object files for debug module version - otherwise derived from ${DBG_OBJS})
# CLEAN_DEPEND (opt) (phony target for additional clean actions)
# CUSTOMLIB (opt) (set to "custom" to override the application library rule)
# CUSTOMLIBZM (opt) (set to "custom" to override the module library rule)
# CUSTOMLIBD (opt) (set to "custom" to override the debug application library rule)
......@@ -117,7 +118,7 @@ ${DIRS} ::
${MKDIR} ${LIBEXT}
${TOUCH} $@
clean ::
clean :: ${CLEAN_DEPEND}
@IfThere o Then ${ECHO} ${WIPE} o ${WFLAGS}
@IfThere o Then ${WIPE} o ${WFLAGS}
@IfThere oz Then ${ECHO} ${WIPE} oz ${WFLAGS}
......@@ -162,15 +163,15 @@ export_libs: ${EXPORTING_LIBS} ${TARGET_LIBS} ${DIRS} create_exp_lib_dir
@${ECHO} ${COMPONENT}: library export complete
${LIBEXT}.${LIBRARY}${CUSTOMLIB}: ${APP_OBJS} ${DIRS}
${AR} ${ARFLAGS} -o ${LIBEXT}.${LIBRARY} ${APP_OBJS}
${AR} ${ARFLAGS} ${LIBEXT}.${LIBRARY} ${APP_OBJS}
${LIBEXT}.${LIBRARYZM}${CUSTOMLIBZM}: ${MOD_OBJS} ${DIRS}
${AR} ${ARFLAGS} -o ${LIBEXT}.${LIBRARYZM} ${MOD_OBJS}
${AR} ${ARFLAGS} ${LIBEXT}.${LIBRARYZM} ${MOD_OBJS}
${LIBEXT}.${LIBRARYD}${CUSTOMLIBD}: ${APP_DBG_OBJS} ${DIRS}
${AR} ${ARFLAGS} -o ${LIBEXT}.${LIBRARYD} ${APP_DBG_OBJS}
${AR} ${ARFLAGS} ${LIBEXT}.${LIBRARYD} ${APP_DBG_OBJS}
${LIBEXT}.${LIBRARYDZM}${CUSTOMLIBDZM}: ${MOD_DBG_OBJS} ${DIRS}
${AR} ${ARFLAGS} -o ${LIBEXT}.${LIBRARYDZM} ${MOD_DBG_OBJS}
${AR} ${ARFLAGS} ${LIBEXT}.${LIBRARYDZM} ${MOD_DBG_OBJS}
# EOF
......@@ -26,17 +26,17 @@ LDDFLAGS += -d
.SUFFIXES: .i .od .odz .s .c .h .c++ .cpp
# C source files -> object files
.c.od:; ${CC} $(filter-out -ff,${CFLAGS}) ${CDFLAGS} -o $@ $<
.c.odz:; ${CC} $(filter-out -ff,${CFLAGS}) ${CDFLAGS} -zM -o $@ $<
.c.i:; ${CC} ${CFLAGS} -E -C $< > $@
.c.od:; ${CC} $(filter-out ${C_NO_FNAMES},${CFLAGS}) ${CDFLAGS} -o $@ $<
.c.odz:; ${CC} $(filter-out ${C_NO_FNAMES},${CFLAGS}) ${CDFLAGS} ${C_MODULE} -o $@ $<
.c.i:; ${CPREPRO} ${CFLAGS} -C $< > $@
# C++ source files -> object files
.c++.od:; ${C++} ${C++FLAGS} ${C++DFLAGS} -o $@ $<
.cpp.od:; ${C++} ${C++FLAGS} ${C++DFLAGS} -o $@ $<
.c++.odz:; ${C++} ${C++FLAGS} ${C++DFLAGS} -zM -o $@ $<
.cpp.odz:; ${C++} ${C++FLAGS} ${C++DFLAGS} -zM -o $@ $<
.c++.i:; ${C++} ${C++FLAGS} -E -C $< > $@
.cpp.i:; ${C++} ${C++FLAGS} -E -C $< > $@
.c++.od:; ${C++} $(filter-out ${C_NO_FNAMES},${C++FLAGS}) ${C++DFLAGS} -o $@ $<
.cpp.od:; ${C++} $(filter-out ${C_NO_FNAMES},${C++FLAGS}) ${C++DFLAGS} -o $@ $<
.c++.odz:; ${C++} $(filter-out ${C_NO_FNAMES},${C++FLAGS}) ${C++DFLAGS} ${C_MODULE} -o $@ $<
.cpp.odz:; ${C++} $(filter-out ${C_NO_FNAMES},${C++FLAGS}) ${C++DFLAGS} ${C_MODULE} -o $@ $<
.c++.i:; ${CPREPRO} ${C++FLAGS} -C $< > $@
.cpp.i:; ${CPREPRO} ${C++FLAGS} -C $< > $@
# Assembler source files -> object files
.s.od:; ${AS} ${ASFLAGS} ${ASDFLAGS} -o $@ $<
......
......@@ -31,13 +31,20 @@ MAKE = amu
MKDIR = ${DO} mkdir -p
SQZ = squeeze
TOUCH = create
RM = remove
WIPE = -wipe
#
# Options.
#
STDTOOLOPTIONS = -depend !Depend ${THROWBACK}
CFLAGS += -c ${STDTOOLOPTIONS} ${CDEFINES} ${CINCLUDES}
C_WARNINGS := -fah
C_OPTSIZE := -Ospace
C_OPTSPEED := -Otime
C_NO_FNAMES := -ff
CFLAGS += -c ${STDTOOLOPTIONS} ${CDEFINES} ${CINCLUDES} ${C_NO_FNAMES} ${C_WARNINGS}
WFLAGS = FR~C~V
# EOF
......@@ -22,13 +22,13 @@
# C source files -> object files
.c.o:; ${CC} ${CFLAGS} -o $@ $<
.c.oz:; ${CC} ${CFLAGS} -zM -o $@ $<
.c.oz:; ${CC} ${CFLAGS} ${C_MODULE} -o $@ $<
# C++ source files -> object files
.c++.o:; ${C++} ${C++FLAGS} -o $@ $<
.cpp.o:; ${C++} ${C++FLAGS} -o $@ $<
.c++.oz:; ${C++} ${C++FLAGS} -zM -o $@ $<
.cpp.oz:; ${C++} ${C++FLAGS} -zM -o $@ $<
.c++.oz:; ${C++} ${C++FLAGS} ${C_MODULE} -o $@ $<
.cpp.oz:; ${C++} ${C++FLAGS} ${C_MODULE} -o $@ $<
# Assembler source files -> object files
.s.o:; ${AS} ${ASFLAGS} -o $@ $<
......
......@@ -26,6 +26,7 @@ STDMAKEKFILE=$Id$
# Core toolset.
#
AASM = aasm
AOFASM = objasm
AR = libfile
AS = objasm
BINAOF = binaof
......@@ -33,8 +34,8 @@ CAT = print
CC = cc
C++ = c++
CMHG = cmhg
CPREPRO = cc -C++ -E
DATA2AOF = datatoaof
DECAOF = decaof
DEFMOD = defmod
DO = do
ECHO = echo
......@@ -42,7 +43,12 @@ FILTERCOMP = ${PERL} Build:FilterComp
FILTERCOMP2 = ${PERL} Build:FilterComp2
GETVERSION = ${PERL} Build:GetVersion
HDR2H = ${PERL} Build:Hdr2H
INSTRES = <Perl$Dir>.perl Build:InstRes
ifeq (C++,${LINK_TYPE})
LD = link -c++
else
LD = link
endif
MAKE = amu
MODGEN = modgen
MODSQZ = modsqz
......@@ -94,10 +100,20 @@ STDTOOLOPTIONS = -depend !Depend ${THROWBACK}
AASMFLAGS += -Stamp -quit ${STDTOOLOPTIONS} ${AASMDEFINES} ${AASMINCLUDES}
ASFLAGS += -Stamp -quit ${STDTOOLOPTIONS} ${ASMDEFINES} ${ASMINCLUDES}
CFLAGS += -c ${STDTOOLOPTIONS} ${CDEFINES} ${CINCLUDES}
CFLAGS += -c ${STDTOOLOPTIONS} ${CDEFINES} ${CINCLUDES} ${C_NO_FNAMES} ${C_WARNINGS}
C++INCLUDES += -ICPP:
C++FLAGS += -c ${STDTOOLOPTIONS} ${C++DEFINES} ${C++INCLUDES}
CMHGFLAGS += -p ${STDTOOLOPTIONS} ${CMHGDEFINES} ${CMHGINCLUDES}
ARFLAGS += -c -o
ARFLAGS += -c
C_WARNINGS := -fah
C_OPTSIZE := -Ospace
C_OPTSPEED := -Otime
C_NO_ZI := -zz100000
C_NO_STKCHK := -zps1
C_STKCHK := -zps0
C_NO_FNAMES := -ff
C_MODULE := -zM
#
# Recursive forced copying options.
......@@ -125,4 +141,8 @@ WIPE = -wipe ${WPREFLAGS}
XWIPE = x wipe ${WPREFLAGS}
# Directory separator character
SEP = .
# EOF
/* (5.00)
/* (5.01)
*
* This file is automatically maintained by srccommit, do not edit manually.
* Last processed by srccommit version: 1.1.
*
*/
#define Module_MajorVersion_CMHG 5.00
#define Module_MajorVersion_CMHG 5.01
#define Module_MinorVersion_CMHG
#define Module_Date_CMHG 23 Mar 2010
#define Module_Date_CMHG 19 May 2010
#define Module_MajorVersion "5.00"
#define Module_Version 500
#define Module_MajorVersion "5.01"
#define Module_Version 501
#define Module_MinorVersion ""
#define Module_Date "23 Mar 2010"
#define Module_Date "19 May 2010"
#define Module_ApplicationDate "23-Mar-10"
#define Module_ApplicationDate "19-May-10"
#define Module_ComponentName "BuildSys"
#define Module_ComponentPath "castle/RiscOS/BuildSys"
#define Module_FullVersion "5.00"
#define Module_HelpVersion "5.00 (23 Mar 2010)"
#define Module_LibraryVersionInfo "5:0"
#define Module_FullVersion "5.01"
#define Module_HelpVersion "5.01 (19 May 2010)"
#define Module_LibraryVersionInfo "5:1"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment