2 # Acess2 Module/Driver Templater Makefile
5 _CPPFLAGS := $(CPPFLAGS)
7 -include $(dir $(lastword $(MAKEFILE_LIST)))../Makefile.cfg
9 LIBINCLUDES := $(addprefix -I$(ACESSDIR)/Modules/,$(DEPS))
10 LIBINCLUDES := $(addsuffix /include,$(LIBINCLUDES))
12 CPPFLAGS := -I$(ACESSDIR)/Kernel/include -I$(ACESSDIR)/Kernel/arch/$(ARCHDIR)/include
13 CPPFLAGS += -DARCH=$(ARCH) -DARCH_is_$(ARCH) -DARCHDIR_is_$(ARCHDIR)
14 CPPFLAGS += $(_CPPFLAGS)
15 CPPFLAGS += $(LIBINCLUDES)
16 CFLAGS := -std=gnu99 -Wall -Werror -fno-stack-protector -g -O3
19 FULLNAME := $(CATEGORY)_$(NAME)
24 CPPFLAGS += -D_MODULE_NAME_=\"$(FULLNAME)\"
26 ifneq ($(BUILDTYPE),static)
27 _SUFFIX := dyn_$(ARCH)
28 BIN := ../$(FULLNAME).kmd.$(ARCH)
29 CFLAGS += $(DYNMOD_CFLAGS) -fPIC
32 CFLAGS += $(KERNEL_CFLAGS)
33 BIN := ../$(NAME).xo.$(ARCH)
36 OBJ := $(addprefix obj-$(_SUFFIX)/,$(OBJ))
37 #OBJ := $(addsuffix .$(_SUFFIX),$(OBJ))
39 DEPFILES := $(filter %.o,$(OBJ))
40 DEPFILES := $(DEPFILES:%.o=%.d)
47 $(RM) $(BIN) $(BIN).dsm $(KOBJ) $(OBJ) $(DEPFILES) $(EXTRA)
48 $(RM) -r obj-$(_SUFFIX)
51 ifneq ($(BUILDTYPE),static)
52 @$(xMKDIR) $(DISTROOT)/Modules/$(ARCH); true
53 $(xCP) $(BIN) $(DISTROOT)/Modules/$(ARCH)/$(NAME).kmd
58 ifneq ($(BUILDTYPE),static)
59 $(BIN): %.kmd.$(ARCH): $(OBJ)
61 @$(LD) --allow-shlib-undefined -shared -nostdlib -o $@ $(OBJ) -defsym=DriverInfo=_DriverInfo_$(FULLNAME)
62 @$(DISASM) $(BIN) > $(BIN).dsm
64 $(BIN): %.xo.$(ARCH): $(OBJ)
66 @$(LD) -r -o $@ $(OBJ)
69 obj-$(_SUFFIX)/%.o: %.c Makefile $(CFGFILES)
72 @$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $<
73 @$(CC) -M $(CPPFLAGS) -MT $@ -o obj-$(_SUFFIX)/$*.d $<