]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lib.git/blobdiff - Makefile
Change license to MIT
[pes-rpp/rpp-lib.git] / Makefile
index 79e840cda301ec911239e37242f8fc28aaf5e9ad..74efa02c46249cf579d333a70ec5855ee15d3d80 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1,45 +1,89 @@
-# This makefile tries to build all RPP projects by calling various
-# Eclipse commands from command line.
+# Copyright (C) 2013-2015 Czech Technical University in Prague
 #
-# See http://processors.wiki.ti.com/index.php/Projects_-_Command_Line_Build/Create
-# and https://bugs.eclipse.org/bugs/show_bug.cgi?id=186847
+# Authors:
+#     - Michal Sojka <sojkam1@fel.cvut.cz>
+#
+# Permission is hereby granted, free of charge, to any person
+# obtaining a copy of this software and associated documentation
+# files (the "Software"), to deal in the Software without
+# restriction, including without limitation the rights to use,
+# copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the
+# Software is furnished to do so, subject to the following
+# conditions:
 
-ECLIPSE=/opt/ti/ccsv5/eclipse/eclipse
+# The above copyright notice and this permission notice shall be
+# included in all copies or substantial portions of the Software.
 
-all:
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+# OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
+# HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+# WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
+# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+# OTHER DEALINGS IN THE SOFTWARE.
+#
+# File : Makefile
+# Abstract:
+#       This makefile tries to build all RPP projects in this repository.
 
-lib: rpp-lib.lib
+TARGETS=$(sort $(notdir $(patsubst %/,%,$(dir $(wildcard build/*/Makefile.config)))))
 
-clean:
-       rm -rf .workspace rpp-lib.lib
+SUBDIRS = $(foreach t,$(TARGETS),build/$(t)/Debug build/$(t)/apps/helloworld build/$(t)/apps/rpp-test-suite)
 
-rpp-lib.lib: $(shell find os rpp -name *.[ch])
-       $(MAKE) rpp-lib
+subdir-targets = $(SUBDIRS:%=subdir-%)
 
-.workspace:
-       mkdir .workspace
+all: $(subdir-targets)
 
-define build_ccs
-all: $1
-$1: .workspace
-       $(ECLIPSE) -noSplash -data .workspace -application com.ti.ccstudio.apps.projectImport -ccs.location $(CURDIR)/apps/$1
-       $(ECLIPSE) -noSplash -data .workspace -application com.ti.ccstudio.apps.projectBuild -ccs.projects $1
-# Previous commands do not return non-zero exit code on build failure - invoke make directly to not miss a potential error
-       $(MAKE) -C $(CURDIR)/apps/$1/Debug all
-endef
+print-targets:
+       @echo "Building for targets: $(TARGETS)"
+
+clean: $(subdir-targets)
+
+lib: # Build only the library
+       $(MAKE) -C build/tms570_hydctr/Debug
+
+doc: # Build API documentation (Doxygen)
+       $(MAKE) -C rpp/doc/api/
 
-define build_cdt
-all: $1
-$1: .workspace
-       $(ECLIPSE) -noSplash -data .workspace -application org.eclipse.cdt.managedbuilder.core.headlessbuild -import $(CURDIR)/apps/$1
-       $(ECLIPSE) -noSplash -data .workspace -application org.eclipse.cdt.managedbuilder.core.headlessbuild -build $1
+.PHONY: all clean lib
+
+# Multiple submakes are invoked in the same directory - e.g.
+# rpp-test-suite/Debug/GNUmakefile invokes Debug/GNUmakefile. We don't
+# want these targets to be invoked twice so we forbid parallel
+# invocation in this Makefile. Note that the submakes still run in
+# parallel.
+.NOTPARALLEL:
+
+subdir-build/%: print-targets
+       $(MAKE) -C $(@:subdir-%=%) $(MAKECMDGOALS)
+
+
+UNCRUSTIFY_FILES = $(shell etc/git-ls-files-attr uncrustify)
+UNCRUSTIFY_CFG = etc/uncrustify.cfg
+define UNCRUSTIFY_ALL
+$(foreach i,$(UNCRUSTIFY_FILES),git show HEAD:$i | uncrustify -c $(UNCRUSTIFY_CFG) -o $i
+)
 endef
 
-$(eval $(call build_ccs,rpp-lib))
-$(eval $(call build_ccs,rpp-test-suite))
+# Usage: Run 'make uncrustify' and then 'git add -p' to commit the
+# changes you agree with.
+uncrustify:
+       git diff --quiet # Check that the tree is clean
+       $(UNCRUSTIFY_ALL)
+
+
+include common.mk
 
-$(eval $(call build_cdt,rpp-lib_posix))
-$(eval $(call build_cdt,rpp-test-suite_posix))
+$(eval $(call release_rules,rpp-lib))
+release: $(RELEASE_BASENAME).zip
 
-ccs-help: .workspace
-       $(ECLIPSE) -noSplash -data .workspace -application com.ti.ccstudio.apps.projectBuild -ccs.help
+$(RELEASE_BASENAME)::
+# lwIP
+       git --git-dir=lwip/.git archive --prefix=$@/lwip/ $(RELEASE_COMMIT) | tar xf -
+# API doc
+       rm -rf rpp/doc/api/html
+       $(MAKE) -C rpp/doc/api
+       mkdir -p $@/rpp/doc/api/html
+       cp -rT rpp/doc/api/html $@/rpp/doc/api/html