Working toward successful link using aslink

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@21 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2007-02-27 23:59:20 +00:00
parent a60059d9d0
commit bb072cb0d2
10 changed files with 109 additions and 83 deletions

View File

@ -42,17 +42,13 @@ ARCH_SRC = $(ARCH_DIR)/src
SUBDIRS = sched lib $(ARCH_SRC) mm fs drivers examples/$(CONFIG_EXAMPLE) SUBDIRS = sched lib $(ARCH_SRC) mm fs drivers examples/$(CONFIG_EXAMPLE)
OBJS = $(ARCH_SRC)/up_head.o LINKOBJS = $(ARCH_SRC)/up_head$(OBJEXT)
LIBGCC = ${shell $(CC) -print-libgcc-file-name} LINKLIBS = sched/libsched$(LIBEXT) $(ARCH_SRC)/libarch$(LIBEXT) mm/libmm$(LIBEXT) \
LIBS = sched/libsched$(LIBEXT) $(ARCH_SRC)/libarch$(LIBEXT) mm/libmm$(LIBEXT) \
fs/libfs$(LIBEXT) drivers/libdrivers$(LIBEXT) lib/liblib$(LIBEXT) \ fs/libfs$(LIBEXT) drivers/libdrivers$(LIBEXT) lib/liblib$(LIBEXT) \
examples/$(CONFIG_EXAMPLE)/lib$(CONFIG_EXAMPLE)$(LIBEXT) examples/$(CONFIG_EXAMPLE)/lib$(CONFIG_EXAMPLE)$(LIBEXT)
LDLIBS = -lsched -larch -lmm -lfs -ldrivers -llib -l$(CONFIG_EXAMPLE) $(LIBGCC) $(EXTRA_LIBS)
BIN = nuttx BIN = nuttx
LDFLAGS += -Lsched -Llib -L$(ARCH_SRC) -Lmm -Lfs -Ldrivers -Lexamples/$(CONFIG_EXAMPLE)
all: $(BIN) all: $(BIN)
.PHONY: clean context clean_context distclean .PHONY: clean context clean_context distclean
@ -87,8 +83,8 @@ lib/liblib$(LIBEXT): context
$(ARCH_SRC)/libarch$(LIBEXT): context $(ARCH_SRC)/libarch$(LIBEXT): context
$(MAKE) -C $(ARCH_SRC) TOPDIR=$(TOPDIR) libarch$(LIBEXT) $(MAKE) -C $(ARCH_SRC) TOPDIR=$(TOPDIR) libarch$(LIBEXT)
$(ARCH_SRC)/up_head.o: context $(ARCH_SRC)/up_head$(OBJEXT): context
$(MAKE) -C $(ARCH_SRC) TOPDIR=$(TOPDIR) up_head.o $(MAKE) -C $(ARCH_SRC) TOPDIR=$(TOPDIR) up_head$(OBJEXT)
mm/libmm$(LIBEXT): context mm/libmm$(LIBEXT): context
$(MAKE) -C mm TOPDIR=$(TOPDIR) libmm$(LIBEXT) $(MAKE) -C mm TOPDIR=$(TOPDIR) libmm$(LIBEXT)
@ -102,25 +98,8 @@ drivers/libdrivers$(LIBEXT): context
examples/$(CONFIG_EXAMPLE)/lib$(CONFIG_EXAMPLE)$(LIBEXT): context examples/$(CONFIG_EXAMPLE)/lib$(CONFIG_EXAMPLE)$(LIBEXT): context
$(MAKE) -C examples/$(CONFIG_EXAMPLE) TOPDIR=$(TOPDIR) lib$(CONFIG_EXAMPLE)$(LIBEXT) $(MAKE) -C examples/$(CONFIG_EXAMPLE) TOPDIR=$(TOPDIR) lib$(CONFIG_EXAMPLE)$(LIBEXT)
$(BIN): context depend $(OBJS) $(LIBS) $(BIN): context depend $(LINKOBJS) $(LINKLIBS)
ifeq ($(CONFIG_ARCH),sim) $(MAKE) -C $(ARCH_SRC) TOPDIR=$(TOPDIR) LINKOBJS="$(LINKOBJS)" LINKLIBS="$(LINKLIBS)" $(BIN)
$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) $(LDLIBS)
@$(NM) $(BIN) | grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | sort > System.map
else
$(LD) --entry=__start $(LDFLAGS) -o $@ $(OBJS) $(LIBS) $(LDLIBS)
@$(NM) $(BIN) | grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | sort > System.map
@export vflashstart=`$(OBJDUMP) --all-headers $(BIN) | grep _vflashstart | cut -d' ' -f1`; \
if [ ! -z "$$vflashstart" ]; then \
$(OBJCOPY) --adjust-section-vma=.vector=0x$$vflashstart $(BIN) $(BIN).flashimage; \
mv $(BIN).flashimage $(BIN); \
fi
ifeq ($(CONFIG_RRLOAD_BINARY),y)
@tools/mkimage.sh nuttx nuttx.rr
@if [ -w /tftpboot ] ; then \
cp -f nuttx.rr /tftpboot/nuttx.rr.${CONFIG_ARCH}; \
fi
endif
endif
depend: depend:
@for dir in $(SUBDIRS) ; do \ @for dir in $(SUBDIRS) ; do \

