default: all ############################################################################ # Defining Variables ############################################################################ VERSION = 3.1 # for the 3.0 final, set PRERELEASE to 100 PRERELEASE = 100 RELEASE = RELVER = $(VERSION) ifneq ($(RELEASE),) RELVER = $(VERSION)-$(RELEASE) endif MOD_DIR = ../modules RTLINUX = $(shell pwd) HOSTARCH := $(shell uname -m | sed -e s/i.86/i386/) ARCH = $(HOSTARCH) # # Include .config file with configurable compilation variables # ifeq ($(RTLINUX)/.config,$(wildcard $(RTLINUX)/.config)) LINUX_CONFIG:=$(RTLINUX)/.config include $(LINUX_CONFIG) endif RTL = $(shell pwd) RTL_DIR = $(shell pwd) HPATH = $(RTL)/include DRIVERS_DIR = $(RTL)/drivers ifdef CONFIG_MODVERSIONS CFLAGS += -DMODVERSIONS -include $(RTLINUX)/include/linux/modversions.h endif ifeq ($(CONFIG_RTL_MODULE),y) CFLAGS += -DMODULE -D__KERNEL__ -Wall -Wstrict-prototypes else CFLAGS += -D__KERNEL__ -Wall -Wstrict-prototypes endif ifeq ($(CONFIG_RTL_GDBAGENT),y) CFLAGS += -g endif CC = ${CROSS_COMPILE}gcc #endif HOSTCC = gcc LD = ${CROSS_COMPILE}ld KERNELRELEASE=$(shell echo `grep UTS_RELEASE $(RTLINUX)/include/linux/version.h 2>/dev/null | cut -d\" -f2`) RPMKERNELRELEASE=$(shell echo $(KERNELRELEASE) | sed 's/-/_/g') #MODULE_DIRS = main schedulers system modules debug init arch/i386/kernel MODULE_DIRS = drivers gdbagent posixio tracer deblin lib main init ipc schedulers tasks arch/i386/kernel modules ifeq ($(CONFIG_RTL_BAKERTEST),y) MODULE_DIRS += schedulers/testbaker endif MODULE_DIRS += arch/i386/boot NEEDS_PATHS_DIRS = $(EXAMPLE_DIRS) $(MODULE_DIRS) RTLINUX_PATH_COMMAND := "RTLINUX_DIR = $(RTLINUX)" INCLUDE := -I$(RTLINUX)/include -I$(RTL)/include -I$(RTL)/include/compat DEPINCLUDE = -I$(RTLINUX)/include -I$(RTL)/include INCLUDE_EMU = "-I$(RTLINUX)/include -I$(RTL)/include" INCLUDE_COMMAND = "INCLUDE= $(INCLUDE)" IDIR=/usr/rtlinux-$(RELVER) INSTDIR=$(DESTDIR)/$(IDIR) INC_INSTDIR=$(INSTDIR)/include LIB_INSTDIR=$(INSTDIR)/lib BIN_INSTDIR=$(INSTDIR)/bin EXAMPLE_INSTDIR=$(INSTDIR)/examples MOD_INSTDIR=$(INSTDIR)/modules DOC_INSTDIR=$(INSTDIR)/doc #MOD_INSTDIR=$(DESTDIR)/lib/modules/$(KERNELRELEASE)/misc DEV_INSTDIR=$(DESTDIR)/dev .EXPORT_ALL_VARIABLES: ifneq ($(wildcard .config),) include .config all: .depend include/rtl_version.h schedulers modules drivers @echo @echo 'Now do "cd arch/i386/boot;make zdisk" to create bootable disk' else all: .config @echo @echo 'Now do "make" to build the RTLinux modules' endif ifeq ($(CONFIG_RTL_MODULE),y) CFLAGS += -D_RTL_MODULE_ endif ifdef CONFIG_RTL_DEBUG CFLAGS += -g else CFLAGS += -fomit-frame-pointer endif EXAMPLE_DIRS = CFLAGS += -D__RTL__ -D_LOOSE_KERNEL_NAMES CXXFLAGS := $(CFLAGS) $(INCLUDE) -I$(RTL)/include/posix -fno-exceptions -fno-rtti CFLAGS += -O2 # Start RTL-CONFIG This section is used to create the rtl.config file # as SPECIFICALLY tailored for RTLinux v. 3.0. This will/may change # for v3.1. Note that the CONFIG_*** series of flags are intended to # be sent out to the users via "rtl-config --xxx". Thus, do not put # anything here that is not intended to be seen by the user during # normal operation of RTLinux. CONFIG_CFLAGS := -O2 CONFIG_CXXFLAGS := -fno-exceptions -fno-rtti CONFIG_LIBS_DIR := $(LIB_INSTDIR) CONFIG_INCLUDE := $(INCLUDE) -I$(RTL)/include/posix CONFIG_FLAGS := $(CFLAGS) RTL_VERSION_MAJOR=$(shell echo $(VERSION) | cut -d\. -f1 -s) RTL_VERSION_MINOR=$(shell echo $(VERSION) | cut -d\. -f2 -s) LINUX_VERSION=$(shell echo $(KERNELRELEASE) | cut -d\. -f1 -s) LINUX_PATCHLEVEL=$(shell echo $(KERNELRELEASE) | cut -d\. -f2 -s) LINUX_SUBLEVEL=$(shell echo $(KERNELRELEASE)|cut -d\. -f3 -s|cut -d\- -f1) LINUX_EXTRAVERSION=$(shell echo $(KERNELRELEASE) | cut -d\- -f2 -s) PARSED_CONFIG_INCLUDE=$(shell echo `echo $(CONFIG_INCLUDE) | \ sed -e s/-I// | \ sed -e s/-I/:/g -e s/\ //g`) PARSED_CONFIG_LIBS=$(shell echo `echo $(CONFIG_LIBS_DIR) | \ sed -e s/-L// | \ sed -e s/-L/:/g -e s/\ //g`) # End of RTL-CONFIG CFLAGS += $(INCLUDE) -I$(RTL)/include/posix include/rtl_version.h: ./Makefile # @echo \#define RTLINUX_VERSION_MAJOR $(RTL_VERSION_MAJOR) > .ver # @echo \#define RTLINUX_VERSION_MINOR $(RTL_VERSION_MINOR) >> .ver # @echo \#define RTLINUX_VERSION_PRERELEASE $(PRERELEASE) >> .ver @echo '#define RTLINUX_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c))' >>.ver @echo \#define RTLINUX_VERSION_CODE RTLINUX_VERSION\($(RTL_VERSION_MAJOR),$(RTL_VERSION_MINOR),$(PRERELEASE)\) >> .ver @mv -f .ver $@ modules: rtl.mk dummy @mkdir -p modules @set -e; @for i in $(MODULE_DIRS); do \ $(MAKE) -C $$i; \ done; symlinks: dummy rm -f include/arch main/arch ln -s $(ARCH) include/arch ln -s $(ARCH) main/arch .config: $(MAKE) config # @if [ -z $$DISPLAY ]; then \ # $(MAKE) menuconfig; \ # else \ # $(MAKE) xconfig; \ # fi # click-through license rule -Nathan ${RTL}/.rtlinuxaccepted: $(SHELL) scripts/click_through.sh ${RELVER} ######################################################################### # UIs to configure OS creating .config file ######################################################################### config: ${RTL}/.rtlinuxaccepted symlinks $(SHELL) scripts/Configure scripts/config.in oldconfig: ${RTL}/.rtlinuxaccepted symlinks $(SHELL) scripts/Configure -d scripts/config.in menuconfig: ${RTL}/.rtlinuxaccepted symlinks $(MAKE) -C scripts ncurses $(MAKE) -C scripts lxdialog $(SHELL) scripts/Menuconfig scripts/config.in xconfig: ${RTL}/.rtlinuxaccepted symlinks $(MAKE) -C scripts tkparse @if [ -f /usr/local/bin/wish ]; then \ echo '#!'"/usr/local/bin/wish -f" > kconfig.tk; \ else \ echo '#!'"/usr/bin/wish -f" > kconfig.tk; \ fi cat scripts/header.tk >> ./kconfig.tk scripts/tkparse < scripts/config.in >> kconfig.tk echo "set defaults \"schedulers/${ARCH}/defconfig\"" >> kconfig.tk echo "set ARCH \"${ARCH}\"" >> kconfig.tk cat scripts/tail.tk >> kconfig.tk chmod 755 kconfig.tk touch include/rtl_conf.h wish -f kconfig.tk rm -f kconfig.tk ######################################################################### # Calculate Module dependencies ######################################################################### dep: .config rtl.mk rtl.config rm -f .depend $(MAKE) .depend .depend: scripts/mkdep # dummy symlinks .config scripts/mkdep @echo Kernel version $(KERNELRELEASE) @if [ ! -f $(RTLINUX)/.config -o ! -f $(RTLINUX)/include/linux/version.h ]; then\ echo You must do a make config and make dep in $(RTLINUX); \ exit 1; \ fi @mkdir -p modules for x in `find . -name Makefile`; do \ F=`echo $$x|sed 's/Makefile$$//g'`; \ (cd $$F; $$RTL/scripts/mkdep *.c *.h *.S > .depend 2>/dev/null); \ done @rm -f .hdepend @find $(subst -I,,$(DEPINCLUDE)) -name SCCS -prune -or -follow -name \*.h ! -name modversions.h -print |xargs scripts/mkdep >> .hdepend ######################################################################### # Files rtl.mk and rtl.config to include in all Makefiles ######################################################################### rtl.mk: .config rtl.config @echo "#Automatically generated by RTLinux Makefile" > rtl.mk; @echo RTL = $(RTL) >>rtl.mk @echo $(RTLINUX_PATH_COMMAND) >> rtl.mk; @echo $(INCLUDE_COMMAND) >> rtl.mk; @echo CFLAGS = $(CFLAGS) >> rtl.mk; @echo ARCH = $(ARCH) >> rtl.mk; @echo CC = $(CC) >> rtl.mk; @echo CXXFLAGS = $(CXXFLAGS) >> rtl.mk; rtl.config: .config @echo "#Automatically generated by RTLinux Makefile" >rtl.config; @echo "" >>rtl.config; @echo "# Version information" >>rtl.config; @echo RTL_VERSION_MAJOR=\"$(RTL_VERSION_MAJOR)\" >>rtl.config; @echo RTL_VERSION_MINOR=\"$(RTL_VERSION_MINOR)\" >>rtl.config; @echo RTL_VERSION_EXTRA=\"$(RELEASE)\" >>rtl.config; @echo LINUX_VERSION=\"$(LINUX_VERSION)\" >>rtl.config; @echo LINUX_PATCHLEVEL=\"$(LINUX_PATCHLEVEL)\" >>rtl.config; @echo LINUX_SUBLEVEL=\"$(LINUX_SUBLEVEL)\" >>rtl.config; @echo LINUX_EXTRAVERSION=\"$(LINUX_EXTRAVERSION)\" >>rtl.config; @echo "" >>rtl.config; @echo "# Directory information" >>rtl.config; @echo RTL_DIR=\"$(INSTDIR)\" >>rtl.config; @echo MODULES_DIR=\"$(MOD_INSTDIR)\" >>rtl.config; @echo USER_INC_DIR=\"$(INC_INSTDIR)\" >>rtl.config; @echo DOC_DIRS=\"$(DOC_INSTDIR)\" >>rtl.config; @echo LIBS_DIR=\"$(PARSED_CONFIG_LIBS)\" >>rtl.config; @echo INCLUDE_DIR=\"$(PARSED_CONFIG_INCLUDE)\" >>rtl.config; @echo "" >>rtl.config; @echo "# Flag information" >>rtl.config; @echo CFLAGS=\"$(CFLAGS)\" >>rtl.config; @echo CXXFLAGS=\"$(CXXFLAGS)\" >>rtl.config; @echo "" >>rtl.config; @echo "# System information" >>rtl.config; @echo ARCH=\"$(ARCH)\" >>rtl.config; @echo CC=\"$(CC)\" >>rtl.config; ######################################################################### # CLEAN clean project ######################################################################### clean: dummy rm -f modules/*.o rm -f modules/rtlinux @rm -f rtl.mk rtl.config @echo RTL_DIR = $(RTL) >rtl.mk @set -e; \ for i in $(MODULE_DIRS); do \ $(MAKE) -C $$i clean ; \ done $(MAKE) -C scripts clean rm -rf kconfig.tk .menuconfig.log scripts/rtlinux.spec regression.log find . -type f \( -name .depend -o -name '#*#' -o -name '*~' -o -name '*.o' -o \( -name core -a \! -type d \) -or -name rtl.mk -or -name '*.a' \) -exec /bin/rm -r '{}' \; rm -f scripts/mkdep ######################################################################## # MKDEP to calculate file dependencies ######################################################################## scripts/mkdep: scripts/mkdep.c ${HOSTCC} -Wall -O2 -o scripts/mkdep scripts/mkdep.c .PHONY: dummy modules schedulers devices fifos