25,699 questions
1
vote
1
answer
54
views
Conditional statement in makefile based on querying present working directory
From here, I realize it is possible to query the pwd.
I have the following 2 lines that I currently comment on/off
# LDLIBSOPTIONS=-L "/home/OpenXLSX/linux/lib"
LDLIBSOPTIONS=-L "/...
1
vote
1
answer
51
views
Using tee in a Linux makefile
I am trying to save the output of a makefile. I have tried everything that I can think of without success.
> >> tee compile.log
> 1> tee compile.log
> 2> tee compile.log
> &>...
-3
votes
0
answers
128
views
"Multiple definition" error in C++ with separate definition and declaration [closed]
So I have a header file with the following code:
#ifndef banana_h
#define banana_h
#include <string>
std::string foo(std::string a);
std::string bar(std::string b);
#endif
and the ...
0
votes
0
answers
145
views
Build fails as both LOCAL_SDK_VERSION and LOCAL_PRIVATE_PLATFORM_APIS are set
I'm beginning to customize my phone and I'm following this guide to build AOSP for an Xperia.
I selected aosp_arm64-eng target by running source build/envsetup.sh && lunch, then ran make -j$(...
2
votes
3
answers
160
views
How to create test executables in Makefile in C?
I want to build make test with Makefile, and the test target should generate <file_name>_test executable based on the folder tests/<file_name>.c. All tests/*.c files have a main() function....
3
votes
3
answers
169
views
How to write Makefile for debugging only one header and source in c
The lib folder contains many *.h and *.c files, and all files are in development phrase and they contain many errors including syntax errors. So I want to write the Makefile to debug all libraries one ...
2
votes
2
answers
135
views
Nested C Makefile
C/Makefile relative newbie here. I have a C project whose structure looks like this:
main.c
subdir1
a.h
a.c
b.h
b.c
subdir2
x.h
x.c
y.h
...
0
votes
1
answer
77
views
Why doesn't make fail if a file exists but there is no rule for it
The following is a minimal example from something odd that was happening to me. My situation was obviously more complex than what follows, but the "misunderstanding" boils down exactly to ...
0
votes
1
answer
49
views
How to pass -B (rebuild all) to submake
I am using an alternate make system tied in to the main make. The issue is when I do:
make -B
For rebuild all, it does not pass that to the submake. I want the submake to also do a rebuild.
The only ...
0
votes
1
answer
59
views
mingw32-make application was unable to start correctly (0xC0000142)
I installed mingw64 on my Windows 11 system a few days ago.
When using mingw32-make, the following code (lines 27 and 28) in the makefile is failing.
voice.exe: ${OBJS}
${CC} -o "$@" ${...
0
votes
2
answers
68
views
How to apply the same recipe to different target with pattern?
Here is my Makefile. All the %.o depend on %.c and main.h, except the ones under main, event, cmd folder, which depend on $(MAIN_HEADERS).
How do I combine the below and make them simpler, as their ...
1
vote
1
answer
62
views
Pattern rules not recognized for files with double suffixes?
I have a minimal Makefile with just this one pattern rule:
%: %.m4
m4 $< > $@
Then, with GNU Make:
touch foo.in.m4 ; make foo.in executes as expected: m4 foo.in.m4 > foo.in
but for foo....
1
vote
1
answer
129
views
Makefile to create .o and program file in separate directories depending on architecture of host PC
Trying to create a Makefile that compiles C source into a .o file in a subfolder as well as creating the executable in a different subfolder depending on the architecture of the host PC. When I run &...
0
votes
1
answer
104
views
Undefined reference to header only library [duplicate]
Goal
Use concise makefile with organized directory structure. In particular, I don't want to have to edit the makefile to manage dependencies with every new source addition. The assumed directory ...
0
votes
0
answers
68
views
Can't build a project in Visual Studio Code when there are two build steps, cmake and make
Visual Studio Code 1.104.1, running on Fedora 42 (Workstation Edition). I can't seem to be able to build a project that requires two build steps, cmake and make. Part of the problem is that I want to ...
0
votes
1
answer
40
views
Why does my recursive Makefile target exit with ‘is up to date’ and no error, unless I redeclare all
I have a recursive Makefile setup where a root Makefile delegates builds to subdirectory Makefiles via $(MAKE) BUILDTARGET=.... Most subdirectories build fine, but the boot/ directory behaves ...
0
votes
1
answer
92
views
Makefile not building pattern rule prerequisites when it involves a chain [closed]
Consider this Makefile:
run-%: %
./$<
I have a test1.cpp file, so I expect make to build test1.o and test1 using chained implicit rules when I run make run-test1. However, what I get is
make: *...
3
votes
2
answers
146
views
What is the purpose of the ar “-l” option?
For context, I have been working on a game engine for a while now. The engine requires several libraries to function (Wayland, XKB, Vulkan, etc.). Because the added complexity of shared libraries ...
1
vote
2
answers
69
views
Conditional declarations in makefile based on target
I'm modifying a makefile and a bit in the dark. I've tried googling and reading make primers but nothing has obvious answers to my problems below
Its first target: "default" compiles and ...
0
votes
0
answers
35
views
shell command doesn't run in makefile [duplicate]
makefile:
BUILD_DIR=build
$(BUILD_DIR)/src_floppy.img: $(BUILD_DIR)/src.bin
copy $(BUILD_DIR)/src.bin $(BUILD_DIR)/src_floppy.img
translates to:
copy build/src.bin build/src_floppy.img
it throws ...
-4
votes
1
answer
61
views
I want `make` to fail if an environment var is not specified
I want GNU make command to fail if the environment var AUTO_CALL is not specified.
I could do so:
.PHONY: x
x:
ifndef AUTO_CALL
@echo "Don't call `make` manually."
else
...
endif
...
0
votes
1
answer
41
views
Building static version of Metakit C++ bindings on Debian
Metakit can be found here: https://github.com/jnorthrup/metakit
So, I'm trying to build Metakit on Debian. The readme file on GitHub have Unix (C++) build instructions. They are basically just the ...
2
votes
1
answer
56
views
GHC(Haskell) not picking up imports from makefile
I have been making a Haskell project that I want to continue on in C at some point through the FFI. I wanted to create a makefile to compile all the source with Clang for C and GHC for Haskell.
The ...
0
votes
1
answer
53
views
Variables depending on target variable not re-evaluated
I have a Makefile where I define a user-provided DEBUG variable to switch compile flags and target files. In one specific target, test, I want this variable to always be 1.
Essential bits:
DEBUG ?= 0
...
0
votes
1
answer
39
views
How to pass information between Makefile recipes
I want to build and push a docker image as two different recipes in a Makefile. However, to avoid installations on the environment, the version tag of the Dockerfile is created inside the container ...
0
votes
1
answer
68
views
Use variables as shell inputs in Makefile
How can I use the output of a shell script as variable in another shell script. Suppose the following Makefile
build:
DOCKER_IMAGE_ID=$(shell docker build -q -t myimage .); \
OUT=$(shell ...
0
votes
1
answer
87
views
Makefile "profiles" to define different flags for the build target
I'm trying to find a way to easily compile a project with debugging flags or with optimized flags. I.e. make debug would build the project with FLAGS = -static -W -Wall -Wextra -g -ggdb and make ...
0
votes
1
answer
99
views
makefile calls a shell script but it doesn't recognize the first argument passed
I have the following script and makefile:
Makefile
WORKING_DIR := /home/user1/working_dir
outdir := /home/user1/working_dir/outdir
script := ./myscript.sh
my_target: file1.ini file2.ini file3.ini ...
0
votes
1
answer
187
views
How do I compile with gcc using SDL2 on Windows with a Makefile?
I was for a while developing an SDL project in code blocks but wanted to transition to instead using VS Code. My experience with compiling my own programs hasn't gone beyond single file, non-dependent ...
1
vote
0
answers
73
views
Usage of sed in Windows OS via Make
I am working on Windows OS. And here is my makefile snippet.
COMPILER_ROOT := C:/Users/kpt
DATE := $(COMPILER_ROOT)/build/busybox_glob.exe date
SED := $(COMPILER_ROOT)/build/busybox_glob.exe sed
...
0
votes
1
answer
106
views
Set custom library path to execute a CGI file from the uhttpd
I am working on OpenWrt 23.05, to run a CGI script from the browser URL e.g. http://192.168.1.1/cgi-bin/myapp.cgi
The server is uHTTPd. My CGI file is written in C++ that needs no interpreter.
The CGI ...
1
vote
2
answers
59
views
gnu make executes commented $(info ) within define
I cannot comment out an info line inside a define. The following makefile shows the behavior (mind the tabs)
define tmpl
$(info info inside define, not commented, parameter is: $(1))
# $(info info ...
0
votes
0
answers
89
views
glibc build error: `syslog` function not inlinable
I am trying to bulid glibc from source at Ubuntu 18.04
GLIBC_VERSION="2.28"
GLIBC_DIR="$HOME/.local/src/opt/glibc-$GLIBC_VERSION"
GLIBC_TAR="$HOME/.local/src/opt/glibc-$...
0
votes
3
answers
61
views
Make: rule with two lists for targets and prerequisites
I am building a C library with external dependencies that I have to compile separately. E.g. I have
./ext/lib1/src/lib1.c
./ext/lib2/lib2.c
./ext/lib3/xyz/whatever.c
Which I want to compile into
./...
0
votes
1
answer
107
views
python pip compile is rending absolute path of requirements.in file
Python version: 3.12
pip-tools: 7.4.1
Project structure
/projectdir
------requirements/
------------requirements.in
------------requirements.txt
------------requirements-dev.in
------------...
0
votes
1
answer
59
views
SECONDEXPANSION and implicit rule recursion don't work
I typed make aaa.zzz after touch a b c.
I got nothing.
No stdout, no stderr.
Why?
GNU Make 3.82
It doesn't work.
.SECONDEXPANSION:
%.xxx: $$(shell echo a b c)
echo in xxx
%.zzz: %.xxx $$(shell ...
0
votes
0
answers
79
views
Add a /etc/sysctl.d/50-foo.conf to a kernel image build
I'm building a kernel image, with my own kernel module being added to the build, using my own Makefile and Kbuild scripts. The final complete kernel image gets flashed to a ROM. I have a few kernel ...
1
vote
1
answer
79
views
How to use shell-assignment operator with gmake?
I'm trying to keep my Makefile compatible between BSD and GNU make. It is not particularly complicated, but there is one spot, where I'd very much like to assign a value based on the output of a ...
3
votes
1
answer
200
views
Using GNU Make to compile all .c files in a subdirectory
I'm working on a project in C, and I'm using GNU Make to handle compiling everything, but I'm having a lot of trouble trying to compile every .c file in my project, including ones in subdirectories. ...
3
votes
2
answers
240
views
How to compile Linux Kernel module from several files?
I am having an issue with my module compilation written in C for Kernel and I even can't find documentation which would be helpful.
My issue looks like following. There are several files written in C ...
0
votes
0
answers
45
views
Makefile clean recipe not working on Windows
I have a small issue where make or the command prompt reports an error when I invoke make clean. This is my Makefile:
CC = gcc
DEPS = $(wildcard *.c *.h)
SRCS = $(wildcard *.c)
TARGET = mforth.exe
# ...
0
votes
3
answers
51
views
makefile clean target over ifdefs blocking makefile execution
Makefile MWE snippet:
ifdef REVISION
$(info "Revision is ${REVISION}")
else
$(error "REVISION missing, can't compile code")
endif
all:
echo "Hello"
.PHONY: ...
0
votes
0
answers
49
views
undefined reference to `DirectInput8Create' [duplicate]
please help.
I am learning the DirectInput API, but I am having trouble calling a single function DirectInput8Create() in my MSYS2-MINGW64 environment. I verified dinput.dll is in the bin/ directory......
1
vote
1
answer
132
views
How makefile handle the ungiven file paths?
In my training course, makefile example is written.
The full makefile code is below can be used to get exe file successfully.
TARGET: exe
exe: main.o mylibmath.a
gcc main.o -o exe -L . mylibmath....
1
vote
2
answers
87
views
Curl command executed concurrently in makefile
I am trying to download two files, A and B, using curl in a Makefile.
The download of A has to be finished to download B.
When I am executing the following command in zsh, the order is respected (B is ...
1
vote
2
answers
60
views
Make assignment commands are not working as expected
A = $(shell date)
B := $(shell date)
all:
@echo $(A)
sleep 2s;
@echo $(A)
sleep 2s;
@echo $(A)
@echo $(B)
As per the documentation that B is evaluated immediately when make is run and A ...
0
votes
0
answers
60
views
Auto-sync of config file in linux kernel compilation produces wrong configuration
I need to load the symbols into gdb so that I can debug the boot loader. I am on an ARM architecture compiling for x86. I have tried this and the symbols do not load. This is the process I follow.
...
0
votes
1
answer
53
views
How to handle directory path in Makefiles
I have the below project structure which consists of multiple submodule Makefiles along with main Makefile. The Makefiles make use of common functions/rules which are placed inside common/...
0
votes
0
answers
31
views
How to give option "/FAcs Machine, source, and assembly code; .cod" through makefile
I have a setup wherein I am building the solution through makefile rather than Visual Studio IDE, I need to give "/FAcs Machine, source, and assembly code; .cod" option by providing as an ...
0
votes
2
answers
76
views
GNU Make variable values with special characters
I have an issue in a Makefile where I'm trying to read a value in from an AWS secret manager secret into a Make variable as follows:
$(eval SECRET_NAME := some/aws/secretname)
$(eval SECRET_FILE := ....