| #******************************************************************************* | |
| # Copyright (c) 2014-2015 Zeligsoft (2009) Limited and others. | |
| # All rights reserved. This program and the accompanying materials | |
| # are made available under the terms of the Eclipse Public License v1.0 | |
| # which accompanies this distribution, and is available at | |
| # http://www.eclipse.org/legal/epl-v10.html | |
| #******************************************************************************* | |
| # Top level makefile for building RTS services library. | |
| # | |
| # Currently only supports linux - linux targets are implied. | |
| # | |
| # By default, the RTS library is put into a 'lib' directory under the $RTSROOT | |
| # directory. The user can specify an alternate location with LIBDEST=xxx. | |
| # The LIBDEST directory is created if it doesn't exist. | |
| # | |
| # Build products are put into BUILDROOT (default is +/build). Created by build. | |
| # | |
| # The 'exportfiles' makefile-target puts the library headers, the library | |
| # and a manifest file (containing version information) into a 'umlrt-rts' | |
| # subdirectory of the EXPORTDIR directory. | |
| # | |
| # The 'exportarchive' makefile-target takes the files generated by the | |
| # 'exportfiles' target and puts them into the EXPORTARCHIVE file. | |
| # The default name is EXPORTDIR/umlrt-rts.tgz. | |
| # | |
| # The directory for EXPORTDIR and EXPORTARCHIVE file can be supplied on the | |
| # command-line. | |
| # | |
| # Note: The export operations remove and regenerate the contents of the | |
| # EXPORTDIR/umlrt-rts subdirectory but do not disturb any other content | |
| # that may be present in the EXPORTDIR directory. | |
| # | |
| # Targets: | |
| # (none) : The default target is 'all' - same as 'library'. | |
| # all : everything - currently only 'library' | |
| # library : the RTS services library | |
| # clean : Delete all build products. | |
| # exportfiles : create a directory with the library, manifest and headers. | |
| # exportarchive : create a tar archive with the library, manifest and headers. | |
| # exportclean : clean the contents of EXPORTDIR/umlrt-rts sub-directory. | |
| # exportdir : create the EXPORTDIR/umlrt-rts sub-directory. | |
| # | |
| # Variables (can be overridden during make invoke with <var>=<value>): | |
| # RTSROOT : default RTSROOT=. : umlrt.rts repo dir. | |
| # BUILDROOT : default BUILDROOT=$(RTSROOT)/build : build output dir. | |
| # OSNAME : default OS=linux : Target platform. | |
| # OSVERSION : default <empty> : os-version, only if required. | |
| # LIBDEST : Change default library destination directory. | |
| # DEPEND : default DEPEND=1 : 'DEPEND=0' to skip dependency generation. | |
| # DEBUG : default DEBUG=0 : 'DEBUG=1' compiles with '-g -O0'. | |
| # CC : default CC=g++ : Change default compiler. | |
| # CPPFLAGS : Replace default cc compile flags. | |
| # AR : default AR=ar : Change default archiver. | |
| # ARFLAGS : Replace default archiver flags. | |
| # EXPORTDIR : default EXPORTDIR=$(BUILDROOT)/export | |
| # EXPORTARCHIVE : default is 'umlrt-rts.tgz' | |
| # | |
| # Local variables (not typically passed in via env) are in lower-case. | |
| # | |
| # Examples: | |
| # make : Default - same as 'make all' and 'make library' | |
| # make all : Default - same as 'make' and 'make library' | |
| # make library : Default - same as 'make' and 'make all' | |
| # make exportfiles : Build the library and make tar-archive with required files. | |
| # make DEBUG=1 : Make the library with debug compile options. | |
| # make DEPEND=0 : Build the library but skip building dependencies | |
| # make clean : clean all build products (library, objects, dependency files.) | |
| # make LIBDEST=~/lib : Put library into '~/lib'. | |
| # make BUILDROOT=~/build : Put build-products into '~/build'. | |
| # make exportfiles : Puts export files into $(BUILDROOT)/export/umlrt-rts. | |
| # make exportarchive : Puts 'umlrt-rts.tgz/ into $(BUILDROOT)/export. | |
| # | |
| # After a clean pull from the repo, "make DEPEND=0" will build everything but | |
| # will skip building dependencies (hence will be faster). (Dependencies are not | |
| # required for this scenario to guarantee everything gets explicitly built.) | |
| # | |
| # RTSROOT and BUILDROOT notes | |
| # --------------------------- | |
| # RTSROOT names the top-level (umlrt.rts) directory. The default RTSROOT | |
| # is current working directory (where this Makefile currently resides). | |
| # | |
| # BUILDROOT names the top-level build-products output directory tree. | |
| # Object files and dependency files are written here. | |
| # This directory tree is created by the build process if it doesn't yexist. | |
| # The tree-structure under BUILDROOT matches the associated directory tree | |
| # under RTSROOT. | |
| # | |
| # -I Header Search Path | |
| # --------------------- | |
| # The include search path for source compiles depends on the OS and OS-version | |
| # and starts in the most specific location and works its way out to the most | |
| # generic location. In general, the include path consists of the following path: | |
| # | |
| # $RTSROOT/os/<os-name>/<os-vers>/include - OS-version-specific (may not exist) | |
| # $RTSROOT/os/<os-name>/include - OS-specific headers | |
| # $RTSROOT/base/include - base utilities headers | |
| # $RTSROOT/include - UML-RT public headers | |
| # cwd is source root - current version assumes cwd is top-level src directory. | |
| # This can be overridden while invoking make with RTSROOT=xxx. | |
| RTSROOT=. | |
| # Build output (objects) are placed in a directory tree | |
| # This can be overridden while invoking make with BUILDROOT=xxx. | |
| BUILDROOT=$(RTSROOT)/build | |
| # OS name | |
| # This can be overridden while invoking make with OSNAME=xxx. | |
| OSNAME=linux | |
| # OS version - no OS-version-specific implementations required yet | |
| OSVERSION= | |
| # Export root directory | |
| EXPORTDIR=$(BUILDROOT)/export | |
| EXPORTARCHIVE=$(EXPORTDIR)/umlrt-rts.tgz | |
| # Destination directory for the RTS services library. | |
| # This can be overridden while invoking make with LIBDEST=xxx. | |
| LIBDEST=$(RTSROOT)/lib | |
| # Misc commands | |
| ECHO=echo | |
| MAKE=make | |
| RM=rm -rf | |
| MD=mkdir -p | |
| SED=sed -e | |
| CP=cp | |
| TAR=tar | |
| # Compiler | |
| # This can be overridden while invoking make with CC=xxx. | |
| CC=g++ | |
| # Archiver | |
| # This can be overridden while invoking make with AR=xxx. | |
| AR=ar | |
| # Compile flags | |
| # TODO: add os-version if required | |
| # i.e. -I $(RTSROOT)/os/$(OSNAME)/$(OSVERSION)/include | |
| INCLUDES=\ | |
| $(RTSROOT)/os/$(OSNAME)/include \ | |
| $(RTSROOT)/base/include \ | |
| $(RTSROOT)/include | |
| CFLAGS=-c -Wall | |
| CFLAGS+= $(foreach i, $(INCLUDES), -I$i) | |
| # This can be overridden while invoking make with DEBUG=1 | |
| DEBUG=0 | |
| # Can optionally skip building dependencies (default is 'build dependencies') | |
| # This can be overridden while invoking make with DEPEND=0 | |
| DEPEND=1 | |
| # Add debugging compile flags | |
| ifeq ($(DEBUG),1) | |
| CFLAGS+= -g -O0 | |
| endif | |
| # Archiver flags | |
| # This can be overridden while invoking make with ARFLAGS=xxx | |
| ARFLAGS=rs | |
| # Ouput RTS services library | |
| library=$(LIBDEST)/librts.a | |
| # Objects that make up the RTS services library | |
| objs=\ | |
| $(BUILDROOT)/base/basedebug.o \ | |
| $(BUILDROOT)/base/basefatal.o \ | |
| $(BUILDROOT)/umlrt/umlrtapi.o \ | |
| $(BUILDROOT)/umlrt/umlrtbasicthread.o \ | |
| $(BUILDROOT)/umlrt/umlrtcapsule.o \ | |
| $(BUILDROOT)/umlrt/umlrtcapsuleid.o \ | |
| $(BUILDROOT)/umlrt/umlrtcapsuletocontrollermap.o \ | |
| $(BUILDROOT)/umlrt/umlrtcommsport.o \ | |
| $(BUILDROOT)/umlrt/umlrtcontroller.o \ | |
| $(BUILDROOT)/umlrt/umlrtframeprotocol.o \ | |
| $(BUILDROOT)/umlrt/umlrtframeservice.o \ | |
| $(BUILDROOT)/umlrt/umlrthashmap.o \ | |
| $(BUILDROOT)/umlrt/umlrtinmessage.o \ | |
| $(BUILDROOT)/umlrt/umlrtinsignal.o \ | |
| $(BUILDROOT)/umlrt/umlrtlogprotocol.o \ | |
| $(BUILDROOT)/umlrt/umlrtmain.o \ | |
| $(BUILDROOT)/umlrt/umlrtmainloop.o \ | |
| $(BUILDROOT)/umlrt/umlrtmaintargetstartup.o \ | |
| $(BUILDROOT)/umlrt/umlrtmaintargetshutdown.o \ | |
| $(BUILDROOT)/umlrt/umlrtmessage.o \ | |
| $(BUILDROOT)/umlrt/umlrtmessagepool.o \ | |
| $(BUILDROOT)/umlrt/umlrtmessagequeue.o \ | |
| $(BUILDROOT)/umlrt/umlrtmutex.o \ | |
| $(BUILDROOT)/umlrt/umlrtobjectclass.o \ | |
| $(BUILDROOT)/umlrt/umlrtoutsignal.o \ | |
| $(BUILDROOT)/umlrt/umlrtpool.o \ | |
| $(BUILDROOT)/umlrt/umlrtprioritymessagequeue.o \ | |
| $(BUILDROOT)/umlrt/umlrtprotocol.o \ | |
| $(BUILDROOT)/umlrt/umlrtqueue.o \ | |
| $(BUILDROOT)/umlrt/umlrtrtsinterfaceumlrt.o \ | |
| $(BUILDROOT)/umlrt/umlrtsemaphore.o \ | |
| $(BUILDROOT)/umlrt/umlrtsignal.o \ | |
| $(BUILDROOT)/umlrt/umlrtsignalelement.o \ | |
| $(BUILDROOT)/umlrt/umlrtsignalelementpool.o \ | |
| $(BUILDROOT)/umlrt/umlrttimerid.o \ | |
| $(BUILDROOT)/umlrt/umlrttimerpool.o \ | |
| $(BUILDROOT)/umlrt/umlrttimerprotocol.o \ | |
| $(BUILDROOT)/umlrt/umlrttimerqueue.o \ | |
| $(BUILDROOT)/umlrt/umlrttimespec.o | |
| # Phony targets. | |
| .PHONY : all clean library exportdir exportclean exportfiles exportarchive | |
| # Build everything. | |
| all : library | |
| # phony target for the RTS services library (is currently the default target) | |
| library : $(library) | |
| # Include dependencies (default) - skip if DEPEND=0 | |
| ifneq ($(MAKECMDGOALS),clean) | |
| ifeq ($(DEPEND),1) | |
| -include $(objs:.o=.d) | |
| endif | |
| endif | |
| # Clean everything. | |
| clean : | |
| $(RM) -rf $(library) $(objs) $(objs:.o=.d) | |
| # Create the export directory if it doesn't exist. | |
| exportdir: | |
| @$(MD) $(EXPORTDIR)/umlrt-rts | |
| # Clean the export directory | |
| exportclean: | |
| @$(ECHO) "removing $(EXPORTDIR)/umlrt-rts" | |
| @$(RM) $(EXPORTDIR)/umlrt-rts | |
| # Build the export files (library, manifest, headers) | |
| exportfiles: library exportclean exportdir | |
| @$(ECHO) "export files to $(EXPORTDIR)/umlrt-rts" | |
| @$(CP) $(library) $(EXPORTDIR)/umlrt-rts | |
| @$(RTSROOT)/script/git-showid.sh > $(EXPORTDIR)/umlrt-rts/manifest | |
| @$(CP) -r $(RTSROOT)/include $(EXPORTDIR)/umlrt-rts | |
| # Build the export archive | |
| exportarchive: exportfiles | |
| @$(ECHO) "creating export archive $(EXPORTARCHIVE)" | |
| @$(TAR) -c -z -f $(EXPORTARCHIVE) -C $(EXPORTDIR)/umlrt-rts . | |
| # RTS services library build | |
| $(library) : $(objs) | |
| @-$(MD) $(LIBDEST) | |
| $(AR) $(ARFLAGS) $@ $^ | |
| # dependencies rule | |
| $(BUILDROOT)/%.d : $(RTSROOT)/%.cc | |
| @$(MD) `dirname $@` | |
| @$(CC) -MP -MM $^ $(CFLAGS) -MT $(subst .d,.o,$@) -MF $@ | |
| # objects rule | |
| $(BUILDROOT)/%.o : $(RTSROOT)/%.cc | |
| @$(MD) `dirname $@` | |
| $(CC) $< $(CFLAGS) -o $@ | |