makefile trouble

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
phoenixifrewingz
Posts: 2
Joined: Tue Sep 22, 2020 4:07 pm

makefile trouble

Post by phoenixifrewingz »

i've tried everything of my know how of Gnu make but no matter what i do the rule exists but make dose not seem to recognize it i don't know why?
problem make files are below:
MAKECOMMON

Code: Select all

MAKEFILE_PATH := $(abspath $(lastword $(MAKEFILE_LIST)))
BASE_DIR := $(patsubst %/,%,$(dir $(MAKEFILE_PATH)))
BUILD_DIR := build
CXX = i686-linux-gnu-g++-10
CC  = i686-linux-gnu-gcc-10
FLAGS = -g -lgcc -MMD -MP -Wextra -Wall -Wundef -Wcast-qual -Wwrite-strings -Wimplicit-fallthrough -Wno-expansion-to-defined -Os -fno-exceptions -fno-rtti -std=c++2a -Wno-sized-deallocation -fno-sized-deallocation -nostdlib -nostdinc -nostdinc++ -ffreestanding -nostartfiles -DSANITIZE_PTRS -DDEBUG

INCLUDE_FLAGS = \
    -I$(BASE_DIR) \
    -I$(BASE_DIR)/libs \
    -I$(BASE_DIR)/libs/CLib

LDFLAGS = \
    -Wl,-T linker.ld \
    -L$(BASE_DIR)/Libraries/CLib \
    -g -ffreestanding -nostdlib -nostartfiles -no-pie

$(BUILD_DIR)/%.s.o: %.s
	$(CXX) -g -MD -no-pie -lgcc -nostartfiles -c $< -o $@

$(BUILD_DIR)/%.cpp.o: %.cpp
	@echo "CXX $<"; $(CXX) -MD -c $< -o $@ $(FLAGS) $(INCLUDE_FLAGS)

$(BUILD_DIR)/%.c.o: %.c
	@echo "CXX $<"; $(CC) -MD -c $< -o $@ $(FLAGS) $(INCLUDE_FLAGS)
CLibMake

Code: Select all

include $(BASE_DIR)/MAKECOMMON
CLIB = CLib

CLIB_SOURCES = \
    stdio/prinf.c


CLIB_OBJS = $(addprefix $(BUILD_DIR)/$(CLIB)/,$(CLIB_SOURCES:.c=.c.o))

$(CLIB): $(CLIB_OBJS)
	@echo "CLib linked";$(CXX) -o $(BUILD_DIR)/isodir/boot/clib.so $(CLIB_OBJS) $(LDFLAGS)
Full Log

Code: Select all

hecking if target is up-to-date: make -q -f MakeFile Debug
Running command: make -f MakeFile Debug
kernel/Kboot.cpp: In function ‘void kernel_main(uint32_t, multiboot_info_t*)’:
kernel/Kboot.cpp:56:31: warning: unused parameter ‘multiboot_magic’ [-Wunused-parameter]
   56 |     void kernel_main(uint32_t multiboot_magic, multiboot_info_t *multiboot)
      |                      ~~~~~~~~~^~~~~~~~~~~~~~~
kernel/Kboot.cpp:56:66: warning: unused parameter ‘multiboot’ [-Wunused-parameter]
   56 |     void kernel_main(uint32_t multiboot_magic, multiboot_info_t *multiboot)
      |                                                ~~~~~~~~~~~~~~~~~~^~~~~~~~~
CXX kernel/Kboot.cpp
i686-linux-gnu-g++-10 -g -MD -no-pie -lgcc -nostartfiles -c kernel/boot.s -o build/kernel/boot.s.o
make: *** No rule to make target 'build/CLib/stdio/prinf.c.o', needed by 'CLib'. Stop.
Kernel linked
Process terminated with status 2 (0 minute(s), 0 second(s))
0 error(s), 2 warning(s) (0 minute(s), 0 second(s))
 
nullplan
Member
Member
Posts: 1790
Joined: Wed Aug 30, 2017 8:24 am

Re: makefile trouble

Post by nullplan »

You are telling make how to make build/%.c.o and are then requesting build/CLib/%.c.o. That will not work. Either put all files into build/ directly or write multiple build rules, one for each subdirectory.
Carpe diem!
phoenixifrewingz
Posts: 2
Joined: Tue Sep 22, 2020 4:07 pm

Re: makefile trouble

Post by phoenixifrewingz »

that makes sencse but the same rule for cpp works for the kernel and this is why i don't understand

Code: Select all

include $(BASE_DIR)/MAKECOMMON
KERNEL = kernel

KERNEL_ASSEMBLY_SOURCES = \
    boot.s

KERNEL_SOURCES = \
    Kboot.cpp


KERNEL_OBJS = $(addprefix $(BUILD_DIR)/$(KERNEL)/,$(KERNEL_SOURCES:.cpp=.cpp.o) $(KERNEL_ASSEMBLY_SOURCES:.s=.s.o))

$(KERNEL): $(KERNEL_OBJS)
	@echo "Kernel linked";$(CXX) -o $(BUILD_DIR)/isodir/boot/kernel.bin $(KERNEL_OBJS) $(LDFLAGS)
Post Reply