Merge ^/head r294169 through r294598.
[freebsd.git] / lib / libstand / Makefile
1 # $FreeBSD$
2 # Originally from       $NetBSD: Makefile,v 1.21 1997/10/26 22:08:38 lukem Exp $
3 #
4 # Notes:
5 # - We don't use the libc strerror/sys_errlist because the string table is
6 #   quite large.
7 #
8
9 MK_PROFILE=     no
10 MK_SSP=         no
11
12 .include <src.opts.mk>
13
14 LIBSTAND_SRC?=  ${.CURDIR}
15 LIBSTAND_CPUARCH?=${MACHINE_CPUARCH}
16 LIBC_SRC=       ${LIBSTAND_SRC}/../libc
17
18 LIB=            stand
19 NO_PIC=
20 INCS?=          stand.h
21 MAN?=           libstand.3
22
23 WARNS?=         0
24
25 CFLAGS+= -I${LIBSTAND_SRC}
26
27 # standalone components and stuff we have modified locally
28 SRCS+=  gzguts.h zutil.h __main.c assert.c bcd.c bswap.c environment.c getopt.c gets.c \
29         globals.c pager.c printf.c strdup.c strerror.c strtol.c strtoul.c random.c \
30         sbrk.c twiddle.c zalloc.c zalloc_malloc.c
31
32 # private (pruned) versions of libc string functions
33 SRCS+=  strcasecmp.c
34
35 .PATH: ${LIBC_SRC}/net
36
37 SRCS+= ntoh.c
38
39 # string functions from libc
40 .PATH: ${LIBC_SRC}/string
41 SRCS+=  bcmp.c bcopy.c bzero.c ffs.c fls.c \
42         memccpy.c memchr.c memcmp.c memcpy.c memmove.c memset.c \
43         qdivrem.c strcat.c strchr.c strcmp.c strcpy.c \
44         strcspn.c strlcat.c strlcpy.c strlen.c strncat.c strncmp.c strncpy.c \
45         strpbrk.c strrchr.c strsep.c strspn.c strstr.c strtok.c swab.c
46 .if ${MACHINE_CPUARCH} == "arm"
47 .PATH: ${LIBC_SRC}/arm/gen
48
49 # Do not generate movt/movw, because the relocation fixup for them does not
50 # translate to the -Bsymbolic -pie format required by self_reloc() in loader(8).
51 # Also, the fpu is not available in a standalone environment.
52 .if ${COMPILER_VERSION} < 30800
53 CFLAGS.clang+=  -mllvm -arm-use-movt=0
54 .else
55 CFLAGS.clang+=  -mno-movt
56 .endif
57 CFLAGS.clang+=  -mfpu=none
58
59 # Compiler support functions
60 .PATH: ${LIBSTAND_SRC}/../../contrib/compiler-rt/lib/builtins/
61 # __clzsi2 and ctzsi2 for various builtin functions
62 SRCS+=  clzsi2.c ctzsi2.c
63 # Divide and modulus functions called by the compiler
64 SRCS+=   divmoddi4.c  divmodsi4.c  divdi3.c  divsi3.c  moddi3.c  modsi3.c
65 SRCS+=  udivmoddi4.c udivmodsi4.c udivdi3.c udivsi3.c umoddi3.c umodsi3.c
66
67 .PATH: ${LIBSTAND_SRC}/../../contrib/compiler-rt/lib/builtins/arm/
68 SRCS+=  aeabi_idivmod.S aeabi_ldivmod.S aeabi_uidivmod.S aeabi_uldivmod.S
69 SRCS+=  aeabi_memcmp.S aeabi_memcpy.S aeabi_memmove.S aeabi_memset.S
70 .endif
71
72 .if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "riscv"
73 .PATH: ${LIBC_SRC}/${MACHINE_CPUARCH}/gen
74 .endif
75
76 .if ${MACHINE_CPUARCH} == "powerpc"
77 .PATH: ${LIBC_SRC}/quad
78 SRCS+=  ashldi3.c ashrdi3.c
79 SRCS+=  syncicache.c
80 .endif
81
82 # uuid functions from libc
83 .PATH: ${LIBC_SRC}/uuid
84 SRCS+= uuid_create_nil.c uuid_equal.c uuid_from_string.c uuid_is_nil.c uuid_to_string.c
85
86 # _setjmp/_longjmp
87 .PATH: ${LIBSTAND_SRC}/${LIBSTAND_CPUARCH}
88 SRCS+=  _setjmp.S
89
90 # decompression functionality from libbz2
91 # NOTE: to actually test this functionality after libbz2 upgrade compile
92 # loader(8) with LOADER_BZIP2_SUPPORT defined
93 .PATH: ${LIBSTAND_SRC}/../../contrib/bzip2
94 CFLAGS+= -DBZ_NO_STDIO -DBZ_NO_COMPRESS
95 SRCS+=  libstand_bzlib_private.h
96
97 .for file in bzlib.c crctable.c decompress.c huffman.c randtable.c
98 SRCS+=  _${file}
99 CLEANFILES+=    _${file}
100
101 _${file}: ${file}
102         sed "s|bzlib_private\.h|libstand_bzlib_private.h|" \
103             ${.ALLSRC} > ${.TARGET}
104 .endfor
105
106 CLEANFILES+= libstand_bzlib_private.h
107 libstand_bzlib_private.h: bzlib_private.h
108         sed -e 's|<stdlib.h>|"stand.h"|' \
109                 ${.ALLSRC} > ${.TARGET}
110
111 # decompression functionality from libz
112 .PATH: ${LIBSTAND_SRC}/../libz
113 CFLAGS+=-DHAVE_MEMCPY -I${LIBSTAND_SRC}/../libz
114 SRCS+=  adler32.c crc32.c libstand_zutil.h libstand_gzguts.h
115
116 .for file in infback.c inffast.c inflate.c inftrees.c zutil.c
117 SRCS+=  _${file}
118 CLEANFILES+=    _${file}
119
120 _${file}: ${file}
121         sed -e "s|zutil\.h|libstand_zutil.h|" \
122             -e "s|gzguts\.h|libstand_gzguts.h|" \
123             ${.ALLSRC} > ${.TARGET}
124 .endfor
125
126 # depend on stand.h being able to be included multiple times
127 .for file in zutil.h gzguts.h
128 CLEANFILES+= libstand_${file}
129 libstand_${file}: ${file}
130         sed -e 's|<fcntl.h>|"stand.h"|' \
131             -e 's|<stddef.h>|"stand.h"|' \
132             -e 's|<string.h>|"stand.h"|' \
133             -e 's|<stdio.h>|"stand.h"|' \
134             -e 's|<stdlib.h>|"stand.h"|' \
135             ${.ALLSRC} > ${.TARGET}
136 .endfor
137
138 # io routines
139 SRCS+=  closeall.c dev.c ioctl.c nullfs.c stat.c \
140         fstat.c close.c lseek.c open.c read.c write.c readdir.c
141
142 # network routines
143 SRCS+=  arp.c ether.c inet_ntoa.c in_cksum.c net.c udp.c netif.c rpc.c
144
145 # network info services:
146 SRCS+=  bootp.c rarp.c bootparam.c
147
148 # boot filesystems
149 SRCS+=  ufs.c nfs.c cd9660.c tftp.c gzipfs.c bzipfs.c
150 SRCS+=  dosfs.c ext2fs.c
151 SRCS+=  splitfs.c
152 SRCS+=  pkgfs.c
153 .if ${MK_NAND} != "no"
154 SRCS+=  nandfs.c
155 .endif
156
157 .include <bsd.stand.mk>
158 .include <bsd.lib.mk>