# set up environment for building outside bitbake # run: make MANUAL_BUILD=1 # run: make strip MANUAL_BUILD=1 ifdef MANUAL_BUILD ifndef OETREE $(error Please set OETREE variable) endif HOST_ARCH=$(shell uname -m) CCDIR = $(OETREE)/build/tmp/sysroots/$(HOST_ARCH)-linux/usr/arm926ejste/bin INCDIR = $(OETREE)/build/tmp/sysroots/arm926ejste-mlinux-linux-gnueabi/usr/include CROSS_COMPILE=$(CCDIR)/arm-mlinux-linux-gnueabi- export AS = $(CROSS_COMPILE)as export LD = $(CROSS_COMPILE)ld export CC = $(CROSS_COMPILE)gcc export CPP = $(CROSS_COMPILE)g++ export CXX = $(CROSS_COMPILE)g++ export AR = $(CROSS_COMPILE)ar export NM = $(CROSS_COMPILE)nm export STRIP = $(CROSS_COMPILE)strip export OBJCOPY = $(CROSS_COMPILE)objcopy export OBJDUMP = $(CROSS_COMPILE)objdump export RANLIB = $(CROSS_COMPILE)ranlib export CFLAGS += -march=arm926ejste -mtune=arm926ej-s -mthumb-interwork -mno-thumb -fexpensive-optimizations -fomit-frame-pointer -frename-registers -O2 -ggdb2 endif BUILDDIR=build SOURCEDIR=src # -g -pg | profiling options CFLAGS += -Werror -Wno-unused-function CXXFLAGS += -std=c++14 -Wno-unused-function LIBS := -lmts -lrt -lssl -lcrypto -lgpiod INC=-Iinclude -Iinclude/Utility -Iinclude/AccessoryCards -Iinclude/Device -Iinclude/Fpga INCLUDES = $(wildcard include/*.h) SOURCES = $(wildcard $(SOURCEDIR)/**/*.cpp) SOURCES += $(SOURCEDIR)/Version.cpp OBJS1 = $(patsubst $(SOURCEDIR)/%.cpp,$(BUILDDIR)/%.o,$(SOURCES)) OBJS = $(patsubst $(SOURCEDIR)/%.c,$(BUILDDIR)/%.o,$(OBJS1)) CPP_DEPPS = $(patsubst $(SOURCEDIR)/%.cpp,$(BUILDDIR)/**/%.d,$(SOURCES)) CPP_DEPPS += $(BUILDDIR)/*.o $(BUILDDIR)/*.d $(BUILDDIR)/**/*.o $(BUILDDIR)/**/*.d JS_OBJS = $(BUILDDIR)/Version.o OUT_DIRS=build/AccessoryCards build/Device build/Fpga MKDIR_P = mkdir -p ifndef MTS_CHECK MTS_CHECK := 1 endif .PHONY: all clean all: postbuild prebuild: @echo PRE-BUILD @echo 'Removing previous version components started' -$(RM) $(BUILDDIR)/Version.o -$(RM) $(BUILDDIR)/Version.d -$(RM) $(SOURCEDIR)/Version.cpp @echo 'Removing previous version components complete' ${MKDIR_P} ${OUT_DIRS} @echo ' ' postbuild: mainbuild @echo POST-BUILD @echo ' ' mainbuild: prebuild @echo MAIN-BUILD @$(MAKE) --no-print-directory mts-io-sysfs mts-io-sysfs: $(OBJS) $(BUILDDIR)/MtsIoSysfs.o @echo 'Building target: $@' $(CXX) $(CFLAGS) $(INC) $(LDFLAGS) -o $(BUILDDIR)/mts-io-sysfs $(OBJS) $(BUILDDIR)/MtsIoSysfs.o $(LIBS) @echo 'Finished building target: $@' @echo ' ' $(BUILDDIR)/%.o: $(SOURCEDIR)/%.cpp @echo 'Building file: $<' $(CXX) $(CFLAGS) $(INC) -Wall -std=c++14 -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<" @echo 'Finished building: $<' @echo ' ' $(BUILDDIR)/Version.o: $(SOURCEDIR)/Version.cpp @echo 'Building file: $<' $(CXX) $(CFLAGS) $(INC) -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<" @echo 'Finished building: $<' @echo ' ' $(SOURCEDIR)/Version.cpp: @echo 'Creating file: Version.cpp' /bin/echo -e "//Pre-Build Auto-Generated Source\n#include \"Version.h\"\n\nconst std::string Version::version(\"$(shell git describe)\");" > $(SOURCEDIR)/Version.cpp @echo 'Finished creating: Version.cpp' @echo ' ' $(BUILDDIR)/MtsIo.o: $(SOURCEDIR)/MtsIo.cpp @echo 'Building file: $<' $(CXX) $(CFLAGS) $(INC) -Wall -std=c++14 -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<" -DENABLE_MTS_CHECK=${MTS_CHECK} @echo 'Finished building: $<' @echo ' ' strip: $(STRIP) -S --strip-unneeded --remove-section=.note.gnu.gold-version --remove-section=.comment --remove-section=.note --remove-section=.note.gnu.build-id --remove-section=.note.ABI-tag $(BUILDDIR)/mts-io-sysfs clean: -$(RM) $(OBJS) $(CPP_DEPPS) $(BUILDDIR)/mts-io-sysfs -@echo ' ' .PHONY: all clean dependents .SECONDARY: