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 2019 Joyent, Inc. 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 24SRCS += $(ZLIB)/gzguts.h $(ZLIB)/zutil.h 25SRCS += $(SASRC)/__main.c $(SASRC)/abort.c $(SASRC)/assert.c 26SRCS += $(SASRC)/bcd.c $(SASRC)/environment.c 27SRCS += $(SASRC)/getopt.c $(SASRC)/random.c 28SRCS += $(SASRC)/sbrk.c $(SASRC)/twiddle.c 29SRCS += $(SASRC)/zalloc.c $(SASRC)/zalloc_malloc.c 30 31OBJECTS += __main.o abort.o assert.o bcd.o environment.o \ 32 getopt.o gets.o globals.o pager.o panic.o printf.o \ 33 strdup.o strerror.o strtol.o strtoll.o strtoul.o strtoull.o random.o \ 34 sbrk.o twiddle.o zalloc.o zalloc_malloc.o 35 36# private (pruned) versions of libc string functions 37SRCS += $(SASRC)/strcasecmp.c 38OBJECTS += strcasecmp.o 39 40# from libc 41SRCS += $(SASRC)/ntoh.c 42OBJECTS += ntoh.o 43 44# string functions from libc 45SRCS += $(SASRC)/string/bcmp.c $(SASRC)/string/bcopy.c 46SRCS += $(SASRC)/string/bzero.c $(SASRC)/string/ffs.c 47SRCS += $(SASRC)/string/fls.c $(SASRC)/string/memccpy.c 48SRCS += $(SASRC)/string/memchr.c $(SASRC)/string/memcmp.c 49SRCS += $(SASRC)/string/memcpy.c $(SASRC)/string/memmove.c 50SRCS += $(SASRC)/string/memset.c $(SASRC)/string/strcat.c 51SRCS += $(SASRC)/string/strchr.c $(SASRC)/string/strcmp.c 52SRCS += $(SASRC)/string/strcpy.c $(SASRC)/string/stpcpy.c 53SRCS += $(SASRC)/string/stpncpy.c $(SASRC)/string/strcspn.c 54SRCS += $(SASRC)/string/strlcat.c $(SASRC)/string/strlcpy.c 55SRCS += $(SASRC)/string/strlen.c $(SASRC)/string/strncat.c 56SRCS += $(SASRC)/string/strncmp.c $(SASRC)/string/strncpy.c 57SRCS += $(SASRC)/string/strpbrk.c $(SASRC)/string/strrchr.c 58SRCS += $(SASRC)/string/strsep.c $(SASRC)/string/strspn.c 59SRCS += $(SASRC)/string/strstr.c $(SASRC)/string/strtok.c 60SRCS += $(SASRC)/string/swab.c 61 62SRCS += $(SASRC)/qdivrem.c 63 64OBJECTS += bcmp.o bcopy.o bzero.o ffs.o fls.o \ 65 memccpy.o memchr.o memcmp.o memcpy.o memmove.o memset.o \ 66 qdivrem.o strcat.o strchr.o strcmp.o strcpy.o stpcpy.o stpncpy.o \ 67 strcspn.o strlcat.o strlcpy.o strlen.o strncat.o strncmp.o strncpy.o \ 68 strpbrk.o strrchr.o strsep.o strspn.o strstr.o strtok.o swab.o 69 70# uuid functions from libc 71SRCS += $(SASRC)/uuid/uuid_create_nil.c 72SRCS += $(SASRC)/uuid/uuid_equal.c 73SRCS += $(SASRC)/uuid/uuid_is_nil.c 74 75SRCS += $(SASRC)/uuid_from_string.c 76SRCS += $(SASRC)/uuid_to_string.c 77 78OBJECTS += uuid_create_nil.o uuid_equal.o uuid_from_string.o uuid_is_nil.o \ 79 uuid_to_string.o 80 81# decompression functionality from libbz2 82# NOTE: to actually test this functionality after libbz2 upgrade compile 83# loader(8) with LOADER_BZIP2_SUPPORT defined 84objs/_bzlib.o := CPPFLAGS += -DBZ_LOADER -DBZ_NO_STDIO -DBZ_NO_COMPRESS 85objs/_bzlib.o := CPPFLAGS += -I$(SRC)/common/bzip2 86objs/_bzlib.o: libstand_bzlib_private.h 87pics/_bzlib.o := CPPFLAGS += -DBZ_LOADER -DBZ_NO_STDIO -DBZ_NO_COMPRESS 88pics/_bzlib.o := CPPFLAGS += -I$(SRC)/common/bzip2 89pics/_bzlib.o: libstand_bzlib_private.h 90objs/_crctable.o := CPPFLAGS += -DBZ_LOADER -DBZ_NO_STDIO -DBZ_NO_COMPRESS 91objs/_crctable.o := CPPFLAGS += -I$(SRC)/common/bzip2 92objs/_crctable.o: libstand_bzlib_private.h 93pics/_crctable.o := CPPFLAGS += -DBZ_LOADER -DBZ_NO_STDIO -DBZ_NO_COMPRESS 94pics/_crctable.o := CPPFLAGS += -I$(SRC)/common/bzip2 95pics/_crctable.o: libstand_bzlib_private.h 96objs/_decompress.o := CPPFLAGS += -DBZ_LOADER -DBZ_NO_STDIO -DBZ_NO_COMPRESS 97objs/_decompress.o := CPPFLAGS += -I$(SRC)/common/bzip2 98objs/_decompress.o: libstand_bzlib_private.h 99pics/_decompress.o := CPPFLAGS += -DBZ_LOADER -DBZ_NO_STDIO -DBZ_NO_COMPRESS 100pics/_decompress.o := CPPFLAGS += -I$(SRC)/common/bzip2 101pics/_decompress.o: libstand_bzlib_private.h 102objs/_huffman.o := CPPFLAGS += -DBZ_LOADER -DBZ_NO_STDIO -DBZ_NO_COMPRESS 103objs/_huffman.o := CPPFLAGS += -I$(SRC)/common/bzip2 104objs/_huffman.o: libstand_bzlib_private.h 105pics/_huffman.o := CPPFLAGS += -DBZ_LOADER -DBZ_NO_STDIO -DBZ_NO_COMPRESS 106pics/_huffman.o := CPPFLAGS += -I$(SRC)/common/bzip2 107pics/_huffman.o: libstand_bzlib_private.h 108objs/_randtable.o := CPPFLAGS += -DBZ_LOADER -DBZ_NO_STDIO -DBZ_NO_COMPRESS 109objs/_randtable.o := CPPFLAGS += -I$(SRC)/common/bzip2 110objs/_randtable.o: libstand_bzlib_private.h 111pics/_randtable.o := CPPFLAGS += -DBZ_LOADER -DBZ_NO_STDIO -DBZ_NO_COMPRESS 112pics/_randtable.o := CPPFLAGS += -I$(SRC)/common/bzip2 113pics/_randtable.o: libstand_bzlib_private.h 114objs/bzipfs.o := CPPFLAGS += -DBZ_LOADER -DBZ_NO_STDIO -DBZ_NO_COMPRESS 115objs/bzipfs.o := CPPFLAGS += -I$(SRC)/common/bzip2 116objs/bzipfs.o: libstand_bzlib_private.h 117pics/bzipfs.o := CPPFLAGS += -DBZ_LOADER -DBZ_NO_STDIO -DBZ_NO_COMPRESS 118pics/bzipfs.o := CPPFLAGS += -I$(SRC)/common/bzip2 119pics/bzipfs.o: libstand_bzlib_private.h 120SRCS += libstand_bzlib_private.h 121 122# too hairy 123objs/_inflate.o := SMATCH=off 124pics/_inflate.o := SMATCH=off 125 126SRCS += _bzlib.c _crctable.c _decompress.c _huffman.c _randtable.c 127OBJECTS += _bzlib.o _crctable.o _decompress.o _huffman.o _randtable.o 128CLEANFILES += _bzlib.c _crctable.c _decompress.c _huffman.c _randtable.c 129 130_bzlib.c: $(SRC)/common/bzip2/bzlib.c 131 sed "s|bzlib_private\.h|libstand_bzlib_private.h|" $^ > $@ 132 133_crctable.c: $(SRC)/common/bzip2/crctable.c 134 sed "s|bzlib_private\.h|libstand_bzlib_private.h|" $^ > $@ 135 136_decompress.c: $(SRC)/common/bzip2/decompress.c 137 sed "s|bzlib_private\.h|libstand_bzlib_private.h|" $^ > $@ 138 139_huffman.c: $(SRC)/common/bzip2/huffman.c 140 sed "s|bzlib_private\.h|libstand_bzlib_private.h|" $^ > $@ 141 142_randtable.c: $(SRC)/common/bzip2/randtable.c 143 sed "s|bzlib_private\.h|libstand_bzlib_private.h|" $^ > $@ 144 145CLEANFILES += libstand_bzlib_private.h 146libstand_bzlib_private.h: $(SRC)/common/bzip2/bzlib_private.h 147 sed -e 's|<stdlib.h>|"stand.h"|' $^ > $@ 148 149# decompression functionality from zlib 150objs/adler32.o := CPPFLAGS += -I$(ZLIB) 151pics/adler32.o := CPPFLAGS += -I$(ZLIB) 152objs/crc32.o := CPPFLAGS += -I$(ZLIB) 153pics/crc32.o := CPPFLAGS += -I$(ZLIB) 154objs/_infback.o := CPPFLAGS += -I$(ZLIB) 155pics/_infback.o := CPPFLAGS += -I$(ZLIB) 156objs/_infback.o pics/_infback.o: libstand_zutil.h libstand_gzguts.h 157objs/_inffast.o := CPPFLAGS += -I$(ZLIB) 158pics/_inffast.o := CPPFLAGS += -I$(ZLIB) 159objs/_inffast.o pics/_inffast.o: libstand_zutil.h libstand_gzguts.h 160objs/_inflate.o := CPPFLAGS += -I$(ZLIB) 161pics/_inflate.o := CPPFLAGS += -I$(ZLIB) 162objs/_inflate.o pics/_inflate.o: libstand_zutil.h libstand_gzguts.h 163objs/_inftrees.o := CPPFLAGS += -I$(ZLIB) 164pics/_inftrees.o := CPPFLAGS += -I$(ZLIB) 165objs/_inftrees.o pics/_inftrees.o: libstand_zutil.h libstand_gzguts.h 166objs/_zutil.o := CPPFLAGS += -I$(ZLIB) 167pics/_zutil.o := CPPFLAGS += -I$(ZLIB) 168objs/_zutil.o pics/_zutil.o: libstand_zutil.h libstand_gzguts.h 169objs/gzipfs.o := CPPFLAGS += -I$(ZLIB) 170pics/gzipfs.o := CPPFLAGS += -I$(ZLIB) 171objs/gzip.o := CPPFLAGS += -I$(ZLIB) 172pics/gzip.o := CPPFLAGS += -I$(ZLIB) 173 174SRCS += $(ZLIB)/adler32.c $(ZLIB)/crc32.c \ 175 libstand_zutil.h libstand_gzguts.h 176OBJECTS += adler32.o crc32.o 177 178_infback.c: $(ZLIB)/infback.c 179 sed -e "s|zutil\.h|libstand_zutil.h|" \ 180 -e "s|gzguts\.h|libstand_gzguts.h|" \ 181 $^ > $@ 182_inffast.c: $(ZLIB)/inffast.c 183 sed -e "s|zutil\.h|libstand_zutil.h|" \ 184 -e "s|gzguts\.h|libstand_gzguts.h|" \ 185 $^ > $@ 186_inflate.c: $(ZLIB)/inflate.c 187 sed -e "s|zutil\.h|libstand_zutil.h|" \ 188 -e "s|gzguts\.h|libstand_gzguts.h|" \ 189 $^ > $@ 190_inftrees.c: $(ZLIB)/inftrees.c 191 sed -e "s|zutil\.h|libstand_zutil.h|" \ 192 -e "s|gzguts\.h|libstand_gzguts.h|" \ 193 $^ > $@ 194_zutil.c: $(ZLIB)/zutil.c 195 sed -e "s|zutil\.h|libstand_zutil.h|" \ 196 -e "s|gzguts\.h|libstand_gzguts.h|" \ 197 $^ > $@ 198 199SRCS += _infback.c _inffast.c _inflate.c _inftrees.c _zutil.c 200OBJECTS += _infback.o _inffast.o _inflate.o _inftrees.o _zutil.o 201CLEANFILES += _infback.c _inffast.c _inflate.c _inftrees.c _zutil.c 202 203# depend on stand.h being able to be included multiple times 204libstand_zutil.h: $(ZLIB)/zutil.h 205 sed -e 's|<fcntl.h>|"stand.h"|' \ 206 -e 's|<stddef.h>|"stand.h"|' \ 207 -e 's|<string.h>|"stand.h"|' \ 208 -e 's|<stdio.h>|"stand.h"|' \ 209 -e 's|<stdlib.h>|"stand.h"|' \ 210 $^ > $@ 211 212libstand_gzguts.h: $(ZLIB)/gzguts.h 213 sed -e 's|<fcntl.h>|"stand.h"|' \ 214 -e 's|<stddef.h>|"stand.h"|' \ 215 -e 's|<string.h>|"stand.h"|' \ 216 -e 's|<stdio.h>|"stand.h"|' \ 217 -e 's|<stdlib.h>|"stand.h"|' \ 218 $^ > $@ 219 220CLEANFILES += libstand_zutil.h libstand_gzguts.h 221 222# lz4 decompression functionality 223pics/lz4.o := CPPFLAGS += -I$(LZ4) 224objs/lz4.o := CPPFLAGS += -I$(LZ4) 225SRCS += $(LZ4)/lz4.c 226OBJECTS += lz4.o 227 228# io routines 229SRCS += $(SASRC)/closeall.c $(SASRC)/dev.c \ 230 $(SASRC)/ioctl.c $(SASRC)/nullfs.c \ 231 $(SASRC)/stat.c $(SASRC)/fstat.c $(SASRC)/close.c \ 232 $(SASRC)/lseek.c $(SASRC)/open.c $(SASRC)/read.c \ 233 $(SASRC)/write.c $(SASRC)/readdir.c 234 235OBJECTS += closeall.o dev.o ioctl.o nullfs.o stat.o fstat.o close.o lseek.o \ 236 open.o read.o write.o readdir.o 237 238# SMBios routines 239SRCS += smbios.c 240OBJECTS += smbios.o 241# Export serial numbers, UUID, and asset tag from loader. 242# Use little-endian UUID format as defined in SMBIOS 2.6. 243pics/smbios.o := CPPFLAGS += -DSMBIOS_SERIAL_NUMBERS -DSMBIOS_LITTLE_ENDIAN_UUID 244objs/smbios.o := CPPFLAGS += -DSMBIOS_SERIAL_NUMBERS -DSMBIOS_LITTLE_ENDIAN_UUID 245 246# network routines 247SRCS += $(SASRC)/arp.c $(SASRC)/ether.c $(SASRC)/ip.c \ 248 $(SASRC)/inet_ntoa.c $(SASRC)/in_cksum.c \ 249 $(SASRC)/net.c $(SASRC)/udp.c $(SASRC)/netif.c \ 250 $(SASRC)/rpc.c 251OBJECTS += arp.o ether.o ip.o inet_ntoa.o in_cksum.o net.o udp.o netif.o rpc.o 252 253# network info services: 254SRCS += $(SASRC)/bootp.c $(SASRC)/rarp.c \ 255 $(SASRC)/bootparam.c 256OBJECTS += bootp.o rarp.o bootparam.o 257 258# boot filesystems 259SRCS += $(SASRC)/ufs.c 260SRCS += $(SASRC)/nfs.c 261SRCS += $(SASRC)/cd9660.c 262SRCS += $(SASRC)/tftp.c 263SRCS += $(SASRC)/gzipfs.c 264SRCS += $(SASRC)/bzipfs.c 265SRCS += $(SASRC)/dosfs.c 266OBJECTS += ufs.o 267OBJECTS += nfs.o 268OBJECTS += cd9660.o 269OBJECTS += tftp.o 270OBJECTS += gzipfs.o 271OBJECTS += bzipfs.o 272OBJECTS += dosfs.o 273 274# utility 275SRCS += $(SRC)/common/util/explicit_bzero.c 276SRCS += $(SRC)/common/util/memmem.c 277OBJECTS += explicit_bzero.o 278OBJECTS += memmem.o 279