From: John Hodge Date: Sun, 9 Mar 2014 07:45:29 +0000 (+0800) Subject: Usermode - C++ support, crtbegin/crtend X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=1f733f85261667f86a083a85bc07e736b44dfbe2;p=tpg%2Facess2.git Usermode - C++ support, crtbegin/crtend --- diff --git a/Usermode/Applications/Makefile.cfg b/Usermode/Applications/Makefile.cfg index a1a0141a..ef17a140 100644 --- a/Usermode/Applications/Makefile.cfg +++ b/Usermode/Applications/Makefile.cfg @@ -25,4 +25,7 @@ LDFLAGS += -rpath-link $(OUTPUTDIR)Libs # 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 +CRTBEGIN = $(shell $(CC) $(CFLAGS) -print-file-name=crtbegin.o) +CRTEND = $(shell $(CC) $(CFLAGS) -print-file-name=crtend.o) + DIR = Bin diff --git a/Usermode/Applications/Makefile.tpl b/Usermode/Applications/Makefile.tpl index 4f9dde51..efcb57de 100644 --- a/Usermode/Applications/Makefile.tpl +++ b/Usermode/Applications/Makefile.tpl @@ -48,7 +48,7 @@ install: $(_BIN) $(_BIN): $(OUTPUTDIR)Libs/acess.ld $(OUTPUTDIR)Libs/crt0.o $(_LIBS) $(OBJ) @mkdir -p $(dir $(_BIN)) @echo [LD] -o $@ - $V$(LD) -g $(LDFLAGS) -o $@ $(OBJ) $(LIBGCC_PATH) + $V$(LD) -g $(LDFLAGS) -o $@ $(CRTBEGIN) $(OBJ) $(LIBGCC_PATH) $(CRTEND) $V$(DISASM) $(_BIN) > $(_OBJPREFIX)$(BIN).dsm $(OBJ): $(_OBJPREFIX)%.o: %.c diff --git a/Usermode/Libraries/Makefile.cfg b/Usermode/Libraries/Makefile.cfg index d134c850..5920059e 100644 --- a/Usermode/Libraries/Makefile.cfg +++ b/Usermode/Libraries/Makefile.cfg @@ -14,6 +14,7 @@ ifeq ($(ARCHDIR),native) else LDFLAGS += -Wl,-init,SoMain CFLAGS += -fPIC + CXXFLAGS += -fPIC endif else ifneq ($(HOST_ARCH),) ASFLAGS += -D ARCHDIR=$(ARCHDIR) -D __ASSEMBLER__=1 @@ -23,10 +24,12 @@ else ifneq ($(HOST_ARCH),) else LDFLAGS += -Wl,-init,SoMain CFLAGS += -fPIC + CXXFLAGS += -fPIC endif else CPPFLAGS := -ffreestanding CFLAGS := -fno-stack-protector -fPIC + CXXFLAGS := -fno-stack-protector -fPIC LDFLAGS := -I/Acess/Libs/ld-acess.so -lld-acess `$(CC) -print-libgcc-file-name` endif LDFLAGS += -g -nostdlib -shared -eSoMain -x --no-undefined -L$(OUTPUTDIR)Libs/ diff --git a/Usermode/Libraries/Makefile.tpl b/Usermode/Libraries/Makefile.tpl index 00913cec..a99ff144 100644 --- a/Usermode/Libraries/Makefile.tpl +++ b/Usermode/Libraries/Makefile.tpl @@ -92,6 +92,11 @@ $(_OBJPREFIX)%.o: %.c @mkdir -p $(dir $@) $V$(CC) $(CFLAGS) $(CPPFLAGS) -o $@ -c $< -MMD -MP -MT $@ -MF $@.dep +$(_OBJPREFIX)%.o: %.cc + @echo [CXX] -o $@ + @mkdir -p $(dir $@) + $V$(CXX) $(CXXFLAGS) $(CPPFLAGS) -o $@ -c $< -MMD -MP -MT $@ -MF $@.dep + $(_OBJPREFIX)%.ao: %.$(ASSUFFIX) @echo [AS] -o $@ @mkdir -p $(dir $@)