Initial commit
This commit is contained in:
@@ -0,0 +1,243 @@
|
|||||||
|
# Makefile
|
||||||
|
#
|
||||||
|
|
||||||
|
DATETIME := `date +'%y%m%d-%H%M'`
|
||||||
|
MAKEFILEPATH := $(strip $(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))))
|
||||||
|
ROOTPATH := $(shell git rev-parse --show-toplevel)
|
||||||
|
COMMANDLINE := $(shell ps -o args= $$PPID)
|
||||||
|
|
||||||
|
ARCHS := $(shell ls $(ROOTPATH)/Makefiles/Makefile.conf.* | grep -v base | sed 's/.*Makefile\.conf\.//g')
|
||||||
|
ARCHS += any
|
||||||
|
ARCH := $(filter $(ARCHS),$(MAKECMDGOALS))
|
||||||
|
MAKECMDGOALS := $(filter-out $(ARCH),$(MAKECMDGOALS))
|
||||||
|
ARCHS := $(filter-out any,$(ARCHS))
|
||||||
|
|
||||||
|
ifeq ($(ARCH),)
|
||||||
|
ARCH := x86-64
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifeq (,$(findstring -S,$(COMMANDLINE)))
|
||||||
|
ifneq ($(ARCH),)
|
||||||
|
$(info ARCH: $(ARCH))
|
||||||
|
endif
|
||||||
|
endif
|
||||||
|
|
||||||
|
-include $(ROOTPATH)/Makefiles/Makefile.conf.$(ARCH)
|
||||||
|
-include $(ROOTPATH)/Makefiles/Makefile.conf.base
|
||||||
|
-include $(ROOTPATH)/Makefile.conf
|
||||||
|
|
||||||
|
PID := $(shell echo $$$$)
|
||||||
|
PREFIX = nice -n 19 /usr/bin/time --format='%E (%U)' -o /dev/shm/t-$(PID)
|
||||||
|
POSTFIX = && cat /dev/shm/t-$(PID) | xargs -I "%" echo -en '\033[1A\033[100D\033[60C' "%\n" && rm -f /dev/shm/t-$(PID)
|
||||||
|
|
||||||
|
ARNAME = $(notdir $(CURDIR)).a.$(ARCH)_
|
||||||
|
|
||||||
|
SUBDIRS := $(wildcard */.)
|
||||||
|
SUBDIRS := $(foreach dir,$(SUBDIRS),$(subst /.,,$(dir)))
|
||||||
|
FILTER = crash% doc% include% lib% Libraries% Makefiles%
|
||||||
|
SUBDIRS := $(filter-out $(FILTER),$(SUBDIRS))
|
||||||
|
SUBDIRARS = $(foreach dir,$(SUBDIRS),$(dir)/$(dir).a)
|
||||||
|
|
||||||
|
LOCALSOURCES = $(wildcard *.cpp *.cc)
|
||||||
|
LOCALOBJECTS := $(LOCALSOURCES:.cpp=.o.$(ARCH))
|
||||||
|
LOCALOBJECTS := $(LOCALOBJECTS:.cc=.o.$(ARCH))
|
||||||
|
LOCALDEPENDS = $(LOCALOBJECTS:.o.$(ARCH)=.d.$(ARCH))
|
||||||
|
SOURCES = $(wildcard *.cpp */*.cpp */*/*.cpp */*/*/*.cpp)
|
||||||
|
FILTER = Libraries%
|
||||||
|
SOURCES := $(filter-out $(FILTER),$(SOURCES))
|
||||||
|
OBJECTS = $(SOURCES:.cpp=.o.$(ARCH))
|
||||||
|
DEPENDS = $(OBJECTS:.o.$(ARCH)=.d.$(ARCH))
|
||||||
|
TARGETS =
|
||||||
|
|
||||||
|
define build_target_library_arch
|
||||||
|
$(eval $@_DATETIME := $(DATETIME))
|
||||||
|
@echo -n " [AR] $(1)\n"
|
||||||
|
@$(PREFIX) $(AR) -crs $(1) $(2) $(POSTFIX)
|
||||||
|
@mkdir -p $(ROOTPATH)/lib/$(ARCH)
|
||||||
|
@mv $(1) $$(echo $(ROOTPATH)/lib/$(ARCH)/lib$(1) | sed 's/\.$(ARCH)//g')
|
||||||
|
endef
|
||||||
|
|
||||||
|
define build_target_arch
|
||||||
|
$(eval $@_DATETIME := $(DATETIME))
|
||||||
|
@echo -n " [LD] $(1)\n"
|
||||||
|
@$(PREFIX) $(CC) -o $(1) $(2) $(LFLAGS) $(CFLAGS) $(POSTFIX)
|
||||||
|
@$(OBJCOPY) --only-keep-debug $(1) $(DEBUGDIR)/$(1)-$($@_DATETIME).debug
|
||||||
|
@$(STRIP) $(SFLAGS) $(1)
|
||||||
|
@$(OBJCOPY) --add-gnu-debuglink="$(DEBUGDIR)/$(1)-$($@_DATETIME).debug" $(1)
|
||||||
|
@chmod -x $(DEBUGDIR)/$(1)-$($@_DATETIME).debug
|
||||||
|
endef
|
||||||
|
|
||||||
|
define build_target
|
||||||
|
@if [ "$(ARCH)" = "any" ]; then \
|
||||||
|
for arch in $(ARCHS); do \
|
||||||
|
echo "ARCH: $$arch"; \
|
||||||
|
$(MAKE) -s -S $(1) $$arch; \
|
||||||
|
done; \
|
||||||
|
true; \
|
||||||
|
else \
|
||||||
|
$(MAKE) -s -S $(1).$(ARCH) $(ARCH); \
|
||||||
|
fi
|
||||||
|
endef
|
||||||
|
|
||||||
|
$(LOCALOBJECTS): | $(SUBDIRS)
|
||||||
|
$(OBJECTS): | $(SUBDIRS)
|
||||||
|
|
||||||
|
artifacts: $(LOCALOBJECTS)
|
||||||
|
|
||||||
|
.DEFAULT_GOAL := artifacts
|
||||||
|
|
||||||
|
-include Makefile.target
|
||||||
|
|
||||||
|
ifneq ($(MAKECMDGOALS),clean)
|
||||||
|
-include $(LOCALDEPENDS)
|
||||||
|
endif
|
||||||
|
|
||||||
|
%.d.$(ARCH): %.cpp
|
||||||
|
@if [ "$(ARCH)" != "any" ]; then \
|
||||||
|
depth=$(MAKELEVEL); \
|
||||||
|
while [ $${depth} -gt 0 ] ; do \
|
||||||
|
echo -n " "; \
|
||||||
|
depth=`expr $$depth - 1`; \
|
||||||
|
done; \
|
||||||
|
true; \
|
||||||
|
echo -n " [MM] $@\n"; \
|
||||||
|
$(PREFIX) $(CC) $(CFLAGS) $< -MM -MT $(@:.d.$(ARCH)=.o.$(ARCH)) >$@ $(POSTFIX); \
|
||||||
|
fi
|
||||||
|
|
||||||
|
%.o.$(ARCH): %.cpp
|
||||||
|
@depth=$(MAKELEVEL); \
|
||||||
|
while [ $${depth} -gt 0 ] ; do \
|
||||||
|
echo -n " "; \
|
||||||
|
depth=`expr $$depth - 1`; \
|
||||||
|
done; \
|
||||||
|
true
|
||||||
|
@echo -n " [CC] $@\n"
|
||||||
|
@$(PREFIX) $(CC) -c $(CFLAGS) $< -o $@ $(POSTFIX)
|
||||||
|
|
||||||
|
%.d.$(ARCH): %.cc
|
||||||
|
@if [ "$(ARCH)" != "any" ]; then \
|
||||||
|
depth=$(MAKELEVEL); \
|
||||||
|
while [ $${depth} -gt 0 ] ; do \
|
||||||
|
echo -n " "; \
|
||||||
|
depth=`expr $$depth - 1`; \
|
||||||
|
done; \
|
||||||
|
true; \
|
||||||
|
echo -n " [MM] $@\n"; \
|
||||||
|
$(PREFIX) $(CC) $(CFLAGS) $< -MM -MT $(@:.d.$(ARCH)=.o.$(ARCH)) >$@ $(POSTFIX); \
|
||||||
|
fi
|
||||||
|
|
||||||
|
%.o.$(ARCH): %.cc
|
||||||
|
@depth=$(MAKELEVEL); \
|
||||||
|
while [ $${depth} -gt 0 ] ; do \
|
||||||
|
echo -n " "; \
|
||||||
|
depth=`expr $$depth - 1`; \
|
||||||
|
done; \
|
||||||
|
true
|
||||||
|
@echo -n " [CC] $@\n"
|
||||||
|
@$(PREFIX) $(CC) -c $(CFLAGS) $< -o $@ $(POSTFIX)
|
||||||
|
|
||||||
|
$(ARNAME): $(SUBDIRS) $(LOCALOBJECTS)
|
||||||
|
@depth=$(MAKELEVEL); \
|
||||||
|
while [ $${depth} -gt 0 ] ; do \
|
||||||
|
echo -n " "; \
|
||||||
|
depth=`expr $$depth - 1`; \
|
||||||
|
done; \
|
||||||
|
true
|
||||||
|
@echo -n " [AR] $@\n"
|
||||||
|
@$(PREFIX) $(AR) rcuT $@ $(LOCALOBJECTS) $(SUBDIRARS) $(POSTFIX)
|
||||||
|
|
||||||
|
.PHONY: $(SUBDIRS)
|
||||||
|
$(SUBDIRS):
|
||||||
|
@depth=$(MAKELEVEL); \
|
||||||
|
while [ $${depth} -gt 0 ] ; do \
|
||||||
|
echo -n " "; \
|
||||||
|
depth=`expr $$depth - 1`; \
|
||||||
|
done; \
|
||||||
|
true
|
||||||
|
@echo " <$@>"
|
||||||
|
@$(MAKE) -s -S -C $@ artifacts $(ARCH)
|
||||||
|
@depth=$(MAKELEVEL); \
|
||||||
|
while [ $${depth} -gt 0 ] ; do \
|
||||||
|
echo -n " "; \
|
||||||
|
depth=`expr $$depth - 1`; \
|
||||||
|
done; \
|
||||||
|
true
|
||||||
|
@echo " </$@>"
|
||||||
|
|
||||||
|
.PHONY: all
|
||||||
|
all: $(TARGETS)
|
||||||
|
|
||||||
|
.PHONY: clean
|
||||||
|
clean:
|
||||||
|
@if [ "$(ARCH)" = "any" ]; then \
|
||||||
|
for arch in $(ARCHS); do \
|
||||||
|
echo "ARCH: $$arch"; \
|
||||||
|
$(MAKE) -s -S $(MAKECMDGOALS) $$arch; \
|
||||||
|
done; \
|
||||||
|
true; \
|
||||||
|
else \
|
||||||
|
for dir in $(SUBDIRS); do \
|
||||||
|
depth=$(MAKELEVEL); \
|
||||||
|
while [ $${depth} -gt 0 ] ; do \
|
||||||
|
echo -n " "; \
|
||||||
|
depth=`expr $$depth - 1`; \
|
||||||
|
done; \
|
||||||
|
echo " <$$dir>"; \
|
||||||
|
$(MAKE) -s -S -C $$dir $@ $(ARCH); \
|
||||||
|
while [ $${depth} -gt 0 ] ; do \
|
||||||
|
echo -n " "; \
|
||||||
|
depth=`expr $$depth - 1`; \
|
||||||
|
done; \
|
||||||
|
echo " </$$dir>"; \
|
||||||
|
done; \
|
||||||
|
for target in $(TARGETS); do \
|
||||||
|
rm -f $$target.$(ARCH); \
|
||||||
|
done; \
|
||||||
|
rm -f lib/$(ARCH)/*; \
|
||||||
|
true; \
|
||||||
|
fi
|
||||||
|
@rm -f $(LOCALOBJECTS) $(LOCALDEPENDS) || true
|
||||||
|
|
||||||
|
.PHONY: cleandeps
|
||||||
|
cleandeps:
|
||||||
|
@if [ "$(ARCH)" = "any" ]; then \
|
||||||
|
for arch in $(ARCHS); do \
|
||||||
|
echo "ARCH: $$arch"; \
|
||||||
|
$(MAKE) -s -S $(MAKECMDGOALS) $$arch; \
|
||||||
|
done; \
|
||||||
|
true; \
|
||||||
|
else \
|
||||||
|
for dir in $(SUBDIRS); do \
|
||||||
|
depth=$(MAKELEVEL); \
|
||||||
|
while [ $${depth} -gt 0 ] ; do \
|
||||||
|
echo -n " "; \
|
||||||
|
depth=`expr $$depth - 1`; \
|
||||||
|
done; \
|
||||||
|
echo " <$$dir>"; \
|
||||||
|
$(MAKE) -s -S -C $$dir $@ $(ARCH); \
|
||||||
|
while [ $${depth} -gt 0 ] ; do \
|
||||||
|
echo -n " "; \
|
||||||
|
depth=`expr $$depth - 1`; \
|
||||||
|
done; \
|
||||||
|
echo " </$$dir>"; \
|
||||||
|
done; \
|
||||||
|
for target in $(TARGETS); do \
|
||||||
|
rm -f $$target.$(ARCH); \
|
||||||
|
done; \
|
||||||
|
true; \
|
||||||
|
fi
|
||||||
|
@rm -f $(LOCALDEPENDS) || true
|
||||||
|
|
||||||
|
.PHONY: $(ARCH)
|
||||||
|
$(ARCH):
|
||||||
|
@if [ "$(words $(MAKECMDGOALS))" = "0" ]; then \
|
||||||
|
if [ "$(ARCH)" = "any" ]; then \
|
||||||
|
for arch in $(ARCHS); do \
|
||||||
|
echo "ARCH: $$arch"; \
|
||||||
|
$(MAKE) -s -S $(.DEFAULT_GOAL) $$arch; \
|
||||||
|
done; \
|
||||||
|
true; \
|
||||||
|
else \
|
||||||
|
$(MAKE) -s -S $(.DEFAULT_GOAL) $(ARCH); \
|
||||||
|
fi \
|
||||||
|
fi
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
#
|
||||||
|
# Makefile.conf.armv6-jessie
|
||||||
|
#
|
||||||
|
|
||||||
|
ARCH := armv6-jessie
|
||||||
|
CFLAGS := -marm -march=armv6
|
||||||
|
|
||||||
|
ARCHBASEDIR := /opt/build/Raspbian-jessie
|
||||||
|
|
||||||
|
AR := $(ARCHBASEDIR)/tools/bin/arm-rpi-linux-gnueabihf-ar
|
||||||
|
CC := $(ARCHBASEDIR)/tools/bin/arm-rpi-linux-gnueabihf-g++
|
||||||
|
STRIP := $(ARCHBASEDIR)/tools/bin/arm-rpi-linux-gnueabihf-strip
|
||||||
|
OBJCOPY := $(ARCHBASEDIR)/tools/bin/arm-rpi-linux-gnueabihf-objcopy
|
||||||
|
|
||||||
|
CFLAGS += -I$(ARCHBASEDIR)/include -I$(ARCHBASEDIR)/include/arm-linux-gnueabihf
|
||||||
|
LFLAGS += -L$(ARCHBASEDIR)/lib -L$(ARCHBASEDIR)/lib/arm-linux-gnueabihf -L$(ARCHBASEDIR)/usr/lib -L$(ARCHBASEDIR)/usr/lib/arm-linux-gnueabihf
|
||||||
|
LFLAGS += -Wl,-rpath,$(ARCHBASEDIR)/lib -Wl,-rpath,$(ARCHBASEDIR)/lib/arm-linux-gnueabihf -Wl,-rpath,$(ARCHBASEDIR)/usr/lib -Wl,-rpath,$(ARCHBASEDIR)/usr/lib/arm-linux-gnueabihf
|
||||||
|
LFLAGS += --sysroot $(ARCHBASEDIR)/tools/arm-rpi-linux-gnueabihf/sysroot
|
||||||
|
|
||||||
|
LFLAGS += -lmysqlclient
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
#
|
||||||
|
# Makefile.conf.armv6-stretch
|
||||||
|
#
|
||||||
|
|
||||||
|
ARCH := armv6-stretch
|
||||||
|
CFLAGS := -marm -march=armv6
|
||||||
|
|
||||||
|
ARCHBASEDIR := /opt/build/Raspbian-stretch
|
||||||
|
|
||||||
|
AR := $(ARCHBASEDIR)/tools/bin/arm-rpi-linux-gnueabihf-ar
|
||||||
|
CC := $(ARCHBASEDIR)/tools/bin/arm-rpi-linux-gnueabihf-g++
|
||||||
|
STRIP := $(ARCHBASEDIR)/tools/bin/arm-rpi-linux-gnueabihf-strip
|
||||||
|
OBJCOPY := $(ARCHBASEDIR)/tools/bin/arm-rpi-linux-gnueabihf-objcopy
|
||||||
|
|
||||||
|
CFLAGS += -I$(ARCHBASEDIR)/include -I$(ARCHBASEDIR)/include/arm-linux-gnueabihf
|
||||||
|
LFLAGS += -L$(ARCHBASEDIR)/lib -L$(ARCHBASEDIR)/lib/arm-linux-gnueabihf -L$(ARCHBASEDIR)/usr/lib -L$(ARCHBASEDIR)/usr/lib/arm-linux-gnueabihf
|
||||||
|
LFLAGS += -Wl,-rpath,$(ARCHBASEDIR)/lib -Wl,-rpath,$(ARCHBASEDIR)/lib/arm-linux-gnueabihf -Wl,-rpath,$(ARCHBASEDIR)/usr/lib -Wl,-rpath,$(ARCHBASEDIR)/usr/lib/arm-linux-gnueabihf
|
||||||
|
LFLAGS += --sysroot $(ARCHBASEDIR)/tools/arm-rpi-linux-gnueabihf/sysroot
|
||||||
|
|
||||||
|
LFLAGS += -lmariadbclient
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
#
|
||||||
|
# Makefile.conf.armv8-jessie
|
||||||
|
#
|
||||||
|
|
||||||
|
ARCH := armv8-jessie
|
||||||
|
CFLAGS := -marm -march=armv8-a
|
||||||
|
|
||||||
|
ARCHBASEDIR := /opt/build/Raspbian-jessie
|
||||||
|
|
||||||
|
AR := $(ARCHBASEDIR)/tools/bin/arm-rpi-linux-gnueabihf-ar
|
||||||
|
CC := $(ARCHBASEDIR)/tools/bin/arm-rpi-linux-gnueabihf-g++
|
||||||
|
STRIP := $(ARCHBASEDIR)/tools/bin/arm-rpi-linux-gnueabihf-strip
|
||||||
|
OBJCOPY := $(ARCHBASEDIR)/tools/bin/arm-rpi-linux-gnueabihf-objcopy
|
||||||
|
|
||||||
|
CFLAGS += -I$(ARCHBASEDIR)/include -I$(ARCHBASEDIR)/include/arm-linux-gnueabihf
|
||||||
|
LFLAGS += -L$(ARCHBASEDIR)/lib -L$(ARCHBASEDIR)/lib/arm-linux-gnueabihf -L$(ARCHBASEDIR)/usr/lib -L$(ARCHBASEDIR)/usr/lib/arm-linux-gnueabihf
|
||||||
|
LFLAGS += -Wl,-rpath,$(ARCHBASEDIR)/lib -Wl,-rpath,$(ARCHBASEDIR)/lib/arm-linux-gnueabihf -Wl,-rpath,$(ARCHBASEDIR)/usr/lib -Wl,-rpath,$(ARCHBASEDIR)/usr/lib/arm-linux-gnueabihf
|
||||||
|
LFLAGS += --sysroot $(ARCHBASEDIR)/tools/arm-rpi-linux-gnueabihf/sysroot
|
||||||
|
|
||||||
|
LFLAGS += -lmysqlclient
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
#
|
||||||
|
# Makefile.conf.armv8-stretch
|
||||||
|
#
|
||||||
|
|
||||||
|
ARCH := armv8-stretch
|
||||||
|
CFLAGS := -marm -march=armv8-a
|
||||||
|
|
||||||
|
ARCHBASEDIR := /opt/build/Raspbian-stretch
|
||||||
|
|
||||||
|
AR := $(ARCHBASEDIR)/tools/bin/arm-rpi-linux-gnueabihf-ar
|
||||||
|
CC := $(ARCHBASEDIR)/tools/bin/arm-rpi-linux-gnueabihf-g++
|
||||||
|
STRIP := $(ARCHBASEDIR)/tools/bin/arm-rpi-linux-gnueabihf-strip
|
||||||
|
OBJCOPY := $(ARCHBASEDIR)/tools/bin/arm-rpi-linux-gnueabihf-objcopy
|
||||||
|
|
||||||
|
CFLAGS += -I$(ARCHBASEDIR)/include -I$(ARCHBASEDIR)/include/arm-linux-gnueabihf
|
||||||
|
LFLAGS += -L$(ARCHBASEDIR)/lib -L$(ARCHBASEDIR)/lib/arm-linux-gnueabihf -L$(ARCHBASEDIR)/usr/lib -L$(ARCHBASEDIR)/usr/lib/arm-linux-gnueabihf
|
||||||
|
LFLAGS += -Wl,-rpath,$(ARCHBASEDIR)/lib -Wl,-rpath,$(ARCHBASEDIR)/lib/arm-linux-gnueabihf -Wl,-rpath,$(ARCHBASEDIR)/usr/lib -Wl,-rpath,$(ARCHBASEDIR)/usr/lib/arm-linux-gnueabihf
|
||||||
|
LFLAGS += --sysroot $(ARCHBASEDIR)/tools/arm-rpi-linux-gnueabihf/sysroot
|
||||||
|
|
||||||
|
LFLAGS += -lmariadbclient
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
#
|
||||||
|
# Makefile.conf.base
|
||||||
|
#
|
||||||
|
|
||||||
|
CFLAGS += -g3 -O3 -fPIC -std=c++11
|
||||||
|
CFLAGS += -Wall -Wextra -Wstrict-aliasing -pedantic -fmax-errors=5 -Werror -Wunreachable-code -Wdisabled-optimization -Wformat=2 -Winit-self -Wlogical-op -Wmissing-include-dirs -Wnoexcept -Woverloaded-virtual -Wsign-promo -Wstrict-null-sentinel -fdiagnostics-show-option
|
||||||
|
CFLAGS += -Wno-unused -Wno-variadic-macros -Wno-parentheses -Wno-unused-parameter
|
||||||
|
# CFLAGS += -Wold-style-cast -Wundef -Wshadow -Wcast-qual -Wctor-dtor-privacy -Wredundant-decls -Wstrict-overflow=5 -Wcast-align -Wswitch-default
|
||||||
|
|
||||||
|
CFLAGS += -ffunction-sections -fdata-sections
|
||||||
|
LFLAGS += -Wl,--gc-sections
|
||||||
|
SFLAGS := -s -R .comment --strip-unneeded
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
#
|
||||||
|
# Makefile.conf.x86-64
|
||||||
|
#
|
||||||
|
|
||||||
|
ARCH := x86-64
|
||||||
|
|
||||||
|
AR := ar
|
||||||
|
CC := g++
|
||||||
|
STRIP := strip
|
||||||
|
OBJCOPY := objcopy
|
||||||
|
|
||||||
|
LFLAGS += -lmysqlclient
|
||||||
Reference in New Issue
Block a user