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