|
From: Peter K. <pk...@us...> - 2001-05-07 11:23:57
|
The following file was modified in apps: Name Old version New version Comment ---- ----------- ----------- ------- Rules.elinux 1.2 1.3=20=20=20=20=20=20=20=20=20=20=20=20=20 The accompanying log: Synchronized with our latest version of this file (requires make 3.79 if I am not mistaken). The diff of the modified file(s): --- Rules.elinux 2001/02/28 23:42:08 1.2 +++ Rules.elinux 2001/05/07 11:23:57 1.3 @@ -1,17 +1,66 @@ # Hey Emacs, this Makefile is in -*- makefile -*- mode! =20 -# If we are building for elinux, then define ELINUX +makefrag_name =3D .target-makefrag + +ifndef AXIS_BUILDTYPE +# If we have a .target-makefrag, read stuff from it. Else we will +# probably create one, so define ROOT_MAKEFRAG. +ifeq ($(makefrag_name),$(wildcard $(makefrag_name))) +include $(makefrag_name) +endif # An $(makefrag_name) existing in current directory. + +# Backward compatibility with the old .target_* files. +ifndef AXIS_BUILDTYPE ifeq (.target_elinux,$(wildcard .target_*)) -ELINUX=3D1 +AXIS_BUILDTYPE=3Delinux endif - -# If we are building for cris (Linux/CRIS), then define CLINUX ifeq (.target_clinux,$(wildcard .target_*)) -CLINUX=3D1 +AXIS_BUILDTYPE=3Dclinux +endif +ifeq (.target_host,$(wildcard .target_*)) +AXIS_BUILDTYPE=3Dhost +endif endif =20 +endif # !AXIS_BUILDTYPE + SUBDIRS +=3D dummy +AXIS_WARNING_PREFIX =3D ---------- WARNING: +AXIS_ERROR_PREFIX =3D ---------- ERROR: +AXIS_USE_UCLIBC_DEPRECATED =3D Makefile in $(shell pwd) sets deprecated \ +USE_UCLIBC. It should set AXIS_USABLE_LIBS =3D UCLIBC +AXIS_LIB_MISMATCH =3D The code in $(shell pwd) cannot be linked with\ + $(AXIS_WILL_USE_LIB) + +########################################################################### +# Deduce other build variables from AXIS_BUILDTYPE. +ifdef AXIS_BUILDTYPE + +ifeq ($(AXIS_BUILDTYPE),cris-axis-linux-gnu) +CLINUX =3D 1 +AXIS_WILL_USE_LIB =3D GLIBC +endif =20 +ifeq ($(AXIS_BUILDTYPE),clinux) +CLINUX =3D 1 +AXIS_WILL_USE_LIB =3D UCLIBC +endif + +ifeq ($(AXIS_BUILDTYPE),elinux) +ELINUX =3D 1 +AXIS_WILL_USE_LIB =3D UCLIBC +endif + +ifeq ($(AXIS_BUILDTYPE),host) +HOST =3D 1 +endif + +# Has this ever been used? What's the difference to "host"? +ifeq ($(AXIS_BUILDTYPE),linux) +LINUX =3D 1 +endif +endif # AXIS_BUILDTYPE + ########################################################################### =20 ifdef ELINUX @@ -25,30 +74,104 @@ CPP =3D gcc_cris -melinux -E CXX =3D gcc_cris -melinux -xc++ =20 -LDFLAGS =3D -s -symbolic +LDFLAGS =3D -s -shlib =20 TARGET_TYPE =3D elinux CRIS =3D 1 -endif =20 +# ELINUX always uses uclibc. Though a check that the app can use uclibc +# is in order. +ifndef USE_UCLIBC + +ifdef AXIS_USABLE_LIBS +ifneq ($(filter $(AXIS_USABLE_LIBS),UCLIBC),UCLIBC) +$(error $(AXIS_ERROR_PREFIX) $(AXIS_LIB_MISMATCH)) +else +# Define legacy macro. +USE_UCLIBC =3D 1 +endif # not UCLIBC in AXIS_USABLE_LIBS +endif # AXIS_USABLE_LIBS + +else +$(warning $(AXIS_WARNING_PREFIX) $(AXIS_USE_UCLIBC_DEPRECATED)) +endif # not USE_UCLIBC +endif # ELINUX + ifdef CLINUX -# Same as ELINUX but with different options (to build as ELF) -# Linux/CRIS does only support statically linked exes currently -# so use -static and not -symbolic + +ifndef ELINUXDIR +ELINUXDIR :=3D $(shell echo `pwd`/../os/linux) +endif + +# Here we will check AXIS_WILL_USE_LIB against AXIS_USABLE_LIBS which +# represents what the thing we want to compile can be linked with. If +# library and compile variable settings (like CC) aren't supposed to be +# set or are not applicable, then AXIS_USABLE_LIBS should not be set. + +# First some backwards compatibility: each app used to set USE_UCLIBC in +# its makefile. +ifdef USE_UCLIBC +$(warning $(AXIS_WARNING_PREFIX) $(AXIS_USE_UCLIBC_DEPRECATED)) +AXIS_USABLE_LIBS +=3D UCLIBC +# Let's unset the original var to fall in line with expected case. +USE_UCLIBC =3D +endif + +ifdef AXIS_USABLE_LIBS +ifneq ($(filter $(AXIS_USABLE_LIBS),$(AXIS_WILL_USE_LIB)),$(AXIS_WILL_USE_= LIB)) +$(error $(AXIS_ERROR_PREFIX) $(AXIS_LIB_MISMATCH)) +endif +endif # AXIS_USABLE_LIBS + +# Set legacy variables used in various unknown Makefiles. +# FIXME: Kill the USE_* variables when all apps are changed to use +# AXIS_WILL_USE_LIB instead. Until then, introduce no new use or setting +# of USE_*. +ifeq ($(AXIS_WILL_USE_LIB),GLIBC) +USE_GLIBC =3D 1 +else # AXIS_WILL_USE_LIB !=3D GLIBC (i.e. currently implying UCLIBC). +ifeq ($(AXIS_WILL_USE_LIB),UCLIBC) +USE_UCLIBC =3D 1 +else +$(error $(AXIS_ERROR_PREFIX) Unexpected library $(AXIS_WILL_USE_LIB).) +endif +endif # AXIS_WILL_USE_LIB !=3D GLIBC + +# Now that we've checked that AXIS_WILL_USE_LIB matches AXIS_USABLE_LIBS, +# we set the other build vars. + +ifeq ($(AXIS_WILL_USE_LIB),UCLIBC) +# Same as ELINUX but with different options (to build as ELF), and we +# build statically since uclibc does not support dynamic linking. =20 CC =3D gcc_cris -mlinux -DCRISMMU CPP =3D gcc_cris -mlinux -DCRISMMU -E CXX =3D gcc_cris -mlinux -DCRISMMU -xc++ =20 LDFLAGS =3D -s -static +endif # AXIS_WILL_USE_LIB =3D UCLIBC + +ifeq ($(AXIS_WILL_USE_LIB),GLIBC) +# Using glibc, linking dynamically like on the host. + +# We prefer getting <asm/...> and <linux/...> from the kernel we compile, +# rather than what was installed with the compiler, so put it first in the +# system include path. =20 +CC =3D gcc-cris -mlinux -isystem $(ELINUXDIR)/include +CPP =3D gcc-cris -mlinux -E -isystem $(ELINUXDIR)/include +CXX =3D g++-cris -mlinux -xc++ -isystem $(ELINUXDIR)/include +LDFLAGS =3D -s -L$(prefix)/lib +endif # AXIS_WILL_USE_LIB !=3D GLIBC + TARGET_TYPE =3D clinux CRIS =3D 1 -endif =20 +endif # CLINUX + ifdef CRIS =20 -# This is for building for the cris architecture +# This is for building for the CRIS architecture. =20 OBJCOPY =3D objcopy-cris LD =3D ld-cris @@ -65,7 +188,7 @@ =20 else =20 -# This is for building for the local host +# This is for building for the local host. =20 RANLIB =3D ranlib =20 @@ -78,31 +201,29 @@ endif # HROOT run_prefix =3D $(prefix) =20 -endif +endif # not CRIS =20 INSTALL =3D install =20 ########################################################################### =20 -# Define CFLAGS to something sensible -CFLAGS =3D -O2 -Wall +# Define CFLAGS to something sensible. +CFLAGS =3D -Wall =20 ifdef CRIS -# Sorry; only -Dlinux is built-in. __linux__ will be defined in -# gcc-cris & Co R26. -CFLAGS +=3D -D__linux__ - +CFLAGS +=3D -O2 ifdef ELINUX CFLAGS +=3D -DELINUX endif =20 else -# We want to be able to use gdb with full debug info for host compiled pro= grams -CFLAGS +=3D -g +# We want to be able to use gdb with full debug info for host compiled +# programs. +CFLAGS +=3D -O0 -g endif =20 -# Can't use -pedantic due to use of long long in standard includes :( -CXXFLAGS =3D $(CFLAGS) -Wno-ctor-dtor-privacy -ansi -pipe -fcheck-new +# Can't use -pedantic due to use of long long in standard includes. :( +CXXFLAGS =3D $(CFLAGS) -Wno-ctor-dtor-privacy -ansi -pipe =20 # An elinux program is expected to be compiled like this: # $(CC) $(CFLAGS) -c my_file.c @@ -113,7 +234,9 @@ # $(CC) $(LDFLAGS) -o my_program my_file.o possibly_other_objects.o =20 ifdef CRIS -ifdef USE_UCLIBC +ifeq ($(AXIS_WILL_USE_LIB),UCLIBC) +# FIXME: Delete the UCLIBC macro once all usage is exterminated. Usage +# should be of if[n]eq ($(AXIS_WILL_USE_LIB),UCLIBC). UCLIBC =3D 1 CC +=3D -muclibc=3D$(prefix) CPP +=3D -muclibc=3D$(prefix) @@ -125,42 +248,73 @@ # The following are a set of standard rules to try to make sure we build # and install the correct files. =20 -all: pre-all-recurse all-recurse +all: all-recurse +all-recurse: pre-all-recurse =20 # Make eroot a dependency of all install rules to make sure the $(prefix) # variable is set (to $HROOT or $EROOT depending on whether this # is a build for the host or elinux). -depend: eroot pre-depend-recurse depend-recurse -install: eroot pre-install-recurse install-recurse +depend: depend-recurse +depend-recurse: pre-depend-recurse +pre-depend-recurse: eroot=20 =20 -uninstall: pre-uninstall-recurse uninstall-recurse +install: install-recurse +install-recurse: pre-install-recurse=20 +pre-install-recurse: eroot =20 -clean: pre-clean-recurse clean-recurse +uninstall: uninstall-recurse +uninstall-recurse: pre-uninstall-recurse +pre-uninstall-recurse: eroot =20 -# Used to change the target for the build. -elinux: pre-elinux-recurse elinux-recurse -clinux: pre-clinux-recurse clinux-recurse -host: pre-host-recurse host-recurse -elinux clinux host: - @if test ! -f .target_$@ ; then \ - NO_SUBDIR_RECURSION=3D1 $(MAKE) --no-print-directory clean; \ +clean: clean-recurse +clean-recurse: pre-clean-recurse + +ifndef ROOT_MAKEFRAG +ROOT_MAKEFRAG :=3D $(shell echo `pwd`/$(makefrag_name)) + +# This rule allows old .target_* files to be converted to .target-makefrag +# by running make configsubs in the root directory +$(ROOT_MAKEFRAG): +ifdef AXIS_BUILDTYPE + $(MAKE) $(AXIS_BUILDTYPE) +else + @echo "You must specify the target type!" + exit 1 +endif +endif # !ROOT_MAKEFRAG + +cris-axis-linux-gnu elinux clinux host: + echo AXIS_BUILDTYPE=3D$@ > .tmp$(makefrag_name) + -$(MAKE) configsubs AXIS_BUILDTYPE=3D$@ ROOT_MAKEFRAG=3D$(shell echo `pwd= `/.tmp$(makefrag_name)) + @rm -f .tmp$(makefrag_name) + +checkclean: + @if ! test -f .target_$(AXIS_BUILDTYPE) \ + && ( ! test -f $(makefrag_name) \ + || ! grep AXIS_BUILDTYPE=3D$(AXIS_BUILDTYPE) $(makefrag_name) > = /dev/null ); then \ + NO_SUBDIR_RECURSION=3D1 $(MAKE) --no-print-directory clean ROOT_MAKEFRA= G=3D$(ROOT_MAKEFRAG); \ fi - rm -rf .target_* - touch .target_$@ + +configsubs: configsubs-recurse +configsubs-recurse: pre-configsubs-recurse +pre-configsubs-recurse: $(ROOT_MAKEFRAG)=20 + +configsubs: checkclean + -cmp -s $(ROOT_MAKEFRAG) $(makefrag_name) || ( rm -f .target*; cp $(ROOT_= MAKEFRAG) $(makefrag_name) ) =20 # These are hooks that can be used to have rules executed before the -# recursive rules are checked -pre-all-recurse pre-depend-recurse pre-install-recurse pre-uninstall-recur= se pre-clean-recurse pre-elinux-recurse pre-clinux-recurse pre-host-recurse: +# recursive rules are checked. +pre-all-recurse pre-depend-recurse pre-install-recurse pre-uninstall-recur= se pre-clean-recurse pre-configsubs-recurse: =20 -# Recursive rules to make all, depend, install, uninstall, clean, elinux, -# clinux and host -all-recurse depend-recurse install-recurse uninstall-recurse clean-recurse= elinux-recurse clinux-recurse host-recurse: +# Recursive rules to make all, depend, install, uninstall, clean and +# configsubs. +all-recurse depend-recurse install-recurse uninstall-recurse clean-recurse= configsubs-recurse: @if test $(NO_SUBDIR_RECURSION)0 -eq 0 ; then \ for subdir in $(SUBDIRS); do \ if test -d $$subdir ; then \ target=3D`echo $@ | sed 's/-recurse//'`; \ - echo Making $$target in $$subdir; \ - (cd $$subdir && $(MAKE) $$target) || exit 1; \ + echo Making $$target in $$subdir for $(AXIS_BUILDTYPE); \ + $(MAKE) -C $$subdir $$target ROOT_MAKEFRAG=3D$(ROOT_MAKEFRAG) || ex= it 1; \ fi; \ done; \ fi |