I see how you get the object files ( .o ) in the root folder, but I donβt know how you get them in the assembly folder.
Letβs take it in stages. First we provide the object files with their own rules:
It is effective but rude. Object files now go to build/ , but there is a lot of redundancy, without dependency processing. Therefore, we have added the necessary prerequisites and suppose that you are using GNUMake (what you need), we can use Automatic variables (and I will shorten the -I line for reading only):
build/file1.o: src/file1.c gcc -g -fPIC -c $< -I... -o $@ build/file2.o: src/file2.c gcc -g -fPIC -c $< -I... -o $@ debug_build: $(OBJS) gcc -shared -o bin/$(SHLIB).so $^ -lm -lpq -lmylib_core
Note that the commands in the object rules now exactly match. Thus, we can combine these two rules in several ways. The easiest way:
build/file1.o: src/file1.c build/file2.o: src/file2.c build/file1.o build/file2.o: gcc -g -fPIC -c $< -I... -o $@
Now one more or two small tricks, and we will be glad:
build/file1.o: src/file1.c build/file2.o: src/file2.c build/file1.o build/file2.o: gcc -g -fPIC -c $< -I`pg_config --includedir` -I`pg_config --includedir-server` -I/some/required/path/include -Iinclude -o $@ debug_build: $(OBJS) gcc -shared -o bin/$(SHLIB).so $^ -lm -lpq -lmylib_core
There are more complicated tricks, but this time it should be a lot.
source share