Browse Source

Fix some mkdeps.c issues; Incorporate mkdeps.c build in Makefiles

git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5343 42af7a65-404d-4744-a932-0658087f49c3
sbg
patacongo 12 years ago
parent
commit
ccc5929f33
  1. 25
      nuttx/Makefile
  2. 29
      nuttx/Makefile.win
  3. 2
      nuttx/configs/stm32f4discovery/winbuild/Make.defs
  4. 58
      nuttx/tools/Makefile.host
  5. 13
      nuttx/tools/mkdeps.c

25
nuttx/Makefile

@ -321,8 +321,8 @@ endif
# part of the overall NuttX configuration sequence. Notice that the # part of the overall NuttX configuration sequence. Notice that the
# tools/mkversion tool is built and used to create include/nuttx/version.h # tools/mkversion tool is built and used to create include/nuttx/version.h
tools/mkversion: tools/mkversion$(HOSTEXEEXT):
$(Q) $(MAKE) -C tools -f Makefile.host TOPDIR="$(TOPDIR)" mkversion $(Q) $(MAKE) -C tools -f Makefile.host TOPDIR="$(TOPDIR)" mkversion$(HOSTEXEEXT)
$(TOPDIR)/.version: $(TOPDIR)/.version:
$(Q) if [ ! -f .version ]; then \ $(Q) if [ ! -f .version ]; then \
@ -331,19 +331,24 @@ $(TOPDIR)/.version:
chmod 755 .version; \ chmod 755 .version; \
fi fi
include/nuttx/version.h: $(TOPDIR)/.version tools/mkversion include/nuttx/version.h: $(TOPDIR)/.version tools/mkversion$(HOSTEXEEXT)
$(Q) tools/mkversion $(TOPDIR) > include/nuttx/version.h $(Q) tools/mkversion $(TOPDIR) > include/nuttx/version.h
# Targets used to build include/nuttx/config.h. Creation of config.h is # Targets used to build include/nuttx/config.h. Creation of config.h is
# part of the overall NuttX configuration sequence. Notice that the # part of the overall NuttX configuration sequence. Notice that the
# tools/mkconfig tool is built and used to create include/nuttx/config.h # tools/mkconfig tool is built and used to create include/nuttx/config.h
tools/mkconfig: tools/mkconfig$(HOSTEXEEXT):
$(Q) $(MAKE) -C tools -f Makefile.host TOPDIR="$(TOPDIR)" mkconfig $(Q) $(MAKE) -C tools -f Makefile.host TOPDIR="$(TOPDIR)" mkconfig$(HOSTEXEEXT)
include/nuttx/config.h: $(TOPDIR)/.config tools/mkconfig include/nuttx/config.h: $(TOPDIR)/.config tools/mkconfig$(HOSTEXEEXT)
$(Q) tools/mkconfig $(TOPDIR) > include/nuttx/config.h $(Q) tools/mkconfig $(TOPDIR) > include/nuttx/config.h
# Targets used to create dependencies
tools/mkdeps$(HOSTEXEEXT):
$(Q) $(MAKE) -C tools -f Makefile.host TOPDIR="$(TOPDIR)" mkdeps$(HOSTEXEEXT)
# dirlinks, and helpers # dirlinks, and helpers
# #
# Directories links. Most of establishing the NuttX configuration involves # Directories links. Most of establishing the NuttX configuration involves
@ -550,7 +555,7 @@ lib/libc$(LIBEXT): libc/libc$(LIBEXT)
# is an archive. Exactly what is performed during pass1 or what it generates # is an archive. Exactly what is performed during pass1 or what it generates
# is unknown to this makefule unless CONFIG_PASS1_OBJECT is defined. # is unknown to this makefule unless CONFIG_PASS1_OBJECT is defined.
pass1deps: context pass1dep $(USERLIBS) pass1deps: pass1dep $(USERLIBS)
pass1: pass1deps pass1: pass1deps
ifeq ($(CONFIG_BUILD_2PASS),y) ifeq ($(CONFIG_BUILD_2PASS),y)
@ -569,7 +574,7 @@ ifeq ($(CONFIG_BUILD_2PASS),y)
$(Q) $(MAKE) -C $(CONFIG_PASS1_BUILDIR) TOPDIR="$(TOPDIR)" LINKLIBS="$(LINKLIBS)" USERLIBS="$(USERLIBS)" "$(CONFIG_PASS1_TARGET)" $(Q) $(MAKE) -C $(CONFIG_PASS1_BUILDIR) TOPDIR="$(TOPDIR)" LINKLIBS="$(LINKLIBS)" USERLIBS="$(USERLIBS)" "$(CONFIG_PASS1_TARGET)"
endif endif
pass2deps: context pass2dep $(NUTTXLIBS) pass2deps: pass2dep $(NUTTXLIBS)
pass2: pass2deps pass2: pass2deps
$(Q) $(MAKE) -C $(ARCH_SRC) TOPDIR="$(TOPDIR)" EXTRA_OBJS="$(EXTRA_OBJS)" LINKLIBS="$(LINKLIBS)" EXTRADEFINES=$(KDEFINE) $(BIN) $(Q) $(MAKE) -C $(ARCH_SRC) TOPDIR="$(TOPDIR)" EXTRA_OBJS="$(EXTRA_OBJS)" LINKLIBS="$(LINKLIBS)" EXTRADEFINES=$(KDEFINE) $(BIN)
@ -619,12 +624,12 @@ download: $(BIN)
# pass1dep: Create pass1 build dependencies # pass1dep: Create pass1 build dependencies
# pass2dep: Create pass2 build dependencies # pass2dep: Create pass2 build dependencies
pass1dep: context pass1dep: context tools/mkdeps$(HOSTEXEEXT)
$(Q) for dir in $(USERDEPDIRS) ; do \ $(Q) for dir in $(USERDEPDIRS) ; do \
$(MAKE) -C $$dir TOPDIR="$(TOPDIR)" depend ; \ $(MAKE) -C $$dir TOPDIR="$(TOPDIR)" depend ; \
done done
pass2dep: context pass2dep: context tools/mkdeps$(HOSTEXEEXT)
$(Q) for dir in $(KERNDEPDIRS) ; do \ $(Q) for dir in $(KERNDEPDIRS) ; do \
$(MAKE) -C $$dir TOPDIR="$(TOPDIR)" EXTRADEFINES=$(KDEFINE) depend; \ $(MAKE) -C $$dir TOPDIR="$(TOPDIR)" EXTRADEFINES=$(KDEFINE) depend; \
done done

