From bfb42102be5c178ce08b7861c11ee2694004413a Mon Sep 17 00:00:00 2001 From: John Hodge Date: Wed, 6 Mar 2013 11:17:01 +0800 Subject: [PATCH] Usermode - Hacking up native compilation target --- BuildConf/native/Makefile.cfg | 2 ++ Usermode/Applications/Makefile.cfg | 20 +++++++++++++++----- Usermode/Applications/Makefile.tpl | 27 ++++++++++++++++++--------- Usermode/Applications/init_src/main.c | 4 ++-- Usermode/Libraries/Makefile.tpl | 27 ++++++++++++++++----------- 5 files changed, 53 insertions(+), 27 deletions(-) diff --git a/BuildConf/native/Makefile.cfg b/BuildConf/native/Makefile.cfg index 389a7388..aa4cd00c 100644 --- a/BuildConf/native/Makefile.cfg +++ b/BuildConf/native/Makefile.cfg @@ -6,6 +6,8 @@ ARCHDIR := native LD ?= $(CC) -print-prog-name=ld +AS = $(CC) -c +ASSUFFIX = S OBJDUMP := objdump -S diff --git a/Usermode/Applications/Makefile.cfg b/Usermode/Applications/Makefile.cfg index 5314aea8..6b80a5e0 100644 --- a/Usermode/Applications/Makefile.cfg +++ b/Usermode/Applications/Makefile.cfg @@ -4,15 +4,25 @@ # Include Usermode Makefile.cfg include $(dir $(lastword $(MAKEFILE_LIST)))../Makefile.cfg +ifeq ($(ARCHDIR),native) ASFLAGS = -felf -CPPFLAGS = -ffreestanding -I$(ACESSUSERDIR)/include/ -DARCHDIR_is_$(ARCHDIR) -CPPFLAGS += $(addprefix -I,$(wildcard $(ACESSUSERDIR)Libraries/*/include_exp/)) -CFLAGS = -fno-stack-protector $(CPPFLAGS) +CPPFLAGS = -Wall +CFLAGS = $(CPPFLAGS) +LDFLAGS = -L $(OUTPUTDIR)Libs -lacess-native +LIBGCC_PATH = $(ACESSDIR)/AcessNative/symbol_renames.ld +else +ASFLAGS = -felf +CPPFLAGS = -ffreestanding +CFLAGS = -fno-stack-protector -fno-builtin $(CPPFLAGS) LDFLAGS = -T $(OUTPUTDIR)Libs/acess.ld -rpath-link $(OUTPUTDIR)Libs -L $(OUTPUTDIR)Libs -I /Acess/Libs/ld-acess.so -lld-acess -lc $(OUTPUTDIR)Libs/crtbegin.o $(OUTPUTDIR)Libs/crtend.o -lposix LIBGCC_PATH = $(shell $(CC) -print-libgcc-file-name) +endif + +CPPFLAGS += $(addprefix -I,$(wildcard $(ACESSUSERDIR)Libraries/*/include_exp/)) +CPPFLAGS += -I$(ACESSUSERDIR)/include/ -DARCHDIR_is_$(ARCHDIR) + # Extra-verbose errors! -#CFLAGS += -Wall -Wextra -Wwrite-strings -Wshadow -Wswitch-default -Wswitch-enum -Wstrict-overflow=5 -Wfloat-equal -Wundef -Wmissing-declarations -Wlogical-op -# -Wformat=2 -Winit-self -Wmissing-include-dirs -Wswitch-default -Wswitch-enum -Wsync-nand -Wunused -Wstrict-overflow=5 -Wfloat-equal -Wundef -Wno-endif-labels -Wshadow -Wunsafe-loop-optimizations -Wbad-function-cast -Wc++-compat -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion -Wlogical-op -Waggregate-return -Wstrict-prototypes -Wold-style-definition -Wmissing-declarations -Wnormalized=nfc -Wpacked -Wpadded -Wredundant-decls -Wnested-externs -Winline -Winvalid-pch -Wdisabled-optimization -Woverlength-strings +#CFLAGS += -Wall -Wextra -Wwrite-strings -Wshadow -Wswitch-default -Wswitch-enum -Wstrict-overflow=5 -Wfloat-equal -Wundef -Wmissing-declarations -Wlogical-op -Wformat=2 -Winit-self -Wmissing-include-dirs -Wswitch-default -Wswitch-enum -Wsync-nand -Wunused -Wstrict-overflow=5 -Wfloat-equal -Wundef -Wno-endif-labels -Wshadow -Wunsafe-loop-optimizations -Wbad-function-cast -Wc++-compat -Wcast-qual -Wcast-align -Wwrite-strings -Wconversion -Wlogical-op -Waggregate-return -Wstrict-prototypes -Wold-style-definition -Wmissing-declarations -Wnormalized=nfc -Wpacked -Wpadded -Wredundant-decls -Wnested-externs -Winline -Winvalid-pch -Wdisabled-optimization -Woverlength-strings DIR = Bin diff --git a/Usermode/Applications/Makefile.tpl b/Usermode/Applications/Makefile.tpl index 5bf963b7..f42e6601 100644 --- a/Usermode/Applications/Makefile.tpl +++ b/Usermode/Applications/Makefile.tpl @@ -3,7 +3,7 @@ # - Application Template Makefile # -CFLAGS += -Wall -Werror -fno-builtin -fno-stack-protector -g +CFLAGS += -g LDFLAGS += -g _BIN := $(OUTPUTDIR)$(DIR)/$(BIN) @@ -12,6 +12,12 @@ _OBJPREFIX := obj-$(ARCH)/ _LIBS := $(filter -l%,$(LDFLAGS)) _LIBS := $(patsubst -l%,$(OUTPUTDIR)Libs/lib%.so,$(_LIBS)) +ifeq ($(VERBOSE),) +V := @ +else +V := +endif + OBJ := $(addprefix $(_OBJPREFIX),$(OBJ)) DEPFILES := $(OBJ:%.o=%.dep) @@ -34,20 +40,21 @@ install: $(_BIN) $(_BIN): $(OUTPUTDIR)Libs/acess.ld $(OUTPUTDIR)Libs/crt0.o $(_LIBS) $(OBJ) @mkdir -p $(dir $(_BIN)) @echo [LD] -o $@ -ifneq ($(_DBGMAKEFILE),) - $(LD) -g $(LDFLAGS) -o $@ $(OBJ) -Map $(_OBJPREFIX)Map.txt $(LIBGCC_PATH) -else - @$(LD) -g $(LDFLAGS) -o $@ $(OBJ) -Map $(_OBJPREFIX)Map.txt $(LIBGCC_PATH) -endif - @$(DISASM) $(_BIN) > $(_OBJPREFIX)$(BIN).dsm +#ifeq ($(ARCHDIR),native) +# $V$(LD) -g -o $@.tmp.o -r $(OBJ) $(LIBGCC_PATH) +# $V$(LD) -g $(LDFLAGS) -o $@ $@.tmp.o -Map $(_OBJPREFIX)Map.txt +#else + $V$(LD) -g $(LDFLAGS) -o $@ $(OBJ) -Map $(_OBJPREFIX)Map.txt $(LIBGCC_PATH) +#endif + $V$(DISASM) $(_BIN) > $(_OBJPREFIX)$(BIN).dsm $(OBJ): $(_OBJPREFIX)%.o: %.c @echo [CC] -o $@ ifneq ($(_OBJPREFIX),) @mkdir -p $(dir $@) endif - @$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ - @$(CC) -M -MP -MT $@ $(CPPFLAGS) $< -o $(_OBJPREFIX)$*.dep + $V$(CC) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ + $V$(CC) -M -MP -MT $@ $(CPPFLAGS) $< -o $(_OBJPREFIX)$*.dep $(OUTPUTDIR)Libs/libld-acess.so: @make -C $(ACESSDIR)/Usermode/Libraries/ld-acess.so_src/ @@ -55,3 +62,5 @@ $(OUTPUTDIR)Libs/%: @make -C $(ACESSDIR)/Usermode/Libraries/$*_src/ -include $(DEPFILES) + +# vim: ft=make diff --git a/Usermode/Applications/init_src/main.c b/Usermode/Applications/init_src/main.c index 0dbbff14..3d960282 100644 --- a/Usermode/Applications/init_src/main.c +++ b/Usermode/Applications/init_src/main.c @@ -216,7 +216,7 @@ int ProcessInittab(const char *Path) line_num ++; int rv; - if( (rv = fscanf(fp, "%64s%*[ \t]", &cmdbuf)) != 1 ) { + if( (rv = fscanf(fp, "%64s%*[ \t]", cmdbuf)) != 1 ) { _SysDebug("fscanf rv %i != exp 1", rv); break; } @@ -258,7 +258,7 @@ int ProcessInittab(const char *Path) // stty [78][NOE][012][bB] char path_seg[32+1]; char modespec[4+6+1]; - if( fscanf(fp, "%32s %6s ", &path_seg, &modespec) != 2 ) { + if( fscanf(fp, "%32s %6s ", path_seg, modespec) != 2 ) { goto lineError; } char **command = ReadCommand(fp); diff --git a/Usermode/Libraries/Makefile.tpl b/Usermode/Libraries/Makefile.tpl index bc5edf8e..77495217 100644 --- a/Usermode/Libraries/Makefile.tpl +++ b/Usermode/Libraries/Makefile.tpl @@ -15,6 +15,12 @@ OBJ := $(addprefix $(_OBJPREFIX),$(OBJ)) UTESTS := $(patsubst TEST_%.c,%,$(wildcard TEST_*.c)) DEPFILES := $(addsuffix .dep,$(OBJ)) +ifeq ($(VERBOSE),1) +V := +else +V := @ +endif + .PHONY: all clean install postbuild all: _libs $(_BIN) $(_XBIN) @@ -49,10 +55,10 @@ clean: install: all @echo [xCP] $(DISTROOT)/Libs/$(BIN) - @$(xMKDIR) $(DISTROOT)/Libs; true - @$(STRIP) $(_BIN) -o $(_BIN)_ - @$(xCP) $(_BIN)_ $(DISTROOT)/Libs/$(BIN) - @$(RM) $(_BIN)_ + $V$(xMKDIR) $(DISTROOT)/Libs; true + $V$(STRIP) $(_BIN) -o $(_BIN)_ + $V$(xCP) $(_BIN)_ $(DISTROOT)/Libs/$(BIN) + $V$(RM) $(_BIN)_ ifneq ($(_XBIN),) $(xCP) $(_XBIN) $(DISTROOT)/Libs/ endif @@ -63,23 +69,22 @@ endif $(_BIN): $(OBJ) $(_LIBS) @mkdir -p $(dir $(_BIN)) @echo [LD] -o $(BIN) $(OBJ) - @$(LD) $(LDFLAGS) -o $(_BIN) $(OBJ) $(shell $(CC) -print-libgcc-file-name) - @$(DISASM) -D -S $(_BIN) > $(_OBJPREFIX)$(BIN).dsm + $V$(LD) $(LDFLAGS) -o $(_BIN) $(OBJ) $(shell $(CC) -print-libgcc-file-name) + $V$(DISASM) -D -S $(_BIN) > $(_OBJPREFIX)$(BIN).dsm $(_OBJPREFIX)%.o: %.c @echo [CC] -o $@ @mkdir -p $(dir $@) - @$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $< - @$(CC) -M -MP -MT $@ $(CPPFLAGS) $< -o $@.dep + $V$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $< -MMD -MP -MT $@ -MF $@.dep $(_OBJPREFIX)%.ao: %.$(ASSUFFIX) @echo [AS] -o $@ @mkdir -p $(dir $@) - @$(AS) $(ASFLAGS) -o $@ $< + $V$(AS) $(ASFLAGS) -o $@ $< ifeq ($(ASSUFFIX),S) - @$(AS) $(ASFLAGS) -o $@.dep $< -M + $V$(AS) $(ASFLAGS) -o $@.dep $< -M else - @$(AS) $(ASFLAGS) -o $@ $< -M > $@.dep + $V$(AS) $(ASFLAGS) -o $@ $< -M > $@.dep endif #$(OUTPUTDIR)Libs/libld-acess.so: -- 2.20.1