Skip to content
Snippets Groups Projects
makefile 5.11 KiB
Newer Older
  • Learn to ignore specific revisions
  • SHELL = /bin/bash
    
    APPPATH = /usr/bin
    
    BINFOLDER = bin
    
    
    ifeq ("$(wildcard build.conf)","")
    $(shell echo USE_RAMDISK=0 >> build.conf)
    $(shell echo USE_LTO=0 >> build.conf)
    
    $(shell echo USE_MARCH= >> build.conf)
    
    Jan Trávníček's avatar
    Jan Trávníček committed
    # can be queued from version 4.2 via MAKEFLAGS sice there is the number of jobs as well
    
    MAKE_PID := $(shell echo $$PPID)
    JOB_FLAG := $(filter -j%, $(subst -j ,-j,$(shell ps T | grep "^\s*$(MAKE_PID).*$(MAKE)")))
    JOBS     := $(subst -j,,$(JOB_FLAG))
    ifndef JOBS
    JOBS := 1
    endif
    
    
    SUBDIRS_LIBS = alib2std \
    
    		alib2abstraction \
    
    Jan Trávníček's avatar
    Jan Trávníček committed
    		alib2dummy \
    
    		alib2data \
    
    		alib2graph_data \
    
    		alib2data_experimental \
    
    		alib2str \
    
    		alib2str_cli_integration \
    
    		alib2raw \
    
    		alib2raw_cli_integration \
    
    		alib2algo \
    
    		alib2graph_algo \
    
    		alib2algo_experimental \
    
    		alib2elgo \
    
    SUBDIRS_BINS = aecho2 \
    
    Jan Trávníček's avatar
    Jan Trávníček committed
    		aarbology2 \
    
    Jan Trávníček's avatar
    Jan Trávníček committed
    		acast2 \
    
    Jan Trávníček's avatar
    Jan Trávníček committed
    		aconversions2 \
    		aconvert2 \
    
    Tomáš Pecka's avatar
    Tomáš Pecka committed
    		acompaction2 \
    
    Jan Trávníček's avatar
    Jan Trávníček committed
    		aderivation2 \
    		adeterminize2 \
    
    Jan Trávníček's avatar
    Jan Trávníček committed
    		aepsilon2 \
    
    Jan Trávníček's avatar
    Jan Trávníček committed
    		aintegral2 \
    
    Jan Trávníček's avatar
    Jan Trávníček committed
    		aminimize2 \
    		anormalize2 \
    
    Jan Trávníček's avatar
    Jan Trávníček committed
    		arand2 \
    
    Tomáš Pecka's avatar
    Tomáš Pecka committed
    		areverse2 \
    
    Jan Trávníček's avatar
    Jan Trávníček committed
    		arun2 \
    
    Jan Trávníček's avatar
    Jan Trávníček committed
    		astat2 \
    
    		astringology2 \
    
    		aquery2 \
    
    Jan Trávníček's avatar
    Jan Trávníček committed
    		atrim2 \
    
    Štěpán Plachý's avatar
    Štěpán Plachý committed
    		tniceprint \
    
    		aintrospection2 \
    
    Jan Trávníček's avatar
    Jan Trávníček committed
    		aql2 \
    
    Jan Trávníček's avatar
    Jan Trávníček committed
    define NEW_LINE
    
    
    endef
    
    export NEW_LINE
    
    
    ifneq (3.81, $(firstword $(sort $(MAKE_VERSION) 3.81)))
    $(error version $(MAKE_VERSION) is not supported. You need at least 3.82 is needed for make to work)
    endif
    
    
    TCLAP_EXISTS = $(shell $(CXX) -c -o /dev/null -xc++ - <<< $$'\#include <tclap/CmdLine.h>'; echo $$?)
    
    ifneq (0, $(TCLAP_EXISTS))
    $(error You need tclap installed)
    endif
    
    
    CPPUNIT_EXISTS = $(shell $(CXX) -o /dev/null -lcppunit -xc++ - <<< $$'\#include <cppunit/Test.h>\nint main() {\nreturn 0;\n}'; echo $$?)
    
    ifneq (0, $(CPPUNIT_EXISTS))
    $(error You need cppunit installed)
    
    Štěpán Plachý's avatar
    Štěpán Plachý committed
    
    
    READLINE_EXISTS = $(shell $(CXX) -o /dev/null -lcppunit -xc++ - <<< $$'\#include <stdio.h>\n\#include <readline/readline.h>\nint main() {\nreturn 0;\n}'; echo $$?)
    
    ifneq (0, $(READLINE_EXISTS))
    $(error You need readline installed)
    endif
    
    
    
    LIBXML2_EXISTS = $(shell $(CXX) -o /dev/null -I/usr/include/libxml2/ -lxml2 -xc++ -std=c++11 - <<< $$'\#include <libxml/xmlreader.h>\nint main() {\nreturn 0;\n}'; echo $$?)
    
    ifneq (0, $(LIBXML2_EXISTS))
    $(error You need libxml2 installed)
    endif
    
    
    SUBDIRS_WITH_MAKE = $(dir $(wildcard */makefile))
    
    
    .PHONY: build-debug   test-debug   clean-debug   \
    	build-release test-release clean-release \
    	debug release clean        doc all
    
    all:
    	@echo "What to do master?"
    
    # -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    # standalone main targets
    
    Jan Trávníček's avatar
    Jan Trávníček committed
    test-unit-debug test-unit-release:
    
    	for dir in $(SUBDIRS_LIBS); do \
    		$(MAKE) $@ -C $$dir || exit 1; \
    	done
    
    build-test-debug build-test-release:
    
    	for dir in $(SUBDIRS_LIBS); do \
    
    		$(MAKE) $@ -C $$dir || exit 1; \
    
    Jan Trávníček's avatar
    Jan Trávníček committed
    build-libs-debug build-libs-release:
    	for dir in $(SUBDIRS_LIBS); do \
    		$(MAKE) $(subst libs,code,$@) -C $$dir || exit 1; \
    
    Jan Trávníček's avatar
    Jan Trávníček committed
    build-bins-debug build-bins-release:
    	for dir in $(SUBDIRS_BINS); do \
    		$(MAKE) $(subst bins,code,$@) -C $$dir || exit 1; \
    	done
    
    build-code-debug build-code-release:
    	$(MAKE) $(subst code,libs,$@); \
    	$(MAKE) $(subst code,bins,$@);
    
    
    test-debug:
    	for test in $(wildcard tests.*.sh); do \
    		./$$test debug $(JOBS); \
    	done
    
    test-release:
    	for test in $(wildcard tests.*.sh); do \
    		./$$test release $(JOBS); \
    
    	mkdir -p $(addsuffix -debug, $(BINFOLDER)); \
    	rm -rf $(addsuffix -debug, $(BINFOLDER))/*; \
    	cd $(addsuffix -debug, $(BINFOLDER)); \
    
    	for dir in $(SUBDIRS_LIBS); do \
    
    		cp -rs ../$$dir/lib-debug/* .; \
    	done; \
    
    	for dir in $(SUBDIRS_BINS); do \
    
    		cp -rs ../$$dir/bin-debug/* .; \
    	done; \
    	cd ..; \
    
    	cp translateAddresses $(addsuffix -debug, $(BINFOLDER)); \
    
    	cp xmlFormat $(addsuffix -debug, $(BINFOLDER))
    
    install-release:
    
    	mkdir -p $(addsuffix -release, $(BINFOLDER)); \
    	rm -rf $(addsuffix -release, $(BINFOLDER))/*; \
    	cd $(addsuffix -release, $(BINFOLDER)); \
    
    	for dir in $(SUBDIRS_LIBS); do \
    
    		cp -rs ../$$dir/lib-release/* .; \
    	done; \
    
    	for dir in $(SUBDIRS_BINS); do \
    
    		cp -rs ../$$dir/bin-release/* .; \
    	done; \
    	cd ..; \
    
    	cp translateAddresses $(addsuffix -release, $(BINFOLDER)); \
    
    	cp xmlFormat $(addsuffix -release, $(BINFOLDER))
    
    
    Jan Trávníček's avatar
    Jan Trávníček committed
    debug release:
    	for dir in $(SUBDIRS_LIBS) $(SUBDIRS_BINS); do \
    
    		$(MAKE) $@ -C $$dir || exit 1; \
    	done
    
    # -----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    # do all main targets
    
    clean: clean-debug clean-release
    
    	$(RM) -r bin-debug bin-release
    
    	for dir in $(SUBDIRS_WITH_MAKE); do \
    
    	    $(MAKE) clean-debug -C $$dir; \
    
    	for dir in $(SUBDIRS_WITH_MAKE); do \
    
    	    $(MAKE) clean-release -C $$dir; \
    
    Jan Trávníček's avatar
    Jan Trávníček committed
    	doxygen
    
    Jan Trávníček's avatar
    Jan Trávníček committed
    	$(MAKE) doc -C alib2std
    
    	$(MAKE) doc -C alib2data
    
    	$(MAKE) doc -C alib2common
    
    	$(MAKE) doc -C alib2str
    
    	$(MAKE) doc -C alib2raw
    
    	$(MAKE) doc -C alib2algo
    
    	$(MAKE) doc -C alib2elgo