1#
2# This makefile contains modifications submitted by Richard Braakman
3# (dark@xs4all.nl) for the shared library generation.
4#
5
6# By default, ftplib uses PASV.  If you need it to use  PORT
7# instead, uncomment the next line
8#DEFINES = -DFTPLIB_DEFMODE=FTPLIB_PORT
9
10SONAME = 4
11SOVERSION = $(SONAME)
12
13TARGETS = qftp libftp.so libftp.a qftp.static
14OBJECTS = qftp.o ftplib.o
15SOURCES = qftp.c ftplib.c
16
17CFLAGS += -Wall $(DEBUG) -I. $(INCLUDES) $(DEFINES) -Wno-unused-variable -D_FILE_OFFSET_BITS=64 -D__unix__
18LDFLAGS += -L.
19DEPFLAGS =
20
21all : $(TARGETS)
22
23clean :
24	rm -f $(OBJECTS) core *.bak
25	rm -rf unshared
26
27clobber : clean
28	rm -f $(TARGETS) .depend
29	rm -f libftp.so.*
30
31install : all
32	install qftp /usr/local/bin
33	install -m 644 libftp.so.$(SONAME) /usr/local/lib
34	install -m 644 ftplib.h /usr/local/include
35	(cd /usr/local/lib && \
36	 true libftp.so.$(SONAME) libftp.so.$(SONAME) && \
37	 true libftp.so.$(SONAME) libftp.so)
38	-(cd /usr/local/bin && \
39	  for f in ftpdir ftpget ftplist ftprm ftpsend; \
40	  do ln -s qftp $$f; done)
41
42depend :
43	$(CC) $(CFLAGS) -M $(SOURCES) > .depend
44
45# build without -fPIC
46unshared/ftplib.o: ftplib.c ftplib.h
47	test -d unshared || mkdir unshared
48	$(CC) -c $(CFLAGS) -D_REENTRANT $< -o $@
49
50static : libftp.a qftp.static
51
52qftp.static : qftp.o libftp.a
53	$(CC) -o $@ $< libftp.a
54
55ftplib.o: ftplib.c ftplib.h
56	$(CC) -c $(CFLAGS) -fPIC -D_REENTRANT $< -o $@
57
58libftp.a: unshared/ftplib.o
59	ar -rcs $@ $<
60
61libftp.so.$(SONAME): ftplib.o
62	$(CC) -shared -Wl,-soname,libftp.so.$(SONAME) -o $@ $<
63
64libftp.so: libftp.so.$(SONAME)
65	true $< libftp.so.$(SONAME)
66	ln -sf $< $@
67
68qftp : qftp.o libftp.so ftplib.h
69	$(CC) $(LDFLAGS) -o $@ $< -lftp
70
71ifeq (.depend,$(wildcard .depend))
72include .depend
73endif
74