2 TARGET := $(shell gcc -v 2>&1 | grep Targ | awk '{print $$2}')
4 include ../../Makefile.Version.cfg
5 -include Makefile.BuildNum
11 KERNEL_SRC = ../../KernelLand/Kernel/
12 MODULE_SRC = ../../KernelLand/Modules/
15 # Kernel Sources (compiled with -ffreestanding)
17 K_OBJ += vfs/acls.o vfs/io.o vfs/fs/devfs.o
20 # Local kernel soruces (same as above, but located in same directory as Makefile)
21 L_OBJ = vfs_shim.o nic.o tcpclient.o tcpserver.o helpers.o
22 # Native Sources (compiled as usual)
26 CFLAGS := -Wall -std=gnu99 -g -Werror -O0 -pthread
27 CPPFLAGS := -I include/ -I ../nativelib/include
28 K_CPPFLAGS := -I $(KERNEL_SRC)include -I $(MODULE_SRC)
29 LDFLAGS += -Wl,--defsym,__buildnum=$(BUILD_NUM) -g -L .. -lpthread -lnativelib
31 BUILDINFO_OBJ := obj/$(TARGET)/buildinfo.o
32 BUILDINFO_SRC := $(BUILDINFO_OBJ:%.o=%.c)
34 # ====================
35 # == Start of Magic ==
36 # ====================
38 $(foreach module,$(MODULES), $(eval include $(MODULE_SRC)$(module)/Makefile) $(eval M_OBJ += $(addprefix $(module)/,$(OBJ))) )
40 # -- Apply Prefixes to object paths
41 OBJ_PREFIX = obj/$(TARGET)/
42 K_OBJ_PREFIX = $(OBJ_PREFIX)_Kernel/
43 M_OBJ_PREFIX = $(OBJ_PREFIX)_Module/
44 K_OBJ := $(addprefix $(K_OBJ_PREFIX),$(K_OBJ))
45 M_OBJ := $(addprefix $(M_OBJ_PREFIX),$(M_OBJ))
46 L_OBJ := $(addprefix $(OBJ_PREFIX),$(L_OBJ))
47 N_OBJ := $(addprefix $(OBJ_PREFIX),$(N_OBJ))
49 OBJ := $(N_OBJ) $(L_OBJ) $(K_OBJ) $(M_OBJ) $(BUILDINFO_OBJ)
51 DEPFILES = $(filter %.o,$(OBJ))
52 DEPFILES := $(DEPFILES:%=%.dep)
60 $(RM) -f $(OBJ) $(DEPFILES) $(BIN)
62 $(BIN): $(OBJ) ../libnativelib.a
63 @echo [CC Link] -o $(BIN)
64 @$(CC) -o $(BIN) $(OBJ) $(LDFLAGS)
65 @echo BUILD_NUM = $$(( $(BUILD_NUM) + 1 )) > Makefile.BuildNum
66 @objdump -S $(BIN) > $(BIN).dsm
68 $(M_OBJ): $(M_OBJ_PREFIX)%.o: $(MODULE_SRC)%.c
70 @echo [CC Module] -o $@
71 @$(CC) -c $< -o $@ -ffreestanding $(CFLAGS) $(CPPFLAGS) $(K_CPPFLAGS) -MMD -MP -MF
[email protected]
73 $(K_OBJ): $(K_OBJ_PREFIX)%.o: $(KERNEL_SRC)%.c
75 @echo [CC Kernel] -o $@
76 @$(CC) -c $< -o $@ -ffreestanding $(CFLAGS) $(CPPFLAGS) $(K_CPPFLAGS) -MMD -MP -MF
[email protected]
78 $(L_OBJ): $(OBJ_PREFIX)%.o: %.c
80 @echo [CC Local] -o $@
81 @$(CC) -c $< -o $@ -ffreestanding $(CFLAGS) $(CPPFLAGS) $(K_CPPFLAGS) -MMD -MP -MF
[email protected]
83 $(N_OBJ): $(OBJ_PREFIX)%.o: %.c
85 @echo [CC Native] -o $@
88 # Hacky buildinfo.c file
89 $(BUILDINFO_SRC): $(filter-out $(BUILDINFO_OBJ), $(OBJ)) Makefile
91 @echo "const char gsKernelVersion[] = \"$(ACESS_VERSION)\";" >> $@
92 @echo "const char gsGitHash[] = \""`git log -n 1 | head -n 1 | awk '{print $$2}'`"\";" >> $@
93 @echo "const int giBuildNumber = $(BUILD_NUM);" >> $@
94 @echo "const char gsBuildInfo[] = \"Acess2 DiskTool v$(ACESS_VERSION)\";" >> $@
95 $(BUILDINFO_OBJ): $(BUILDINFO_SRC)
97 @$(CC) -o $@ -c $< $(CFLAGS) $(CPPFLAGS)