Library: Makefile changes so we can have a saner build set up
authorAlan Cox <alan@linux.intel.com>
Fri, 29 Sep 2017 21:12:26 +0000 (22:12 +0100)
committerAlan Cox <alan@linux.intel.com>
Fri, 29 Sep 2017 21:12:26 +0000 (22:12 +0100)
Library/libs/Makefile.65c816 [new file with mode: 0644]
Library/libs/Makefile.z80 [new file with mode: 0644]

diff --git a/Library/libs/Makefile.65c816 b/Library/libs/Makefile.65c816
new file mode 100644 (file)
index 0000000..bdb5325
--- /dev/null
@@ -0,0 +1 @@
+       include Makefile.6502
diff --git a/Library/libs/Makefile.z80 b/Library/libs/Makefile.z80
new file mode 100644 (file)
index 0000000..95d816b
--- /dev/null
@@ -0,0 +1,189 @@
+CC = fcc
+ASM = sdasz80
+AR = sdar
+LINKER = sdldz80
+export MAKE = make
+# This gets set for 'awkward' devices like ZX128
+#PLATFORM = -zx128
+PLATFORM =
+export PLATFORM
+#CC_OPT = -mz80 -c --opt-code-size --std-c99 --max-allocs-per-node 2000000 -I../include
+#CC_OPT = -mz80 --std-c99 -c --opt-code-size --max-allocs-per-node 20000 -I../include -I../../Kernel/include
+# for stuff that gives sdcc nightmares
+#CC_NOOPT = -mz80 --std-c99 -c --opt-code-size --max-allocs-per-node 1000 -I../include
+CC_OPT = -O2 -c
+CC_NOOPT = -c
+ASM_OPT = -l -o -s
+LINKER_OPT = -m -i -o
+SRC_CRT0 = crt0$(PLATFORM).s
+OBJ_CRT0 = $(SRC_CRT0:.s=.rel)
+SRC_CRT0NS = crt0nostdio$(PLATFORM).s
+OBJ_CRT0NS = $(SRC_CRT0NS:.s=.rel)
+SRC_ASM = enter.s htonl-z80.s htons-z80.s
+OBJ_ASM = $(SRC_ASM:.s=.rel)
+SRC_C =  __argv.c a64l.c abort.c asctime.c assert.c atexit.c atoi_small.c
+SRC_C += bcmp.c bcopy.c bsearch.c bzero.c calloc.c cfree.c clock.c closedir.c
+SRC_C += closedir_r.c clock_gettime.c clock_getres.c clock_settime.c
+SRC_C += creat.c crypt.c ctermid.c ctime.c cuserid.c
+SRC_C += difftime.c drand48.c err.c errno.c error.c
+SRC_C += execl.c execv.c execvp.c exit.c
+SRC_C += fclose.c fdatasync.c fflush.c fgetc.c fgetgrent.c fgetpwent.c
+SRC_C += fgetpos.c fgets.c fopen.c fork.c fprintf.c fputc.c fputs.c fread.c
+SRC_C += free.c fsetpos.c fsync.c ftell.c fwrite.c getcwd.c
+SRC_C += getenv.c __getgrent.c getgrgid.c getgrnam.c getloadavg.c getlogin.c
+SRC_C += getopt.c
+SRC_C += getpw.c __getpwent.c getpwnam.c getpwuid.c gets.c gettimeofday.c
+SRC_C += getw.c gmtime.c gmtime_r.c grent.c
+SRC_C += inet_addr.c inet_aton.c inet_network.c inet_ntoa.c inet_ntop.c inet_pton.c
+SRC_C += index.c initgroups.c isatty.c killpg.c
+SRC_C += l64a.c libintl.c localtim.c localtim_r.c
+SRC_C += lrand48.c lseek.c lsearch.c lstat.c ltoa.c ltostr.c
+SRC_C += malloc.c mkfifo.c mkstemps.c nanosleep.c opendir.c opendir_r.c
+SRC_C += pause.c perror.c
+SRC_C += popen.c printf.c putenv.c putgetch.c putpwent.c putw.c pwent.c qsort.c
+SRC_C += raise.c rand.c readdir.c readlink.c realloc.c recv.c
+SRC_C += recvfrom.c regerror.c
+SRC_C += regsub.c remove.c rewind.c rewinddir.c rindex.c seekdir.c
+SRC_C += send.c sendto.c setbuffer.c setenv.c
+SRC_C += setlocale.c setvbuf.c settimeofday.c sleep.c sprintf.c 
+SRC_C += stat.c stdio0.c stime.c
+SRC_C += strcasecmp.c strcasestr.c strdup.c stricmp.c strlcpy.c strncasecmp.c
+SRC_C += strnlen.c strnicmp.c strsep.c strxfrm.c strcoll.c strsignal.c
+SRC_C += strtod.c strtol.c swab.c system.c telldir.c time.c tmpfile.c tmpnam.c ttyname.c
+SRC_C += tzset.c ungetc.c usleep.c utent.c utimes.c utsname.c
+SRC_C += vfprintf.c vprintf.c wait.c xitoa.c pathconf.c
+SRC_C += gethostname.c sysconf.c confstr.c memccpy.c getpass.c
+# ctype
+SRC_C += isalnum.c isalpha.c isascii.c isblank.c iscntrl.c isdigit.c
+SRC_C += isgraph.c islower.c isprint.c ispunct.c isspace.c isupper.c
+SRC_C += isxdigit.c toupper.c tolower.c
+# tty layer
+SRC_C += tcgetattr.c tcsetattr.c tcdrain.c tcflow.c tcflush.c
+SRC_C += cfmakeraw.c cfspeed.c revoke.c
+# scanf
+SRC_C += fscanf.c scanf.c sscanf.c vfscanf.c vscanf.c vsscanf.c
+# Seems to give the compiler a hard time
+SRC_HARD += regexp.c
+# Pieces we inherit in this case from the compiler library instead
+#SRC_C += strcpy.c strlen.c abs.c atof.c atoi.c atol.c labs.c
+#SRC_C += strcat.c strchr.c strcmp.c strcspn.c strncat.c strncmp.c
+#SRC_C += strncpy.c strpbrk.c strrchr.c strspn.c strstr.c strtok.c
+#SRC_C += memchr.c memcmp.c memcpy.c memset.c
+
+SRC_CT += termcap.c tgetent.c
+
+SRC_CURS = $(shell find curses -name '*.c')
+
+SRC_LM += acosf.c acoshf.c asinf.c asinhf.c atan2f.c atanf.c atanhf.c
+SRC_LM += cbrtf.c ceilf.c copysignf.c erff.c expf.c expm1f.c
+SRC_LM += fabsf.c fdimf.c floorf.c fmaxf.c fminf.c fmodf.c frexpf.c
+SRC_LM += hypotf.c ilogbf.c j0f.c j1f.c jnf.c
+SRC_LM += ldexpf.c lgammaf.c lgammaf_r.c logf.c log2f.c log10f.c logbf.c
+SRC_LM += lrintf.c lroundf.c
+SRC_LM += modff.c nearbyintf.c nextafterf.c powf.c
+SRC_LM += remainderf.c remquof.c rintf.c
+SRC_LM += scalbnf.c scalbinf.c
+SRC_LM += sinf.c sincosf.c sinhf.c
+SRC_LM += sqrtf.c tgammaf.c
+SRC_LM += vfscanf_m.c vfprintf_m.c
+SRC_LM += __expo2f.c __float_bits.c __fpclassifyf.c __log1pf.c __signgam.c
+
+SRC_TM = tinymalloc.c
+
+SRC_RES = resolv.c
+
+OBJ_C = $(SRC_C:.c=.rel)
+OBJ_CURS = $(SRC_CURS:.c=.rel)
+OBJ_CT = $(SRC_CT:.c=.rel)
+OBJ_LM = $(SRC_LM:.c=.rel)
+OBJ_TM = $(SRC_TM:.c=.rel)
+OBJ_HARD = $(SRC_HARD:.c=.rel)
+OBJ_ALL = $(OBJ_ASM) $(OBJ_C) $(OBJ_HARD)
+OBJ_RES = $(SRC_RES:.c=.rel)
+
+all: syslib$(PLATFORM).lib crt0$(PLATFORM).rel crt0nostdio$(PLATFORM).rel liberror.txt curses$(PLATFORM).lib termcap$(PLATFORM).lib m$(PLATFORM).lib tinymalloc$(PLATFORM).lib resolv$(PLATFORM).lib
+
+libc.l:%.l:$(OBJ_ALL)
+       ls $(OBJ_ALL) > libc.l
+
+syscall.l: fuzix/syslib.l
+       ../tools/syscall
+       (cd fuzix; $(MAKE))
+       cat fuzix/syslib.l | tr " " "\\n" | sed -e "s/^/fuzix\//" >syscall.l
+
+sdccz80.lib:
+       ../tools/libclean
+
+syslib$(PLATFORM).lib: syscall.l libc.l sdccz80.lib
+       cat libc.l syscall.l >syslib.l
+       cp sdccz80.lib syslib$(PLATFORM).lib
+       $(AR) rc syslib$(PLATFORM).lib @syslib.l
+       $(AR) s syslib$(PLATFORM).lib
+       ln -sf syslib$(PLATFORM).lib c$(PLATFORM).lib
+
+fuzix/syslib.l:
+       ../tools/syscall
+       $(MAKE) -C fuzix
+
+liberror.txt:
+       ../tools/liberror > liberror.txt
+
+curses$(PLATFORM).lib: $(OBJ_CURS)
+       $(AR) rc curses$(PLATFORM).lib $(OBJ_CURS)
+       $(AR) s curses$(PLATFORM).lib
+
+m$(PLATFORM).lib: $(OBJ_LM)
+       $(AR) rc m$(PLATFORM).lib $(OBJ_LM)
+       $(AR) s m$(PLATFORM).lib
+
+termcap$(PLATFORM).lib: $(OBJ_CT)
+       $(AR) rc termcap$(PLATFORM).lib $(OBJ_CT)
+       $(AR) s termcap$(PLATFORM).lib
+
+tinymalloc$(PLATFORM).lib: $(OBJ_TM)
+       $(AR) rc tinymalloc$(PLATFORM).lib $(OBJ_TM)
+       $(AR) s tinymalloc$(PLATFORM).lib
+
+resolv$(PLATFORM).lib: $(OBJ_RES)
+       $(AR) rc resolv$(PLATFORM).lib $(OBJ_RES)
+       $(AR) s resolv$(PLATFORM).lib
+
+$(OBJ_ASM):%.rel: %.s
+       $(ASM) $(ASM_OPT) $@ $(@:.rel=.s)
+
+$(OBJ_CRT0):%.rel: %.s
+       $(ASM) $(ASM_OPT) $@ $(@:.rel=.s)
+
+$(OBJ_CRT0NS):%.rel: %.s
+       $(ASM) $(ASM_OPT) $@ $(@:.rel=.s)
+
+$(OBJ_C):%.rel: %.c
+       $(CC) $(CC_OPT) $(@:.rel=.c)
+
+$(OBJ_CT):%.rel: %.c
+       $(CC) $(CC_OPT) $(@:.rel=.c)
+
+$(OBJ_CURS):%.rel: %.c
+       $(CC) $(CC_OPT) $(@:.rel=.c) -o $@
+
+$(OBJ_LM):%.rel: %.c
+       $(CC) $(CC_OPT) -DBUILD_LIBM $< -o $@
+
+$(OBJ_TM):%.rel: %.c
+       $(CC) $(CC_OPT) $(@:.rel=.c)
+
+$(OBJ_RES):%.rel: %.c
+       $(CC) $(CC_OPT) $(@:.rel=.c)
+
+$(OBJ_HARD):%.rel: %.c
+       $(CC) $(CC_NOOPT) $(@:.rel=.c)
+
+clean:
+       rm -rf *.rel *.asm *.sym *.lst *.lib *~ syscall.l  libc.l syslib.l liberror.txt *.o
+       (cd curses; rm -rf *.rel *.asm *.sym *.lst *~ *.o)
+       (cd fuzix; $(MAKE) clean)
+
+install:
+       cp crt0$(PLATFORM).rel crt0nostdio$(PLATFORM).rel c$(PLATFORM).lib /opt/fcc/lib/
+       cp curses$(PLATFORM).lib termcap$(PLATFORM).lib /opt/fcc/lib/
+       cp m$(PLATFORM).lib tinymalloc$(PLATFORM).lib /opt/fcc/lib/