ref: 56eb24683409678fe676cca2d181853581c15414
parent: b2c7174d6f340458f7b10b0357dfdddc06668f31
author: Roberto E. Vargas Caballero <k0ga@shike2.com>
date: Mon Dec 31 10:41:50 EST 2018
[scripts] Add mklib script This script uses lorder to get a correct order in the library and it uses -q or -ru to make faster the creation of the library. Some build options of GNU make make make not POSIX compliant and the libc is fully replaced in the archive every time. Send a patch to GNU to solve that problem.
--- a/LICENSE
+++ b/LICENSE
@@ -1,29 +1,4 @@
-ISC License
+All the files in this project are covered by the ISC license
+except the next files:
-(c) 2012-2017 Roberto E. Vargas Caballero <k0ga@shike2.com>
-
-(c) 2017 Michael Forney <mforney@mforney.org>
-(c) 2015-2016 Dimitris Papastamos <sin@2f30.org>
-(c) 2015-2016 Hiltjo Posthuma <hiltjo@codemadness.org>
-(c) 2015-2016 Laslo Hunhold <dev@frign.de>
-(c) 2015 Evan Gates <evan.gates@gmail.com>
-(c) 2015-2017 Quentin Rameau <quinq@fifth.space>
-(c) 2016-2017 Andrew Chambers <andrewchamberss@gmail.com>
-(c) 2015 Sören Tempel <soeren+git@soeren-tempel.net>
-(c) 2015-2017 Quentin Carbonneaux <quentin@c9x.me>
-(c) 2016 Pekka Jylhä-Ollila <pekka.jylha.ollila@gmail.com>
-(c) 2016 Alexander Krotov <ilabdsf@yandex.ru>
-(c) 2016 Lucas Gabriel Vuotto <l.vuotto92@gmail.com>
-(c) 2016 Raymond Nicholson <rain1@openmailbox.org>
-
-Permission to use, copy, modify, and/or distribute this software for any
-purpose with or without fee is hereby granted, provided that the above
-copyright notice and this permission notice appear in all copies.
-
-THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
-WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
-ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
-WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
-ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
-OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+scripts/lorder Caldera
--- a/Makefile
+++ b/Makefile
@@ -4,6 +4,7 @@
include $(PROJECTDIR)/scripts/rules.mk
DIRS = src include/scc/scc tests
+ENV = $(SCRIPTDIR)/env.sh
all: src
@@ -13,15 +14,25 @@
xargs mkdir -p < $(SCRIPTDIR)/libc-proto
touch dirs
-$(DIRS): FORCE
- +@cd $@ && $(MAKE)
+$(DIRS): $(ENV) FORCE
+ . $(ENV) && cd $@ && $(MAKE)
+$(ENV):
+ @rm -f $@; \
+ trap 'r=$?;rm -f $$$$.tmp;exit $r' EXIT HUP INT QUIT TERM; \
+ (echo PATH=$$PWD/scripts:$$PATH:.; \
+ echo NM=\"$(NM)\"; \
+ echo AR=\"$(AR)\"; \
+ echo RL=\"$(RL)\"; \
+ echo RLFLAGS=\"$(RLFLAGS)\"; \
+ echo export PATH RLFLAGS NM AR RL) > $$$$.tmp && mv $$$$.tmp $@
+
dep:
$(FORALL)
clean:
$(FORALL)
- rm -rf lib bin libexec dirs
+ rm -rf lib bin libexec dirs $(ENV)
distclean: clean
+@cd include/scc/scc && $(MAKE) distclean
--- a/config/amd64-linux.mk
+++ b/config/amd64-linux.mk
@@ -7,3 +7,4 @@
MANPREFIX = $(PREFIX)/share/man
AS = as
RANLIB = ranlib
+NM = nm
--- a/config/i386-linux.mk
+++ b/config/i386-linux.mk
@@ -4,3 +4,4 @@
MANPREFIX = $(PREFIX)/share/man
AS = as
RANLIB = ranlib
+NM = nm
--- /dev/null
+++ b/doc/caldera.txt
@@ -1,0 +1,53 @@
+Caldera International, Inc. hereby grants a fee free license that includes
+the rights use, modify and distribute this named source code, including
+creating derived binary products created from the source code. The source
+code for which Caldera International, Inc. grants rights are limited
+to the following UNIX Operating Systems that operate on the 16-Bit
+PDP-11 CPU and early versions of the 32-Bit UNIX Operating System, with
+specific exclusion of UNIX System III and UNIX System V and successor
+operating systems:
+
+32-bit 32V UNIX
+
+16 bit UNIX Versions 1, 2, 3, 4, 5, 6, 7
+
+Caldera International, Inc. makes no guarantees or commitments that any
+source code is available from Caldera International, Inc.
+
+The following copyright notice applies to the source code files for
+which this license is granted.
+
+Copyright(C) Caldera International Inc. 2001-2002. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+
+Redistributions of source code and documentation must retain the above
+copyright notice, this list of conditions and the following disclaimer.
+
+Redistributions in binary form must reproduce the above copyright notice,
+this list of conditions and the following disclaimer in the documentation
+and/or other materials provided with the distribution.
+
+All advertising materials mentioning features or use of this software
+must display the following acknowledgement:
+
+This product includes software developed or owned by Caldera
+International, Inc.
+
+Neither the name of Caldera International, Inc. nor the names of other
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
+
+USE OF THE SOFTWARE PROVIDED FOR UNDER THIS LICENSE BY CALDERA
+INTERNATIONAL, INC. AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
+EVENT SHALL CALDERA INTERNATIONAL, INC. BE LIABLE FOR ANY DIRECT, INDIRECT
+INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
+USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
+ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
--- /dev/null
+++ b/doc/isc.txt
@@ -1,0 +1,30 @@
+ISC License
+
+(c) 2012-2019 Roberto E. Vargas Caballero <k0ga@shike2.com>
+
+(c) 2017 Michael Forney <mforney@mforney.org>
+(c) 2015-2016 Dimitris Papastamos <sin@2f30.org>
+(c) 2015-2016 Hiltjo Posthuma <hiltjo@codemadness.org>
+(c) 2015-2016 Laslo Hunhold <dev@frign.de>
+(c) 2015 Evan Gates <evan.gates@gmail.com>
+(c) 2015-2019 Quentin Rameau <quinq@fifth.space>
+(c) 2016-2017 Andrew Chambers <andrewchamberss@gmail.com>
+(c) 2015 Sören Tempel <soeren+git@soeren-tempel.net>
+(c) 2015-2017 Quentin Carbonneaux <quentin@c9x.me>
+(c) 2016 Pekka Jylhä-Ollila <pekka.jylha.ollila@gmail.com>
+(c) 2016 Alexander Krotov <ilabdsf@yandex.ru>
+(c) 2016 Lucas Gabriel Vuotto <l.vuotto92@gmail.com>
+(c) 2016 Raymond Nicholson <rain1@openmailbox.org>
+(c) 2018-2019 zerous Naveen Narayanan <zerous@nocebo.space>
+
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
--- /dev/null
+++ b/scripts/.gitignore
@@ -1,0 +1,1 @@
+env.sh
--- /dev/null
+++ b/scripts/lorder
@@ -1,0 +1,47 @@
+#!/bin/sh
+
+set -e
+trap 'r=$?;rm -f $$sym?ef; exit $r' EXIT HUP INT QUIT TERM
+
+case $# in
+0)
+ echo usage: lorder file ... >&2
+ exit 1
+esac
+
+rm -f $$sym?ef
+
+(echo $1:
+ ${NM:-nm} -g "$@") | sed -n '
+ /\.o:$/ {
+ s/://
+ h
+ s/.*/& &/
+ p
+ }
+ / [ADTR] / {
+ s/.* //
+ G
+ s/\n/ /
+ w '$$symdef'
+ }
+ / C / {
+ s/.* //
+ G
+ s/\n/ /
+ w '$$symcef'
+ }
+ / U / {
+ s/.* //
+ G
+ s/\n/ /
+ w '$$symref'
+ }
+'
+sort $$symdef -o $$symdef
+sort $$symref -o $$symref
+sort $$symcef -o $$symcef
+(join $$symref $$symdef
+ join $$symref $$symcef
+ join $$symcef $$symdef) |
+sed 's/[^ ]* *//'
--- /dev/null
+++ b/scripts/mklib
@@ -1,0 +1,43 @@
+#!/bin/sh
+
+set -e
+
+usage()
+{
+ echo usage: mklib [-o library] file ... >&2
+ exit 1
+}
+
+for i
+do
+ case "$1" in
+ -o)
+ out=$2
+ shift 2
+ ;;
+ --)
+ shift
+ break;
+ ;;
+ -*)
+ usage
+ ;;
+ esac
+done
+
+case $# in
+0)
+ usage
+ ;;
+esac
+
+lib=${out-a.out}
+
+if ! test -f $lib
+then
+ ${AR:-ar} -qv $lib $(lorder $@ | tsort)
+else
+ ${AR:-ar} -ruv $lib $(lorder $@ | tsort)
+fi
+
+${RL:-ranlib} $RLFLAGS $lib
--- a/src/driver/posix/Makefile
+++ b/src/driver/posix/Makefile
@@ -27,10 +27,9 @@
mv $$$$.sh $@
config.h:
- PREFIX=$(PREFIX) ./config.sh $(SYSLST)
+ PREFIX=$(PREFIX) config.sh $(SYSLST)
-dep:
- $(PROJECTDIR)/mkdep.sh
+dep: inc-dep
clean:
rm -f scc scpp *.o
--- a/src/libc/Makefile
+++ b/src/libc/Makefile
@@ -19,12 +19,11 @@
$(DIRS): FORCE
+@cd $@ && $(MAKE)
-objlst: FORCE
- ./mklst $(TARGET)
+objlst:
+ find . -name '*.o' > $@
-$(TARGET): objlst
- xargs $(AR) $(ARFLAGS) $@ < objlst
- $(RL) $(RANLIBFLAGS) $@
+$(TARGET): objlst FORCE
+ mklib -o $@ `cat objlst`
clean:
$(FORALL)
--- a/src/libc/arch/amd64/darwin/Makefile
+++ b/src/libc/arch/amd64/darwin/Makefile
@@ -26,7 +26,7 @@
objs: $(OBJS)
syscall: syscall.lst
- ./gensys.sh syscall.lst
+ gensys.sh syscall.lst
touch syscall
clean:
--- a/src/libc/arch/amd64/dragonfly/Makefile
+++ b/src/libc/arch/amd64/dragonfly/Makefile
@@ -27,7 +27,7 @@
objs: $(OBJS)
syscall: syscall.lst
- ./gensys.sh syscall.lst
+ gensys.sh syscall.lst
touch syscall
clean:
--- a/src/libc/arch/amd64/linux/Makefile
+++ b/src/libc/arch/amd64/linux/Makefile
@@ -29,7 +29,7 @@
objs: $(OBJS)
syscall: syscall.lst
- ./gensys.sh syscall.lst
+ gensys.sh syscall.lst
touch syscall
clean:
--- a/src/libc/arch/amd64/netbsd/Makefile
+++ b/src/libc/arch/amd64/netbsd/Makefile
@@ -30,7 +30,7 @@
objs: $(OBJS)
syscall: syscall.lst
- ./gensys.sh syscall.lst
+ gensys.sh syscall.lst
touch syscall
clean:
--- a/src/libc/arch/amd64/openbsd/Makefile
+++ b/src/libc/arch/amd64/openbsd/Makefile
@@ -27,7 +27,7 @@
objs: $(OBJS)
syscall: syscall.lst
- ./gensys.sh syscall.lst
+ gensys.sh syscall.lst
touch syscall
clean:
--- a/src/libc/arch/arm32/linux/Makefile
+++ b/src/libc/arch/arm32/linux/Makefile
@@ -29,7 +29,7 @@
objs: $(OBJS)
syscall: syscall.lst
- ./gensys.sh syscall.lst
+ gensys.sh syscall.lst
touch syscall
clean:
--- a/src/libc/arch/arm64/linux/Makefile
+++ b/src/libc/arch/arm64/linux/Makefile
@@ -29,7 +29,7 @@
objs: $(OBJS)
syscall: syscall.lst
- ./gensys.sh syscall.lst
+ gensys.sh syscall.lst
touch syscall
clean:
--- a/src/libc/libc.h
+++ b/src/libc/libc.h
@@ -16,12 +16,6 @@
#define SECHOUR (60 * SECMIN) /* 3600 */
#define SECDAY (24 * SECHOUR) /* 86400 */
-#ifdef stdin
-extern FILE *_fpopen(const char * restrict fname,
- const char * restrict mode,
- FILE * restrict fp);
-#endif
-
struct tzone {
char *name;
int gmtoff;
@@ -35,9 +29,13 @@
extern int _newyear(int year);
extern void *_getheap(void);
extern int _dtoi(char);
-#ifdef FILE
+
+#ifdef stdin
extern int _flsbuf(FILE *fp);
-extern void _allocbuf(FILE *fp);
+extern int _allocbuf(FILE *fp);
+extern FILE *_fpopen(const char * restrict fname,
+ const char * restrict mode,
+ FILE * restrict fp);
#endif
extern int _daysmon[12];
--- a/src/libc/mklst
+++ /dev/null
@@ -1,12 +1,0 @@
-#!/bin/sh
-
-set -e
-trap 'r=$?;rm -f $$.tmp;exit $r' EXIT HUP QUIT INT TERM
-archive=${1?'First parameter must be the archive name'}
-
-if test -f $archive
-then
- newer="-newer $archive"
-fi
-
-find . -name '*.o' $newer > $$.tmp && mv $$.tmp objlst
--- a/src/libcoff32/Makefile
+++ b/src/libcoff32/Makefile
@@ -17,8 +17,7 @@
all: $(TARGET)
$(TARGET): $(OBJS)
- $(AR) $(ARFLAGS) $@ $?
- ranlib $@
+ mklib -o $@ $?
dep: inc-dep
--- a/src/libscc/Makefile
+++ b/src/libscc/Makefile
@@ -24,8 +24,7 @@
all: $(TARGET)
$(TARGET): $(OBJS)
- $(AR) $(ARFLAGS) $@ $?
- ranlib $@
+ mklib -o $@ $(OBJS)
dep: inc-dep
--- a/tests/ar/execute/Makefile
+++ b/tests/ar/execute/Makefile
@@ -6,7 +6,7 @@
all: tests
tests: master.a
- @TZ=UTC PATH=$(ROOT)/bin:$$PATH ./chktest.sh
+ @TZ=UTC PATH=$(ROOT)/bin:$$PATH chktest.sh
master.a:
./mkmaster.sh
--- a/tests/as/execute/Makefile
+++ b/tests/as/execute/Makefile
@@ -6,7 +6,7 @@
all: tests
tests:
- @PATH=$(ROOT)/bin:$$PATH ./chktest.sh
+ @PATH=$(ROOT)/bin:$$PATH chktest.sh
clean:
rm -f test.log
--- a/tests/libc/execute/Makefile
+++ b/tests/libc/execute/Makefile
@@ -10,7 +10,7 @@
all: tests
tests:
- @CFLAGS='' SCCPREFIX=$(ROOT) ./chktest.sh libc-tests.lst
+ @CFLAGS='' SCCPREFIX=$(ROOT) chktest.sh libc-tests.lst
clean:
rm -f *.o *core a.out test.log
--- a/tests/nm/execute/Makefile
+++ b/tests/nm/execute/Makefile
@@ -7,7 +7,7 @@
all: tests
tests: $(OUT)
- @PATH=$(ROOT)/bin:$$PATH ./chktest.sh
+ @PATH=$(ROOT)/bin:$$PATH chktest.sh
z80.out: master.s
z80-unknown-coff-as -o $@ master.s
--- a/tests/scc/error/Makefile
+++ b/tests/scc/error/Makefile
@@ -5,7 +5,7 @@
all: tests
tests:
- @CFLAGS='' SCCPREFIX=$(ROOT) PATH=$(ROOT)/bin:$$PATH ./chktest.sh scc-tests.lst
+ @CFLAGS='' SCCPREFIX=$(ROOT) PATH=$(ROOT)/bin:$$PATH chktest.sh scc-tests.lst
clean:
rm -f *.as *.o *.ir *.qbe *core test.log
--- a/tests/scc/execute/Makefile
+++ b/tests/scc/execute/Makefile
@@ -5,7 +5,7 @@
all: tests
tests:
- @CFLAGS='' SCCPREFIX=$(ROOT) PATH=$(ROOT)/bin:$$PATH ./chktest.sh scc-tests.lst
+ @CFLAGS='' SCCPREFIX=$(ROOT) PATH=$(ROOT)/bin:$$PATH chktest.sh scc-tests.lst
clean:
rm -f *.as *.o *.ir *.qbe *core test.log