P
P
Pavel Kaptur2017-02-10 15:20:02
linux
Pavel Kaptur, 2017-02-10 15:20:02

What is the correct way to make a Makefile?

I just recently started developing for Linux and Android and wanted to make a Makefile for easy assembly of all components, and there are currently three of them, there are two projects for android, they are built by ndk-build and one project is built through make and builds the program.
I tried to make a makefile, but I ran into a problem that when I run the makefile from the parent directory, then when I cd I enter the folder, but when I run ndk-build, the execution still comes from the parent directory and does not find the necessary files. And the same with a normal linux project. How can I make the commands run from the directory where I moved the build script?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
C
CityCat4, 2017-02-11
@drem1lin

There are two options.
Either do everything in the target processing "with one command", or write a few more Makefiles and sort them into directories. Large projects usually use the second path.
Here is an example of the first path:

dist: realclean
        (cd .. \
           && $(RM) -f $(DSTNAME) && $(LN) -s $(BINARY) $(DSTNAME) \
           && $(TAR) chyf $(DSTNAME).tar.bz2 $(DSTNAME) && cd $(DSTNAME))

the general principle is that all actions are recorded in one command. It's not very convenient.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question