I need makefile that is to copy the file to the name proj3 and change the prmission to make proj3 executable by everyone.
so far i have following code with error msg `proj3' is note up to date.
proj3:
cp final proj3
chmod 755 proj3
$(proj3):
cp final proj3
chmod 755 proj3
Related
I have a Makefile in the workspace folder. There are individual projects where there are project.mk files.
In the main Makefile, I want to use targets from the individual project.mk files.
all: buildUIProject1 buildUIProject2
Where buildUIProject1 is a target in project.mk
buildUIProject1: $(shell find src -name *)
npm run build
How can I accomplish this?
What you'd do is a recipe for the buildUIProject1 that runs make (recursively) on project.mk. In the main makefile:
buildUIProject1:
$(MAKE) -C project1/folder -f project.mk $#
Hi!
I started messing with makefiles a few days ago, so I gave myself a exercise to learn as well as making my life easier.
I basically want to read the directory the makefile is in (root) and use luamin to compress the file as much as possible before I deploy it to our server. But I would like to have it as flexible as possible, so depending on where said file is in the directory it should mirror it to the server.
So if it finds a file in a sub folder called home it should create a new folder with the same name with the compressed file within. I have gotten the compression of files in the root folder working as well as creation of the directories where the files should reside.
objs = $(wildcard *.lua)
dirs = $(wildcard */)
compress: $(objs)
mkdir -p .build
luamin -f $(objs) > .build/$(objs)
mkdir .build/$(dirs)
clean:
rm -rf ./.build
deploy: .build
cp ./.build/* ~
If you use GNU make, there are several features that really help to do what you want. Warning: this works if and only if your file names do not contain spaces:
srcfiles := $(shell find . -path .build -prune -o -type f -name '*.lua' -print)
dstfiles := $(addprefix .build/,$(srcfiles))
.PHONY: compress clean deploy
compress: $(dstfiles)
$(dstfiles): .build/%: %
mkdir -p $(dir $#)
luamin -f $< > $#
clean:
rm -rf ./.build
deploy: .build
cp ./.build/* ~
Explanation:
The shell make function is used to run the find command that searches all subdirectories, except .build, for *.lua files. The result is assigned to the srcfiles make variable.
The addprefix make function is used to add the .build/ prefix to all words of the srcfiles make variable and assign the result to the dstfiles make variable.
The compress target is the first (real) target in the Makefile. It is thus the default goal that gets run when invoking just make. It is the same as invoking make compress. The compress target is declared as phony. This tells make that it is not a real file, just like clean and deploy. The compress target depends on all destination files. If one is missing or older than its corresponding source file, it must be rebuilt.
The make static pattern rule $(dstfiles): .build/%: %... declares a generic rule where each destination file (.build/./foo/bar/baz.lua) depends on the corresponding source file (./foo/bar/baz.lua). The recipe creates the destination directory (./foo/bar/), computed thanks to the dir make function. Then, it applies the luamin command. The recipe makes use of the $# and $< automatic variables.
I have to compile a file .po to .mo with msgfmt, so I installed gettext (newest version) and do chmod 777 to my entire folder.
When I compile the file:
msgfmt /home/myuser/file.po -o /home/myuser/file.mo
there are no errors, no life signal, nothing.
How can I solve it?
You have to change the order of your command:
msgfmt /home/myuser/file.po -o /home/myuser/file.mo
to:
msgfmt -o /home/myuser/file.mo /home/myuser/file.po
The usage of msgfmt can you get with:
msgfmt --help
I have this simple makefile:
% cat Makefile
all: dir_a dir_b
dir_a: dir_a.tar.gz
tar xf dir_a.tar.gz
dir_b:
tar xf dir_b.tar.gz
All the targets are already created:
% ls
dir_a dir_a.tar.gz dir_b dir_b.tar.gz Makefile
But when I run make it keeps rebuilding dir_a target:
% make
tar xf dir_a.tar.gz
% make
tar xf dir_a.tar.gz
The only difference is that dir_a has tar file specified as a dependency. This tar file is not changed. Any reason it keeps remaking dir_a?
By making dir_a depend on the archive you are telling make to re-run the recipe if it is older than the archive, which will always be true unless you touch some of the files inside the folder or the folder itself after extracting it, as by default tar will preserve the original file timestamps.
The --touch/ -m flag forces tar to set the timestamps to when the files were extracted rather than the archive timestamps. I've also taken the liberty of tidying up a couple of things.
.PHONY: all
all: dir_a dir_b
dir_a dir_b: %: %.tar.gz
tar xmf $<
My current Makefile.am looks something like this:
bin_PROGRAMS = MyProgram
AM_CPPFLAGS = -I../shared
MyProgram_SOURCES = main.cpp Source1.cpp ../shared/Source2.cpp
clean : clean-am
rm -f *~
rm -f DEADJOE
distclean: distclean-am
rm -f *~
rm -f DEADJOE
rm -f Makefile
rm -f *log
This creates all the .o files in the current directory. How can I specify a different object directory in a Makefile.am? I failed to find this in the GNU documentation, although I am sure it must be there somewhere.
You can't do this in Makefile.am. This approach is not generally supported by autoconf and automake at all.
Instead, Automake supports configuring and building outside the source tree. So in your current tree, "make distclean", then:
mkdir ../build
cd ../build
../src/configure
make