Merge remote-tracking branch 'origin/vendor/LIBARCHIVE'
[dragonfly.git] / lib / libstand / Makefile
1 # $FreeBSD: src/lib/libstand/Makefile,v 1.14.2.10 2002/07/22 14:21:50 ru Exp $
2 #
3 # Originally from       $NetBSD: Makefile,v 1.21 1997/10/26 22:08:38 lukem Exp $
4 #
5 # Notes:
6 # - We don't use the libc strerror/sys_errlist because the string table is
7 #   quite large.
8 #
9
10 LIB?=           stand
11 NOPROFILE=      YES
12 NOPIC=          YES
13 INCS?=          stand.h
14 MAN?=           libstand.3
15 CSTD?=          c99
16 WARNS?=         2
17 NO_STRICT_ALIASING=
18
19 LIBSTAND_SRC?=  ${.CURDIR}
20 LIBSTAND_ARCH?= ${MACHINE_ARCH}
21 LIBC_SRC=       ${LIBSTAND_SRC}/../libc
22
23 # Mostly OK, some of the libc imports are a bit noisy
24 CFLAGS+=        -ffreestanding
25
26 # Disable stack protector
27 CFLAGS+=        -fno-stack-protector
28
29 .if (${CFLAGS:M-flto} && ${CCVER:Mgcc*})
30 CFLAGS+=        -fno-builtin    # LTO exposes too much stuff
31 .endif
32
33 .if ${LIBSTAND_ARCH} == "x86_64"
34 CFLAGS+=        -mno-red-zone -fPIC
35 .endif
36
37 .if ${LIBSTAND_ARCH} == "i386"
38 .if ${CCVER:Mgcc*}
39 CFLAGS+=        -mpreferred-stack-boundary=2
40 .endif
41 FORCE_CPUTYPE=  i386
42 CFLAGS+=        -m32
43 .endif
44
45 .if ${LIBSTAND_ARCH} == "i386" || ${LIBSTAND_ARCH} == "x86_64"
46 CFLAGS+=        -mno-mmx -mno-3dnow -mno-sse -mno-sse2 -mno-sse3 -msoft-float
47 .endif
48
49 # standalone components and stuff we have modified locally
50 SRCS+=  __main.c assert.c bcd.c bswap.c environment.c getopt.c gets.c \
51         globals.c pager.c printf.c random.c \
52         strdup.c strerror.c strtol.c strtoul.c sbrk.c \
53         twiddle.c zalloc.c zalloc_malloc.c
54
55 # private (pruned) versions of libc string functions
56 SRCS+=  strcasecmp.c
57
58 # string functions from libc
59 .PATH:  ${LIBSTAND_SRC}/../libc/string
60 .if ${LIBSTAND_ARCH} == "x86_64" || ${LIBSTAND_ARCH} == "i386"
61 SRCS+=  bcmp.c bcopy.c bzero.c ffs.c index.c memccpy.c memchr.c memcmp.c \
62         memcpy.c memmove.c memset.c qdivrem.c rindex.c strcat.c strchr.c \
63         strcmp.c strcpy.c strcspn.c strlen.c strncat.c strncmp.c strncpy.c \
64         strpbrk.c strrchr.c strsep.c strspn.c strstr.c strtok.c swab.c
65
66 # math stuff, thus no -flto!
67 qdivrem.o:      qdivrem.c
68         ${CC} ${CFLAGS:N-flto} -c -o ${.TARGET} ${.IMPSRC}
69 .endif
70
71 # _setjmp/_longjmp
72 .PATH:  ${LIBSTAND_SRC}/${LIBSTAND_ARCH}
73 .if ${LIBSTAND_ARCH} == "x86_64" || ${LIBSTAND_ARCH} == "i386"
74 # really only required for i386
75 CFLAGS+=-I${LIBSTAND_SRC}/../libc/${MACHINE_ARCH}
76 .endif
77 SRCS+=  _setjmp.S
78
79 # decompression functionality from libz
80 # NOTE: crc32.c is used from libz and not libkern
81 .include "../libz/Makefile.stand"
82
83 # iscsi_crc32() for hammer2
84 .PATH:  ${LIBSTAND_SRC}/../../sys/libkern
85 SRCS+=  icrc32.c
86
87 # decompression functionality from libbz2
88 BZ2DIR= ${LIBSTAND_SRC}/../../contrib/bzip2
89 .PATH:  ${BZ2DIR}
90 CFLAGS+=-I${BZ2DIR} -DBZ_NO_STDIO -DBZ_NO_COMPRESS
91 SRCS+=  bzlib.c crctable.c decompress.c huffman.c randtable.c bzlib.h \
92         bzlib_private.h
93
94 # check your belt - ugly bzip2 stuff ahead
95 .for file in bzlib.c
96 CLEANFILES+=   ${file}
97
98 ${file}: ${BZ2DIR}/${file} ${file}.diff
99         patch -o ${.TARGET} < ${.ALLSRC:M*.diff} ${.ALLSRC:M*.[ch]}
100 .endfor
101
102 # io routines
103 SRCS+=  closeall.c dev.c ioctl.c nullfs.c stat.c \
104         fstat.c close.c lseek.c open.c read.c write.c readdir.c
105
106 # uuid routines
107 SRCS+=  uuid_from_string.c uuid_to_string.c
108
109 # uuid routines from libc
110 .PATH: ${LIBC_SRC}/uuid
111 SRCS+=  uuid_create_nil.c
112
113 # network routines
114 SRCS+=  arp.c ether.c inet_ntoa.c in_cksum.c net.c udp.c netif.c rpc.c
115
116 # network info services:
117 SRCS+=  bootp.c rarp.c bootparam.c
118
119 # boot filesystems
120 SRCS+=  ufs.c nfs.c cd9660.c tftp.c bzipfs.c gzipfs.c
121 SRCS+=  netif.c nfs.c
122 SRCS+=  dosfs.c ext2fs.c
123 SRCS+=  splitfs.c
124 SRCS+=  hammer1.c
125 SRCS+=  hammer2.c
126
127 .include <bsd.lib.mk>