So I am writing some assembly code which is then compiled by a Makefile:
# linking
main: main.o #
ld -o build/main build/main.o -melf_i386
# compiling
main.o: main.s #
as -o build/main.o main.s --32
I had to add build directory, cause I often push the code to my GitHub repository, and its kinda hard to .gitignore
the linux executables. Now I know, that I can execute bash commands in Makefile. F.e I tested something like bash -c "pwd"
, and yes, it printed my current working directory. What I wanted to actually do was to jump to build directory right after the compilation. So I wrote my Makefile like this:
# linking
main: main.o #
ld -o build/main build/main.o -melf_i386
bash -c "cd ~/Desktop/asm/build"
# compiling
main.o: main.s #
as -o build/main.o main.s --32
The output was:
[frynio@manjaro asm]$ make
as -o build/main.o main.s --32
ld -o build/main build/main.o -melf_i386
bash -c "cd ~/Desktop/asm/build"
[frynio@manjaro asm]
So as you can see it didnt change the directory (tried with just a relative build
path, doesn't work as well). How can I make it work?