View File

@ -62,6 +62,8 @@ CFLAGS = $(ARCHWARNINGS) $(ARCHOPTIMIZATION) \
LDFLAGS = $(ARCHSCRIPT) LDFLAGS = $(ARCHSCRIPT)
EXTRA_LIBS = EXTRA_LIBS =
OBJEXT = .o
LIBEXT = .a LIBEXT = .a
ifeq ("${CONFIG_DEBUG}","y") ifeq ("${CONFIG_DEBUG}","y")

View File

@ -56,6 +56,13 @@ COBJS = $(CSRCS:.c=.o)
SRCS = $(ASRCS) $(CSRCS) SRCS = $(ASRCS) $(CSRCS)
OBJS = $(AOBJS) $(COBJS) OBJS = $(AOBJS) $(COBJS)
LINKOBJS =
LINKLIBS =
LDPATHES = $(addprefix -L$(TOPDIR)/,$(dir $(LINKLIBS)))
LDLIBS = $(patsubst lib%,-l%,$(basename $(notdir $(LINKLIBS))))
LIBGCC = ${shell $(CC) -print-libgcc-file-name}
all: up_head.o libarch$(LIBEXT) all: up_head.o libarch$(LIBEXT)
$(AOBJS) up_head.o: %.o: %.S $(AOBJS) up_head.o: %.o: %.S
@ -70,6 +77,25 @@ libarch$(LIBEXT): $(OBJS)
{ echo "$(AR) $@ $obj FAILED!" ; exit 1 ; } ; \ { echo "$(AR) $@ $obj FAILED!" ; exit 1 ; } ; \
done ; ) done ; )
nuttx:
$(LD) --entry=__start $(LDFLAGS) $(LDPATHES) -o $(TOPDIR)/$@ \
$(addprefix $(TOPDIR)/,$(LINKOBJS)) \
--start-group $(LDLIBS) $(EXTRA_LIBS) $(LIBGCC) --end-group
@$(NM) $(TOPDIR)/$@ | \
grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \
sort > $(TOPDIR)/System.map
@export vflashstart=`$(OBJDUMP) --all-headers $(TOPDIR)/$@ | grep _vflashstart | cut -d' ' -f1`; \
if [ ! -z "$$vflashstart" ]; then \
$(OBJCOPY) --adjust-section-vma=.vector=0x$$vflashstart $(TOPDIR)/$@ $(TOPDIR)/$@.flashimage; \
mv $(TOPDIR)/$@.flashimage $(TOPDIR)/$@; \
fi
ifeq ($(CONFIG_RRLOAD_BINARY),y)
@$(TOPDIR)/tools/mkimage.sh $(TOPDIR)/$@ $(TOPDIR)/$@.rr
@if [ -w /tftpboot ] ; then \
cp -f $(TOPDIR)/$@.rr /tftpboot/$@.rr.${CONFIG_ARCH}; \
fi
endif
.depend: Makefile $(SRCS) .depend: Makefile $(SRCS)
$(MKDEP) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep $(MKDEP) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep
touch $@ touch $@

