makefile fixed, c++ stl working :)
This commit is contained in:
parent
0f74c6d90f
commit
24b76da4b0
41
makefile
41
makefile
|
@ -1,7 +1,7 @@
|
|||
PROJ_NAME=hello_world
|
||||
DEBUG=no
|
||||
BENCH=no
|
||||
MULDIV=no
|
||||
PROJ_NAME = hello_world
|
||||
DEBUG = yes
|
||||
BENCH = no
|
||||
MULDIV = no
|
||||
|
||||
SRCS = $(wildcard src/*.c) \
|
||||
$(wildcard src/*.cpp) \
|
||||
|
@ -23,17 +23,17 @@ ifeq ($(GCC_PACK),yes)
|
|||
RISCV_PATH ?= /home/user/riscv/opt/rv32im/
|
||||
endif
|
||||
|
||||
MABI=ilp32
|
||||
MABI = ilp32
|
||||
MARCH := rv32i_zicsr
|
||||
ifeq ($(MULDIV),yes)
|
||||
MARCH := $(MARCH)m
|
||||
endif
|
||||
|
||||
#CFLAGS += -march=$(MARCH) -mabi=$(MABI) -DNDEBUG
|
||||
#LDFLAGS += -march=$(MARCH) -mabi=$(MABI)
|
||||
|
||||
ifeq ($(DEBUG),yes)
|
||||
CFLAGS += -g3 -O0
|
||||
# CFLAGS += -g3 -O0
|
||||
CFLAGS += -g3 -gdwarf-3 -O0 -DDEBUG
|
||||
CXXFLAGS += -g3 -gdwarf-3 -O0 -DDEBUG
|
||||
LDFLAGS += -g3 -gdwarf-3
|
||||
endif
|
||||
|
||||
ifeq ($(DEBUG),no)
|
||||
|
@ -52,16 +52,19 @@ endif
|
|||
|
||||
RISCV_OBJCOPY = $(RISCV_PATH)/bin/$(RISCV_NAME)-objcopy
|
||||
RISCV_OBJDUMP = $(RISCV_PATH)/bin/$(RISCV_NAME)-objdump
|
||||
RISCV_CC=$(RISCV_PATH)/bin/$(RISCV_NAME)-g++
|
||||
#RISCV_CC=$(RISCV_PATH)/bin/$(RISCV_NAME)-gcc
|
||||
|
||||
#CFLAGS += -MD -fstrict-volatile-bitfields -fno-strict-aliasing
|
||||
#LDFLAGS += -nostdlib -lgcc -mcmodel=medany -nostartfiles -ffreestanding -Wl,-Bstatic,-T,$(LDSCRIPT),-Map,$(OBJDIR)/$(PROJ_NAME).map,--print-memory-usage
|
||||
|
||||
#CFLAGS += -march=$(MARCH) -mabi=$(MABI) -DNDEBUG -std=c++11 -fno-pic -ffreestanding -MD -fstrict-volatile-bitfields -fno-strict-aliasing
|
||||
#LDFLAGS += -march=$(MARCH) -mabi=$(MABI) -lc -lgcc -nostdlib -nostartfiles -mcmodel=medany -ffreestanding -Wl,-Bstatic,-T,$(LDSCRIPT),-Map,$(OBJDIR)/$(PROJ_NAME).map
|
||||
RISCV_CC = $(RISCV_PATH)/bin/$(RISCV_NAME)-gcc
|
||||
CXX = $(RISCV_PATH)/bin/$(RISCV_NAME)-g++
|
||||
|
||||
CFLAGS += -march=$(MARCH) \
|
||||
-mabi=$(MABI) \
|
||||
-DNDEBUG \
|
||||
-fno-pic \
|
||||
-ffreestanding \
|
||||
-MD \
|
||||
-fstrict-volatile-bitfields \
|
||||
-fno-strict-aliasing
|
||||
|
||||
CXXFLAGS += -march=$(MARCH) \
|
||||
-mabi=$(MABI) \
|
||||
-DNDEBUG \
|
||||
-fno-pic \
|
||||
|
@ -90,7 +93,7 @@ OBJS := $(addprefix $(OBJDIR)/,$(OBJS))
|
|||
all: $(OBJDIR)/$(PROJ_NAME).elf $(OBJDIR)/$(PROJ_NAME).hex $(OBJDIR)/$(PROJ_NAME).asm $(OBJDIR)/$(PROJ_NAME).v
|
||||
|
||||
$(OBJDIR)/%.elf: $(OBJS) | $(OBJDIR)
|
||||
$(RISCV_CC) $(CFLAGS) -o $@ $^ $(LDFLAGS) $(LIBSINC) $(LIBS)
|
||||
$(CXX) $(CXXFLAGS) -o $@ $^ $(LDFLAGS) $(LIBSINC) $(LIBS)
|
||||
|
||||
%.hex: %.elf
|
||||
$(RISCV_OBJCOPY) -O ihex $^ $@
|
||||
|
@ -110,7 +113,7 @@ $(OBJDIR)/%.o: %.c
|
|||
|
||||
$(OBJDIR)/%.o: %.cpp
|
||||
mkdir -p $(dir $@)
|
||||
$(RISCV_CC) -c $(CFLAGS) $(INC) -o $@ $^
|
||||
$(CXX) -c $(CXXFLAGS) $(INC) -o $@ $^
|
||||
|
||||
$(OBJDIR)/%.o: %.S
|
||||
mkdir -p $(dir $@)
|
||||
|
|
12
src/main.cpp
12
src/main.cpp
|
@ -87,19 +87,23 @@ int myfunc(const char *s)
|
|||
|
||||
|
||||
void test (std::initializer_list<int> vals) {
|
||||
char buffer[50];
|
||||
int buffer[50];
|
||||
|
||||
for (auto p = vals.begin(); p != vals.end(); ++p) {
|
||||
std::sprintf(buffer, "%d\n", *p);
|
||||
|
||||
int * i = buffer;
|
||||
*i++ = *p;
|
||||
// sprintf(buffer, "%d\n", *p);
|
||||
// printf("%s", buffer);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
int main() {
|
||||
|
||||
char str[10] = {1,2,3};
|
||||
myfunc(str);
|
||||
/// myfunc(str);
|
||||
// println("hello world arty a7 v1");
|
||||
|
||||
|
||||
|
@ -118,7 +122,9 @@ int main() {
|
|||
// Thread 0
|
||||
while( 1){
|
||||
char * s = "11111111112222222222";
|
||||
|
||||
++ile;
|
||||
test({1,2,3,4,5});
|
||||
// len (s);
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue