I have the following makefile. However, I notice that intermediate build results are being removed from T2OUT. Is this normal/expected behaviour?
BUILDROOT=../../..
T2OUT=$(BUILDROOT)/t2-output/linux64-gcc-production-default
TUNDRA2=cd $(BUILDROOT); tundra2 production
DOCKER_TAG=services
SERVICES=managerservice \
schedulerservice \
paymentservice \
userservice \
storageservice \
libModCouchbase.so
all: $(SERVICES)
chmod +x wait_to_start.sh
docker build -t $(DOCKER_TAG) .
docker push $(DOCKER_TAG)
$(T2OUT)/libModCouchbase.so:
$(TUNDRA2) ModCouchbase
$(T2OUT)/%:
$(TUNDRA2) $*
%: $(T2OUT)/%
cp $< $#
clean:
rm -f $(SERVICES)
rm -rf $(T2OUT)
.PHONY: all clean
Related
So I have this code:
CELLMECH=../cellmech
ALL: \
png/01.png \
png/02.png \
png/03.png \
png/04.png \
png/05.png \
png/06.png \
png/07.png \
png/08.png \
png/09.png \
png/10.png pickles/cellMech.10.pickle.gz
include ${CELLMECH}/png.make
pickles/modLink.01.pickle.gz : stretched-plane.pickle.gz
mkdir -p pickles
${CELLMECH}/modLink.py -i $< -o $# -c conf
pickles/cellMech.01.pickle.gz : pickles/modLink.01.pickle.gz
${CELLMECH}/cellMech.py -dt 0.001 -nmax 10000 -i $< -o $# > /dev/null
.
.
.
This is a .make extension file that I exceute with: "make -f 10.make"
Then I get an error:
modLink.py -i stretched-plane.pickle.gz -o pickles/modLink.01.pickle.gz -c conf
make: modLink.py: No such file or directory
make: *** [10.make:19: pickles/modLink.01.pickle.gz] Error 127
I have tried everything, direct path to files, changing names, remaking the files, nothing worked. The make program can find the files with .make extension, but no matter what I do, it somehow cannot see the .py extension files.
Any help would be greatly appreciated.
Okay, after some consultation I found a solution: inserting "python" before the files, so they are given to the python interpeter directly. So the code runs in this form:
.
.
.
pickles/modLink.01.pickle.gz : stretched-plane.pickle.gz
mkdir -p pickles
python ${CELLMECH}/modLink.py -i $< -o $# -c conf
pickles/cellMech.01.pickle.gz : pickles/modLink.01.pickle.gz
python ${CELLMECH}/cellMech.py -dt 0.001 -nmax 10000 -i $< -o $# > /dev/null
.
.
.
I'm trying to compile OpenWRT package. Already compile toolchain. From here I know it can be when use static pattern rules, but I don't. I checked the whole file for syntax errors - everything is fine (maybe I missed something).
OS: Ubuntu 20.04 Server
g++: 9.3.0
OpenWRT: 19.07.7
wiha#osboxes:~/source$ ./scripts/feeds update mypackage
Updating feed 'mypackage' from '\home\wiha\package_src\package' ...
Create index file './feeds/mypackage.index'
/home/wiha/source/feeds/mypackage.tmp/info/.files-packageinfo.mk:1: *** target pattern contains no '%'. Stop.
Makefile:
include $(TOPDIR)/rules.mk
PKG_NAME:=mypackage
PKG_VERSION:=0.1
PKG_RELEASE:=1
SOURCE_DIR:=../../..
include $(INCLUDE_DIR)/package.mk
define Package/mypackage
SECTION:=mypackage
CATEGORY:=Network
TITLE:=The router`s agent
DEPENDS:=+libopenssl +libjson-c +libcurl
URL:=https://www.example.com
endef
define Build/Prepare
mkdir -p $(PKG_BUILD_DIR)
# copy source files
$(CP) -r $(SOURCE_DIR)/src $(PKG_BUILD_DIR)/src
$(CP) $(SOURCE_DIR)/CMakeLists.txt $(PKG_BUILD_DIR)
rm -f $(PKG_BUILD_DIR)/CMakeCache.txt
rm -fR $(PKG_BUILD_DIR)/CMakeFiles
rm -f $(PKG_BUILD_DIR)/Makefile
rm -f $(PKG_BUILD_DIR)/cmake_install.cmake
rm -f $(PKG_BUILD_DIR)/progress.make
endef
define Build/Configure
IN_OPENWRT=1 \
AR="$(TOOLCHAIN_DIR)/bin/$(TARGET_CROSS)ar" \
AS="$(TOOLCHAIN_DIR)/bin/$(TARGET_CC) -c $(TARGET_CFLAGS)" \
LD="$(TOOLCHAIN_DIR)/bin/$(TARGET_CROSS)ld" \
NM="$(TOOLCHAIN_DIR)/bin/$(TARGET_CROSS)nm" \
CC="$(TOOLCHAIN_DIR)/bin/$(TARGET_CC)" \
GCC="$(TOOLCHAIN_DIR)/bin/$(TARGET_CC)" \
CXX="$(TOOLCHAIN_DIR)/bin/$(TARGET_CROSS)g++" \
RANLIB="$(TOOLCHAIN_DIR)/bin/$(TARGET_CROSS)ranlib" \
STRIP="$(TOOLCHAIN_DIR)/bin/$(TARGET_CROSS)strip" \
OBJCOPY="$(TOOLCHAIN_DIR)/bin/$(TARGET_CROSS)objcopy" \
OBJDUMP="$(TOOLCHAIN_DIR)/bin/$(TARGET_CROSS)objdump" \
TARGET_CPPFLAGS="$(TARGET_CPPFLAGS)" \
TARGET_CFLAGS="$(TARGET_CFLAGS)" \
TARGET_LDFLAGS="$(TARGET_LDFLAGS)" \
cmake $(PKG_BUILD_DIR)/CMakeLists.txt
endef
define Build/Compile
$(MAKE) -C $(PKG_BUILD_DIR)
$(STRIP) $(PKG_BUILD_DIR)/mypackage
endef
define Package/mypackage/install
$(CP) $(SOURCE_DIR)/files/* $(1)/
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/mypackage $(1)/usr/bin/
endef
$(eval $(call BuildPackage,mypackage))
.files-packageinfo.mk:
$(eval $(call PackageDir,Makefile:$(eval $(call BuildPackage,mypackage)),Makefile:$(eval $(call BuildPackage,mypackage)),))
let me start off by saying this is an entirely new world to me so forgive any improper use of terminology.
The problem in a nutshell, I was given the file which is used to run a GUI for controlling a motor. The UI was created in Qt Creator. After numerous google searches and trial and error I learned how to run the Makefile on the Raspberry Pi3 device. This code is in working order and should not need any modifications to the code itself persay, it is just a matter of installing the right packages and typing the correct commands.
These are the steps I am getting to and the resulting output:
pi#raspberrypi:~/Documents/BasicInterface $ make
cp source/Collection.py build/Collection.py
cp source/main_release.py build/main_release.py
cp source/utilities.py build/utilities.py
cp source/Calibration.py build/Calibration.py
cp source/main_debug.py build/main_debug.py
cp source/archive.py build/archive.py
cp source/MotorControl.py build/MotorControl.py
cp source/MainCanvas.py build/MainCanvas.py
cp source/Report.py build/Report.py
cp source/MainWindow.py build/MainWindow.py
cp source/LoadCell.py build/LoadCell.py
cp source/Analysis.py build/Analysis.py
pyrcc5 resources/resources_rc.qrc -o build/resources_rc.py
pyuic5 resources/Ui_MainWindow.ui > build/Ui_MainWindow.py
pyuic5 resources/Ui_About.ui > build/Ui_About.py
python3 -m zipapp -p "/usr/bin/env python3" build -m main_release:main -o main_release.pyz
This is the Makefile file:
SRC = $(wildcard source/*.py)
OBJ = $(subst source,build,$(SRC))
OBJ += build/resources_rc.py
OBJ += build/Ui_MainWindow.py
OBJ += build/Ui_About.py
RCS = $(wildcard resources/embed/*)
RCS += $(wildcard resources/dynamic/*)
PYTHON = python3
FLAGS = -m zipapp -p "/usr/bin/env python3" build
all: release
release: main_release.pyz
debug: main_debug.pyz
install: main_release.pyz
.PRECIOUS: $(OBJ)
.PHONY: clean
.PHONY: install
%.pyz: $(OBJ)
$(PYTHON) $(FLAGS) -m $(basename $#):main -o $#
build/%.py: source/%.py
cp $< $#
build/%.py: resources/%.qrc $(RCS)
pyrcc5 $< -o $#
build/%.py: resources/%.ui
pyuic5 $< > $#
resources/dynamic/about.html: support/writeAbout.sh
./support/writeAbout.sh resources/dynamic/about.html
clean:
-rm $(OBJ)
-rm main_*.pyz
-rm -rf build/__pycache__
install:
mkdir -p $(HOME)/.irisEngineering
install main_release.pyz $(HOME)/.irisEngineering/AdhesionTester.pyz
install resources/embed/icon.svg $(HOME)/.irisEngineering/
envsubst <support/AdhesionTester.desktop >$(HOME)/Desktop/AdhesionTester.desktop
Basically it is not creating the directory (unless I'm looking in the wrong spot) and I do not see the application anywhere. I'm not sure if the information I have provided will suffice in helping me, but please let me know if any additional information is needed.
I write a ugly copy/paste way created Makefile:
all: download install
install: \
${EXTERNAL_MODELS_LOCAL}/squeezenet_weights_tf_dim_ordering_tf_kernels.h5 \
${EXTERNAL_MODELS_LOCAL}/resnet50_weights_tf_dim_ordering_tf_kernels.h5 \
${EXTERNAL_MODELS_LOCAL}/inception_v3_weights_tf_dim_ordering_tf_kernels.h5 \
${EXTERNAL_MODELS_LOCAL}/squeezenet_weights_tf_dim_ordering_tf_kernels.h5:
ln -s ${EXTERNAL_MODELS_ROOT}/squeezenet_weights_tf_dim_ordering_tf_kernels.h5 $#
${EXTERNAL_MODELS_LOCAL}/resnet50_weights_tf_dim_ordering_tf_kernels.h5:
ln -s ${EXTERNAL_MODELS_ROOT}/resnet50_weights_tf_dim_ordering_tf_kernels.h5 $#
${EXTERNAL_MODELS_LOCAL}/inception_v3_weights_tf_dim_ordering_tf_kernels.h5:
ln -s ${EXTERNAL_MODELS_ROOT}/inception_v3_weights_tf_dim_ordering_tf_kernels.h5 $#
download: $(EXTERNAL_MODELS_ROOT)/ \
$(EXTERNAL_MODELS_ROOT)/squeezenet_weights_tf_dim_ordering_tf_kernels.h5 \
$(EXTERNAL_MODELS_ROOT)/resnet50_weights_tf_dim_ordering_tf_kernels.h5 \
$(EXTERNAL_MODELS_ROOT)/inception_v3_weights_tf_dim_ordering_tf_kernels.h5 \
$(EXTERNAL_MODELS_ROOT)/squeezenet_weights_tf_dim_ordering_tf_kernels.h5:
wget https://github.com/OlafenwaMoses/ImageAI/releases/download/1.0/squeezenet_weights_tf_dim_ordering_tf_kernels.h5 \
-O $#
$(EXTERNAL_MODELS_ROOT)/resnet50_weights_tf_dim_ordering_tf_kernels.h5:
wget https://github.com/OlafenwaMoses/ImageAI/releases/download/1.0/resnet50_weights_tf_dim_ordering_tf_kernels.h5 \
-O $#
$(EXTERNAL_MODELS_ROOT)/inception_v3_weights_tf_dim_ordering_tf_kernels.h5:
wget https://github.com/OlafenwaMoses/ImageAI/releases/download/1.0/inception_v3_weights_tf_dim_ordering_tf_kernels.h5 \
-O $#
Biggest part skipped ,but looks the same. Is it possible to optimize this boilerplate?
A mixture of make variables, make automatic variables (e.g. $<, $#), make functions (e.g. addsuffix, addprefix) and pattern rules, maybe:
RHOST := https://github.com/OlafenwaMoses/ImageAI/releases/download/1.0/
H5STEM := squeezenet resnet50 inception_v3
H5 := $(addsuffix _weights_tf_dim_ordering_tf_kernels.h5,$(H5STEM))
H5LOCAL := $(addprefix $(EXTERNAL_MODELS_LOCAL)/,$(H5))
H5ROOT := $(addprefix $(EXTERNAL_MODELS_ROOT)/,$(H5))
.PHONY: install download
install: $(H5LOCAL)
download: $(H5ROOT)
$(EXTERNAL_MODELS_LOCAL)/%.h5: $(EXTERNAL_MODELS_ROOT)/%.h5
ln -s $< $#
$(EXTERNAL_MODELS_ROOT)/%.h5:
wget $(RHOST)/$*.h5 -O $#
And of course, if there was a way to automatically discover the list of remote *.h5 files, it would be even better. But some more information is needed to imagine how to do it (ssh, curl, wget... ?). The make shell function would be the starting point, of course:
H5 := $(shell <the-command-that-lists-the-remote-h5-files>)
I have this rule in my Makefile, that responds to flags I pass:
$(BUILD_DIR)/disable_%:
mkdir -p $(BUILD_DIR)
touch $(BUILD_DIR)/disable_$*
rm -f $(BUILD_DIR)/enable_$*
cd $(BUILD_DIR) && rm -f Makefile
$(BUILD_DIR)/enable_%:
mkdir -p $(BUILD_DIR)
touch $(BUILD_DIR)/enable_$*
rm -f $(BUILD_DIR)/disable_$*
cd $(BUILD_DIR) && rm -f Makefile
What this means is that when changing the flags by which I invoke the makefile, I can trigger some recompilations that could depend on these flags.
The code presented above is a bit redundant: you see that I remove a file, touch another and remove a Makefile in both cases. The only thing that changes is the name of the files that I touch/remove, and they are related.
For instance,
make clean
make enable_debug=yes enable_video=no # will compile from zero
make enable_debug=no enable_video=no # flag change detected -> recompile some submodules that depend on this flag
Provided that the only thing that changes between the two rules ( [en|dis]able ), what I would like is to only have 1 generic rule, something like that:
# match 2 parts in the rule
$(BUILD_DIR)/%ble_%:
mkdir -p $(BUILD_DIR)
touch $(BUILD_DIR)/(???)ble_$* # should be $#
rm -f $(BUILD_DIR)/(???)able_$* # should be disable if $# is enable and inverse
cd $(BUILD_DIR) && rm -f Makefile
Is this possible ?
PS: Sorry if I didn't get the title correctly, I couldn't figure how to explain it better.
$(BUILD_DIR)/enable_% $(BUILD_DIR)/disable_%:
mkdir -p $(BUILD_DIR)
rm -f $(BUILD_DIR)/*able_$*
touch $#
cd $(BUILD_DIR) && rm -f Makefile
Not literally what you wanted (multi-wildcards are forbidden in make), but does quite the same.