View File

@ -61,6 +61,8 @@ CFLAGS = $(ARCHWARNINGS) $(ARCHOPTIMIZATION) \
LDFLAGS = $(ARCHSCRIPT) LDFLAGS = $(ARCHSCRIPT)
EXTRA_LIBS = -lc EXTRA_LIBS = -lc
OBJEXT = .o
LIBEXT = .a LIBEXT = .a
ifeq ("${CONFIG_DEBUG}","y") ifeq ("${CONFIG_DEBUG}","y")

View File

@ -39,22 +39,29 @@ MKDEP = $(TOPDIR)/tools/mkdeps.sh
CFLAGS += -I$(TOPDIR)/sched CFLAGS += -I$(TOPDIR)/sched
ASRCS = up_setjmp.S ASRCS = up_setjmp.S
AOBJS = $(ASRCS:.S=.o) AOBJS = $(ASRCS:.S=$(OBJEXT))
CSRCS = up_initialize.c up_idle.c up_interruptcontext.c up_initialstate.c \ CSRCS = up_initialize.c up_idle.c up_interruptcontext.c \
up_createstack.c up_usestack.c up_releasestack.c \ up_initialstate.c up_createstack.c up_usestack.c \
up_unblocktask.c up_blocktask.c up_releasepending.c up_reprioritizertr.c \ up_releasestack.c up_unblocktask.c up_blocktask.c \
up_exit.c up_schedulesigaction.c up_allocateheap.c up_devconsole.c up_releasepending.c up_reprioritizertr.c \
COBJS = $(CSRCS:.c=.o) up_exit.c up_schedulesigaction.c up_allocateheap.c \
up_devconsole.c
COBJS = $(CSRCS:.c=$(OBJEXT))
SRCS = $(ASRCS) $(CSRCS) SRCS = $(ASRCS) $(CSRCS)
OBJS = $(AOBJS) $(COBJS) OBJS = $(AOBJS) $(COBJS)
all: up_head.o libarch$(LIBEXT) LINKOBJS =
LINKLIBS =
LDPATHES = $(addprefix -L$(TOPDIR)/,$(dir $(LINKLIBS)))
LDLIBS = $(patsubst lib%,-l%,$(basename $(notdir $(LINKLIBS))))
$(AOBJS): %.o: %.S all: up_head$(OBJEXT) libarch$(LIBEXT)
$(AOBJS): %$(OBJEXT): %.S
$(CC) -c $(CFLAGS) -D__ASSEMBLY__ $< -o $@ $(CC) -c $(CFLAGS) -D__ASSEMBLY__ $< -o $@
$(COBJS) up_head.o: %.o: %.c $(COBJS) up_head$(OBJEXT): %$(OBJEXT): %.c
$(CC) -c $(CFLAGS) $< -o $@ $(CC) -c $(CFLAGS) $< -o $@
libarch$(LIBEXT): $(OBJS) libarch$(LIBEXT): $(OBJS)
@ -63,6 +70,15 @@ libarch$(LIBEXT): $(OBJS)
{ echo "$(AR) $@ $obj FAILED!" ; exit 1 ; } ; \ { echo "$(AR) $@ $obj FAILED!" ; exit 1 ; } ; \
done ; ) done ; )
nuttx:
$(CC) $(LDFLAGS) $(LDPATHES) -o $(TOPDIR)/$@ \
$(addprefix $(TOPDIR)/,$(LINKOBJS)) \
-Wl,--start-group $(LDLIBS) $(EXTRA_LIBS) -Wl,--end-group
@$(NM) $(TOPDIR)/$@ | \
grep -v '\(compiled\)\|\(\.o$$\)\|\( [aUw] \)\|\(\.\.ng$$\)\|\(LASH[RL]DI\)' | \
sort > $(TOPDIR)/System.map
.depend: Makefile $(SRCS) .depend: Makefile $(SRCS)
$(MKDEP) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep $(MKDEP) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep
touch $@ touch $@
@ -70,10 +86,10 @@ libarch$(LIBEXT): $(OBJS)
depend: .depend depend: .depend
clean: clean:
rm -f libarch$(LIBEXT) *.o *~ rm -f libarch$(LIBEXT) *~
if [ ! -z "$(OBJEXT)" ]; then rm -f *$(OBJEXT); fi
distclean: clean distclean: clean
rm -f Make.dep .depend rm -f Make.dep .depend
-include Make.dep -include Make.dep

