use the -newos toolchain even if -elf is present.
[newos.git] / templates / lib.mk
blobb9fbe89fb6213a7fbf43d99da1c2558b4b09085a
1 MY_TARGET_IN := $(MY_TARGET)
2 MY_STATIC_TARGET_IN := $(MY_STATIC_TARGET)
3 MY_TARGETDIR_IN := $(MY_TARGETDIR)
4 MY_SRCDIR_IN := $(MY_SRCDIR)
5 MY_SRCS_IN := $(MY_SRCS)
6 MY_OBJS_IN := $(MY_OBJS)
7 MY_CFLAGS_IN := $(MY_CFLAGS)
8 MY_CPPFLAGS_IN := $(MY_CPPFLAGS)
9 MY_INCLUDES_IN := $(MY_INCLUDES)
10 MY_LINKSCRIPT_IN := $(MY_LINKSCRIPT)
12 #$(warning MY_OBJS = $(MY_OBJS))
14 # extract the different source types out of the list
15 #$(warning MY_SRCS_IN = $(MY_SRCS_IN))
16 MY_CPPSRCS_IN := $(filter %.cpp,$(MY_SRCS_IN))
17 MY_CSRCS_IN := $(filter %.c,$(MY_SRCS_IN))
18 MY_ASMSRCS_IN := $(filter %.S,$(MY_SRCS_IN))
20 #$(warning MY_CPPSRCS_IN = $(MY_CPPSRCS_IN))
21 #$(warning MY_CSRCS_IN = $(MY_CSRCS_IN))
22 #$(warning MY_ASMSRCS_IN = $(MY_ASMSRCS_IN))
24 # build a list of objects
25 MY_CPPOBJS_IN := $(addprefix $(MY_TARGETDIR_IN)/,$(patsubst %.cpp,%.o,$(MY_CPPSRCS_IN)))
26 MY_COBJS_IN := $(addprefix $(MY_TARGETDIR_IN)/,$(patsubst %.c,%.o,$(MY_CSRCS_IN)))
27 MY_ASMOBJS_IN := $(addprefix $(MY_TARGETDIR_IN)/,$(patsubst %.S,%.o,$(MY_ASMSRCS_IN)))
28 _TEMP_OBJS := $(MY_CPPOBJS_IN) $(MY_COBJS_IN) $(MY_ASMOBJS_IN)
29 #$(warning _TEMP_OBJS = $(_TEMP_OBJS))
31 # add to the global object list
32 ALL_OBJS := $(ALL_OBJS) $(_TEMP_OBJS)
34 # add to the global deps
35 ALL_DEPS := $(ALL_DEPS) $(_TEMP_OBJS:.o=.d)
37 ifneq ($(MY_TARGET_IN), )
38 $(MY_TARGET_IN): MY_TARGET_IN:=$(MY_TARGET_IN)
39 $(MY_TARGET_IN): MY_LINKSCRIPT_IN:=$(MY_LINKSCRIPT_IN)
40 $(MY_TARGET_IN): MY_TARGETDIR_IN:=$(MY_TARGETDIR_IN)
41 $(MY_TARGET_IN): $(LIBGLUE) $(_TEMP_OBJS)
42 @$(MKDIR)
43 @mkdir -p $(MY_TARGETDIR_IN)
44 @echo linking library $@
45 @$(LD) $(GLOBAL_LDFLAGS) -shared -soname $(notdir $(MY_TARGET_IN)) --script=$(MY_LINKSCRIPT_IN) -o $@ $^
46 @echo creating listing file $@.lst
47 @$(OBJDUMP) -C -S $@ > $@.lst
48 endif
49 ifneq ($(MY_STATIC_TARGET_IN), )
50 $(MY_STATIC_TARGET_IN): MY_TARGETDIR_IN:=$(MY_TARGETDIR_IN)
51 $(MY_STATIC_TARGET_IN): $(_TEMP_OBJS)
52 @$(MKDIR)
53 @echo creating static lib $@
54 @$(AR) r $@ $^
55 endif
57 include templates/compile.mk
59 MY_TARGET :=
60 MY_STATIC_TARGET :=
61 MY_TARGETDIR :=
62 MY_SRCDIR :=
63 MY_SRCS :=
64 MY_CFLAGS :=
65 MY_CPPFLAGS :=
66 MY_INCLUDES :=
67 MY_LINKSCRIPT :=