29
nuttx/Makefile.win

@ -314,8 +314,8 @@ endif
# part of the overall NuttX configuration sequence. Notice that the # part of the overall NuttX configuration sequence. Notice that the
# tools\mkversion tool is built and used to create include\nuttx\version.h # tools\mkversion tool is built and used to create include\nuttx\version.h
tools\mkversion: tools\mkversion$(HOSTEXEEXT):
$(Q) $(MAKE) -C tools -f Makefile.host TOPDIR="$(TOPDIR)" mkversion $(Q) $(MAKE) -C tools -f Makefile.host TOPDIR="$(TOPDIR)" mkversion$(HOSTEXEEXT)
$(TOPDIR)\.version: $(TOPDIR)\.version:
$(Q) if [ ! -f .version ]; then \ $(Q) if [ ! -f .version ]; then \
@ -324,18 +324,23 @@ $(TOPDIR)\.version:
chmod 755 .version; \ chmod 755 .version; \
fi fi
include\nuttx\version.h: $(TOPDIR)\.version tools\mkversion include\nuttx\version.h: $(TOPDIR)\.version tools\mkversion$(HOSTEXEEXT)
$(Q) tools\mkversion $(TOPDIR) > include\nuttx\version.h $(Q) tools\mkversion$(HOSTEXEEXT) $(TOPDIR) > include\nuttx\version.h
# Targets used to build include\nuttx\config.h. Creation of config.h is # Targets used to build include\nuttx\config.h. Creation of config.h is
# part of the overall NuttX configuration sequence. Notice that the # part of the overall NuttX configuration sequence. Notice that the
# tools\mkconfig tool is built and used to create include\nuttx\config.h # tools\mkconfig tool is built and used to create include\nuttx\config.h
tools\mkconfig: tools\mkconfig$(HOSTEXEEXT):
$(Q) $(MAKE) -C tools -f Makefile.host TOPDIR="$(TOPDIR)" mkconfig $(Q) $(MAKE) -C tools -f Makefile.host TOPDIR="$(TOPDIR)" mkconfig$(HOSTEXEEXT)
include\nuttx\config.h: $(TOPDIR)\.config tools\mkconfig include\nuttx\config.h: $(TOPDIR)\.config tools\mkconfig$(HOSTEXEEXT)
$(Q) tools\mkconfig $(TOPDIR) > include\nuttx\config.h $(Q) tools\mkconfig$(HOSTEXEEXT) $(TOPDIR) > include\nuttx\config.h
# Targets used to create dependencies
tools/mkdeps$(HOSTEXEEXT):
$(Q) $(MAKE) -C tools -f Makefile.host TOPDIR="$(TOPDIR)" mkdeps$(HOSTEXEEXT)
# dirlinks, and helpers # dirlinks, and helpers
# #
@ -566,7 +571,7 @@ lib\libc$(LIBEXT): libc\libc$(LIBEXT)
# is an archive. Exactly what is performed during pass1 or what it generates # is an archive. Exactly what is performed during pass1 or what it generates
# is unknown to this makefule unless CONFIG_PASS1_OBJECT is defined. # is unknown to this makefule unless CONFIG_PASS1_OBJECT is defined.
pass1deps: context pass1dep $(USERLIBS) pass1deps: pass1dep $(USERLIBS)
pass1: pass1deps pass1: pass1deps
ifeq ($(CONFIG_BUILD_2PASS),y) ifeq ($(CONFIG_BUILD_2PASS),y)
@ -585,7 +590,7 @@ ifeq ($(CONFIG_BUILD_2PASS),y)
$(Q) $(MAKE) -C $(CONFIG_PASS1_BUILDIR) TOPDIR="$(TOPDIR)" LINKLIBS="$(LINKLIBS)" USERLIBS="$(USERLIBS)" "$(CONFIG_PASS1_TARGET)" $(Q) $(MAKE) -C $(CONFIG_PASS1_BUILDIR) TOPDIR="$(TOPDIR)" LINKLIBS="$(LINKLIBS)" USERLIBS="$(USERLIBS)" "$(CONFIG_PASS1_TARGET)"
endif endif
pass2deps: context pass2dep $(NUTTXLIBS) pass2deps: pass2dep $(NUTTXLIBS)
pass2: pass2deps pass2: pass2deps
$(Q) $(MAKE) -C $(ARCH_SRC) TOPDIR="$(TOPDIR)" EXTRA_OBJS="$(EXTRA_OBJS)" LINKLIBS="$(LINKLIBS)" EXTRADEFINES=$(KDEFINE) $(BIN) $(Q) $(MAKE) -C $(ARCH_SRC) TOPDIR="$(TOPDIR)" EXTRA_OBJS="$(EXTRA_OBJS)" LINKLIBS="$(LINKLIBS)" EXTRADEFINES=$(KDEFINE) $(BIN)
@ -635,10 +640,10 @@ download: $(BIN)
# pass1dep: Create pass1 build dependencies # pass1dep: Create pass1 build dependencies
# pass2dep: Create pass2 build dependencies # pass2dep: Create pass2 build dependencies
pass1dep: context pass1dep: context tools/mkdeps$(HOSTEXEEXT)
$(Q) for %%G in ($(USERDEPDIRS)) do ( $(MAKE) -C %%G TOPDIR="$(TOPDIR)" depend ) $(Q) for %%G in ($(USERDEPDIRS)) do ( $(MAKE) -C %%G TOPDIR="$(TOPDIR)" depend )
pass2dep: context pass2dep: context tools/mkdeps$(HOSTEXEEXT)
$(Q) for %%G in ($(KERNDEPDIRS)) do ( $(MAKE) -C %%G TOPDIR="$(TOPDIR)" EXTRADEFINES=$(KDEFINE) depend ) $(Q) for %%G in ($(KERNDEPDIRS)) do ( $(MAKE) -C %%G TOPDIR="$(TOPDIR)" EXTRADEFINES=$(KDEFINE) depend )
# Configuration targets # Configuration targets

