From f522aba4afdcde0c8a1c8c9e8ee7f5e46f1999c8 Mon Sep 17 00:00:00 2001 From: David Given Date: Wed, 29 May 2013 17:10:58 +0100 Subject: [PATCH 01/13] Add support for snprintf and vsnprintf. Try and make the return value a bit more standards-compliant. --HG-- extra : source : a19eb606871f918e3d9e195b487b5276855edc8e --- lang/cem/libcc.ansi/build.mk | 2 ++ lang/cem/libcc.ansi/headers/stdio.h | 2 ++ lang/cem/libcc.ansi/stdio/doprnt.c | 42 +++++++++++++-------------- lang/cem/libcc.ansi/stdio/snprintf.c | 31 ++++++++++++++++++++ lang/cem/libcc.ansi/stdio/vsnprintf.c | 26 +++++++++++++++++ 5 files changed, 82 insertions(+), 21 deletions(-) create mode 100644 lang/cem/libcc.ansi/stdio/snprintf.c create mode 100644 lang/cem/libcc.ansi/stdio/vsnprintf.c diff --git a/lang/cem/libcc.ansi/build.mk b/lang/cem/libcc.ansi/build.mk index a9434ceb4..6140b4b50 100644 --- a/lang/cem/libcc.ansi/build.mk +++ b/lang/cem/libcc.ansi/build.mk @@ -133,9 +133,11 @@ $(call ackfile, lang/cem/libcc.ansi/stdio/perror.c) $(call ackfile, lang/cem/libcc.ansi/stdio/fprintf.c) $(call ackfile, lang/cem/libcc.ansi/stdio/printf.c) $(call ackfile, lang/cem/libcc.ansi/stdio/sprintf.c) +$(call ackfile, lang/cem/libcc.ansi/stdio/snprintf.c) $(call ackfile, lang/cem/libcc.ansi/stdio/vfprintf.c) $(call ackfile, lang/cem/libcc.ansi/stdio/vprintf.c) $(call ackfile, lang/cem/libcc.ansi/stdio/vsprintf.c) +$(call ackfile, lang/cem/libcc.ansi/stdio/vsnprintf.c) $(call ackfile, lang/cem/libcc.ansi/stdio/doprnt.c) $(call ackfile, lang/cem/libcc.ansi/stdio/icompute.c) $(call ackfile, lang/cem/libcc.ansi/stdio/fscanf.c) diff --git a/lang/cem/libcc.ansi/headers/stdio.h b/lang/cem/libcc.ansi/headers/stdio.h index 4c5a42a08..52f286f20 100644 --- a/lang/cem/libcc.ansi/headers/stdio.h +++ b/lang/cem/libcc.ansi/headers/stdio.h @@ -72,10 +72,12 @@ extern int fscanf(FILE *_stream, const char *_format, ...); extern int printf(const char *_format, ...); extern int scanf(const char *_format, ...); extern int sprintf(char *_s, const char *_format, ...); +extern int snprintf(char *_s, size_t _len, const char *_format, ...); extern int sscanf(const char *_s, const char *_format, ...); extern int vfprintf(FILE *_stream, const char *_format, char *_arg); extern int vprintf(const char *_format, char *_arg); extern int vsprintf(char *_s, const char *_format, char *_arg); +extern int vsnprintf(char *_s, size_t _len, const char *_format, char *_arg); extern int fgetc(FILE *_stream); extern char *fgets(char *_s, int _n, FILE *_stream); extern int fputc(int _c, FILE *_stream); diff --git a/lang/cem/libcc.ansi/stdio/doprnt.c b/lang/cem/libcc.ansi/stdio/doprnt.c index 81714de47..395c45704 100644 --- a/lang/cem/libcc.ansi/stdio/doprnt.c +++ b/lang/cem/libcc.ansi/stdio/doprnt.c @@ -38,6 +38,16 @@ gnum(register const char *f, int *ip, va_list *app) #define set_pointer(flags) /* compilation might continue */ #endif +#define PUTC(c) \ + do { \ + int i = putc(c, stream); \ + if (i == EOF) \ + { \ + if (ferror(stream)) \ + return -1; \ + } \ + } while (0) + /* print an ordinal number */ static char * o_print(va_list *ap, int flags, char *s, char c, int precision, int is_signed) @@ -125,13 +135,10 @@ _doprnt(register const char *fmt, va_list ap, FILE *stream) if (c != '%') { #ifdef CPM if (c == '\n') { - if (putc('\r', stream) == EOF) - return nrchars ? -nrchars : -1; - nrchars++; + PUTC('\r'); } #endif - if (putc(c, stream) == EOF) - return nrchars ? -nrchars : -1; + PUTC(c); nrchars++; continue; } @@ -181,13 +188,11 @@ _doprnt(register const char *fmt, va_list ap, FILE *stream) default: #ifdef CPM if (c == '\n') { - if (putc('\r', stream) == EOF) - return nrchars ? -nrchars : -1; + PUTC('\r'); nrchars++; } #endif - if (putc(c, stream) == EOF) - return nrchars ? -nrchars : -1; + PUTC(c); nrchars++; continue; case 'n': @@ -280,31 +285,26 @@ _doprnt(register const char *fmt, va_list ap, FILE *stream) if (between_fill) { if (flags & FL_SIGNEDCONV) { j--; nrchars++; - if (putc(*s1++, stream) == EOF) - return nrchars ? -nrchars : -1; + PUTC(*s1++); } else { j -= 2; nrchars += 2; - if ((putc(*s1++, stream) == EOF) - || (putc(*s1++, stream) == EOF)) - return nrchars ? -nrchars : -1; - } + PUTC(*s1++); + PUTC(*s1++); + } } do { - if (putc(zfill, stream) == EOF) - return nrchars ? -nrchars : -1; + PUTC(zfill); } while (--i); } nrchars += j; while (--j >= 0) { - if (putc(*s1++, stream) == EOF) - return nrchars ? -nrchars : -1; + PUTC(*s1++); } if (i > 0) nrchars += i; while (--i >= 0) - if (putc(zfill, stream) == EOF) - return nrchars ? -nrchars : -1; + PUTC(zfill); } return nrchars; } diff --git a/lang/cem/libcc.ansi/stdio/snprintf.c b/lang/cem/libcc.ansi/stdio/snprintf.c new file mode 100644 index 000000000..7d428118c --- /dev/null +++ b/lang/cem/libcc.ansi/stdio/snprintf.c @@ -0,0 +1,31 @@ +/* + * sprintf - print formatted output on an array + */ +/* $Id$ */ + +#include +#include +#include "loc_incl.h" + +int +snprintf(char * s, size_t len, const char *format, ...) +{ + va_list ap; + int retval; + FILE tmp_stream; + + va_start(ap, format); + + tmp_stream._fd = -1; + tmp_stream._flags = _IOWRITE + _IONBF + _IOWRITING; + tmp_stream._buf = (unsigned char *) s; + tmp_stream._ptr = (unsigned char *) s; + tmp_stream._count = len; + + retval = _doprnt(format, ap, &tmp_stream); + putc('\0',&tmp_stream); + + va_end(ap); + + return retval; +} diff --git a/lang/cem/libcc.ansi/stdio/vsnprintf.c b/lang/cem/libcc.ansi/stdio/vsnprintf.c new file mode 100644 index 000000000..870e23df2 --- /dev/null +++ b/lang/cem/libcc.ansi/stdio/vsnprintf.c @@ -0,0 +1,26 @@ +/* + * vsprintf - print formatted output without ellipsis on an array + */ +/* $Id$ */ + +#include +#include +#include "loc_incl.h" + +int +vsnprintf(char *s, size_t len, const char *format, va_list arg) +{ + int retval; + FILE tmp_stream; + + tmp_stream._fd = -1; + tmp_stream._flags = _IOWRITE + _IONBF + _IOWRITING; + tmp_stream._buf = (unsigned char *) s; + tmp_stream._ptr = (unsigned char *) s; + tmp_stream._count = len; + + retval = _doprnt(format, arg, &tmp_stream); + putc('\0',&tmp_stream); + + return retval; +} From d273497077b7dda5430ab61fa4b5f39167856fad Mon Sep 17 00:00:00 2001 From: David Given Date: Wed, 29 May 2013 21:41:58 +0100 Subject: [PATCH 02/13] Add some missing libc functions: setenv, unsetenv, strdup. --HG-- rename : lang/cem/libcc.ansi/stdlib/getenv.c => lang/cem/libcc.ansi/stdlib/setenv.c rename : lang/cem/libcc.ansi/string/strlen.c => lang/cem/libcc.ansi/string/strdup.c extra : source : 64d6e6eec18d76bf8f3947ec5d171db94acdb282 --- lang/cem/libcc.ansi/build.mk | 2 + lang/cem/libcc.ansi/headers/stdlib.h | 3 + lang/cem/libcc.ansi/headers/string.h | 3 + lang/cem/libcc.ansi/misc/putenv.c | 22 ++++--- lang/cem/libcc.ansi/stdlib/getenv.c | 56 +++++++++++++----- lang/cem/libcc.ansi/stdlib/setenv.c | 87 ++++++++++++++++++++++++++++ lang/cem/libcc.ansi/string/strdup.c | 17 ++++++ 7 files changed, 162 insertions(+), 28 deletions(-) create mode 100644 lang/cem/libcc.ansi/stdlib/setenv.c create mode 100644 lang/cem/libcc.ansi/string/strdup.c diff --git a/lang/cem/libcc.ansi/build.mk b/lang/cem/libcc.ansi/build.mk index 6140b4b50..5987de9e3 100644 --- a/lang/cem/libcc.ansi/build.mk +++ b/lang/cem/libcc.ansi/build.mk @@ -186,6 +186,7 @@ $(call ackfile, lang/cem/libcc.ansi/stdlib/div.c) $(call ackfile, lang/cem/libcc.ansi/stdlib/atexit.c) $(call ackfile, lang/cem/libcc.ansi/stdlib/exit.c) $(call ackfile, lang/cem/libcc.ansi/stdlib/getenv.c) +$(call ackfile, lang/cem/libcc.ansi/stdlib/setenv.c) $(call ackfile, lang/cem/libcc.ansi/stdlib/labs.c) $(call ackfile, lang/cem/libcc.ansi/stdlib/ldiv.c) $(call ackfile, lang/cem/libcc.ansi/stdlib/mblen.c) @@ -238,6 +239,7 @@ $(call ackfile, lang/cem/libcc.ansi/string/strpbrk.c) $(call ackfile, lang/cem/libcc.ansi/string/strspn.c) $(call ackfile, lang/cem/libcc.ansi/string/strncmp.c) $(call ackfile, lang/cem/libcc.ansi/string/strxfrm.c) +$(call ackfile, lang/cem/libcc.ansi/string/strdup.c) # Time diff --git a/lang/cem/libcc.ansi/headers/stdlib.h b/lang/cem/libcc.ansi/headers/stdlib.h index c14db91a8..64a6de16c 100644 --- a/lang/cem/libcc.ansi/headers/stdlib.h +++ b/lang/cem/libcc.ansi/headers/stdlib.h @@ -36,6 +36,9 @@ extern int atexit(void (*_func)(void)); extern void exit(int _status); extern void _Exit(int _status); extern char* getenv(const char *_name); +extern int setenv(const char *_name, const char *_value, int _overwrite); +extern int unsetenv(const char *_name); +extern int putenv(char *_string); extern int system(const char *_string); extern void* bsearch(const void *_key, const void *_base, size_t _nmemb, size_t _size, diff --git a/lang/cem/libcc.ansi/headers/string.h b/lang/cem/libcc.ansi/headers/string.h index b9d50617b..eef924f74 100644 --- a/lang/cem/libcc.ansi/headers/string.h +++ b/lang/cem/libcc.ansi/headers/string.h @@ -33,5 +33,8 @@ extern char *strtok(char *_s1, const char *_s2); extern void *memset(void *_s, int _c, size_t _n); extern char *strerror(int _errnum); extern size_t strlen(const char *_s); +extern char *strdup(const char *_s); + +#define bcopy(s, d, z) memmove(d, s, z) #endif diff --git a/lang/cem/libcc.ansi/misc/putenv.c b/lang/cem/libcc.ansi/misc/putenv.c index dc448fef2..a1f94aba4 100644 --- a/lang/cem/libcc.ansi/misc/putenv.c +++ b/lang/cem/libcc.ansi/misc/putenv.c @@ -10,18 +10,17 @@ #define ENTRY_INC 10 #define rounded(x) (((x / ENTRY_INC) + 1) * ENTRY_INC) -extern const char **_penvp; -extern const char **environ; /* environ is a shadow name for _penvp */ +extern char **environ; int putenv(char *name) { - register const char **v = _penvp; + register char **v = environ; register char *r; static int size = 0; /* When size != 0, it contains the number of entries in the * table (including the final NULL pointer). This means that the - * last non-null entry is _penvp[size - 2]. + * last non-null entry is environ[size - 2]. */ if (!name) return 0; @@ -48,11 +47,11 @@ putenv(char *name) } } *r = '='; - v = _penvp; + v = environ; } if (!size) { - register const char **p; + register char **p; register int i = 0; if (v) @@ -62,18 +61,17 @@ putenv(char *name) if (!(v = malloc(rounded(i) * sizeof(char **)))) return 1; size = i; - p = _penvp; - _penvp = v; + p = environ; + environ = v; while (*v++ = *p++); /* copy the environment */ - v = _penvp; + v = environ; } else if (!(size % ENTRY_INC)) { - if (!(v = realloc(_penvp, rounded(size) * sizeof(char **)))) + if (!(v = realloc(environ, rounded(size) * sizeof(char **)))) return 1; - _penvp = v; + environ = v; } v[size - 1] = name; v[size] = NULL; size++; - environ = _penvp; return 0; } diff --git a/lang/cem/libcc.ansi/stdlib/getenv.c b/lang/cem/libcc.ansi/stdlib/getenv.c index 01b887a1d..592e0c05d 100644 --- a/lang/cem/libcc.ansi/stdlib/getenv.c +++ b/lang/cem/libcc.ansi/stdlib/getenv.c @@ -5,23 +5,47 @@ /* $Id$ */ #include -#include +#include -char * -getenv(const char *name) +extern char* _findenv(const char* name, int* offset); + +/* + * getenv(name) -- + * Returns ptr to value associated with name, if any, else NULL. + */ +char* getenv(const char* name) { - register char **v = environ; - register const char *p, *q; + int offset; - if (v == NULL || name == NULL) - return (char *)NULL; - while ((p = *v++) != NULL) { - q = name; - while (*q && (*q == *p++)) - q++; - if (*q || (*p != '=')) - continue; - return (char *)p + 1; - } - return (char *)NULL; + return(_findenv(name,&offset)); } + +/* + * _findenv(name,offset) -- + * Returns pointer to value associated with name, if any, else NULL. + * Sets offset to be the offset of the name/value combination in the + * environmental array, for use by setenv(3) and unsetenv(3). + * Explicitly removes '=' in argument name. + * + * This routine *should* be a static; don't use it. + */ +char* _findenv(register const char* name, int* offset) +{ + extern char **environ; + register int len; + register char **P; + register const char *C; + + if (!environ) + return NULL; + + for (C = name,len = 0;*C && *C != '=';++C,++len); + for (P = environ;*P;++P) + if (!strncmp(*P,name,len)) + if (*(C = *P + len) == '=') { + *offset = P - environ; + return (char*)(++C); + } + return(NULL); +} + diff --git a/lang/cem/libcc.ansi/stdlib/setenv.c b/lang/cem/libcc.ansi/stdlib/setenv.c new file mode 100644 index 000000000..086b2118d --- /dev/null +++ b/lang/cem/libcc.ansi/stdlib/setenv.c @@ -0,0 +1,87 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* $Id$ */ + +#include +#include + +extern char* _findenv(const char* name, int* offset); +extern char **environ; + +/* + * setenv(name,value,rewrite) + * Set the value of the environmental variable "name" to be + * "value". If rewrite is set, replace any current value. + */ +int setenv(register const char* name, register const char* value, int rewrite) +{ + static int alloced = 0; /* if allocated space before */ + register char *C; + int l_value, + offset; + + if (*value == '=') /* no `=' in value */ + ++value; + l_value = strlen(value); + if ((C = _findenv(name,&offset))) { /* find if already exists */ + if (!rewrite) + return(0); + if (strlen(C) >= l_value) { /* old larger; copy over */ + while (*C++ = *value++); + return(0); + } + } + else { /* create new slot */ + register int cnt = 0; + register char **P; + + if (environ) + for (P = environ;*P;++P,++cnt); + if (alloced) { /* just increase size */ + environ = (char **)realloc((char *)environ, + (unsigned)(sizeof(char *) * (cnt + 2))); + if (!environ) + return(-1); + } + else { /* get new space */ + alloced = 1; /* copy old entries into it */ + P = (char **)malloc((unsigned)(sizeof(char *) * + (cnt + 2))); + if (!P) + return(-1); + if (environ) + bcopy(environ,P,cnt * sizeof(char *)); + environ = P; + } + environ[cnt + 1] = NULL; + offset = cnt; + } + for (C = name;*C && *C != '=';++C); /* no `=' in name */ + if (!(environ[offset] = /* name + `=' + value */ + malloc((unsigned)((int)(C - name) + l_value + 2)))) + return(-1); + for (C = environ[offset];(*C = *name++) && *C != '=';++C); + for (*C++ = '=';*C++ = *value++;); + return(0); +} + +/* + * unsetenv(name) -- + * Delete environmental variable "name". + */ +int +unsetenv(const char* name) +{ + register char **P; + int offset; + + while (_findenv(name,&offset)) /* if set multiple times */ + for (P = &environ[offset];;++P) + if (!(*P = *(P + 1))) + break; + + return 0; +} + diff --git a/lang/cem/libcc.ansi/string/strdup.c b/lang/cem/libcc.ansi/string/strdup.c new file mode 100644 index 000000000..730796b5f --- /dev/null +++ b/lang/cem/libcc.ansi/string/strdup.c @@ -0,0 +1,17 @@ +/* + * (c) copyright 1987 by the Vrije Universiteit, Amsterdam, The Netherlands. + * See the copyright notice in the ACK home directory, in the file "Copyright". + */ +/* $Id$ */ + +#include + +char* +strdup(const char *s) +{ + int len = strlen(s); + char *p = malloc(len+1); + if (p) + memcpy(p, s, len+1); + return p; +} From aacabba16584ab2db0b6580d873679c1522c2b05 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 2 Jun 2013 22:02:15 +0100 Subject: [PATCH 03/13] Apply fix contributed by George Koehler: - don't crash if BSS overlaps BDOS - fix stack initialisation bug - fix command line argification --- plat/cpm/boot.s | 86 ++++++++++++++++++++++++++----------------------- 1 file changed, 45 insertions(+), 41 deletions(-) diff --git a/plat/cpm/boot.s b/plat/cpm/boot.s index b36d1ce02..960dc400d 100644 --- a/plat/cpm/boot.s +++ b/plat/cpm/boot.s @@ -15,12 +15,21 @@ MAX_ARGV = 8 .sect .bss STACKSIZE = 2*1024 .comm stack, STACKSIZE -.comm oldstack, 2 .sect .text begtext: - ! The absolute first thing we have to do is to clear the bss. (argify - ! requires it.) + ! Check if bss would overlap BDOS. We must not overwrite + ! BDOS and crash CP/M. We cheat by comparing only high bytes + ! of each address. + + lxi b, __end + lda 0x0007 + mov c, a ! c = high byte of BDOS address + mov a, b ! a = high byte of _end + cmp c + jnc __exit ! emergency exit if a >= c + + ! We have to clear the bss. (argify requires it.) lxi h, begbss lxi b, endbss @@ -36,8 +45,8 @@ begtext: jnz 1b ! Set up the stack (now it's been cleared, since it's in the BSS). - - lxi sp, oldstack + STACKSIZE + + lxi sp, stack + STACKSIZE ! C-ify the command line at 0x0080. @@ -54,43 +63,38 @@ begtext: ! Now argify it. lxi b, 0x0081 ! bc = command line pointer - lxi d, argv ! de = argv pointer - - ldax b ! peek for any leading whitespace - ora a - cpi ' ' - jz 3f - -1: xchg ! write out the next argument - mov m, c - inx h - mov m, b - inx h - xchg + lxi h, argv ! hl = argv pointer - lda argc ! exit if this was the last argument +loop_of_argify: + ldax b ! a = next character + ora a ! check for end of string + jz end_of_argify + cpi ' ' ! scan for non-space + jz 2f + + mov m, c ! put next argument in argv + inx h + mov m, b + inx h + + lda argc ! increment argc inr a sta argc - cpi MAX_ARGV - jz end_of_argify - -2: inx b ! scan for whitespace - ldax b - ora a - jz end_of_argify - cpi ' ' - jnz 2b - - xra a ! replace the space with a \0 - stax b - -3: inx b ! scan for non-whitespace - ldax b - ora a - jz end_of_argify - cpi ' ' - jz 3b - jmp 1b + cpi MAX_ARGV ! exit loop if argv is full + jz end_of_argify + +1: inx b ! scan for space + ldax b + ora a + jz end_of_argify + cpi ' ' + jnz 1b + + xra a ! replace the space with a '\0' + stax b + +2: inx b + jmp loop_of_argify end_of_argify: ! Add the fake parameter for the program name. @@ -110,8 +114,8 @@ end_of_argify: mvi h, 0 push h call __m_a_i_n - jmp EXIT - + ! FALLTHROUGH + ! Emergency exit routine. .define EXIT, __exit From 6a340ea1bd8798b7c538ab794d76c555d4fdedad Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 31 Aug 2014 13:40:39 +0200 Subject: [PATCH 04/13] Remove regrettable comment. --- util/grind/run.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/util/grind/run.c b/util/grind/run.c index 0b793ba13..ce19af8e3 100644 --- a/util/grind/run.c +++ b/util/grind/run.c @@ -114,9 +114,7 @@ start_child(p) char *in_redirect = 0; /* standard input redirected */ char *out_redirect = 0; /* standard output redirected */ - signal_child(SIGKILL); /* like families in China, this debugger is only - allowed one child - */ + signal_child(SIGKILL); if (p != run_command) { freenode(run_command); From 2271bcd0a705b67c4d30cfa3b32cfcb5c71be8ba Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 9 Nov 2014 18:47:51 +0100 Subject: [PATCH 05/13] Fixed a parallel build race condition (forgot to declare a dependency to the makefile). --- util/ncgg/build.mk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/util/ncgg/build.mk b/util/ncgg/build.mk index c3a7f31fa..aaa81769f 100644 --- a/util/ncgg/build.mk +++ b/util/ncgg/build.mk @@ -26,7 +26,7 @@ $(call cfile, $D/var.c) $(call cfile, $D/hall.c) $(eval CLEANABLES += $(OBJDIR)/$D/enterkeyw.c) -$(OBJDIR)/$D/enterkeyw.c: $D/cvtkeywords $D/keywords +$(OBJDIR)/$D/enterkeyw.c: $D/cvtkeywords $D/keywords $(OBJDIR)/$D/y.tab.h @echo KEYWORDS $$@ @mkdir -p $$(dir $$@) $(hide) cd $$(dir $$@) && sh $(abspath $D/cvtkeywords) $(abspath $D/keywords) From 3d5e72e20b3651895693eaf21eb415287546d212 Mon Sep 17 00:00:00 2001 From: David Given Date: Sun, 22 Mar 2015 12:09:46 +0100 Subject: [PATCH 06/13] Newer versions of GNU Make have a new function which collides with a variable we're using; change the name of the variable. --- first/core.mk | 2 +- lang/basic/src/build.mk | 14 +++++++------- lang/cem/cemcom.ansi/build.mk | 20 ++++++++++---------- lang/cem/cpp.ansi/build.mk | 12 ++++++------ lang/m2/comp/build.mk | 20 ++++++++++---------- lang/m2/libm2/build.mk | 2 +- lang/pc/comp/build.mk | 20 ++++++++++---------- mach/proto/as/build.mk | 2 +- mach/proto/ncg/build.mk | 4 ++-- util/amisc/build.mk | 2 +- util/arch/build.mk | 8 ++++---- util/ego/build.mk | 10 +++++----- util/led/build.mk | 4 ++-- util/misc/build.mk | 28 ++++++++++++++-------------- util/ncgg/build.mk | 2 +- util/opt/build.mk | 21 ++++++++++++--------- util/topgen/build.mk | 10 +++++----- 17 files changed, 92 insertions(+), 89 deletions(-) diff --git a/first/core.mk b/first/core.mk index d2e32fc68..261a2c30e 100644 --- a/first/core.mk +++ b/first/core.mk @@ -51,7 +51,7 @@ endef # --- Add a raw to the queue -define file +define rawfile $(eval q += $1) endef diff --git a/lang/basic/src/build.mk b/lang/basic/src/build.mk index 00d429107..95019babd 100644 --- a/lang/basic/src/build.mk +++ b/lang/basic/src/build.mk @@ -29,13 +29,13 @@ $g: $D/maketokentab $(OBJDIR)/$D/Lpars.h $(eval $q: $(OBJDIR)/$D/Lpars.h) $(eval $q: $(INCDIR)/print.h) -$(call file, $(LIBEM_MES)) -$(call file, $(LIBEMK)) -$(call file, $(LIBEM_DATA)) -$(call file, $(LIBALLOC)) -$(call file, $(LIBPRINT)) -$(call file, $(LIBSTRING)) -$(call file, $(LIBSYSTEM)) +$(call rawfile, $(LIBEM_MES)) +$(call rawfile, $(LIBEMK)) +$(call rawfile, $(LIBEM_DATA)) +$(call rawfile, $(LIBALLOC)) +$(call rawfile, $(LIBPRINT)) +$(call rawfile, $(LIBSTRING)) +$(call rawfile, $(LIBSYSTEM)) $(call cprogram, $(BINDIR)/em_bem) $(call installto, $(PLATDEP)/em_bem) diff --git a/lang/cem/cemcom.ansi/build.mk b/lang/cem/cemcom.ansi/build.mk index 0e6b45267..1f2b483ec 100644 --- a/lang/cem/cemcom.ansi/build.mk +++ b/lang/cem/cemcom.ansi/build.mk @@ -134,16 +134,16 @@ $(call build-cemcom-ansi-next, \ $(eval $q: $(OBJDIR)/$D/Lpars.h) -$(call file, $(LIBEM_MES)) -$(call file, $(LIBEMK)) -$(call file, $(LIBEM_DATA)) -$(call file, $(LIBINPUT)) -$(call file, $(LIBASSERT)) -$(call file, $(LIBALLOC)) -$(call file, $(LIBFLT_ARITH)) -$(call file, $(LIBPRINT)) -$(call file, $(LIBSYSTEM)) -$(call file, $(LIBSTRING)) +$(call rawfile, $(LIBEM_MES)) +$(call rawfile, $(LIBEMK)) +$(call rawfile, $(LIBEM_DATA)) +$(call rawfile, $(LIBINPUT)) +$(call rawfile, $(LIBASSERT)) +$(call rawfile, $(LIBALLOC)) +$(call rawfile, $(LIBFLT_ARITH)) +$(call rawfile, $(LIBPRINT)) +$(call rawfile, $(LIBSYSTEM)) +$(call rawfile, $(LIBSTRING)) $(call cprogram, $(BINDIR)/cemcom.ansi) $(call installto, $(PLATDEP)/em_cemcom.ansi) $(eval CEMCOMANSI := $o) diff --git a/lang/cem/cpp.ansi/build.mk b/lang/cem/cpp.ansi/build.mk index e102c523b..be03bc958 100644 --- a/lang/cem/cpp.ansi/build.mk +++ b/lang/cem/cpp.ansi/build.mk @@ -71,12 +71,12 @@ define build-cpp-ansi-impl $(call llgen, $(OBJDIR)/$D, $(OBJDIR)/$D/tokenfile.g $D/expression.g) - $(call file, $(LIBINPUT)) - $(call file, $(LIBASSERT)) - $(call file, $(LIBALLOC)) - $(call file, $(LIBPRINT)) - $(call file, $(LIBSYSTEM)) - $(call file, $(LIBSTRING)) + $(call rawfile, $(LIBINPUT)) + $(call rawfile, $(LIBASSERT)) + $(call rawfile, $(LIBALLOC)) + $(call rawfile, $(LIBPRINT)) + $(call rawfile, $(LIBSYSTEM)) + $(call rawfile, $(LIBSTRING)) $(call tabgen, $D/char.tab) diff --git a/lang/m2/comp/build.mk b/lang/m2/comp/build.mk index a3be0ee7a..18ca8b7dd 100644 --- a/lang/m2/comp/build.mk +++ b/lang/m2/comp/build.mk @@ -108,16 +108,16 @@ $(eval $q: $(INCDIR)/em_codeEK.h) $(eval $q: $(INCDIR)/print.h) $(eval $q: $(INCDIR)/system.h) -$(call file, $(LIBEM_MES)) -$(call file, $(LIBEMK)) -$(call file, $(LIBEM_DATA)) -$(call file, $(LIBINPUT)) -$(call file, $(LIBASSERT)) -$(call file, $(LIBALLOC)) -$(call file, $(LIBFLT_ARITH)) -$(call file, $(LIBPRINT)) -$(call file, $(LIBSYSTEM)) -$(call file, $(LIBSTRING)) +$(call rawfile, $(LIBEM_MES)) +$(call rawfile, $(LIBEMK)) +$(call rawfile, $(LIBEM_DATA)) +$(call rawfile, $(LIBINPUT)) +$(call rawfile, $(LIBASSERT)) +$(call rawfile, $(LIBALLOC)) +$(call rawfile, $(LIBFLT_ARITH)) +$(call rawfile, $(LIBPRINT)) +$(call rawfile, $(LIBSYSTEM)) +$(call rawfile, $(LIBSTRING)) $(call cprogram, $(BINDIR)/em_m2) $(call installto, $(PLATDEP)/em_m2) diff --git a/lang/m2/libm2/build.mk b/lang/m2/libm2/build.mk index 7dadeb347..1ebc89cc3 100644 --- a/lang/m2/libm2/build.mk +++ b/lang/m2/libm2/build.mk @@ -95,7 +95,7 @@ $(eval g := \ $(foreach f, $g, \ $(call reset) \ - $(call file, lang/m2/libm2/$f) \ + $(call rawfile, lang/m2/libm2/$f) \ $(call installto, $(PLATIND)/include/modula2/$f)) endef diff --git a/lang/pc/comp/build.mk b/lang/pc/comp/build.mk index 2939c4524..c3b4dd918 100644 --- a/lang/pc/comp/build.mk +++ b/lang/pc/comp/build.mk @@ -111,16 +111,16 @@ $(eval $q: $(INCDIR)/em_codeEK.h) $(eval $q: $(INCDIR)/print.h) $(eval $q: $(INCDIR)/system.h) -$(call file, $(LIBEM_MES)) -$(call file, $(LIBEMK)) -$(call file, $(LIBEM_DATA)) -$(call file, $(LIBINPUT)) -$(call file, $(LIBASSERT)) -$(call file, $(LIBALLOC)) -$(call file, $(LIBFLT_ARITH)) -$(call file, $(LIBPRINT)) -$(call file, $(LIBSYSTEM)) -$(call file, $(LIBSTRING)) +$(call rawfile, $(LIBEM_MES)) +$(call rawfile, $(LIBEMK)) +$(call rawfile, $(LIBEM_DATA)) +$(call rawfile, $(LIBINPUT)) +$(call rawfile, $(LIBASSERT)) +$(call rawfile, $(LIBALLOC)) +$(call rawfile, $(LIBFLT_ARITH)) +$(call rawfile, $(LIBPRINT)) +$(call rawfile, $(LIBSYSTEM)) +$(call rawfile, $(LIBSTRING)) $(call cprogram, $(BINDIR)/em_pc) $(call installto, $(PLATDEP)/em_pc) diff --git a/mach/proto/as/build.mk b/mach/proto/as/build.mk index 64eaab1e9..fce5ec204 100644 --- a/mach/proto/as/build.mk +++ b/mach/proto/as/build.mk @@ -36,7 +36,7 @@ $(OBJDIR)/$D/preprocessed-comm2.y: mach/proto/as/comm2.y $(CPPANSI) \ -Ih \ mach/proto/as/comm2.y > $$@ - $(call file, $(LIBOBJECT)) + $(call rawfile, $(LIBOBJECT)) $(call cprogram, $(BINDIR)/$(PLATFORM)/as) $(call installto, $(PLATDEP)/$(PLATFORM)/as) endef diff --git a/mach/proto/ncg/build.mk b/mach/proto/ncg/build.mk index 1bbda2b49..0056452c1 100644 --- a/mach/proto/ncg/build.mk +++ b/mach/proto/ncg/build.mk @@ -36,8 +36,8 @@ $(call cfile, $(OBJDIR)/$D/tables.c) $(eval $q: $(INCDIR)/flt_arith.h) -$(call file, $(LIBEM_DATA)) -$(call file, $(LIBFLT_ARITH)) +$(call rawfile, $(LIBEM_DATA)) +$(call rawfile, $(LIBFLT_ARITH)) $(call cprogram, $(BINDIR)/$(PLATFORM)/ncg) $(call installto, $(PLATDEP)/$(PLATFORM)/ncg) diff --git a/util/amisc/build.mk b/util/amisc/build.mk index 03f44b5e9..286b8f305 100644 --- a/util/amisc/build.mk +++ b/util/amisc/build.mk @@ -2,7 +2,7 @@ define build-simple-tool-impl $(call reset) $(call cfile, util/amisc/$1.c) - $(call file, $(LIBOBJECT)) + $(call rawfile, $(LIBOBJECT)) $(call cprogram, $(BINDIR)/$1) $(eval INSTALLABLES += $o) $(call installto, $(INSDIR)/bin/$1) diff --git a/util/arch/build.mk b/util/arch/build.mk index 4d283f881..11851f5c9 100644 --- a/util/arch/build.mk +++ b/util/arch/build.mk @@ -6,10 +6,10 @@ define build-aal-impl $(call cfile, $D/archiver.c) - $(call file, $(LIBOBJECT)) - $(call file, $(LIBPRINT)) - $(call file, $(LIBSTRING)) - $(call file, $(LIBSYSTEM)) + $(call rawfile, $(LIBOBJECT)) + $(call rawfile, $(LIBPRINT)) + $(call rawfile, $(LIBSTRING)) + $(call rawfile, $(LIBSYSTEM)) $(call cprogram, $(BINDIR)/aal) $(call installto, $(INSDIR)/bin/aal) diff --git a/util/ego/build.mk b/util/ego/build.mk index ee1e7f865..2fba61ff3 100644 --- a/util/ego/build.mk +++ b/util/ego/build.mk @@ -6,8 +6,8 @@ $(call reset) $(eval cflags += -DVERBOSE -DNOTCOMPACT) $(eval cflags += -I$D/share -I$(OBJDIR)/$D) $(foreach f, $2, $(call cfile, $f)) -$(call file, $(LIBDIR)/libegocore.a) -$(call file, $(LIBEM_DATA)) +$(call rawfile, $(LIBDIR)/libegocore.a) +$(call rawfile, $(LIBEM_DATA)) $(call cprogram, $(BINDIR)/ego/$(strip $1)) $(call installto, $(PLATDEP)/ego/$(strip $1)) $(eval EGO_MODULES += $q) @@ -166,9 +166,9 @@ $(call cfile, $D/em_ego/em_ego.c) $(eval $q: $(INCDIR)/print.h $(INCDIR)/system.h) $(eval $q: $(INCDIR)/em_path.h) -$(call file, $(LIBPRINT)) -$(call file, $(LIBSTRING)) -$(call file, $(LIBSYSTEM)) +$(call rawfile, $(LIBPRINT)) +$(call rawfile, $(LIBSTRING)) +$(call rawfile, $(LIBSYSTEM)) $(call cprogram, $(BINDIR)/em_ego) $(call installto, $(PLATDEP)/em_ego) diff --git a/util/led/build.mk b/util/led/build.mk index d96dd35c6..419948a13 100644 --- a/util/led/build.mk +++ b/util/led/build.mk @@ -16,8 +16,8 @@ define build-led-impl $(call cfile, $D/sym.c) $(call cfile, $D/write.c) - $(call file, $(LIBSTRING)) - $(call file, $(LIBOBJECT)) + $(call rawfile, $(LIBSTRING)) + $(call rawfile, $(LIBOBJECT)) $(call cprogram, $(BINDIR)/em_led) $(call installto, $(PLATDEP)/em_led) diff --git a/util/misc/build.mk b/util/misc/build.mk index dfa8ac7c1..95b6fb2d9 100644 --- a/util/misc/build.mk +++ b/util/misc/build.mk @@ -14,13 +14,13 @@ define build-misc-impl $(eval objdir := encode) $(call cfile, $D/convert.c) $(eval $q: $(INCDIR)/em_comp.h $(INCDIR)/em_codeEK.h) - $(call file, $(LIBREAD_EMEV)) - $(call file, $(LIBEMK)) - $(call file, $(LIBEM_DATA)) - $(call file, $(LIBALLOC)) - $(call file, $(LIBPRINT)) - $(call file, $(LIBSTRING)) - $(call file, $(LIBSYSTEM)) + $(call rawfile, $(LIBREAD_EMEV)) + $(call rawfile, $(LIBEMK)) + $(call rawfile, $(LIBEM_DATA)) + $(call rawfile, $(LIBALLOC)) + $(call rawfile, $(LIBPRINT)) + $(call rawfile, $(LIBSTRING)) + $(call rawfile, $(LIBSYSTEM)) $(call cprogram, $(BINDIR)/em_encode) $(call installto, $(PLATDEP)/em_encode) $(eval EM_ENCODE := $o) @@ -30,13 +30,13 @@ define build-misc-impl $(eval objdir := decode) $(call cfile, $D/convert.c) $(eval $q: $(INCDIR)/em_comp.h $(INCDIR)/em_codeEK.h) - $(call file, $(LIBREAD_EMKV)) - $(call file, $(LIBEME)) - $(call file, $(LIBEM_DATA)) - $(call file, $(LIBALLOC)) - $(call file, $(LIBPRINT)) - $(call file, $(LIBSTRING)) - $(call file, $(LIBSYSTEM)) + $(call rawfile, $(LIBREAD_EMKV)) + $(call rawfile, $(LIBEME)) + $(call rawfile, $(LIBEM_DATA)) + $(call rawfile, $(LIBALLOC)) + $(call rawfile, $(LIBPRINT)) + $(call rawfile, $(LIBSTRING)) + $(call rawfile, $(LIBSYSTEM)) $(call cprogram, $(BINDIR)/em_decode) $(call installto, $(PLATDEP)/em_decode) $(eval EM_DECODE := $o) diff --git a/util/ncgg/build.mk b/util/ncgg/build.mk index c3a7f31fa..b0ee29d21 100644 --- a/util/ncgg/build.mk +++ b/util/ncgg/build.mk @@ -34,7 +34,7 @@ $(call cfile, $(OBJDIR)/$D/enterkeyw.c) $(eval $q: $(INCDIR)/em_spec.h) -$(call file, $(LIBEM_DATA)) +$(call rawfile, $(LIBEM_DATA)) $(call cprogram, $(BINDIR)/ncgg) $(eval NCGG := $o) diff --git a/util/opt/build.mk b/util/opt/build.mk index 39eafe355..75cb92553 100644 --- a/util/opt/build.mk +++ b/util/opt/build.mk @@ -10,12 +10,15 @@ $(call yacc, $(OBJDIR)/$D, $D/mktab.y) $(call flex, $(OBJDIR)/$D, $D/scan.l) $(call dependson, $(OBJDIR)/$D/y.tab.h) -$(call file, $(LIBEM_DATA)) -$(call file, -lfl) +$(call rawfile, $(LIBEM_DATA)) +$(call rawfile, -lfl) $(call cprogram, $(OBJDIR)/$D/mktab) endef +.PHONY: -lfl +-lfl: + define build-opt-impl $(call reset) @@ -53,12 +56,12 @@ $g: $(OBJDIR)/$D/mktab $D/patterns $(BINDIR)/cpp.ansi $(hide) $(BINDIR)/cpp.ansi < $D/patterns | $(OBJDIR)/$D/mktab > $$@ $(call cfile, $g) -$(call file, $(LIBEM_DATA)) -$(call file, $(LIBASSERT)) -$(call file, $(LIBPRINT)) -$(call file, $(LIBALLOC)) -$(call file, $(LIBSYSTEM)) -$(call file, $(LIBSTRING)) +$(call rawfile, $(LIBEM_DATA)) +$(call rawfile, $(LIBASSERT)) +$(call rawfile, $(LIBPRINT)) +$(call rawfile, $(LIBALLOC)) +$(call rawfile, $(LIBSYSTEM)) +$(call rawfile, $(LIBSTRING)) $(eval $q: $(INCDIR)/em_spec.h) @@ -79,4 +82,4 @@ endef $(eval $(build-opt-mktab-impl)) $(eval $(call build-opt-impl, em_opt,)) $(eval $(call build-opt-impl, em_opt2, -DGLOBAL_OPT)) -$(eval $(build-opt-manpage-impl)) \ No newline at end of file +$(eval $(build-opt-manpage-impl)) diff --git a/util/topgen/build.mk b/util/topgen/build.mk index 4ef15c278..9bf48a4d3 100644 --- a/util/topgen/build.mk +++ b/util/topgen/build.mk @@ -15,11 +15,11 @@ define build-topgen-impl $(call llgen, $(OBJDIR)/$D, $D/topgen.g) - $(call file, $(LIBASSERT)) - $(call file, $(LIBPRINT)) - $(call file, $(LIBALLOC)) - $(call file, $(LIBSYSTEM)) - $(call file, $(LIBSTRING)) + $(call rawfile, $(LIBASSERT)) + $(call rawfile, $(LIBPRINT)) + $(call rawfile, $(LIBALLOC)) + $(call rawfile, $(LIBSYSTEM)) + $(call rawfile, $(LIBSTRING)) $(call cprogram, $(BINDIR)/topgen) TOPGEN := $o From c5018d70880641643090602b7d9118e7b40bf3cc Mon Sep 17 00:00:00 2001 From: David Given Date: Mon, 23 Mar 2015 00:07:59 +0100 Subject: [PATCH 07/13] 64-bit-ify (adhoc varargs are evil). --- mach/proto/as/comm0.h | 1 + mach/proto/as/comm1.h | 4 +++ mach/proto/as/comm7.c | 63 ++++++++++++++++++++++++++----------------- 3 files changed, 43 insertions(+), 25 deletions(-) diff --git a/mach/proto/as/comm0.h b/mach/proto/as/comm0.h index 11f1231a9..4996350ac 100644 --- a/mach/proto/as/comm0.h +++ b/mach/proto/as/comm0.h @@ -265,3 +265,4 @@ typedef struct sect_t sect_t; #endif extern FILE *fopen(); /* some systems don't have this in stdio.h */ + diff --git a/mach/proto/as/comm1.h b/mach/proto/as/comm1.h index 7e4620471..6a40a2e90 100644 --- a/mach/proto/as/comm1.h +++ b/mach/proto/as/comm1.h @@ -116,6 +116,10 @@ extern valu_t load(); extern FILE *ffcreat(); extern FILE *fftemp(); +extern void fatal(const char* s, ...); +extern void serror(const char* s, ...); +extern void warning(const char* s, ...); + /* ========== Machine dependent C declarations ========== */ #include "mach1.c" diff --git a/mach/proto/as/comm7.c b/mach/proto/as/comm7.c index d0a147bdb..3c7871fbe 100644 --- a/mach/proto/as/comm7.c +++ b/mach/proto/as/comm7.c @@ -11,6 +11,7 @@ #include "comm0.h" #include "comm1.h" #include "y.tab.h" +#include valu_t load(ip) @@ -27,7 +28,7 @@ register item_t *ip; if ((ip->i_type & S_TYP) == S_UND || (ip->i_type & S_COM)) { if (pass == PASS_3) { if (relonami != 0) - serror("relocation error"); + serror("relocation error (relonami=%d, type=%08x)", relonami, ip->i_type); relonami = ip->i_valu+1; } return(0); @@ -380,13 +381,28 @@ wr_fatal() fatal("write error"); } -/* VARARGS1 */ -fatal(s, a1, a2, a3, a4) -char *s; +void diag(const char* tail, const char* s, va_list ap) { + fflush(stdout); + if (modulename) + fprintf(stderr, "\"%s\", line %ld: ", modulename, lineno); + else + fprintf(stderr, "%s: ", progname); + vfprintf(stderr, s, ap); + fprintf(stderr, "%s", tail); +} + +/* VARARGS1 */ +void fatal(const char* s, ...) +{ + va_list ap; + va_start(ap, s); + nerrors++; - diag(" (fatal)\n", s, a1, a2, a3, a4); + diag(" (fatal)\n", s, ap); stop(); + + va_end(ap); } #if DEBUG == 2 @@ -400,37 +416,34 @@ char *file; #if DEBUG == 1 assert1() { - diag(" (fatal)\n", "assertion failed"); + fatal("assertion failed"); abort(); } #endif -/* VARARGS1 */ -serror(s, a1, a2, a3, a4) -char *s; +void serror(const char* s, ...) { + va_list ap; + va_start(ap, s); + nerrors++; - diag("\n", s, a1, a2, a3, a4); + diag("\n", s, ap); + stop(); + + va_end(ap); } /* VARARGS1 */ -warning(s, a1, a2, a3, a4) -char *s; +void warning(const char* s, ...) { - diag(" (warning)\n", s, a1, a2, a3, a4); -} + va_list ap; + va_start(ap, s); -/* VARARGS1 */ -diag(tail, s, a1, a2, a3, a4) -char *tail, *s; -{ - fflush(stdout); - if (modulename) - fprintf(stderr, "\"%s\", line %ld: ", modulename, lineno); - else - fprintf(stderr, "%s: ", progname); - fprintf(stderr, s, a1, a2, a3, a4); - fprintf(stderr, tail); + nerrors++; + diag(" (warning)\n", s, ap); + stop(); + + va_end(ap); } nofit() From 9f23fbbe6a8f32dba3fa6aa7acf776b081d14af9 Mon Sep 17 00:00:00 2001 From: David Given Date: Mon, 23 Mar 2015 00:08:51 +0100 Subject: [PATCH 08/13] Allow machines to use cg if they wish. --HG-- rename : mach/proto/ncg/build.mk => mach/proto/cg/build.mk rename : util/ncgg/build.mk => util/cgg/build.mk --- mach/proto/cg/build.mk | 46 ++++++++++++++++++++++++++++++++++++++++++ plat/build.mk | 4 ++-- util/cgg/build.mk | 25 +++++++++++++++++++++++ util/cgg/main.c | 5 +++++ 4 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 mach/proto/cg/build.mk create mode 100644 util/cgg/build.mk diff --git a/mach/proto/cg/build.mk b/mach/proto/cg/build.mk new file mode 100644 index 000000000..2327009e0 --- /dev/null +++ b/mach/proto/cg/build.mk @@ -0,0 +1,46 @@ +define build-cg-impl + +$(call reset) + +$(eval cflags += -Imach/$(ARCH)/cg -I$(OBJDIR)/$D -Imach/proto/cg) +$(eval objdir := $(ARCH)) + +$(call cfile, mach/proto/cg/codegen.c) +$(call cfile, mach/proto/cg/compute.c) +$(call cfile, mach/proto/cg/equiv.c) +$(call cfile, mach/proto/cg/fillem.c) +$(call cfile, mach/proto/cg/gencode.c) +$(call cfile, mach/proto/cg/glosym.c) +$(call cfile, mach/proto/cg/main.c) +$(call cfile, mach/proto/cg/move.c) +$(call cfile, mach/proto/cg/nextem.c) +$(call cfile, mach/proto/cg/reg.c) +$(call cfile, mach/proto/cg/regvar.c) +$(call cfile, mach/proto/cg/salloc.c) +$(call cfile, mach/proto/cg/state.c) +$(call cfile, mach/proto/cg/subr.c) +$(call cfile, mach/proto/cg/var.c) + +$(eval $q: $(OBJDIR)/$D/tables.h) +$(eval CLEANABLES += $(OBJDIR)/$D/tables.h $(OBJDIR)/$D/tables.c) +$(OBJDIR)/$D/tables.c: $(OBJDIR)/$D/tables.h +$(OBJDIR)/$D/tables.h: $(CGG) $(CPPANSI) mach/$(ARCH)/cg/table + @echo CGG $$@ + @mkdir -p $$(dir $$@) + $(hide) cd $$(dir $$@) && \ + $(abspath $(CPPANSI)) -I$(abspath mach/$(ARCH)/cg) $(abspath mach/$(ARCH)/cg/table) | $(abspath $(CGG)) + +$(call cfile, $(OBJDIR)/$D/tables.c) + +$(eval $q: $(INCDIR)/flt_arith.h) + +$(call rawfile, $(LIBEM_DATA)) +$(call rawfile, $(LIBFLT_ARITH)) + +$(call cprogram, $(BINDIR)/$(PLATFORM)/cg) +$(call installto, $(PLATDEP)/$(PLATFORM)/cg) + +endef + +build-cg = $(eval $(build-cg-impl)) + diff --git a/plat/build.mk b/plat/build.mk index aff84c04c..623658b07 100644 --- a/plat/build.mk +++ b/plat/build.mk @@ -17,7 +17,7 @@ define build-platform-impl $(PLATIND)/descr/$(PLATFORM) \ $(PLATFORM_HEADERS_$(PLATFORM)) \ $(PLATDEP)/$(PLATFORM)/as \ - $(PLATDEP)/$(PLATFORM)/ncg \ + $(if $(arch-cg-$(ARCH)), $(PLATDEP)/$(PLATFORM)/cg, $(PLATDEP)/$(PLATFORM)/ncg) \ $(ARCHITECTURE_$(ARCH))) # libsys @@ -48,7 +48,7 @@ define build-platform-impl # The tools themselves $(call build-as) - $(call build-ncg) + $(if $(arch-cg-$(ARCH)), $(call build-cg), $(call build-ncg)) # Build top only if the architecture asks for it. diff --git a/util/cgg/build.mk b/util/cgg/build.mk new file mode 100644 index 000000000..4fc8532b2 --- /dev/null +++ b/util/cgg/build.mk @@ -0,0 +1,25 @@ +D := util/cgg + +define build-cgg-impl + +$(call reset) +$(eval cflags += -I$D) + +$(call yacc, $(OBJDIR)/$D, $D/bootgram.y) + +$(call flex, $(OBJDIR)/$D, $D/bootlex.l) +$(call dependson, $(OBJDIR)/$D/y.tab.h) + +$(call cfile, $D/main.c) + +$(eval $q: $(INCDIR)/em_spec.h) + +$(call rawfile, $(LIBEM_DATA)) +$(call rawfile, $(LIBASSERT)) +$(call rawfile, $(LIBSYSTEM)) +$(call cprogram, $(BINDIR)/cgg) +$(eval CGG := $o) + +endef + +$(eval $(build-cgg-impl)) diff --git a/util/cgg/main.c b/util/cgg/main.c index fba8e31b5..86375b776 100644 --- a/util/cgg/main.c +++ b/util/cgg/main.c @@ -1009,3 +1009,8 @@ max(a,b) { return(a); return(b); } + +int yywrap(void) { + return 1; +} + From 98ea849d031b68508970a13ebd17823d5532819e Mon Sep 17 00:00:00 2001 From: David Given Date: Mon, 23 Mar 2015 00:09:27 +0100 Subject: [PATCH 09/13] Improve flex correctness. --- util/opt/build.mk | 1 - util/opt/mktab.y | 4 ++++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/util/opt/build.mk b/util/opt/build.mk index 75cb92553..a4e62ced7 100644 --- a/util/opt/build.mk +++ b/util/opt/build.mk @@ -11,7 +11,6 @@ $(call flex, $(OBJDIR)/$D, $D/scan.l) $(call dependson, $(OBJDIR)/$D/y.tab.h) $(call rawfile, $(LIBEM_DATA)) -$(call rawfile, -lfl) $(call cprogram, $(OBJDIR)/$D/mktab) endef diff --git a/util/opt/mktab.y b/util/opt/mktab.y index 08beaeccc..e2a6c0b1a 100644 --- a/util/opt/mktab.y +++ b/util/opt/mktab.y @@ -294,6 +294,10 @@ main() { return nerrors; } +int yywrap(void) { + return 1; +} + yyerror(s) char *s; { fprintf(stderr,"line %d: %s\n",lino,s); From b146d2641c494ddf97d24aebcc888e7e45cd528d Mon Sep 17 00:00:00 2001 From: David Given Date: Mon, 23 Mar 2015 00:09:41 +0100 Subject: [PATCH 10/13] Fix a slightly mysterious dependency issue. --- util/data/build.mk | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/util/data/build.mk b/util/data/build.mk index 424712956..b6b5c7cea 100644 --- a/util/data/build.mk +++ b/util/data/build.mk @@ -3,12 +3,13 @@ D := util/data define util-data-impl $(eval g := \ + $(OBJDIR)/$D/em_flag.c \ + $(OBJDIR)/$D/em_pseu.c \ + $(OBJDIR)/$D/em_mnem.c \ $(INCDIR)/em_spec.h \ $(INCDIR)/em_pseu.h \ $(INCDIR)/em_mnem.h \ - $(OBJDIR)/$D/em_flag.c \ - $(OBJDIR)/$D/em_pseu.c \ - $(OBJDIR)/$D/em_mnem.c) +) $(eval CLEANABLES += $g) $(wordlist 2, $(words $g), $g): $(firstword $g) From ff774212beacd5da20bf2c1092bd2a6b30f4730c Mon Sep 17 00:00:00 2001 From: David Given Date: Thu, 18 Jun 2015 23:39:25 +0200 Subject: [PATCH 11/13] Rename branch. --HG-- branch : default-branch From 5e9f79db0510df8bb734bd7bcbcccfcfb9cbd754 Mon Sep 17 00:00:00 2001 From: David Given Date: Fri, 19 Jun 2015 22:07:16 +0200 Subject: [PATCH 12/13] Add Travis config file. --HG-- branch : default-branch --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..e0f0a1abf --- /dev/null +++ b/.travis.yml @@ -0,0 +1,4 @@ +language: c +script: + - make PREFIX=/tmp/acki -j4 + From 4c5eb9a602eb34926c4636702f58bc24d83b4c05 Mon Sep 17 00:00:00 2001 From: David Given Date: Fri, 19 Jun 2015 22:14:09 +0200 Subject: [PATCH 13/13] The ACK needs ed? Also, Ubuntu doesn't *have* ed? --HG-- branch : default-branch --- .travis.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.travis.yml b/.travis.yml index e0f0a1abf..dd9fd3e0c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,5 @@ +before_install: + - sudo apt-get install ed language: c script: - make PREFIX=/tmp/acki -j4