summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile124
1 files changed, 124 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..0d9a9e7
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,124 @@
+# 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 ccflags-y += -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
+
+ccflags-y += -Werror -Wno-unused-function
+
+CXXFLAGS += -std=c++11 -Wno-unused-function
+
+LIBS := -lmts -lrt
+
+INC=-Iinclude -Iinclude/Utility -Iinclude/AccessoryCards -Iinclude/Device
+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_DEPPS1 = $(patsubst $(SOURCEDIR)/%.cpp,$(BUILDDIR)/%.d,$(SOURCES))
+CPP_DEPPS = $(patsubst $(SOURCEDIR)/%.c,$(BUILDDIR)/%.d,$(CPP_DEPPS1))
+CPP_DEPPS = $(BUILDDIR)/MtsIo.d
+JS_OBJS = $(BUILDDIR)/Version.o
+OUT_DIRS=build/AccessoryCards build/Device
+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) $(ccflags-y) $(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) $(ccflags-y) $(INC) -Wall -std=c++11 -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) $(ccflags-y) $(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) $(ccflags-y) $(INC) -Wall -std=c++11 -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<" -DENABLE_MTS_CHECK=${MTS_CHECK}
+ @echo 'Finished building: $<'
+ @echo ' '
+
+install:
+ mkdir -p $(DESTDIR)/opt/lora
+
+strip:
+ $(STRIP) $(BUILDDIR)/mts-io-sysfs
+
+clean:
+ -$(RM) $(OBJS) $(CPP_DEPPS) $(BUILDDIR)/mts-io $(BUILDDIR)/MtsIoSysfs.o $(BUILDDIR)/AccessoryCards/*.o $(BUILDDIR)/Device/*.o
+ -@echo ' '
+
+.PHONY: all clean dependents
+.SECONDARY:
+
+