2
nuttx/configs/stm32f4discovery/winbuild/Make.defs

@ -135,3 +135,5 @@ HOSTCC = mingw-gcc.exe
HOSTINCLUDES = -I. HOSTINCLUDES = -I.
HOSTCFLAGS = -Wall -Wstrict-prototypes -Wshadow -g -pipe HOSTCFLAGS = -Wall -Wstrict-prototypes -Wshadow -g -pipe
HOSTLDFLAGS = HOSTLDFLAGS =
HOSTEXEEXT = .exe

58
nuttx/tools/Makefile.host

@ -37,10 +37,10 @@ TOPDIR ?= ${shell pwd}/..
-include $(TOPDIR)/Make.defs -include $(TOPDIR)/Make.defs
include ${TOPDIR}/tools/Config.mk include ${TOPDIR}/tools/Config.mk
all: mkconfig$(EXEEXT) mkversion$(EXEEXT) mksyscall$(EXEEXT) bdf-converter$(EXEEXT) mksymtab$(EXEEXT) mkdeps$(EXEEXT) all: mkconfig$(HOSTEXEEXT) mkversion$(HOSTEXEEXT) mksyscall$(HOSTEXEEXT) bdf-converter$(HOSTEXEEXT) mksymtab$(HOSTEXEEXT) mkdeps$(HOSTEXEEXT)
default: mkconfig$(EXEEXT) mksyscall$(EXEEXT) mkdeps$(EXEEXT) default: mkconfig$(HOSTEXEEXT) mksyscall$(HOSTEXEEXT) mkdeps$(HOSTEXEEXT)
ifdef EXEEXT ifdef HOSTEXEEXT
.PHONY: clean mkconfig mkversion mksyscall bdf-converter mksymtab mkdeps .PHONY: clean mkconfig mkversion mksyscall bdf-converter mksymtab mkdeps
else else
.PHONY: clean .PHONY: clean
@ -53,11 +53,11 @@ HOSTCC ?= gcc
# mkconfig - Convert a .config file into a C config.h file # mkconfig - Convert a .config file into a C config.h file
mkconfig$(EXEEXT): mkconfig.c cfgparser.c mkconfig$(HOSTEXEEXT): mkconfig.c cfgparser.c
$(Q) $(HOSTCC) $(HOSTCFLAGS) -o mkconfig$(EXEEXT) mkconfig.c cfgparser.c $(Q) $(HOSTCC) $(HOSTCFLAGS) -o mkconfig$(HOSTEXEEXT) mkconfig.c cfgparser.c
ifdef EXEEXT ifdef HOSTEXEEXT
mkconfig: mkconfig$(EXEEXT) mkconfig: mkconfig$(HOSTEXEEXT)
endif endif
# cmpconfig - Compare the contents of two configuration files # cmpconfig - Compare the contents of two configuration files
@ -65,53 +65,53 @@ endif
cmpconfig: cmpconfig.c cmpconfig: cmpconfig.c
$(Q) $(HOSTCC) $(HOSTCFLAGS) -o cmpconfig cmpconfig.c $(Q) $(HOSTCC) $(HOSTCFLAGS) -o cmpconfig cmpconfig.c
ifdef EXEEXT ifdef HOSTEXEEXT
cmpconfig: cmpconfig$(EXEEXT) cmpconfig: cmpconfig$(HOSTEXEEXT)
endif endif
# mkversion - Convert a .version file into a C version.h file # mkversion - Convert a .version file into a C version.h file
mkversion$(EXEEXT): mkconfig.c cfgparser.c mkversion$(HOSTEXEEXT): mkconfig.c cfgparser.c
$(Q) $(HOSTCC) $(HOSTCFLAGS) -o mkversion$(EXEEXT) mkversion.c cfgparser.c $(Q) $(HOSTCC) $(HOSTCFLAGS) -o mkversion$(HOSTEXEEXT) mkversion.c cfgparser.c
ifdef EXEEXT ifdef HOSTEXEEXT
mkversion: mkversion$(EXEEXT) mkversion: mkversion$(HOSTEXEEXT)
endif endif
# mksyscall - Convert a CSV file into syscall stubs and proxies # mksyscall - Convert a CSV file into syscall stubs and proxies
mksyscall$(EXEEXT): mksyscall.c csvparser.c mksyscall$(HOSTEXEEXT): mksyscall.c csvparser.c
$(Q) $(HOSTCC) $(HOSTCFLAGS) -o mksyscall$(EXEEXT) mksyscall.c csvparser.c $(Q) $(HOSTCC) $(HOSTCFLAGS) -o mksyscall$(HOSTEXEEXT) mksyscall.c csvparser.c
ifdef EXEEXT ifdef HOSTEXEEXT
mksyscall: mksyscall$(EXEEXT) mksyscall: mksyscall$(HOSTEXEEXT)
endif endif
# mksymtab - Convert a CSV file into a symbol table # mksymtab - Convert a CSV file into a symbol table
mksymtab$(EXEEXT): mksymtab.c csvparser.c mksymtab$(HOSTEXEEXT): mksymtab.c csvparser.c
$(Q) $(HOSTCC) $(HOSTCFLAGS) -o mksymtab$(EXEEXT) mksymtab.c csvparser.c $(Q) $(HOSTCC) $(HOSTCFLAGS) -o mksymtab$(HOSTEXEEXT) mksymtab.c csvparser.c
ifdef EXEEXT ifdef HOSTEXEEXT
mksymtab: mksymtab$(EXEEXT) mksymtab: mksymtab$(HOSTEXEEXT)
endif endif
# bdf-converter - Converts a BDF font to the NuttX font format # bdf-converter - Converts a BDF font to the NuttX font format
bdf-converter$(EXEEXT): bdf-converter.c bdf-converter$(HOSTEXEEXT): bdf-converter.c
$(Q) $(HOSTCC) $(HOSTCFLAGS) -o bdf-converter$(EXEEXT) bdf-converter.c $(Q) $(HOSTCC) $(HOSTCFLAGS) -o bdf-converter$(HOSTEXEEXT) bdf-converter.c
ifdef EXEEXT ifdef HOSTEXEEXT
bdf-converter: bdf-converter$(EXEEXT) bdf-converter: bdf-converter$(HOSTEXEEXT)
endif endif
# Create dependencies for a list of files # Create dependencies for a list of files
mkdeps$(EXEEXT): mkdeps.c csvparser.c mkdeps$(HOSTEXEEXT): mkdeps.c csvparser.c
$(Q) $(HOSTCC) $(HOSTCFLAGS) -o mkdeps$(EXEEXT) mkdeps.c $(Q) $(HOSTCC) $(HOSTCFLAGS) -o mkdeps$(HOSTEXEEXT) mkdeps.c
ifdef EXEEXT ifdef HOSTEXEEXT
mkdeps: mkdeps$(EXEEXT) mkdeps: mkdeps$(HOSTEXEEXT)
endif endif
clean: clean:

