OpenCores
URL https://opencores.org/ocsvn/minsoc/minsoc/trunk

Subversion Repositories minsoc

[/] [minsoc/] [branches/] [rc-1.0/] [sw/] [uart/] [Makefile] - Blame information for rev 141

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 65 rfajardo
include ../support/Makefile.inc
2 80 rfajardo
include $(BACKEND_DIR)/gcc-opt.mk
3 65 rfajardo
 
4 80 rfajardo
#USER INPUT
5
SRCS = uart.c
6
OR32_TARGET = uart.hex
7
TARGET =
8
TARGETLIB =
9
MODEL = static          #dynamic|static
10
VERSION = 0.1
11
MODE = debug            #release|debug
12 65 rfajardo
 
13 80 rfajardo
INCLUDEDIRS = $(BACKEND_DIR) $(SUPPORT_DIR) $(DRIVERS_DIR)
14
#libsystemc or systemc (system ignores lib at the beginning)
15
LIBNAMES =
16
LIBDIRS =
17
DEPENDDIR = ./depend
18 65 rfajardo
 
19 80 rfajardo
 
20
#CONFIGURATION
21
DEBUGPARAM =
22
RELEASEPARAM =
23
 
24
DEBUGFLAGS = -g -O0
25
RELEASEFLAGS = -O2 -fomit-frame-pointer
26
 
27
CFLAGS = -Wall
28
CC = or32-elf-gcc
29
AR = or32-elf-ar
30
RANLIB = or32-elf-ranlib
31
 
32
CFLAGS += $(GCC_OPT)
33
 
34
 
35
#MECHANICS
36
INCLUDESPATH = $(addprefix -I, $(INCLUDEDIRS))
37
LIBSPATH = $(addprefix -L, $(LIBDIRS))
38
LIBSLINKAGE = $(addprefix -l, $(subst lib, , $(LIBNAMES)) )
39
COMMA = ,
40
RPATH = $(addprefix -Wl$(COMMA)-R, $(LIBDIRS))
41
 
42
OBJS = $(addsuffix .o, $(basename $(SRCS)))
43
DEPS = $(addprefix $(DEPENDDIR)/, $(addsuffix .d, $(basename $(SRCS) ) ) )
44
 
45
STATICLIB = $(addprefix lib, $(addsuffix .a, $(TARGETLIB) ) )
46
DYNAMICLIB = $(addprefix lib, $(addsuffix .so, $(TARGETLIB) ) )
47
SONAME = $(addsuffix .$(VERSION), $(DYNAMICLIB))
48
 
49
ifeq (debug,$(findstring debug, $(MODE)))
50
CFLAGS += $(DEBUGFLAGS) $(addprefix -D, $(DEBUGPARAM))
51
else
52
CFLAGS += $(RELEASEFLAGS) $(addprefix -D, $(RELEASEPARAM))
53
endif
54
 
55
ifdef TARGETLIB
56
ifeq (dynamic,$(findstring dynamic, $(MODEL)))
57
TARGET = $(DYNAMICLIB)
58
CFLAGS += -fPIC
59
else
60
TARGET = $(STATICLIB)
61
endif
62
endif
63
 
64
 
65
#MAKEFILE RULES
66
all: $(TARGET) $(OR32_TARGET)
67
 
68
depend: $(DEPS)
69
 
70
docs: Doxyfile
71
        doxygen
72
 
73
distclean:
74
        make clean
75
        rm -rf $(DEPENDDIR) Doxygen
76
 
77
 
78
-include $(DEPS)
79
 
80
 
81
ifndef TARGETLIB
82
$(TARGET): $(OBJS)
83
        $(CC) $(LIBSPATH) $(RPATH) -o $@ $^ $(LIBSLINKAGE)
84
endif
85
 
86
 
87
$(STATICLIB): $(OBJS)
88
        $(AR) cru $@ $^
89
        $(RANLIB) $@
90
 
91
$(DYNAMICLIB): $(OBJS)
92
        $(CC) -shared -Wl,-soname,$(SONAME) -o $@ $^
93
        ln -fs $@ $(SONAME)
94
 
95
 
96
%.o: %.c
97
        $(CC) $(CFLAGS) $(INCLUDESPATH) -c $< -o $@
98
 
99
 
100
$(DEPENDDIR)/%.d: %.c
101
        mkdir -p $(DEPENDDIR)
102
        $(CC) $(INCLUDESPATH) -MM -MF $@ $<
103
 
104
 
105
# DO NOT DELETE
106
 
107
STEM = $(subst .hex, , $(OR32_TARGET))
108
BINARY = $(addsuffix .bin, $(STEM) )
109
EXECUTABLE = $(addsuffix .or32, $(STEM) )
110
 
111
$(OR32_TARGET): $(BINARY)
112
        $(BIN2HEX) $? 1 -size_word > $@
113
 
114
$(BINARY): $(EXECUTABLE)
115
        $(OR32_TOOL_PREFIX)-objcopy -O binary $? $@
116
 
117
#except.o and reset.o should be already inside of $(SUPPORT) (libsupport.a) but for some reason the compiler ignores that fact
118
#(e.g. or32-elf-objdump -t libsupport.a shows it)
119
$(EXECUTABLE): $(OBJS) ../support/except.o ../support/reset.o $(SUPPORT) $(DRIVERS)
120
        $(CC) $(CFLAGS) $(GCC_LIB_OPTS) -T $(LINKER_SCRIPT) $^ -o $@
121
 
122
clean:
123
        rm -f *.o *~ $(TARGET) $(STATICLIB) $(DYNAMICLIB) $(SONAME) $(OR32_TARGET) $(BINARY) $(EXECUTABLE)
124
 
125
#EOF

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.