1 #
   2 # This file and its contents are supplied under the terms of the
   3 # Common Development and Distribution License ("CDDL"), version 1.0.
   4 # You may only use this file in accordance with the terms of version
   5 # 1.0 of the CDDL.
   6 #
   7 # A full copy of the text of the CDDL should have accompanied this
   8 # source.  A copy of the CDDL is also available via the Internet at
   9 # http://www.illumos.org/license/CDDL.
  10 #
  11 
  12 #
  13 # Copyright 2016 Toomas Soome <tsoome@me.com>
  14 #
  15 
  16 #
  17 # Notes:
  18 # - We don't use the libc strerror/sys_errlist because the string table is
  19 #   quite large.
  20 #
  21 
  22 # standalone components and stuff we have modified locally
  23 SRCS=   $(LIB_BASE)/libz/gzguts.h $(LIB_BASE)/libz/zutil.h
  24 SRCS += $(LIBSTAND_SRC)/__main.c $(LIBSTAND_SRC)/assert.c
  25 SRCS += $(LIBSTAND_SRC)/bcd.c $(LIBSTAND_SRC)/environment.c
  26 SRCS += $(LIBSTAND_SRC)/getopt.c $(LIBSTAND_SRC)/strtol.c
  27 SRCS += $(LIBSTAND_SRC)/strtoul.c $(LIBSTAND_SRC)/random.c
  28 SRCS += $(LIBSTAND_SRC)/sbrk.c $(LIBSTAND_SRC)/twiddle.c
  29 SRCS += $(LIBSTAND_SRC)/zalloc.c $(LIBSTAND_SRC)/zalloc_malloc.c
  30 
  31 OBJS=   __main.o assert.o bcd.o environment.o \
  32         getopt.o gets.o globals.o pager.o printf.o \
  33         strdup.o strerror.o strtol.o strtoul.o random.o \
  34         sbrk.o twiddle.o zalloc.o zalloc_malloc.o
  35 
  36 # private (pruned) versions of libc string functions
  37 SRCS += $(LIBSTAND_SRC)/strcasecmp.c
  38 OBJS += strcasecmp.o
  39 
  40 # from libc
  41 SRCS += $(LIB_BASE)/libc/net/ntoh.c
  42 OBJS += ntoh.o
  43 
  44 # string functions from libc
  45 SRCS += $(LIB_BASE)/libc/string/bcmp.c $(LIB_BASE)/libc/string/bcopy.c
  46 SRCS += $(LIB_BASE)/libc/string/bzero.c $(LIB_BASE)/libc/string/ffs.c
  47 SRCS += $(LIB_BASE)/libc/string/fls.c $(LIB_BASE)/libc/string/memccpy.c
  48 SRCS += $(LIB_BASE)/libc/string/memchr.c $(LIB_BASE)/libc/string/memcmp.c
  49 SRCS += $(LIB_BASE)/libc/string/memcpy.c $(LIB_BASE)/libc/string/memmove.c
  50 SRCS += $(LIB_BASE)/libc/string/memset.c $(LIB_BASE)/libc/string/strcat.c
  51 SRCS += $(LIB_BASE)/libc/string/strchr.c $(LIB_BASE)/libc/string/strcmp.c
  52 SRCS += $(LIB_BASE)/libc/string/strcpy.c $(LIB_BASE)/libc/string/strcspn.c
  53 SRCS += $(LIB_BASE)/libc/string/strlcat.c $(LIB_BASE)/libc/string/strlcpy.c
  54 SRCS += $(LIB_BASE)/libc/string/strlen.c $(LIB_BASE)/libc/string/strncat.c
  55 SRCS += $(LIB_BASE)/libc/string/strncmp.c $(LIB_BASE)/libc/string/strncpy.c
  56 SRCS += $(LIB_BASE)/libc/string/strpbrk.c $(LIB_BASE)/libc/string/strrchr.c
  57 SRCS += $(LIB_BASE)/libc/string/strsep.c $(LIB_BASE)/libc/string/strspn.c
  58 SRCS += $(LIB_BASE)/libc/string/strstr.c $(LIB_BASE)/libc/string/strtok.c
  59 SRCS += $(LIB_BASE)/libc/string/swab.c
  60 
  61 SRCS += $(LIBSTAND_SRC)/qdivrem.c
  62 
  63 OBJS += bcmp.o bcopy.o bzero.o ffs.o fls.o \
  64         memccpy.o memchr.o memcmp.o memcpy.o memmove.o memset.o \
  65         qdivrem.o strcat.o strchr.o strcmp.o strcpy.o \
  66         strcspn.o strlcat.o strlcpy.o strlen.o strncat.o strncmp.o strncpy.o \
  67         strpbrk.o strrchr.o strsep.o strspn.o strstr.o strtok.o swab.o
  68 
  69 # uuid functions from libc
  70 SRCS += $(LIB_BASE)/libc/uuid/uuid_create_nil.c
  71 SRCS += $(LIB_BASE)/libc/uuid/uuid_equal.c
  72 SRCS += $(LIB_BASE)/libc/uuid/uuid_is_nil.c
  73 
  74 SRCS += $(LIBSTAND_SRC)/uuid_from_string.c
  75 SRCS += $(LIBSTAND_SRC)/uuid_to_string.c
  76 
  77 OBJS += uuid_create_nil.o uuid_equal.o uuid_from_string.o uuid_is_nil.o \
  78         uuid_to_string.o
  79 
  80 # decompression functionality from libbz2
  81 # NOTE: to actually test this functionality after libbz2 upgrade compile
  82 # loader(8) with LOADER_BZIP2_SUPPORT defined
  83 CFLAGS += -DBZ_LOADER -DBZ_NO_STDIO -DBZ_NO_COMPRESS
  84 SRCS += libstand_bzlib_private.h
  85 
  86 SRCS += _bzlib.c _crctable.c _decompress.c _huffman.c _randtable.c
  87 OBJS += _bzlib.o _crctable.o _decompress.o _huffman.o _randtable.o
  88 CLEANFILES +=   _bzlib.c _crctable.c _decompress.c _huffman.c _randtable.c
  89 
  90 _bzlib.c: $(SRC)/common/bzip2/bzlib.c
  91         sed "s|bzlib_private\.h|libstand_bzlib_private.h|" $^ > $@
  92 
  93 _crctable.c: $(SRC)/common/bzip2/crctable.c
  94         sed "s|bzlib_private\.h|libstand_bzlib_private.h|" $^ > $@
  95 
  96 _decompress.c: $(SRC)/common/bzip2/decompress.c
  97         sed "s|bzlib_private\.h|libstand_bzlib_private.h|" $^ > $@
  98 
  99 _huffman.c: $(SRC)/common/bzip2/huffman.c
 100         sed "s|bzlib_private\.h|libstand_bzlib_private.h|" $^ > $@
 101 
 102 _randtable.c: $(SRC)/common/bzip2/randtable.c
 103         sed "s|bzlib_private\.h|libstand_bzlib_private.h|" $^ > $@
 104 
 105 CLEANFILES += libstand_bzlib_private.h
 106 libstand_bzlib_private.h: $(SRC)/common/bzip2/bzlib_private.h
 107         sed -e 's|<stdlib.h>|"stand.h"|' $^ > $@
 108 
 109 # decompression functionality from libz
 110 CFLAGS += -DHAVE_MEMCPY -I$(LIB_BASE)/libz
 111 SRCS += $(LIB_BASE)/libz/adler32.c $(LIB_BASE)/libz/crc32.c \
 112         libstand_zutil.h libstand_gzguts.h
 113 OBJS += adler32.o crc32.o
 114 
 115 _infback.c: $(LIB_BASE)/libz/infback.c
 116         sed -e "s|zutil\.h|libstand_zutil.h|" \
 117             -e "s|gzguts\.h|libstand_gzguts.h|" \
 118             $^ > $@
 119 _inffast.c: $(LIB_BASE)/libz/inffast.c
 120         sed -e "s|zutil\.h|libstand_zutil.h|" \
 121             -e "s|gzguts\.h|libstand_gzguts.h|" \
 122             $^ > $@
 123 _inflate.c: $(LIB_BASE)/libz/inflate.c
 124         sed -e "s|zutil\.h|libstand_zutil.h|" \
 125             -e "s|gzguts\.h|libstand_gzguts.h|" \
 126             $^ > $@
 127 _inftrees.c: $(LIB_BASE)/libz/inftrees.c
 128         sed -e "s|zutil\.h|libstand_zutil.h|" \
 129             -e "s|gzguts\.h|libstand_gzguts.h|" \
 130             $^ > $@
 131 _zutil.c: $(LIB_BASE)/libz/zutil.c
 132         sed -e "s|zutil\.h|libstand_zutil.h|" \
 133             -e "s|gzguts\.h|libstand_gzguts.h|" \
 134             $^ > $@
 135 
 136 SRCS += _infback.c _inffast.c _inflate.c _inftrees.c _zutil.c
 137 OBJS += _infback.o _inffast.o _inflate.o _inftrees.o _zutil.o
 138 CLEANFILES +=   _infback.c _inffast.c _inflate.c _inftrees.c _zutil.c
 139 
 140 # depend on stand.h being able to be included multiple times
 141 libstand_zutil.h: $(LIB_BASE)/libz/zutil.h
 142         sed -e 's|<fcntl.h>|"stand.h"|' \
 143             -e 's|<stddef.h>|"stand.h"|' \
 144             -e 's|<string.h>|"stand.h"|' \
 145             -e 's|<stdio.h>|"stand.h"|' \
 146             -e 's|<stdlib.h>|"stand.h"|' \
 147             $^ > $@
 148 
 149 libstand_gzguts.h: $(LIB_BASE)/libz/gzguts.h
 150         sed -e 's|<fcntl.h>|"stand.h"|' \
 151             -e 's|<stddef.h>|"stand.h"|' \
 152             -e 's|<string.h>|"stand.h"|' \
 153             -e 's|<stdio.h>|"stand.h"|' \
 154             -e 's|<stdlib.h>|"stand.h"|' \
 155             $^ > $@
 156 
 157 CLEANFILES += libstand_zutil.h libstand_gzguts.h
 158 
 159 # io routines
 160 SRCS += $(LIBSTAND_SRC)/closeall.c $(LIBSTAND_SRC)/dev.c \
 161         $(LIBSTAND_SRC)/ioctl.c $(LIBSTAND_SRC)/nullfs.c \
 162         $(LIBSTAND_SRC)/stat.c $(LIBSTAND_SRC)/fstat.c $(LIBSTAND_SRC)/close.c \
 163         $(LIBSTAND_SRC)/lseek.c $(LIBSTAND_SRC)/open.c $(LIBSTAND_SRC)/read.c \
 164         $(LIBSTAND_SRC)/write.c $(LIBSTAND_SRC)/readdir.c
 165 
 166 OBJS += closeall.o dev.o ioctl.o nullfs.o stat.o fstat.o close.o lseek.o \
 167         open.o read.o write.o readdir.o
 168 
 169 # network routines
 170 SRCS += $(LIBSTAND_SRC)/arp.c $(LIBSTAND_SRC)/ether.c \
 171         $(LIBSTAND_SRC)/inet_ntoa.c $(LIBSTAND_SRC)/in_cksum.c \
 172         $(LIBSTAND_SRC)/net.c $(LIBSTAND_SRC)/udp.c $(LIBSTAND_SRC)/netif.c \
 173         $(LIBSTAND_SRC)/rpc.c
 174 OBJS += arp.o ether.o inet_ntoa.o in_cksum.o net.o udp.o netif.o rpc.o
 175 
 176 # network info services:
 177 SRCS += $(LIBSTAND_SRC)/bootp.c $(LIBSTAND_SRC)/rarp.c \
 178         $(LIBSTAND_SRC)/bootparam.c
 179 OBJS += bootp.o rarp.o bootparam.o
 180 
 181 # boot filesystems
 182 SRCS += $(LIBSTAND_SRC)/ufs.c
 183 SRCS += $(LIBSTAND_SRC)/nfs.c
 184 SRCS += $(LIBSTAND_SRC)/cd9660.c
 185 SRCS += $(LIBSTAND_SRC)/tftp.c
 186 SRCS += $(LIBSTAND_SRC)/gzipfs.c
 187 SRCS += $(LIBSTAND_SRC)/bzipfs.c
 188 SRCS += $(LIBSTAND_SRC)/dosfs.c
 189 OBJS += ufs.o
 190 OBJS += nfs.o
 191 OBJS += cd9660.o
 192 OBJS += tftp.o
 193 OBJS += gzipfs.o
 194 OBJS += bzipfs.o
 195 OBJS += dosfs.o
 196 #