From df49c60c9671e4a28e636964d744c1f59fb6cb68 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Mon, 12 Jun 2000 15:00:15 +0000 Subject: Merged from 4.5.0-beta3a --- c/src/make/Makefile.am | 29 ++--- c/src/make/README | 158 +++++++++++++++------------- c/src/make/compilers/Makefile.am | 7 +- c/src/make/compilers/gcc-target-default.cfg | 20 ++-- c/src/make/configure.in | 6 +- c/src/make/custom/Makefile.am | 7 +- c/src/make/host.cfg.in | 8 +- c/src/make/leaf.cfg | 13 --- c/src/make/main.cfg.in | 76 +------------ 9 files changed, 118 insertions(+), 206 deletions(-) (limited to 'c/src/make') diff --git a/c/src/make/Makefile.am b/c/src/make/Makefile.am index 01bac334d9..4c09e3160b 100644 --- a/c/src/make/Makefile.am +++ b/c/src/make/Makefile.am @@ -5,35 +5,24 @@ AUTOMAKE_OPTIONS = foreign 1.4 ACLOCAL_AMFLAGS = -I $(RTEMS_TOPdir)/aclocal -rtems_makedir=$(prefix)/make +rtems_makedir = $(prefix)/make -GENERIC_FILES = \ -host.cfg +GENERIC_FILES = host.cfg -MAKE_FILES = README \ -directory.cfg leaf.cfg \ -lib.cfg +MAKE_FILES = README directory.cfg lib.cfg -rtems_make_DATA = \ -$(MAKE_FILES) \ -$(GENERIC_FILES) +rtems_make_DATA = $(MAKE_FILES) $(GENERIC_FILES) -noinst_DATA = \ -main.cfg +noinst_DATA = main.cfg leaf.cfg rtemsdir = $(prefix) rtems_bspdir = $(rtemsdir)/@RTEMS_BSP@ -rtems_bsp_DATA = \ -Makefile.inc +rtems_bsp_DATA = Makefile.inc rtems_bsp_makedir = $(rtems_bspdir)/make -rtems_bsp_make_DATA = \ -bsp.cfg +rtems_bsp_make_DATA = bsp.cfg if MAINTAINER_MODE -$(srcdir)/main.cfg.in: $(top_srcdir)/@RTEMS_TOPdir@/make/main.cfg - sed -e 's%\$$(RTEMS_BSP)%\@RTEMS_BSP\@%g' < $< >$@ - $(srcdir)/host.cfg.in: $(top_srcdir)/@RTEMS_TOPdir@/make/host.cfg.in cp $< $@ @@ -48,5 +37,9 @@ include $(RTEMS_ROOT)/make/custom/@RTEMS_BSP@.cfg @echo rtems_cv_RTEMS_CPU_MODEL=\$${rtems_cv_RTEMS_CPU_MODEL=$(RTEMS_CPU_MODEL)} >> $@ @echo rtems_cv_RTEMS_BSP_FAMILY=\$${rtems_cv_RTEMS_BSP_FAMILY=$(RTEMS_BSP_FAMILY)} >> $@ +DISTCLEANFILES = @RTEMS_BSP@.cache + +EXTRA_DIST = leaf.cfg + include $(top_srcdir)/../../../automake/subdirs.am include $(top_srcdir)/../../../automake/local.am diff --git a/c/src/make/README b/c/src/make/README index 911d2b8aea..8a3d599aef 100644 --- a/c/src/make/README +++ b/c/src/make/README @@ -4,21 +4,26 @@ make/README - This file describes the layout and conventions of the make tree used in - the RTEMS software project and others. + This file describes the layout and conventions of the application + makefile support for RTEMS applications. Internally, RTEMS uses + GNU-style autoconf/automake Makefiles as much as possible to + ease integration with other GNU tools. + All of these "make" trees are substantially similar; however this - file documents the current state of the rtems Makefile tree. + file documents the current state of the RTEMS Application Makefile + support. - This make tree was developed originally to simplify porting projects - between various os's. The primary goals are: + This make tree is based on a build system originally developed + to simplify porting projects between various OS's. The primary + goals were: . simple *and* customizable individual makefiles . use widely available GNU make. There is no pre-processing or automatic generation of Makefiles. - . Same makefiles work on *many* host os's due to portability - of GNU make and the host os config files. + . Same makefiles work on *many* host OS's due to portability + of GNU make and the host OS config files. . Support for different compilers and operating systems on a per-user basis. Using the same sources (including @@ -35,6 +40,13 @@ PATH variable is set to, you should get the same thing when you 'make' as everyone else on the project. + This Makefile system has evolved into its present form and as it + exists in RTEMS today, its sole goal is to build RTEMS applications. + The use of these Makefiles hides the complexity of producing + executables for a wide variety of embedded CPU families and target + BSPs. Switching between RTEMS BSPs is accomplished via setting + the environment variable "RTEMS_MAKEFILE_PATH." + This description attempts to cover all aspects of the Makefile tree. Most of what is described here is maintained automatically by the configuration files. @@ -88,7 +100,7 @@ combining source and directories (that make(1) would be expected to recurse into) in one source directory. Ie., a directory in the source tree may contain EITHER source files OR recursive sub directories, but NOT - both. + both. This assumption is generally shared with GNU automake. Variants (where objects go) --------------------------- @@ -96,30 +108,30 @@ All binary targets are placed in a sub-directory whose name is (for example): - o-pc386/ -- binaries (no debug, no profile) - o-pc386-debug/ -- debug binaries - o-pc386-profile/ -- profiling binaries - - Using the template Makefiles, this will all happen automatically. + o-optimize/ -- optimized binaries + o-debug/ -- debug binaries + o-profile/ -- profiling binaries - Within a Makefile, the ${ARCH} variable is set to o-pc386, - o-pc386-debug, etc., as appropriate. + Using the template Makefiles, this will all happen automatically. + The contents of these directories are specific to a BSP. - Typing 'make' will place objects in o-pc386. - 'make debug' will place objects in o-pc386-debug. - 'make profile' will place objects in o-pc386-profile. + Within a Makefile, the ${ARCH} variable is set to o-optimize, + o-debug, etc., as appropriate. - NOTE: For RTEMS work, the word 'pc386' is the specified - RTEMS_BSP (specified in the modules file) + HISTORICAL NOTE: Prior to version 4.5, the name of the sub-directory + in which objects were placed included the BSP name. + + Typing 'make' will place objects in o-optimize. + 'make debug' will place objects in o-debug. + 'make profile' will place objects in o-profile. The debug and profile targets are equivalent to 'all' except that CFLAGS and/or LDFLAGS are modified as per the compiler config file for debug and profile support. - The targets debug, profile, etc., can be - invoked recursively at the directory make level. So from the top of a - tree, one could install a debug version of everything under that point - by: + The targets debug, profile, etc., can be invoked recursively at + the directory make level. So from the top of a tree, one could + install a debug version of everything under that point by: $ cd src/lib $ gmake debug @@ -131,14 +143,14 @@ For example, the following fragments link the normal, debug, or profile version of "libmine.a" as appropriate: - LDLIBS += $(LIBMINE) + LD_LIBS += $(LIBMINE) LIBMINE = ../libmine/${ARCH}/libmine.a ${ARCH}/pgm: $(LIBMINE) ${OBJS} - $(LINK.c) -o $@ ${OBJS} $(LDLIBS) + $(make-exe) If we do 'gmake debug', then the library in - ../libmine/sparc-debug/libmine.a will be linked in. If $(LIBMINE) + ../libmine/o-debug/libmine.a will be linked in. If $(LIBMINE) might not exist (or might be out of date) at this point, we could add ${LIBMINE}: FORCEIT @@ -165,9 +177,6 @@ the included config files: clean -- delete all targets - clobber -- 'clean' plus delete sccs'd files - lint -- run lint or lint-like tool - get -- "sccs get" all sources depend -- build a make dependency file "variant targets" -- special variants, see below @@ -186,9 +195,9 @@ All Makefiles include a customization file which is used to select compiler and host operating system. The environment variable - RTEMS_CUSTOM must point to this file; eg: + RTEMS_MAKEFILE_PATH must point to the directory containing this file; eg: - /.../make/custom/pc386.cfg + export RTEMS_MAKEFILE_PATH=/.../pc386/ All leaf Makefile's also include either 'make/leaf.cfg' (or 'make/lib.cfg' for building libraries). These config files provide @@ -209,14 +218,6 @@ compiler ( make/compilers/??.cfg ) - private customization files - --------------------------- - - [ $(RTEMS_CUSTOM) ] - - Your own private configuration file. Specifies which of the above - files you want to include. - generic rules file ------------------ @@ -257,29 +258,32 @@ ----------------------- Variables you have to set in the environment or in your Makefile. - Note: the rtems module files set RTEMS_ROOT and RTEMS_CUSTOM + Note: the RTEMS module files set RTEMS_ROOT and RTEMS_CUSTOM for you. - Environment Variables - --------------------- + Makefile Variables + ------------------ + + RTEMS_BSP -- name of your 'bsp' eg: pc386, mvme136 + + RTEMS_CPU -- CPU architecture e.g.: i386, m68k - RTEMS_BSP -- name of your 'bsp' eg: pc386 + RTEMS_CPU_FAMILY -- CPU model e.g.: i486dx, m68020 RTEMS_ROOT -- The root of your source tree. All other file names are derived from this. - [ eg: % setenv RTEMS_ROOT $HOME/work/rtems ] + [ eg: % setenv RTEMS_ROOT $HOME/work/RTEMS ] RTEMS_CUSTOM -- name of your config files in make/custom Example: $(RTEMS_ROOT)/make/custom/$(RTEMS_BSP).cfg - RTEMS_GNUTOOLS -- root of the gcc tools for the target - The value RTEMS_ROOT is used in the custom files to generate the make(1) variables: - PROJECT_ROOT PROJECT_RELEASE + PROJECT_BIN + PROJECT_INCLUDE PROJECT_TOOLS etc., which are used within the make config files themselves. @@ -289,7 +293,7 @@ Preset variables ---------------- - Aside from command names set by the os and compiler config files, + Aside from command names set by the OS and compiler config files, a number of MAKE variables are automatically set and maintained by the config files. @@ -305,16 +309,12 @@ -- directory for build environment commands [ eg: $(PROJECT_ROOT)/build-tools ] - TARCH -- ${TARGET_ARCH} - [ eg: o-forc386 ] - obsolete and should not be referenced - ARCH -- target sub-directory for object code - [ eg: o-pc386 or o-pc386-debug ] + [ eg: o-optimize or o-debug ] VARIANTS -- full list of all possible values for $(ARCH); used mainly for 'make clean' - [ eg: "o-pc386 o-pc386-debug o-pc386-profile" ] + [ eg: "o-optimize o-debug o-profile" ] VARIANT_VA -- Variant name. Normally "", but for 'make debug' it is "debug", @@ -355,14 +355,6 @@ -- ld option for dynamic libraries -Bdynamic or -dn (svr4) - LIB_SOCKET - -- ld(1) -l option(s) to provide - socket support. - - LIB_MATH -- ld(1) -l option(s) to provide - math library. - - Makefile Variables ------------------ @@ -389,10 +381,6 @@ leaf Makefiles. [ eg: CPPFLAGS += -I../include ] - YFLAGS -- Yacc flags. - leaf Makefiles. - [ eg: YFLAGS += -v ] - LD_PATHS -- arguments to -L for ld. Will be prefixed with '-L' or '-L ' as appropriate and included in LDFLAGS. @@ -434,27 +422,44 @@ Since 'make clobber' includes 'make clean', you don't need to duplicate items in both. - TARGET_ARCH -- target architecture (eg: o-pc386) - leaf makefiles only. - Should be specified before 'include leaf.cfg'. - Only needs to be specified if your target is - different from output of `arch`. - Command names ------------- The following commands should only be called as make variables: - MAKE,INSTALL,SHELL + MAKE,INSTALL,INSTALL_VARIANT,SHELL - ECHO,CAT,RM,CP,MV,LN,MKDIR,CHMOD + ECHO,CAT,CP,MV,LN,MKDIR,CHMOD - ED,SED + SED CC,CPP,AS,AR,LD,NM,SIZE,RANLIB,MKLIB, YACC,LEX,LINT,CTAGS,ETAGS + In addition, the following commands specifically support + the installation of libraries, executables, header files, + and other things that need to be installed: + + INSTALL_CHANGE - install a file only if the source + file is actually different than + the installed copy or if there is + no installed copy. USAGE: + + usage: install-if-change [ -vmV ] file [ file ... ] dest-directory-or-file + -v -- verbose + -V suffix -- suffix to append to targets (before any . suffix) + eg: -V _g would change 'foo' to 'foo_g' and + 'libfoo.a' to 'libfoo_g.a' + -m mode -- mode for new file(s) + + INSTALL_VARIANT - installs the built file using the + proper variant suffix (e.g. _g + for debug turns libmine.a into libmine_g.a) + This is implemented as a macro that + invokes install-if-change with the + appropriate -V argument setting. + Special Directory Makefile Targets ---------------------------------- @@ -486,4 +491,5 @@ Template "directory" makefile. + diff --git a/c/src/make/compilers/Makefile.am b/c/src/make/compilers/Makefile.am index d067af45a7..b12aec574d 100644 --- a/c/src/make/compilers/Makefile.am +++ b/c/src/make/compilers/Makefile.am @@ -4,12 +4,11 @@ AUTOMAKE_OPTIONS = foreign 1.4 -rtems_makedir=$(prefix)/make -rtems_make_compilersdir=$(rtems_makedir)/compilers +rtems_makedir = $(prefix)/make +rtems_make_compilersdir = $(rtems_makedir)/compilers ## At the moment all actively supported configurations ## use gcc-target-default.cfg only. -rtems_make_compilers_DATA= \ -gcc-target-default.cfg +rtems_make_compilers_DATA = gcc-target-default.cfg include $(top_srcdir)/../../../automake/local.am diff --git a/c/src/make/compilers/gcc-target-default.cfg b/c/src/make/compilers/gcc-target-default.cfg index 88b5e58c0d..fb5dfbad62 100644 --- a/c/src/make/compilers/gcc-target-default.cfg +++ b/c/src/make/compilers/gcc-target-default.cfg @@ -93,21 +93,21 @@ ifeq ($(RTEMS_USE_GCC272),no) CFLAGS_DEBUG_V+=-qrtems_debug endif -# when debugging, optimize flag: typically empty -# some compilers do allow optimization with their "-g" -CFLAGS_DEBUG_OPTIMIZE_V=-g - # profile flag; use gprof(1) CFLAGS_PROFILE_V=-pg +ifndef AUTOMAKE # default is to optimize CFLAGS_OPTIMIZE=$(CFLAGS_OPTIMIZE_V) +endif # dynamic libraries #CFLAGS_DYNAMIC_V=-fpic #ASFLAGS_DYNAMIC_V= +ifndef AUTOMAKE CFLAGS += $(CFLAGS_OPTIMIZE) $(CFLAGS_DEBUG) $(CFLAGS_PROFILE) +endif # List of library paths without -L LD_PATHS= $(PROJECT_RELEASE)/lib @@ -186,7 +186,7 @@ ${ARCH}/%.o: %.S # Make foo.rel from foo.o ${ARCH}/%.rel: ${ARCH}/%.o - ${LD} $(LDFLAGS_INCOMPLETE) -o $@ $^ + ${make-rel} # create $(ARCH)/pgm from pgm.sh ${ARCH}/%: %.sh @@ -214,7 +214,7 @@ ifneq ($(words $(C_FILES) $(CC_FILES) $(S_FILES)), 0) # Replace foo.o with $(ARCH)/foo.o # Replace $(ARCH) value with string $(ARCH) # so that it will for debug and profile cases - $(COMPILE.c) -M $^ | \ + $(COMPILE.c) $(AM_CPPFLAGS) $(AM_CFLAGS) -M $^ | \ $(SED) -e 's?^\(.*\)\.o[ ]*:?$$(ARCH)/\1.o:?' \ -e 's?$(ARCH)/?$$(ARCH)/?' >$(DEPEND).tmp $(MV) $(DEPEND).tmp $(DEPEND) @@ -289,7 +289,13 @@ ifndef LINKCMDS LINKCMDS=$(PROJECT_RELEASE)/lib/linkcmds endif - +ifeq ($(RTEMS_USE_GCC272),yes) define make-rel $(LD) $(LDFLAGS_INCOMPLETE) $(XLDFLAGS) -o $@ $^ endef +else +define make-rel + $(LINK.c) $(AM_CFLAGS) $(AM_LDFLAGS) \ + -qnolinkcmds -nostdlib -Wl,-r $(XLDFLAGS) -o $@ $^ +endef +endif diff --git a/c/src/make/configure.in b/c/src/make/configure.in index a73b18dd0c..f4d00a20c9 100644 --- a/c/src/make/configure.in +++ b/c/src/make/configure.in @@ -31,7 +31,6 @@ RTEMS_ENV_RTEMSBSP dnl BEGIN configure.host.in AC_PATH_PROG(CAT,cat) -AC_PATH_PROG(RM,rm) AC_PATH_PROG(CP,cp) AC_PATH_PROG(MV,mv) AC_PATH_PROG(LN,ln) @@ -114,7 +113,7 @@ AC_LINK_FILES($cfg_dir/Templates/Makefile.leaf,Templates/Makefile.leaf) AC_LINK_FILES($cfg_dir/Templates/Makefile.dir,Templates/Makefile.dir) AC_LINK_FILES($cfg_dir/compilers/gcc-target-default.cfg,compilers/gcc-target-default.cfg) AC_LINK_FILES($cfg_dir/directory.cfg,directory.cfg) -AC_LINK_FILES($cfg_dir/leaf.cfg,leaf.cfg) +AC_LINK_FILES(leaf.cfg,leaf.cfg) AC_LINK_FILES($cfg_dir/lib.cfg,lib.cfg) AC_LINK_FILES($cfg_dir/README,README) @@ -128,6 +127,7 @@ bsp.cfg custom/Makefile custom/default.cfg compilers/Makefile, -make $RTEMS_BSP.cache, +${MAKE} $RTEMS_BSP.cache, +MAKE=${MAKE-make} RTEMS_BSP=${RTEMS_BSP} ) diff --git a/c/src/make/custom/Makefile.am b/c/src/make/custom/Makefile.am index 60e10bf712..01c6aba402 100644 --- a/c/src/make/custom/Makefile.am +++ b/c/src/make/custom/Makefile.am @@ -4,11 +4,10 @@ AUTOMAKE_OPTIONS = foreign 1.4 -rtems_makedir=$(prefix)/make -rtems_make_customdir=$(rtems_makedir)/custom +rtems_makedir = $(prefix)/make +rtems_make_customdir = $(rtems_makedir)/custom rtems_make_custom_DATA = @CUSTOM_CFG_FILES@ -noinst_DATA = \ -default.cfg +noinst_DATA = default.cfg include $(top_srcdir)/../../../automake/local.am diff --git a/c/src/make/host.cfg.in b/c/src/make/host.cfg.in index cae07de613..aa215b8eae 100644 --- a/c/src/make/host.cfg.in +++ b/c/src/make/host.cfg.in @@ -19,15 +19,13 @@ SHELL=@SHELL@ ECHO=echo CAT=cat -RM=@RM@ -f +## RM=@RM@ -f CP=@CP@ MV=@MV@ LN=@LN@ MKDIR=mkdir CHMOD=chmod SED=sed -# Anybody using this? -# M4=@M4@ # Global tools ifndef PACKHEX @@ -74,7 +72,3 @@ INSTDATAFLAGS = -m 0644 INSTLIBFLAGS = -m 0644 INSTDIRFLAGS = -m 0755 -d INSTINCFLAGS = -m 0644 - -ifndef INSTALL_DATA -INSTALL_DATA = $(INSTALL) $(INSTDATAFLAGS) -endif diff --git a/c/src/make/leaf.cfg b/c/src/make/leaf.cfg index 9fb166b960..8ec8fa3109 100644 --- a/c/src/make/leaf.cfg +++ b/c/src/make/leaf.cfg @@ -41,16 +41,3 @@ include ${CONFIG.CC} ifeq (${DEPEND},$(wildcard ${DEPEND})) include ${DEPEND} # pull in dependencies if they exist endif - -# -# LIBSUFFIX_VA, will "index" into LIBSUFF-*-v macros and -# convert our ${ARCH} back into .a or _g.a or _p.a based on debug or profile. -# Useful for installing libraries. -# - -LIBSUFFIX_o-optimize_V= -LIBSUFFIX_o-debug_V=_g -LIBSUFFIX_o-profile_V=_p - -LIB_VARIANT=$(LIBSUFFIX_$(ARCH)_V) -LIBSUFFIX_VA = $(LIB_VARIANT).a diff --git a/c/src/make/main.cfg.in b/c/src/make/main.cfg.in index 3e1c8fc50e..4f72950a3d 100644 --- a/c/src/make/main.cfg.in +++ b/c/src/make/main.cfg.in @@ -1,81 +1,9 @@ -# # $Id$ # # make/main.cfg # # Make(1) configuration file include'd by all Makefile's # - -# -# where things are relative to PROJECT_ROOT; shouldn't need to change, -# but could be overridden in custom files. -# - -PROJECT_RELEASE=$(PROJECT_ROOT)/@RTEMS_BSP@ -PROJECT_BIN=$(PROJECT_RELEASE)/bin -PROJECT_INCLUDE=$(PROJECT_RELEASE)/lib/include -PROJECT_TOOLS = $(PROJECT_RELEASE)/build-tools - -# -# Target architecture; may be changed as per 'make "ARCH=debug"' -# This is where the object files get put. -# - -ARCH=o-optimize - -VARIANT= - -# -# Initial target for make(1) -# Once this is established we can safely include other targets -# within this make-include file. -# - -default_target: all - -# -# Default makefile name -# May be overridden by command line macro assignment -# - -MAKEFILE=Makefile - -# -# Target variant names -# -TARGET_VARIANTS = optimize debug profile - -# -# Generate list of object directories: o-optimize, o-debug, o-profile -# -VARIANTS=${TARGET_VARIANTS:%=o-%} - -# -# List of "recursion-able" targets for directory Makefiles +# NOTE: This file does not get exported from the source tree # - -RECURSE_TARGETS=all depend install \ -preinstall-recursive \ -$(TARGET_VARIANTS) - -${ARCH}: - test -d ${ARCH} || mkdir ${ARCH} - -# general purpose forcing dependency; try to use .PHONY instead -FORCEIT: - -FORCE: - -ifndef AUTOMAKE -distclean-generic: - -$(RM) Makefile .#* $(CONFIG_CLEAN_FILES) - -$(RM) -r $(CLOBBER_ADDITIONS) - -clean-generic: - -$(RM) a.out core mon.out gmon.out - -$(RM) -r $(CLEAN_ADDITIONS) -endif - -.PHONY: $(RECURSE_TARGETS) -.PHONY: clean-generic -.PHONY: distclean-generic +# Now, it's empty :) -- cgit v1.2.3