-include $(dir $(lastword $(MAKEFILE_LIST)))../Makefile.cfg
-CPPFLAGS := -I$(ACESSDIR)/Kernel/include -I$(ACESSDIR)/Kernel/arch/$(ARCHDIR)/include -DARCH=$(ARCH) $(_CPPFLAGS)
-CFLAGS := -Wall -Werror -fno-stack-protector -g -O3 -fno-builtin
+LIBINCLUDES := $(addprefix -I$(ACESSDIR)/Modules/,$(DEPS))
+LIBINCLUDES := $(addsuffix /include,$(LIBINCLUDES))
+
+CPPFLAGS := -I$(ACESSDIR)/Kernel/include -I$(ACESSDIR)/Kernel/arch/$(ARCHDIR)/include
+CPPFLAGS += -DARCH=$(ARCH) -DARCH_is_$(ARCH) -DARCHDIR_is_$(ARCHDIR)
+CPPFLAGS += $(_CPPFLAGS)
+CPPFLAGS += $(LIBINCLUDES)
+CFLAGS := -std=gnu99 -Wall -Werror -fno-stack-protector -g -O3
ifneq ($(CATEGORY),)
FULLNAME := $(CATEGORY)_$(NAME)
BIN := ../$(NAME).xo.$(ARCH)
endif
-OBJ := $(addsuffix .$(_SUFFIX),$(OBJ))
+OBJ := $(addprefix obj-$(_SUFFIX)/,$(OBJ))
+#OBJ := $(addsuffix .$(_SUFFIX),$(OBJ))
-DEPFILES := $(filter %.o.$(_SUFFIX),$(OBJ))
-DEPFILES := $(DEPFILES:%.o.$(_SUFFIX)=%.d.$(ARCH))
+DEPFILES := $(filter %.o,$(OBJ))
+DEPFILES := $(DEPFILES:%.o=%.d)
.PHONY: all clean
clean:
$(RM) $(BIN) $(BIN).dsm $(KOBJ) $(OBJ) $(DEPFILES) $(EXTRA)
+ $(RM) -r obj-$(_SUFFIX)
install: $(BIN)
ifneq ($(BUILDTYPE),static)
- $(xMKDIR) $(DISTROOT)/Modules/$(ARCH)
+ @$(xMKDIR) $(DISTROOT)/Modules/$(ARCH); true
$(xCP) $(BIN) $(DISTROOT)/Modules/$(ARCH)/$(NAME).kmd
else
endif
+
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) -defsym=DriverInfo=_DriverInfo_$(FULLNAME)
+ @$(LD) --allow-shlib-undefined -shared -nostdlib -o $@ $(OBJ) -defsym=DriverInfo=_DriverInfo_$(FULLNAME) $(LDFLAGS)
@$(DISASM) $(BIN) > $(BIN).dsm
else
$(BIN): %.xo.$(ARCH): $(OBJ)
@echo --- $(LD) -o $@
- @$(LD) -r -o $@ $(OBJ)
+ @$(LD) -r -o $@ $(OBJ) $(LDFLAGS)
endif
-%.o.$(_SUFFIX): %.c Makefile ../Makefile.tpl $(CFGFILES)
+obj-$(_SUFFIX)/%.o: %.c Makefile $(CFGFILES)
@echo --- $(CC) -o $@
+ @mkdir -p $(dir $@)
@$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<
- @$(CC) -M $(CPPFLAGS) -MT $@ -o $*.d.$(ARCH) $<
+ @$(CC) -M $(CPPFLAGS) -MT $@ -o obj-$(_SUFFIX)/$*.d $<
-include $(DEPFILES)