Mirror of :pserver:cvs@cvs.fefe.de:/cvs libowfat https://www.fefe.de/libowfat/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

377 lines
12 KiB

16 years ago
6 years ago
21 years ago
21 years ago
5 years ago
21 years ago
5 years ago
6 years ago
18 years ago
5 years ago
5 years ago
6 years ago
21 years ago
21 years ago
20 years ago
16 years ago
6 years ago
21 years ago
21 years ago
21 years ago
16 years ago
6 years ago
21 years ago
21 years ago
20 years ago
16 years ago
6 years ago
21 years ago
6 years ago
5 years ago
5 years ago
5 years ago
21 years ago
21 years ago
12 years ago
18 years ago
5 years ago
21 years ago
21 years ago
5 years ago
20 years ago
5 years ago
5 years ago
20 years ago
5 years ago
20 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
5 years ago
18 years ago
5 years ago
17 years ago
5 years ago
17 years ago
5 years ago
5 years ago
5 years ago
18 years ago
5 years ago
18 years ago
5 years ago
18 years ago
21 years ago
5 years ago
5 years ago
  1. # Warning! There is no real "make install" support.
  2. # The include files are named after the djb, i.e. pretty generic. They
  3. # will probably conflict with other headers. That's why I install them
  4. # in /opt/diet, where they are in the default search path for my diet libc
  5. # work but don't conflict with anything there. YMMV.
  6. prefix=/opt/diet
  7. LIBDIR=${prefix}/lib
  8. INCLUDEDIR=${prefix}/include
  9. MAN3DIR=${prefix}/man/man3
  10. LIBS=byte.a fmt.a scan.a str.a uint.a open.a stralloc.a unix.a socket.a \
  11. buffer.a mmap.a taia.a tai.a dns.a case.a mult.a array.a io.a \
  12. textcode.a cdb.a critbit.a
  13. all: ent $(LIBS) libowfat.a libsocket t
  14. CROSS=
  15. #CROSS=i686-mingw-
  16. CC=gcc
  17. CCC=$(CROSS)$(CC)
  18. WERROR=
  19. WARN=-W -Wall -Wextra $(WERROR)
  20. # Use the second version if you are building for a binary that is only
  21. # supposed to run on this machine. It tells gcc to use CPU instructions
  22. # that are specific to the CPU the code is compiled on.
  23. NATIVE=
  24. #NATIVE=-march=native -mtune=native
  25. OPT_REG=-O2
  26. OPT_PLUS=-O3 $(NATIVE)
  27. DEFINE=-D_REENTRANT
  28. CFLAGS=-pipe $(WARN) $(DEFINE) $(OPT_REG)
  29. CFLAGS_OPT=-pipe $(WARN) $(DEFINE) $(OPT_PLUS)
  30. #CFLAGS=-pipe -Os -march=pentiumpro -mcpu=pentiumpro -fomit-frame-pointer -fschedule-insns2 -Wall
  31. ent: ent.c haveuint128.h
  32. $(CC) -g -o ent ent.c -I.
  33. # CFLAGS += -fstrict-aliasing -Wstrict-aliasing=2
  34. # startrip
  35. ifneq ($(DEBUG),)
  36. CFLAGS=-pipe -Wall -g -Og
  37. endif
  38. path = $(subst :, ,$(PATH))
  39. diet_path = $(foreach dir,$(path),$(wildcard $(dir)/diet))
  40. ifeq ($(strip $(diet_path)),)
  41. ifneq ($(wildcard /opt/diet/bin/diet),)
  42. DIET=/opt/diet/bin/diet
  43. else
  44. DIET=
  45. endif
  46. else
  47. DIET:=$(strip $(diet_path))
  48. endif
  49. gcc_path = $(foreach dir,$(path),$(wildcard $(dir)/gcc))
  50. ifeq ($(strip $(gcc_path)),)
  51. CC=clang
  52. else
  53. CC=gcc
  54. endif
  55. ifneq ($(DIET),)
  56. DIETLIBPATH=$(shell $(DIET) -L $(CCC))
  57. ifneq ($(wildcard $(DIETLIBPATH)/*ibc.a),)
  58. LIBDIR=$(DIETLIBPATH)
  59. endif
  60. ifneq ($(DEBUG),1)
  61. DIET+=-Os
  62. endif
  63. endif
  64. # to build without diet libc support, use $ make DIET=
  65. # see http://www.fefe.de/dietlibc/ for details about the diet libc
  66. VPATH=str:byte:fmt:scan:uint:open:stralloc:unix:socket:buffer:mmap:textcode:taia:tai:dns:case:array:mult:io:cdb:critbit
  67. BYTE_OBJS=$(patsubst byte/%.c,%.o,$(wildcard byte/*.c))
  68. FMT_OBJS=$(patsubst fmt/%.c,%.o,$(wildcard fmt/*.c))
  69. SCAN_OBJS=$(patsubst scan/%.c,%.o,$(wildcard scan/*.c))
  70. STR_OBJS=$(patsubst str/%.c,%.o,$(wildcard str/*.c))
  71. UINT_OBJS=$(patsubst uint/%.c,%.o,$(wildcard uint/*.c))
  72. OPEN_OBJS=$(patsubst open/%.c,%.o,$(wildcard open/*.c))
  73. STRALLOC_OBJS=$(patsubst stralloc/%.c,%.o,$(wildcard stralloc/*.c))
  74. UNIX_OBJS=$(patsubst unix/%.c,%.o,$(wildcard unix/*.c))
  75. SOCKET_OBJS=$(patsubst socket/%.c,%.o,$(wildcard socket/*.c))
  76. BUFFER_OBJS=$(patsubst buffer/%.c,%.o,$(wildcard buffer/*.c))
  77. MMAP_OBJS=$(patsubst mmap/%.c,%.o,$(wildcard mmap/*.c))
  78. TEXTCODE_OBJS=$(patsubst textcode/%.c,%.o,$(wildcard textcode/*.c))
  79. TAI_OBJS=$(patsubst tai/%.c,%.o,$(wildcard tai/*.c))
  80. TAIA_OBJS=$(patsubst taia/%.c,%.o,$(wildcard taia/*.c))
  81. DNS_OBJS=$(patsubst dns/%.c,%.o,$(wildcard dns/*.c))
  82. CASE_OBJS=$(patsubst case/%.c,%.o,$(wildcard case/*.c))
  83. ARRAY_OBJS=$(patsubst array/%.c,%.o,$(wildcard array/*.c))
  84. MULT_OBJS=$(patsubst mult/%.c,%.o,$(wildcard mult/*.c))
  85. IO_OBJS=$(patsubst io/%.c,%.o,$(wildcard io/*.c))
  86. CDB_OBJS=$(patsubst cdb/%.c,%.o,$(wildcard cdb/*.c))
  87. CRITBIT_OBJS=$(patsubst critbit/%.c,%.o,$(wildcard critbit/*.c))
  88. $(BYTE_OBJS): byte.h
  89. $(FMT_OBJS): fmt.h
  90. $(SCAN_OBJS): scan.h haveuint128.h
  91. $(STR_OBJS): str.h
  92. $(UINT_OBJS): uint16.h uint32.h
  93. $(STRALLOC_OBJS): stralloc.h
  94. $(SOCKET_OBJS): socket.h
  95. $(BUFFER_OBJS): buffer.h
  96. $(MMAP_OBJS): mmap.h open.h
  97. $(TEXTCODE_OBJS): textcode.h
  98. $(TAI_OBJS): tai.h uint64.h
  99. $(TAIA_OBJS): taia.h tai.h uint64.h
  100. $(DNS_OBJS): dns.h stralloc.h taia.h tai.h uint64.h iopause.h
  101. $(CASE_OBJS): case.h
  102. $(ARRAY_OBJS): uint64.h array.h
  103. $(MULT_OBJS): uint64.h uint32.h uint16.h safemult.h
  104. $(IO_OBJS): uint64.h array.h io.h io_internal.h taia.h tai.h haveepoll.h havekqueue.h havesigio.h havebsdsf.h havedevpoll.h havesendfile.h
  105. $(CDB_OBJS): cdb.h uint32.h
  106. $(CRITBIT_OBJS): critbit.h
  107. mult64.o: haveuint128.h
  108. iob_addbuf.o iob_addfile.o iob_new.o iob_reset.o iob_send.o: iob_internal.h iob.h
  109. iopause.o: iopause.h select.h
  110. openreadclose.o readclose.o: readclose.h
  111. dns_rcip.o dns_rcrw.o openreadclose.o: openreadclose.h
  112. iob_send.o scan_ip6if.o: havealloca.h
  113. cdb.o io_mmapwritefile.o: havepread.h
  114. # stoprip
  115. byte.a: $(BYTE_OBJS)
  116. fmt.a: $(FMT_OBJS)
  117. scan.a: $(SCAN_OBJS)
  118. str.a: $(STR_OBJS)
  119. uint.a: $(UINT_OBJS)
  120. open.a: $(OPEN_OBJS)
  121. stralloc.a: $(STRALLOC_OBJS)
  122. unix.a: $(UNIX_OBJS)
  123. socket.a: $(SOCKET_OBJS)
  124. buffer.a: $(BUFFER_OBJS)
  125. mmap.a: $(MMAP_OBJS)
  126. textcode.a: $(TEXTCODE_OBJS)
  127. taia.a: $(TAIA_OBJS)
  128. tai.a: $(TAI_OBJS)
  129. dns.a: $(DNS_OBJS)
  130. case.a: $(CASE_OBJS)
  131. array.a: $(ARRAY_OBJS)
  132. mult.a: $(MULT_OBJS)
  133. io.a: $(IO_OBJS)
  134. cdb.a: $(CDB_OBJS)
  135. critbit.a: $(CRITBIT_OBJS)
  136. ALL_OBJS=$(DNS_OBJS) $(BYTE_OBJS) $(FMT_OBJS) $(SCAN_OBJS) \
  137. $(STR_OBJS) $(UINT_OBJS) $(OPEN_OBJS) $(STRALLOC_OBJS) $(UNIX_OBJS) \
  138. $(SOCKET_OBJS) $(BUFFER_OBJS) $(MMAP_OBJS) $(TEXTCODE_OBJS) \
  139. $(TAIA_OBJS) $(TAI_OBJS) $(CASE_OBJS) $(ARRAY_OBJS) $(MULT_OBJS) \
  140. $(IO_OBJS) $(CDB_OBJS) $(CRITBIT_OBJS)
  141. libowfat.a: $(ALL_OBJS)
  142. $(CROSS)ar cru $@ $(ALL_OBJS)
  143. -$(CROSS)ranlib $@
  144. CFLAGS+=-I.
  145. CFLAGS_OPT+=-I.
  146. %.o: byte/%.c
  147. $(DIET) $(CCC) -c $< $(CFLAGS_OPT)
  148. %.o: %.c
  149. $(DIET) $(CCC) -c $< $(CFLAGS)
  150. %.a:
  151. $(CROSS)ar cru $@ $^
  152. -$(CROSS)ranlib $@
  153. t.o: t.c fmt.h scan.h str.h uint16.h uint32.h stralloc.h socket.h \
  154. buffer.h ip4.h ip6.h byte.h mmap.h open.h textcode.h dns.h iopause.h \
  155. taia.h tai.h uint64.h case.h errmsg.h iob.h io.h array.h safemult.h \
  156. iarray.h io_internal.h haveepoll.h havekqueue.h havedevpoll.h \
  157. havesigio.h CAS.h
  158. t: t.o libowfat.a libsocket
  159. $(DIET) $(CCC) -g -o $@ t.o libowfat.a `cat libsocket` -lpthread
  160. .PHONY: all clean tar install rename
  161. clean:
  162. rm -f *.o *.a *.da *.bbg *.bb core t haveip6.h haven2i.h \
  163. havesl.h haveinline.h iopause.h select.h havekqueue.h haveepoll.h \
  164. libepoll havesigio.h havebsdsf.h havesendfile.h havescope.h havedevpoll.h \
  165. dep libsocket havealloca.h haveuint128.h entities.h ent havepread.h
  166. INCLUDES=buffer.h byte.h fmt.h ip4.h ip6.h mmap.h scan.h socket.h str.h stralloc.h \
  167. uint16.h uint32.h uint64.h open.h textcode.h tai.h taia.h dns.h iopause.h case.h \
  168. openreadclose.h readclose.h ndelay.h array.h io.h safemult.h iob.h havealloca.h \
  169. errmsg.h cdb.h cdb_make.h rangecheck.h iarray.h va_narg.h isset.h \
  170. compiletimeassert.h critbit.h
  171. install-inc:
  172. install -d $(DESTDIR)$(INCLUDEDIR)
  173. install -m 644 $(INCLUDES) $(DESTDIR)$(INCLUDEDIR)
  174. install-lib: libowfat.a
  175. install -d $(DESTDIR)$(LIBDIR)
  176. install -m 644 libowfat.a $(DESTDIR)$(LIBDIR)
  177. install-man:
  178. install -d $(DESTDIR)$(MAN3DIR)
  179. install -m 644 $(wildcard */*.3) $(DESTDIR)$(MAN3DIR)
  180. install: install-inc install-man install-lib
  181. uninstall:
  182. rm -f $(patsubst %.h,$(INCLUDEDIR)/%.h,$(INCLUDES))
  183. rm -f $(patsubst %.3,$(MAN3DIR)/%.3,$(notdir $(wildcard */*.3)))
  184. rm -f $(LIBDIR)/libowfat.a
  185. VERSION=libowfat-$(shell head -n 1 CHANGES|sed 's/://')
  186. CURNAME=$(notdir $(shell pwd))
  187. tar: Makefile clean rename
  188. rm -f dep libdep
  189. cd ..; tar cvvf $(VERSION).tar.xz --use=xz --exclude CVS $(VERSION)
  190. rename:
  191. if test $(CURNAME) != $(VERSION); then cd .. && mv $(CURNAME) $(VERSION); fi
  192. haveip6.h: tryip6.c
  193. -rm -f $@
  194. if $(DIET) $(CCC) $(CFLAGS) -c tryip6.c >/dev/null 2>&1; then echo "#define LIBC_HAS_IP6"; fi > $@
  195. -rm -f tryip6.o
  196. havescope.h: tryscope.c
  197. -rm -f $@
  198. if $(DIET) $(CCC) $(CFLAGS) -c tryscope.c >/dev/null 2>&1; then echo "#define LIBC_HAS_SCOPE_ID"; fi > $@
  199. -rm -f tryscope.o
  200. haven2i.h: tryn2i.c
  201. -rm -f $@
  202. if $(DIET) $(CCC) $(CFLAGS) -o t tryn2i.c >/dev/null 2>&1; then echo "#define HAVE_N2I"; fi > $@
  203. -rm -f t
  204. havesl.h: trysl.c
  205. -rm -f $@
  206. if ! $(DIET) $(CCC) $(CFLAGS) -o t trysl.c >/dev/null 2>&1; then echo "typedef int socklen_t;"; fi > $@
  207. -rm -f t
  208. haveinline.h: tryinline.c
  209. -rm -f $@
  210. if ! $(DIET) $(CCC) $(CFLAGS) -c tryinline.c >/dev/null 2>&1; then echo "#define inline"; fi > $@
  211. -rm -f tryinline.o
  212. havekqueue.h: trykqueue.c
  213. -rm -f $@
  214. if $(DIET) $(CCC) $(CFLAGS) -c trykqueue.c >/dev/null 2>&1; then echo "#define HAVE_KQUEUE"; fi > $@
  215. -rm -f trykqueue.o
  216. havebsdsf.h: trybsdsf.c
  217. -rm -f $@
  218. if $(DIET) $(CCC) $(CFLAGS) -o trybsdsf trybsdsf.c >/dev/null 2>&1; then echo "#define HAVE_BSDSENDFILE"; fi > $@
  219. -rm -f trybsdsf.o trybsdsf
  220. havesendfile.h: trysendfile.c
  221. -rm -f $@
  222. if $(DIET) $(CCC) $(CFLAGS) -c trysendfile.c >/dev/null 2>&1; then echo "#define HAVE_SENDFILE"; fi > $@
  223. -rm -f trysendfile.o
  224. haveepoll.h: tryepoll.c
  225. -rm -f $@
  226. if $(DIET) $(CCC) $(CFLAGS) -o tryepoll tryepoll.c >/dev/null 2>&1; then echo "#define HAVE_EPOLL 1"; else \
  227. if $(DIET) $(CCC) $(CFLAGS) -o tryepoll tryepoll.c -lepoll >/dev/null 2>&1; then echo "#define HAVE_EPOLL 2"; fi; fi > $@
  228. -rm -f tryepoll
  229. havedevpoll.h: trydevpoll.c
  230. -rm -f $@
  231. if $(DIET) $(CCC) $(CFLAGS) -c trydevpoll.c >/dev/null 2>&1; then echo "#define HAVE_DEVPOLL"; fi > $@
  232. -rm -f trydevpoll.o
  233. libepoll: haveepoll.h
  234. if test "z`cat haveepoll.h`" = "z#define HAVE_EPOLL 2"; then echo -lepoll; fi > $@
  235. havesigio.h: trysigio.c
  236. -rm -f $@
  237. if $(DIET) $(CCC) $(CFLAGS) -c trysigio.c >/dev/null 2>&1; then echo "#define HAVE_SIGIO"; fi > $@
  238. -rm -f trysigio.o
  239. havealloca.h: tryalloca.c
  240. -rm -f $@
  241. echo "#include <stdlib.h>" > $@
  242. if $(DIET) $(CCC) $(CFLAGS) -c tryalloca.c -DA >/dev/null 2>&1; then echo "#include <alloca.h>"; fi >> $@
  243. if $(DIET) $(CCC) $(CFLAGS) -c tryalloca.c -DB >/dev/null 2>&1; then echo "#include <malloc.h>"; fi >> $@
  244. -rm -f tryalloca.o
  245. haveuint128.h: tryuint128.c
  246. -rm -f $@
  247. if $(DIET) $(CCC) $(CFLAGS) -c tryuint128.c >/dev/null 2>&1; then echo "#define HAVE_UINT128"; fi > $@
  248. -rm -f tryuint128.o
  249. havepread.h: trypread.c
  250. -rm -f $@
  251. if $(DIET) $(CCC) $(CFLAGS) -c trypread.c >/dev/null 2>&1; then echo "#define HAVE_PREAD"; fi > $@
  252. -rm -f trypread.o
  253. iopause.h: iopause.h1 iopause.h2 trypoll.c
  254. -rm -f $@
  255. if $(DIET) $(CCC) $(CFLAGS) -o t trypoll.c >/dev/null 2>&1; then cp iopause.h2 iopause.h; else cp iopause.h1 iopause.h; fi
  256. -rm -f t
  257. select.h: select.h1 select.h2 trysysel.c
  258. -rm -f $@
  259. if $(DIET) $(CCC) $(CFLAGS) -c trysysel.c >/dev/null 2>&1; then cp select.h2 select.h; else cp select.h1 select.h; fi
  260. -rm -f trysysel.o
  261. libsocket: trysocket.c
  262. if $(DIET) $(CCC) $(CFLAGS) -o trysocket trysocket.c >/dev/null 2>&1; then echo ""; else \
  263. if $(DIET) $(CCC) $(CFLAGS) -o trysocket trysocket.c -lsocket >/dev/null 2>&1; then echo "-lsocket"; else \
  264. if $(DIET) $(CCC) $(CFLAGS) -o trysocket trysocket.c -lsocket -lnsl >/dev/null 2>&1; then echo "-lsocket -lnsl"; \
  265. fi; fi; fi > blah
  266. if $(DIET) $(CCC) $(CFLAGS) -o trysocket trysendfile.c `cat blah`>/dev/null 2>&1; then cat blah; else \
  267. if $(DIET) $(CCC) $(CFLAGS) -o trysocket trysendfile.c -lsendfile `cat blah` >/dev/null 2>&1; then echo "-lsendfile"; cat blah; \
  268. fi; fi > libsocket
  269. rm -f blah trysocket
  270. socket_accept6.o socket_bind6.o socket_connect6.o socket_local6.o \
  271. socket_mchopcount6.o socket_mcjoin6.o socket_mcleave6.o socket_mcloop6.o \
  272. socket_recv6.o socket_remote6.o socket_sctp6b.o socket_send6.o \
  273. socket_tcp6b.o socket_tcp6.o socket_udp6.o: haveip6.h
  274. socket_accept6.o socket_connect6.o socket_local6.o socket_recv6.o \
  275. socket_remote6.o socket_send6.o: havescope.h
  276. socket_getifidx.o socket_getifname.o: haven2i.h
  277. socket_accept4.o socket_accept6.o socket_connected.o socket_local4.o \
  278. socket_local6.o socket_recv4.o socket_recv6.o socket_remote4.o \
  279. socket_remote6.o: havesl.h
  280. dns_nd6.o fmt_xlong.o scan_xlong.o fmt_ip6_flat.o $(TEXTCODE_OBJS): haveinline.h
  281. iob_send.o scan_ip6if.o: havealloca.h
  282. dep: haveip6.h haven2i.h havesl.h haveinline.h iopause.h select.h haveepoll.h havekqueue.h havedevpoll.h havescope.h havesigio.h havebsdsf.h havesendfile.h havealloca.h haveuint128.h entities.h havepread.h
  283. $(CC) -I. -MM `ls */*.c | grep -v test` t.c | sed -e 's@ \./@ @g' > dep
  284. libdep:
  285. for i in $(LIBS); do (echo -n $$i|tr a-z A-Z|sed 's/.A$$/_OBJS=/'; echo $${i%.a}/*.c|sed -e 's@[^/]*/\([^.]*\)\.c@\1.o @g'); done > libdep
  286. Makefile: GNUmakefile dep libdep
  287. echo "# do not edit! edit GNUmakefile instead" > $@
  288. sed '/startrip/,$$d' < GNUmakefile >> $@
  289. cat dep libdep >> $@
  290. sed -e '1,/stoprip/d' -e 's/ %.c$$//' \
  291. -e 's/^VERSION=.*/'VERSION=$(VERSION)/ \
  292. -e 's/^CURNAME=.*/'CURNAME=$(CURNAME)/ \
  293. -e 's/ Makefile//' < GNUmakefile >> $@
  294. windoze:
  295. $(MAKE) DIET= CROSS=i686-mingw32-
  296. windoze64:
  297. $(MAKE) DIET= CROSS=x86_64-mingw32-
  298. update:
  299. dl -n http://www.w3.org/TR/html5/entities.json
  300. entities.h: entities.json ent
  301. ./ent
  302. scan_html.o: entities.h