_CPPFLAGS := $(CPPFLAGS)
-CFGFILES :=
-CFGFILES += $(shell test -f ../../../Makefile.cfg && echo ../../../Makefile.cfg)
-CFGFILES += $(shell test -f ../../Makefile.cfg && echo ../../Makefile.cfg)
-CFGFILES += $(shell test -f ../Makefile.cfg && echo ../Makefile.cfg)
-CFGFILES += $(shell test -f Makefile.cfg && echo Makefile.cfg)
--include $(CFGFILES)
+-include $(dir $(lastword $(MAKEFILE_LIST)))../Makefile.cfg
CPPFLAGS := -I$(ACESSDIR)/Kernel/include -I$(ACESSDIR)/Kernel/arch/$(ARCHDIR)/include -DARCH=$(ARCH) $(_CPPFLAGS)
-CFLAGS := $(KERNEL_CFLAGS) -Wall -Werror -fno-stack-protector $(CPPFLAGS) -O3 -fno-builtin
+CFLAGS := -Wall -Werror -fno-stack-protector -g -O3 -fno-builtin
-ifeq ($(BUILDTYPE),dynamic)
+ifneq ($(CATEGORY),)
+ FULLNAME := $(CATEGORY)_$(NAME)
+else
+ FULLNAME := $(NAME)
+endif
+
+CPPFLAGS += -D_MODULE_NAME_=\"$(FULLNAME)\"
+
+ifneq ($(BUILDTYPE),static)
_SUFFIX := dyn_$(ARCH)
- ifneq ($(CATEGORY),)
- BIN := ../$(CATEGORY)_$(NAME).kmd.$(ARCH)
- else
- BIN := ../$(NAME).kmd.$(ARCH)
- endif
- CFLAGS += -fPIC
+ BIN := ../$(FULLNAME).kmd.$(ARCH)
+ CFLAGS += $(DYNMOD_CFLAGS) -fPIC
else
_SUFFIX := st_$(ARCH)
+ CFLAGS += $(KERNEL_CFLAGS)
BIN := ../$(NAME).xo.$(ARCH)
endif
all: $(BIN)
clean:
- $(RM) $(BIN) $(BIN).dsm $(KOBJ) $(OBJ) $(DEPFILES)
+ $(RM) $(BIN) $(BIN).dsm $(KOBJ) $(OBJ) $(DEPFILES) $(EXTRA)
install: $(BIN)
- $(xCP) $(BIN) $(DISTROOT)/Modules/$(NAME).kmd
+ifneq ($(BUILDTYPE),static)
+ $(xMKDIR) $(DISTROOT)/Modules/$(ARCH)
+ $(xCP) $(BIN) $(DISTROOT)/Modules/$(ARCH)/$(NAME).kmd
+else
+endif
-ifeq ($(BUILDTYPE),dynamic)
+ifneq ($(BUILDTYPE),static)
$(BIN): %.kmd.$(ARCH): $(OBJ)
@echo --- $(LD) -o $@
-# $(LD) -T $(ACESSDIR)/Modules/link.ld --allow-shlib-undefined -shared -nostdlib -o $@ $(OBJ)
- @$(LD) --allow-shlib-undefined -shared -nostdlib -o $@ $(OBJ)
- @$(OBJDUMP) -d $(BIN) > $(BIN).dsm
+# @$(LD) -T $(ACESSDIR)/Modules/link.ld --allow-shlib-undefined -shared -nostdlib -o $@ $(OBJ)
+ @$(LD) --allow-shlib-undefined -shared -nostdlib -o $@ $(OBJ) -defsym=DriverInfo=_DriverInfo_$(FULLNAME)
+ @$(DISASM) $(BIN) > $(BIN).dsm
else
$(BIN): %.xo.$(ARCH): $(OBJ)
@echo --- $(LD) -o $@
%.o.$(_SUFFIX): %.c Makefile ../Makefile.tpl $(CFGFILES)
@echo --- $(CC) -o $@
- @$(CC) $(CFLAGS) -o $@ -c $<
+ @$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<
@$(CC) -M $(CPPFLAGS) -MT $@ -o $*.d.$(ARCH) $<
-include $(DEPFILES)