-
Jan Trávníček authoredJan Trávníček authored
Code owners
Assign users and groups as approvers for specific file changes. Learn more.
makefile 4.40 KiB
SHELL = /bin/bash
USE_RAMDISK ?= 0
APPPATH = /usr/bin
LIBPATH = /usr/lib
BINFOLDER = bin
RUN_TESTS ?= 1
# 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 \
alib2common \
alib2data \
alib2str \
alib2raw \
alib2algo \
alib2elgo \
alib2measurepp \
SUBDIRS_BINS = aecho2 \
aarbology2 \
acast2 \
aconversions2 \
aconvert2 \
acompaction2 \
aderivation2 \
adeterminize2 \
acompare2 \
aepsilon2 \
agenerate2 \
aintegral2 \
alangop2 \
ameasure2 \
ameasurep2 \
aminimize2 \
anormalize2 \
araw2 \
arand2 \
arename2 \
areverse2 \
arun2 \
astat2 \
aaccess2 \
astringology2 \
atrim2 \
tniceprint \
alphabetManip2 \
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)
endif
LIBXML2_EXISTS = $(shell $(CXX) -o /dev/null -I/usr/include/libxml2/ -lxml2 -xc++ - <<< $$'\#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 clean-debug \
build-release clean-release \
debug release clean doc all
all:
@echo "What to do master?"
debug build-debug:
for dir in $(SUBDIRS_LIBS); do \
$(MAKE) $@ -C $$dir || exit 1; \
done
for dir in $(SUBDIRS_BINS); do \
$(MAKE) debug -C $$dir || exit 1; \
done
if [ ! -w $(addsuffix -debug, $(BINFOLDER)) ] && [ $(USE_RAMDISK) -eq 1 ]; then\
ln -s /tmp/`date +'%s%N'`-$(addsuffix -debug, $(BINFOLDER)) $(subst /, , $(addsuffix -debug, $(BINFOLDER))) 2>/dev/null;\
fi;\
if [ -L $(subst /, , $(addsuffix -debug, $(BINFOLDER))) ]; then\
mkdir -p `readlink $(subst /, , $(addsuffix -debug, $(BINFOLDER)))`;\
else\
mkdir -p $(addsuffix -debug, $(BINFOLDER));\
fi
rm -rf $(addsuffix -debug, $(BINFOLDER))/*
for dir in $(SUBDIRS_LIBS); do \
cp $$dir/lib-debug/* $(addsuffix -debug, $(BINFOLDER)); \
done
for dir in $(SUBDIRS_BINS); do \
cp $$dir/bin-debug/* $(addsuffix -debug, $(BINFOLDER)); \
done
cp translateAddresses $(addsuffix -debug, $(BINFOLDER)); \
if [ "$@" == "debug" ] && [ $(RUN_TESTS) -eq 1 ]; then for test in $(wildcard tests.*.sh); do \
./$$test debug $(JOBS); \
done; fi
release build-release:
for dir in $(SUBDIRS_LIBS); do \
$(MAKE) $@ -C $$dir || exit 1; \
done
for dir in $(SUBDIRS_BINS); do \
$(MAKE) release -C $$dir || exit 1; \
done
if [ ! -w $(addsuffix -release, $(BINFOLDER)) ] && [ $(USE_RAMDISK) -eq 1 ]; then\
ln -s /tmp/`date +'%s%N'`-$(addsuffix -release, $(BINFOLDER)) $(subst /, , $(addsuffix -release, $(BINFOLDER))) 2>/dev/null;\
fi;\
if [ -L $(subst /, , $(addsuffix -release, $(BINFOLDER))) ]; then\
mkdir -p `readlink $(subst /, , $(addsuffix -release, $(BINFOLDER)))`;\
else\
mkdir -p $(addsuffix -release, $(BINFOLDER));\
fi
rm -rf $(addsuffix -release, $(BINFOLDER))/*
for dir in $(SUBDIRS_LIBS); do \
cp $$dir/lib-release/* $(addsuffix -release, $(BINFOLDER)); \
done
for dir in $(SUBDIRS_BINS); do \
cp $$dir/bin-release/* $(addsuffix -release, $(BINFOLDER)); \
done
cp translateAddresses $(addsuffix -release, $(BINFOLDER)); \
if [ "$@" == "release" ] && [ $(RUN_TESTS) -eq 1 ]; then for test in $(wildcard tests.*.sh); do \
./$$test release $(JOBS); \
done; fi
clean: clean-debug clean-release
$(RM) -r bin-debug bin-release
clean-debug:
for dir in $(SUBDIRS_WITH_MAKE); do \
$(MAKE) clean-debug -C $$dir; \
done
clean-release:
for dir in $(SUBDIRS_WITH_MAKE); do \
$(MAKE) clean-release -C $$dir; \
done
doc:
$(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
$(MAKE) doc -C alib2measurepp