I'm trying to compile a kernel but can't figure out how its Makefile work : https://github.com/LineageOS/android_kernel_sony_msm8994/blob/cm-14.1/scripts/Makefile.build
As I have this error when building : Build of a custom Linux/Android/LineageOS kernel in C doesn't work , I'm for now trying to understand up until the line 44.
Why are there several Makefile with extensions like .build .clean etc rather than these actions being "targets" within the main Makefile?
How can I figure out what the very first $(obj) var refers to ?
Is the mathematical syntax := "equals by definition" instead of = specific to the developper? I do saw this on mathematics notes or symbolic languages such as Wolfram/Mathematica if I'm right, but never within a program.
Why does PHONY := is a variable and not a "type of action" as in the doc ? It should be written .PHONY: as on the very last line of the file. I didn't get this trick.
Why are there 2 underscores before __build the value of PHONY ?
By thanking you for your precisions
Because the person who wrote the makefile wanted to break those out into separate files. Maybe they're included in multiple other files, or they just wanted the top-level makefile to be more clean to read.
You can run make with the -p option and it will print all the values of all the variables in the makefile.
I don't quite understand the question: the := operator in a makefile is used for simply-expanded variable assignments. See the GNU make manual for more info.
That sets the variable PHONY to contain some contents. It is just a normal variable assignment, there's nothing fancy here. Presumably somewhere else in the makefile will appear a line: .PHONY: $(PHONY) and that will make all the targets in the PHONY variable phony.
Because the person who wrote the makefile wanted to use two underscores.
Related
I'm trying to build libavformat with this MAKEFILE. Although the makefile includes avio.o file in its build instruction but it doesn't add any symbol for the functions that are declared on the header file url.h. Source folder which includes the avio.c, avio.h and url.h files can be found HERE.
The nm command for avio.o returns
nm: avio.o: File format not recognized
file command on avio.o shows the following output
avio.o: LLVM IR bitcode
I have checked the nm command on the generated libavformat.so and did not find any symbols for the functions declared on the url.h file
I have been stuck on this for two days. Could not figure out how to solve this problem!
Calling the ff_check_interrupt method and results in
undefined reference to 'ff_check_interrupt'
Configurations and flags.
FFmpeg Configuration File: Config.h
FFmpeg Root MakeFile: Root MakeFile
CC, CXX, CFLAGS, LDFLAGS: FLAGS
First off, a function declared by url.h should be defined in url.c, not in avio.c.
Second the only use of the ff_check_interrupt in avoi.c is within a static inline function, so indeed the toolchain is likely optimizing this symbol away.
I think what's occurring for you is that the toolchain making the decision that this is only used in this compilation unit.
Moving the definition of ff_check_interrupt to 'url.c' should resolve the issue. This is a library though, so out of your control.
However, this doesn't answer why thousands of users on Github have this same library in their code. I'd suggest comparing your Makefile against those (e.g. first search return is this one.
In android mk files it is possible to call a shell command right after generating assembly files with LOCAL_FILTER_ASM.
I was wondering is there any workaround to have something similar in cmake?
I admit I had lookup what LOCAL_FILTER_ASM does.
So the following is my piece of code (same functionality just in CMake):
cmake_minimum_required(VERSION 3.0)
project(LocalFilterASM C ASM)
set(LOCAL_FILTER_ASM "cp")
string(
REPLACE
"<ASSEMBLY_SOURCE>" "<OBJECT>.S.original"
MY_CREATE_ASSEMBLY "${CMAKE_C_CREATE_ASSEMBLY_SOURCE}"
)
string(
REPLACE
"<SOURCE>" "<OBJECT>.S"
MY_COMPILE_OBJECT "${CMAKE_ASM_COMPILE_OBJECT}"
)
set(
CMAKE_C_COMPILE_OBJECT
"${MY_CREATE_ASSEMBLY}"
"${LOCAL_FILTER_ASM} <OBJECT>.S.original <OBJECT>.S"
"${MY_COMPILE_OBJECT}"
)
file(WRITE main.c "int main(void) { return 0; }")
add_executable(${PROJECT_NAME} main.c)
This just takes some of the existing CMake compiler rules and combines it into a new multi-line rule for CMAKE_C_COMPILE_OBJECT. Please note that this will only work with CMake's makefile generators.
It's very hard to say since you haven't provided any example of what you currently have.
However, you can use the add_custom_command() function to add before and after scripts to any target (see the bottom of the page in the "Build Events" section for the syntax you want).
I am a newbie to Android makefiles. While reading this file I see a "-include" statement.
What does this actually mean to the build system?
The include simply means that another makefile should be included. The - means that if the file to include doesn't exist it will simply be ignored:
We can also put a minus sign - in front of include (with no space in-between) to ignore filenames that do not exist. For example:
-include makefile1 makefile2 makefile3
If makefile2 does not exist, then make will skip it, and no error will occur. In general, inserting a minus sign in front of any command tells make to ignore errors that might occur during the execution of that command.
(source)
For reasons, I want to compile the AOSP 4.3.3 tree with the 'user' (aosp_deb-user) build (and not the user-debug / eng builds).
However I would like to specify that I:
would like the su package included (system/extras)
possibly (but less importantly) remove some things I do not need in my testing (therefore speed compilation up) - such as chromium app / camera app / whatever.
Could anyone let me know how to do this?
I already attempted changing the build tag in the su 'Android.mk' to user (which was the old way of doing it) - but it now gives me an error stating I must request in my product packages, however i am unsure where this is.
thank you,
It's (mainly) the PRODUCT_PACKAGES variable that controls which modules are installed. That variable is set in the product makefiles, which form hierarchies of makefiles. The leaf file for a concrete product is usually device/vendorname/productname/productname.mk or similar, in your case device/asus/deb/aosp_deb.mk. In that file you'll find a couple of inclusions:
$(call inherit-product, device/asus/deb/device.mk)
$(call inherit-product, $(SRC_TARGET_DIR)/product/aosp_base.mk)
If you following the trail of inherit-product breadcrumbs you'll eventually encounter all PRODUCT_PACKAGES assignments, at least one of which will list the modules that you want to exclude. (The SRC_TARGET_DIR variable in the example above points to the build/target directory.)
For all you C4DROID dev's, I have a question about the Makefile option. I have been toying around with it for some time now, and just can't seem to get it to function properly. I've tried implementing the tutorial from http://mrbook.org/tutorials/make/ as well as http://www.gnu.org/software/make/manual/make.html#Implicit-Rules . These sites have helped me at least get different error messages (which in some ways is helpful) but I'm just not sure what else I need to be doing. I'm not sure how much detail I should include about what I'm doing (first time posting), so here goes.
At the moment, I have the files (for test purposes only) main.cpp, hello.cpp, factorial.cpp, and functions.h . I created a Makefile with:
all:
g++ main.cpp hello.cpp factorial.cpp functions.h -o MyFile
I have also tried variations like:
all: testTwo
testTwo:
g++ main.cpp hello.cpp factorial.cpp functions.h -o MyFile
In the compilation settings, I have selected Makefile, I have not modified the "Commands Before Make" code (I don't even understand it), my Make command is
make -f Makefile
I have selected the Native Activity in Run Mode, and that's all that I can think of explaining. My error message I get on compilation is "Failed to copy file".
Any help with the process would be greatly appreciated and thank you in advance.
In the compile options screen, section 'Result binary filename': enter the name of the executable that your Makefile generates i.e. MyFile for your example.
I also tend to use 'Run mode: Terminal app' for simple console programs. NativeActivity is intended for Android NDK app development and hence is a bit more involved.