View File

@ -38,10 +38,10 @@
MKDEP = $(TOPDIR)/tools/mkdeps.sh MKDEP = $(TOPDIR)/tools/mkdeps.sh
ASRCS = ASRCS =
AOBJS = $(ASRCS:.S=.o) AOBJS = $(ASRCS:.S=$(OBJEXT))
CSRCS = dev_null.c CSRCS = dev_null.c
COBJS = $(CSRCS:.c=.o) COBJS = $(CSRCS:.c=$(OBJEXT))
SRCS = $(ASRCS) $(CSRCS) SRCS = $(ASRCS) $(CSRCS)
OBJS = $(AOBJS) $(COBJS) OBJS = $(AOBJS) $(COBJS)
@ -50,10 +50,10 @@ BIN = libdrivers$(LIBEXT)
all: $(BIN) all: $(BIN)
$(AOBJS): %.o: %.S $(AOBJS): %$(OBJEXT): %.S
$(CC) -c $(CFLAGS) -D__ASSEMBLY__ $< -o $@ $(CC) -c $(CFLAGS) -D__ASSEMBLY__ $< -o $@
$(cOBJS): %.o: %.c $(cOBJS): %$(OBJEXT): %.c
$(CC) -c $(CFLAGS) $< -o $@ $(CC) -c $(CFLAGS) $< -o $@
$(BIN): $(OBJS) $(BIN): $(OBJS)
@ -69,7 +69,7 @@ $(BIN): $(OBJS)
depend: .depend depend: .depend
clean: clean:
rm -f $(BIN) *.o *.asm *.lst *.sym *.adb *~ rm -f $(BIN) *.o *.rel *.asm *.lst *.sym *.adb *~
distclean: clean distclean: clean
rm -f Make.dep .depend rm -f Make.dep .depend

View File

@ -39,10 +39,10 @@
MKDEP = $(TOPDIR)/tools/mkdeps.sh MKDEP = $(TOPDIR)/tools/mkdeps.sh
ASRCS = ASRCS =
AOBJS = $(ASRCS:.S=.o) AOBJS = $(ASRCS:.S=$(OBJEXT))
CSRCS = main.c dev_null.c mutex.c cancel.c sem.c cond.c \ CSRCS = main.c dev_null.c mutex.c cancel.c sem.c cond.c \
timedwait.c mqueue.c sighand.c timedwait.c mqueue.c sighand.c
COBJS = $(CSRCS:.c=.o) COBJS = $(CSRCS:.c=$(OBJEXT))
SRCS = $(ASRCS) $(CSRCS) SRCS = $(ASRCS) $(CSRCS)
OBJS = $(AOBJS) $(COBJS) OBJS = $(AOBJS) $(COBJS)
@ -51,10 +51,10 @@ BIN = lib$(CONFIG_EXAMPLE)$(LIBEXT)
all: $(BIN) all: $(BIN)
$(AOBJS): %.o: %.S $(AOBJS): %$(OBJEXT): %.S
$(CC) -c $(CFLAGS) $< -o $@ $(CC) -c $(CFLAGS) $< -o $@
$(COBJS): %.o: %.c $(COBJS): %$(OBJEXT): %.c
$(CC) -c $(CFLAGS) $< -o $@ $(CC) -c $(CFLAGS) $< -o $@
$(BIN): $(OBJS) $(BIN): $(OBJS)
@ -70,7 +70,7 @@ $(BIN): $(OBJS)
depend: .depend depend: .depend
clean: clean:
rm -f $(BIN) *.o *.asm *.lst *.sym *.adb *~ rm -f $(BIN) *.o *.rel *.asm *.lst *.sym *.adb *~
distclean: clean distclean: clean
rm -f Make.dep .depend rm -f Make.dep .depend

