- Jul 23, 2006
- 3,934
- 0
- 76
I'm having issues coaxing my makefile into doing what I need. I have a source tree that looks something like:
kern/
| -> .c Files
arch/x86
| -> .c Files
| -> .S Files
Then I have basic pattern rules like:
build/%.o : %.c
The first thing that my makefile does is symlink arch/$(ARCH) to kern/arch, and my platform-specific object-file dependencies are listed like in a variale like "build/arch/somefile.o", and the symlink is created by another make target. This method works file for a single job, however if I try to run with "make -j", then the any files in "build/arch/*" don't get compiled on the first try, and the linker will fail for one of the later targets since it doesn't have all the .o files it needs. My guess is that make is sending a thread off to calculate what the list of .c and .S files are that go to my pattern rules while another thread is creating the symlinks, however the pattern thread is resolving before the symlinks are created.
I was thinking of using a static pattern rule like:
$(KOBJS): build/%.o : %.c
However this doesn't behave correctly because if any .S files will cause problems since it will try to find .c versions of .S files and vice versa.
kern/
| -> .c Files
arch/x86
| -> .c Files
| -> .S Files
Then I have basic pattern rules like:
build/%.o : %.c
The first thing that my makefile does is symlink arch/$(ARCH) to kern/arch, and my platform-specific object-file dependencies are listed like in a variale like "build/arch/somefile.o", and the symlink is created by another make target. This method works file for a single job, however if I try to run with "make -j", then the any files in "build/arch/*" don't get compiled on the first try, and the linker will fail for one of the later targets since it doesn't have all the .o files it needs. My guess is that make is sending a thread off to calculate what the list of .c and .S files are that go to my pattern rules while another thread is creating the symlinks, however the pattern thread is resolving before the symlinks are created.
I was thinking of using a static pattern rule like:
$(KOBJS): build/%.o : %.c
However this doesn't behave correctly because if any .S files will cause problems since it will try to find .c versions of .S files and vice versa.