Okay guys this is killing me,
In my makefile, I tell it to use G++ along with some custom flags to compile, but those flags do not appear to work, they don't even appear in a command line.
Makefile:
CPP_FILES := $(wildcard source/*.cpp)
OBJ_FILES := $(patsubst %.cpp,%.o,$(CPP_FILES))
LD_FLAGS := -T linker.ld
CC_FLAGS := -ggdb -Wall -Wextra -nostdlib -fno-builtin -nostartfiles -nodefaultlibs -fno-exceptions -fno-rtti -fno-stack-protector -fleading-underscore
kernel.bin: $(OBJ_FILES) ; ld $(LD_FLAGS) -o kernel.bin boot.o $(OBJ_FILES)
source/%.o: source/%cpp ; g++ $(CC_FLAGS) -o $@ $<
P.S: LD_FLAGS work flawlessly
Makefile
Re: Makefile Lulz
Code: Select all
source/%.o: source/%cpp ; g++ $(CC_FLAGS) -o $@ $<
if things does not match any rule, the default action would be made such as invoke g++ without your custom flags.
The easiest way is to replace or insert echo checkpoints to debug, which is essential skill for general programming.
Re: Makefile Lulz
Code: Select all
source/%.o: source/%cpp ; g++ $(CC_FLAGS) -o $@ $<
Everything after the colon is the dependency. The command(s) to be executed should be on subsequent lines, starting with a tab. This is important!
Code: Select all
source/%.o: source/%.cpp
$(CXX) $(CC_FLAGS) -o $@ $<
Every good solution is obvious once you've found it.
Re: Makefile Lulz
Yeah thanks that worked, but how do I go on adding ASM code support, because this doesn't work
PROJECT_DIRS := source
CPP_FILES := $(wildcard source/*.cpp)
ASM_FILES :=$(wildcard source/*.asm)
OBJ_FILES := $(patsubst %.cpp,%.o,$(CPP_FILES))
ASM_OBJ :=$(patsubst %.asm,%.o,$(ASM_FILES))
LD_FLAGS := -T linker.ld
CC_FLAGS := -ggdb -Wall -Wextra -nostdlib -fno-builtin -nostartfiles -nodefaultlibs -fno-exceptions -fno-rtti -fno-stack-protector -fleading-underscore
kernel.bin: $(OBJ_FILES)
ld $(LD_FLAGS) -o kernel.bin $(OBJ_FILES) $(ASM_OBJ)
source/%.o: source/%.cpp
g++ $(CC_FLAGS) -o $@ $<
source/%.o: source/%.asm
nasm -f elf -o $@ $<
PROJECT_DIRS := source
CPP_FILES := $(wildcard source/*.cpp)
ASM_FILES :=$(wildcard source/*.asm)
OBJ_FILES := $(patsubst %.cpp,%.o,$(CPP_FILES))
ASM_OBJ :=$(patsubst %.asm,%.o,$(ASM_FILES))
LD_FLAGS := -T linker.ld
CC_FLAGS := -ggdb -Wall -Wextra -nostdlib -fno-builtin -nostartfiles -nodefaultlibs -fno-exceptions -fno-rtti -fno-stack-protector -fleading-underscore
kernel.bin: $(OBJ_FILES)
ld $(LD_FLAGS) -o kernel.bin $(OBJ_FILES) $(ASM_OBJ)
source/%.o: source/%.cpp
g++ $(CC_FLAGS) -o $@ $<
source/%.o: source/%.asm
nasm -f elf -o $@ $<
Re: Makefile Lulz
As a positive suggestion you should read Getting_Started, specifically Required Knowledge & Toolchain
To your question, it's quite obvious you didn't include assembly files in your definition of OBJ_FILES; or otherwise include ASM_OBJ in kernel.bin.
To your question, it's quite obvious you didn't include assembly files in your definition of OBJ_FILES; or otherwise include ASM_OBJ in kernel.bin.
Re: Makefile
Gotcha,
Well sorry guys, I had my OS compiling but the problem was that it was a bash file and everytime I added a file, I needed to make changes myself, so I looked into makefile, even though with some fail
Well sorry guys, I had my OS compiling but the problem was that it was a bash file and everytime I added a file, I needed to make changes myself, so I looked into makefile, even though with some fail
Re: Makefile
Make sure you really understand 'make'. Using a half-understood tool in a non-trivial project is an error source unto itself.
For example, your Makefile doesn't cater to changes made in header files. You change a constant in a header file, you might be in for a lengthy debug session before you realize that your object files didn't get recompiled. Might I recommend the Makefile tutorial a second time?
For example, your Makefile doesn't cater to changes made in header files. You change a constant in a header file, you might be in for a lengthy debug session before you realize that your object files didn't get recompiled. Might I recommend the Makefile tutorial a second time?
Every good solution is obvious once you've found it.