View File

@ -38,11 +38,11 @@
MKDEP = $(TOPDIR)/tools/mkdeps.sh MKDEP = $(TOPDIR)/tools/mkdeps.sh
ASRCS = ASRCS =
AOBJS = $(ASRCS:.S=.o) AOBJS = $(ASRCS:.S=$(OBJEXT))
CSRCS = fs_open.c fs_close.c fs_read.c fs_write.c fs_ioctl.c fs_dup.c \ CSRCS = fs_open.c fs_close.c fs_read.c fs_write.c fs_ioctl.c fs_dup.c \
fs_files.c fs_inode.c fs_files.c fs_inode.c
COBJS = $(CSRCS:.c=.o) COBJS = $(CSRCS:.c=$(OBJEXT))
SRCS = $(ASRCS) $(CSRCS) SRCS = $(ASRCS) $(CSRCS)
OBJS = $(AOBJS) $(COBJS) OBJS = $(AOBJS) $(COBJS)
@ -51,10 +51,10 @@ BIN = libfs$(LIBEXT)
all: $(BIN) all: $(BIN)
$(AOBJS): %.o: %.S $(AOBJS): %$(OBJEXT): %.S
$(CC) -c $(CFLAGS) -D__ASSEMBLY__ $< -o $@ $(CC) -c $(CFLAGS) -D__ASSEMBLY__ $< -o $@
$(cOBJS): %.o: %.c $(cOBJS): %$(OBJEXT): %.c
$(CC) -c $(CFLAGS) $< -o $@ $(CC) -c $(CFLAGS) $< -o $@
$(BIN): $(OBJS) $(BIN): $(OBJS)
@ -70,7 +70,7 @@ $(BIN): $(OBJS)
depend: .depend depend: .depend
clean: clean:
rm -f $(BIN) *.o *.asm *.lst *.sym *.adb *~ rm -f $(BIN) *.o *.rel *.asm *.lst *.sym *.adb *~
distclean: clean distclean: clean
rm -f Make.dep .depend rm -f Make.dep .depend

View File

@ -38,7 +38,7 @@
MKDEP = $(TOPDIR)/tools/mkdeps.sh MKDEP = $(TOPDIR)/tools/mkdeps.sh
ASRCS = ASRCS =
AOBJS = $(ASRCS:.S=.o) AOBJS = $(ASRCS:.S=$(OBJEXT))
MISC_SRCS = lib_init.c lib_streamsem.c lib_filesem.c MISC_SRCS = lib_init.c lib_streamsem.c lib_filesem.c
STRING_SRCS = lib_memset.c lib_memcpy.c lib_memcmp.c lib_memmove.c \ STRING_SRCS = lib_memset.c lib_memcpy.c lib_memcmp.c lib_memmove.c \
@ -63,7 +63,7 @@ DQ_SRCS = dq_addlast.c dq_addfirst.c dq_addafter.c dq_addbefore.c \
CSRCS = $(MISC_SRCS) $(STRING_SRCS) $(CTYPE_SRCS) $(STDIO_SRCS) \ CSRCS = $(MISC_SRCS) $(STRING_SRCS) $(CTYPE_SRCS) $(STDIO_SRCS) \
$(STDLIB_SRCS) $(MATH_SRCS) $(SQ_SRCS) $(DQ_SRCS) $(STDLIB_SRCS) $(MATH_SRCS) $(SQ_SRCS) $(DQ_SRCS)
COBJS = $(CSRCS:.c=.o) COBJS = $(CSRCS:.c=$(OBJEXT))
SRCS = $(ASRCS) $(CSRCS) SRCS = $(ASRCS) $(CSRCS)
OBJS = $(AOBJS) $(COBJS) OBJS = $(AOBJS) $(COBJS)
@ -72,10 +72,10 @@ BIN = liblib$(LIBEXT)
all: $(BIN) all: $(BIN)
$(AOBJS): %.o: %.S $(AOBJS): %$(OBJEXT): %.S
$(CC) -c $(CFLAGS) -D__ASSEMBLY__ $< -o $@ $(CC) -c $(CFLAGS) -D__ASSEMBLY__ $< -o $@
$(COBJS): %.o: %.c $(COBJS): %$(OBJEXT): %.c
$(CC) -c $(CFLAGS) $< -o $@ $(CC) -c $(CFLAGS) $< -o $@
$(BIN): $(OBJS) $(BIN): $(OBJS)
@ -91,7 +91,7 @@ $(BIN): $(OBJS)
depend: .depend depend: .depend
clean: clean:
rm -f $(BIN) *.o *.asm *.lst *.sym *.adb *~ rm -f $(BIN) *.o *.rel *.asm *.lst *.sym *.adb *~
distclean: clean distclean: clean
rm -f Make.dep .depend rm -f Make.dep .depend

