release 0.92.3
[cntlm.git] / Makefile
blobdf253cef361fcc346b4f90458789188b98d78481
2 # You can tweak these three variables to make things install where you
3 # like, but do not touch more unless you know what you are doing. ;)
5 DESTDIR=
6 SYSCONFDIR=$(DESTDIR)/etc
7 BINDIR=$(DESTDIR)/usr/sbin
8 MANDIR=$(DESTDIR)/usr/share/man
11 # Careful now...
12 # __BSD_VISIBLE is for FreeBSD AF_* constants
13 # _ALL_SOURCE is for AIX 5.3 LOG_PERROR constant
15 NAME=cntlm
16 CC=gcc
17 VER=`cat VERSION`
18 CFLAGS+=$(FLAGS) -std=c99 -Wall -Wno-unused-but-set-variable -pedantic -O3 -D__BSD_VISIBLE -D_ALL_SOURCE -D_XOPEN_SOURCE=600 -D_POSIX_C_SOURCE=200112 -D_ISOC99_SOURCE -D_REENTRANT -D_BSD_SOURCE -DVERSION=\"`cat VERSION`\"
19 OS=$(shell uname -s)
20 OSLDFLAGS=$(shell [ $(OS) = "SunOS" ] && echo "-lrt -lsocket -lnsl")
21 LDFLAGS:=-lpthread $(OSLDFLAGS)
23 ifeq ($(findstring CYGWIN,$(OS)),)
24 OBJS=utils.o ntlm.o xcrypt.o config.o socket.o acl.o auth.o http.o forward.o direct.o scanner.o pages.o main.o
25 else
26 OBJS=utils.o ntlm.o xcrypt.o config.o socket.o acl.o auth.o http.o forward.o direct.o scanner.o pages.o main.o win/resources.o
27 endif
29 $(NAME): configure-stamp $(OBJS)
30 @echo "Linking $@"
31 @$(CC) $(CFLAGS) -o $@ $(OBJS) $(LDFLAGS)
33 main.o: main.c
34 @echo "Compiling $<"
35 @if [ -z "$(SYSCONFDIR)" ]; then \
36 $(CC) $(CFLAGS) -c main.c -o $@; \
37 else \
38 $(CC) $(CFLAGS) -DSYSCONFDIR=\"$(SYSCONFDIR)\" -c main.c -o $@; \
41 .c.o:
42 @echo "Compiling $<"
43 @$(CC) $(CFLAGS) -c -o $@ $<
45 install: $(NAME)
46 # Special handling for install(1)
47 if [ "`uname -s`" = "AIX" ]; then \
48 install -M 755 -S -f $(BINDIR) $(NAME); \
49 install -M 644 -f $(MANDIR)/man1 doc/$(NAME).1; \
50 install -M 600 -c $(SYSCONFDIR) doc/$(NAME).conf; \
51 elif [ "`uname -s`" = "Darwin" ]; then \
52 install -d -m 755 -s $(NAME) $(BINDIR)/$(NAME); \
53 install -d -m 644 doc/$(NAME).1 $(MANDIR)/man1/$(NAME).1; \
54 [ -f $(SYSCONFDIR)/$(NAME).conf -o -z "$(SYSCONFDIR)" ] \
55 || install -d -m 600 doc/$(NAME).conf $(SYSCONFDIR)/$(NAME).conf; \
56 else \
57 install -D -m 755 -s $(NAME) $(BINDIR)/$(NAME); \
58 install -D -m 644 doc/$(NAME).1 $(MANDIR)/man1/$(NAME).1; \
59 [ -f $(SYSCONFDIR)/$(NAME).conf -o -z "$(SYSCONFDIR)" ] \
60 || install -D -m 600 doc/$(NAME).conf $(SYSCONFDIR)/$(NAME).conf; \
62 @echo; echo "Cntlm will look for configuration in $(SYSCONFDIR)/$(NAME).conf"
64 tgz:
65 mkdir -p tmp
66 rm -rf tmp/$(NAME)-$(VER)
67 svn export . tmp/$(NAME)-$(VER)
68 tar zcvf $(NAME)-$(VER).tar.gz -C tmp/ $(NAME)-$(VER)
69 rm -rf tmp/$(NAME)-$(VER)
70 rmdir tmp 2>/dev/null || true
72 tbz2:
73 mkdir -p tmp
74 rm -rf tmp/$(NAME)-$(VER)
75 svn export . tmp/$(NAME)-$(VER)
76 tar jcvf $(NAME)-$(VER).tar.bz2 -C tmp/ $(NAME)-$(VER)
77 rm -rf tmp/$(NAME)-$(VER)
78 rmdir tmp 2>/dev/null || true
80 deb: builddeb
81 builddeb:
82 sed -i "s/^\(cntlm *\)([^)]*)/\1($(VER))/g" debian/changelog
83 if [ `id -u` = 0 ]; then \
84 debian/rules binary; \
85 debian/rules clean; \
86 else \
87 fakeroot debian/rules binary; \
88 fakeroot debian/rules clean; \
90 mv ../cntlm_$(VER)*.deb .
92 rpm: buildrpm
93 buildrpm:
94 sed -i "s/^\(Version:[\t ]*\)\(.*\)/\1$(VER)/g" rpm/cntlm.spec
95 if [ `id -u` = 0 ]; then \
96 rpm/rules binary; \
97 rpm/rules clean; \
98 else \
99 fakeroot rpm/rules binary; \
100 fakeroot rpm/rules clean; \
103 win: buildwin
104 buildwin:
105 @echo
106 @echo "* This build target must be run from a Cywgin shell on Windows *"
107 @echo "* and you also need InnoSetup installed *"
108 @echo
109 rm -f win/cntlm_manual.pdf
110 groff -t -e -mandoc -Tps doc/cntlm.1 | ps2pdf - win/cntlm_manual.pdf
111 cat doc/cntlm.conf | unix2dos > win/cntlm.ini
112 cat COPYRIGHT LICENSE | unix2dos > win/license.txt
113 sed "s/\$$VERSION/$(VER)/g" win/setup.iss.in > win/setup.iss
114 cp /bin/cygwin1.dll /bin/cyggcc_s-1.dll /bin/cygrunsrv.exe win/
115 cp cntlm.exe win/
116 strip win/cntlm.exe
117 ln -s win $(NAME)-$(VER)
118 zip -9 $(NAME)-$(VER).zip $(NAME)-$(VER)/cntlm.exe $(NAME)-$(VER)/cyggcc_s-1.dll $(NAME)-$(VER)/cygwin1.dll $(NAME)-$(VER)/cygrunsrv.exe $(NAME)-$(VER)/cntlm.ini $(NAME)-$(VER)/README.txt $(NAME)-$(VER)/license.txt
119 rm -f $(NAME)-$(VER)
120 @echo
121 @echo Now open folder "win", right-click "setup.iss", then "Compile".
122 @echo InnoSetup will generate a new installer cntlm-X.XX-setup.exe
123 @echo
125 win/resources.o: win/resources.rc
126 @echo Adding EXE resources
127 @windres $^ -o $@
129 uninstall:
130 rm -f $(BINDIR)/$(NAME) $(MANDIR)/man1/$(NAME).1 2>/dev/null || true
132 clean:
133 @rm -f *.o cntlm cntlm.exe configure-stamp build-stamp config/config.h 2>/dev/null
134 @rm -f win/*.exe win/*.dll win/*.iss win/*.pdf win/cntlm.ini win/license.txt win/resouces.o 2>/dev/null
135 @rm -f config/endian config/gethostname config/strdup config/socklen_t config/*.exe
136 @if [ -h Makefile ]; then rm -f Makefile; mv Makefile.gcc Makefile; fi
138 distclean: clean
139 if [ `id -u` = 0 ]; then \
140 debian/rules clean; \
141 rpm/rules clean; \
142 else \
143 fakeroot debian/rules clean; \
144 fakeroot rpm/rules clean; \
146 @rm -f *.exe *.deb *.rpm *.tgz *.tar.gz *.tar.bz2 tags ctags pid 2>/dev/null