13
nuttx/tools/mkdeps.c

@ -105,7 +105,7 @@ static void append(char **base, char *str)
} }
else else
{ {
alloclen = strlen(newbase) + strlen(str) + 2; alloclen = strlen(oldbase) + strlen(str) + 2;
newbase = (char *)malloc(alloclen); newbase = (char *)malloc(alloclen);
if (!newbase) if (!newbase)
{ {
@ -288,7 +288,6 @@ static void do_dependency(const char *file, char separator)
struct stat buf; struct stat buf;
char *altpath; char *altpath;
char *path; char *path;
char *bufptr;
int cmdlen; int cmdlen;
int pathlen; int pathlen;
int filelen; int filelen;
@ -300,7 +299,7 @@ static void do_dependency(const char *file, char separator)
cmdlen = strlen(g_cc); cmdlen = strlen(g_cc);
if (cmdlen >= MAX_BUFFER) if (cmdlen >= MAX_BUFFER)
{ {
fprintf(stderr, "ERROR: Compiler string is too long: %s\n", path); fprintf(stderr, "ERROR: Compiler string is too long: %s\n", g_cc);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
@ -355,7 +354,7 @@ static void do_dependency(const char *file, char separator)
if (command[totallen] != '\0') if (command[totallen] != '\0')
{ {
fprintf(stderr, "ERROR: Missing NUL terminator\n", path); fprintf(stderr, "ERROR: Missing NUL terminator\n");
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
@ -379,7 +378,7 @@ static void do_dependency(const char *file, char separator)
/* Check that a file actually exists at this path */ /* Check that a file actually exists at this path */
ret = stat(command, &buf); ret = stat(&command[cmdlen], &buf);
if (ret < 0) if (ret < 0)
{ {
altpath = NULL; altpath = NULL;
@ -388,7 +387,7 @@ static void do_dependency(const char *file, char separator)
if (!S_ISREG(buf.st_mode)) if (!S_ISREG(buf.st_mode))
{ {
fprintf(stderr, "ERROR: File %s exists but is not a regular file\n"); fprintf(stderr, "ERROR: File %s exists but is not a regular file\n", &command[cmdlen]);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }
@ -397,7 +396,7 @@ static void do_dependency(const char *file, char separator)
ret = system(command); ret = system(command);
if (ret != 0) if (ret != 0)
{ {
fprintf(stderr, "ERROR: ssystem(%s) failed\n"); fprintf(stderr, "ERROR: ssystem(%s) failed\n", command);
exit(EXIT_FAILURE); exit(EXIT_FAILURE);
} }

Loading…
Cancel
Save