View File

@ -38,7 +38,7 @@
MKDEP = $(TOPDIR)/tools/mkdeps.sh MKDEP = $(TOPDIR)/tools/mkdeps.sh
ASRCS = ASRCS =
AOBJS = $(ASRCS:.S=.o) AOBJS = $(ASRCS:.S=$(OBJEXT))
MISC_SRCS = os_start.c get_errno_ptr.c \ MISC_SRCS = os_start.c get_errno_ptr.c \
sched_setupstreams.c sched_getfiles.c sched_getstreams.c \ sched_setupstreams.c sched_getfiles.c sched_getstreams.c \
@ -96,7 +96,7 @@ SEM_SRCS = sem_initialize.c sem_init.c sem_destroy.c\
IRQ_SRCS = irq_initialize.c irq_attach.c irq_dispatch.c irq_unexpectedisr.c IRQ_SRCS = irq_initialize.c irq_attach.c irq_dispatch.c irq_unexpectedisr.c
CSRCS = $(MISC_SRCS) $(TSK_SRCS) $(SCHED_SRCS) $(WDOG_SRCS) $(TIME_SRCS) \ CSRCS = $(MISC_SRCS) $(TSK_SRCS) $(SCHED_SRCS) $(WDOG_SRCS) $(TIME_SRCS) \
$(SIGNAL_SRCS) $(MQUEUE_SRCS) $(PTHREAD_SRCS) $(SEM_SRCS) $(IRQ_SRCS) $(SIGNAL_SRCS) $(MQUEUE_SRCS) $(PTHREAD_SRCS) $(SEM_SRCS) $(IRQ_SRCS)
COBJS = $(CSRCS:.c=.o) COBJS = $(CSRCS:.c=$(OBJEXT))
SRCS = $(ASRCS) $(CSRCS) SRCS = $(ASRCS) $(CSRCS)
OBJS = $(AOBJS) $(COBJS) OBJS = $(AOBJS) $(COBJS)
@ -105,10 +105,10 @@ BIN = libsched$(LIBEXT)
all: $(BIN) all: $(BIN)
$(AOBJS): %.o: %.S $(AOBJS): %$(OBJEXT): %.S
$(CC) -c $(CFLAGS) -D__ASSEMBLY__ $< -o $@ $(CC) -c $(CFLAGS) -D__ASSEMBLY__ $< -o $@
$(COBJS): %.o: %.c $(COBJS): %$(OBJEXT): %.c
$(CC) -c $(CFLAGS) $< -o $@ $(CC) -c $(CFLAGS) $< -o $@
$(BIN): $(OBJS) $(BIN): $(OBJS)
@ -124,7 +124,8 @@ $(BIN): $(OBJS)
depend: .depend depend: .depend
clean: clean:
rm -f $(BIN) *.o *.asm *.lst *.sym *.adb *~ rm -f $(BIN) *.o *.rel *.asm *.lst *.sym *.adb *~
if [ ! -z "$(OBJEXT)" ]; then rm -f *$(OBJEXT); fi
distclean: clean distclean: clean
rm -f Make.dep .depend rm -f Make.dep .depend