Removed non portable -v flag for rm command.
[uftps.git] / Makefile
blob0c160bb3483bdc88c2d5ea6e85e2198700443e6d
2 # User FTP Server
4 # To display this Makefile help use: make help
7 RETR ?= generic
9 HCC := i586-mingw32msvc-gcc
10 CFLAGS := -O2 -Wall -pipe -fomit-frame-pointer
11 CFLAGS_DBG := -O0 -Wall -pipe -g -pg -DDEBUG
12 LDFLAGS := -Wall -pipe -Wl,-s,-O1
13 LDFLAGS_DBG := -Wall -pipe -g -pg
14 #LDFLAGS := -lsocket -lnsl
15 #LDFLAGS_DBG := -lsocket -lnsl -g -pg
17 SOURCES := change_dir.c command_loop.c enable_passive.c expand_arg.c \
18 file_stats.c init_session.c list_dir.c log.c next_command.c \
19 open_data_channel.c open_file.c parse_port_argument.c reply.c \
20 send_file-$(RETR).c
22 SOURCES_unix := $(SOURCES) main-unix.c
23 SOURCES_hase := $(SOURCES) main-hase.c
27 # Phony targets and aliases
30 .PHONY: all debug clean distclean help
32 all : uftps
33 debug: uftps.dbg
34 hase : uftps.exe
35 dhase: uftps.dbg.exe
39 # Binaries (release and debug)
42 uftps: $(SOURCES_unix:.c=.o)
43 @echo ' Linking $@' && $(CC) $(LDFLAGS) -o $@ $^
45 uftps.dbg: $(SOURCES_unix:.c=.dbg.o)
46 @echo ' Linking [debug] $@' && $(CC) $(LDFLAGS_DBG) -o $@ $^
48 uftps.exe: $(SOURCES_hase:.c=.obj)
49 @echo ' Linking [win32] $@' && $(HCC) $(LDFLAGS) -o $@ $^ -lws2_32
51 uftps.dbg.exe: $(SOURCES_hase:.c=.dbg.obj)
52 @echo ' Linking [win32] [debug] $@' && $(HCC) $(LDFLAGS_DBG) -o $@ $^ -lws2_32
56 # Pattern rules
59 %.o: %.c uftps.h
60 ifdef ARCH
61 @echo ' Compiling [tuned] $@' && $(CC) $(CFLAGS) $(ARCH) -c -o $@ $<
62 else
63 @echo ' Compiling $@' && $(CC) $(CFLAGS) -c -o $@ $<
64 endif
66 %.obj: %.c uftps.h hase.h
67 ifdef ARCH
68 @echo ' Compiling [win32] [tuned] $@' && $(HCC) $(CFLAGS) $(ARCH) -c -o $@ $<
69 else
70 @echo ' Compiling [win32] $@' && $(HCC) $(CFLAGS) -c -o $@ $<
71 endif
73 %.dbg.o: %.c uftps.h
74 @echo ' Compiling [debug] $@' && $(CC) $(CFLAGS_DBG) -c -o $@ $<
76 %.dbg.obj: %.c uftps.h hase.h
77 @echo ' Compiling [win32] [debug] $@' && $(HCC) $(CFLAGS_DBG) -c -o $@ $<
81 # Special rules
84 next_command.o : command_parser.h
85 next_command.dbg.o : command_parser.h
86 next_command.obj : command_parser.h
87 next_command.dbg.obj: command_parser.h
89 command_parser.h: command_parser.gperf
90 @echo ' Generating $@' && gperf --output-file=$@ $<
94 # Cleaning and help
97 clean:
98 @-rm -f *.o *.obj gmon.out uftps uftps.dbg uftps.exe uftps.dbg.exe
100 distclean: clean
101 @-rm -f command_parser.h
103 help:
104 @echo 'User targets:'
105 @echo ''
106 @echo ' all - Default target. Build the UNIX binary.'
107 @echo ' debug - Build the UNIX binary with debugging support.'
108 @echo ' hase - Build the Hasefroch binary.'
109 @echo ' dhase - Build the Hasefroch binary with debugging support.'
110 @echo ' clean - Clean object and binary files.'
111 @echo ' distclean - Clean the command parser (clean implied).'
112 @echo ''
113 @echo 'You can also choose which RETR implementation to use by setting the'
114 @echo 'RETR make variable to one of these values:'
115 @echo ''
116 @echo ' generic - Generic multiplatform implementation using read() and'
117 @echo ' send(). Works everyhere but it is the least memory'
118 @echo ' efficient. This is the default value when none selected.'
119 @echo ' mmap - Generic UNIX implementation using mmap() instead of '
120 @echo ' read() to save some memory copies.'
121 @echo ' linux - Linux (2.2 and above) version using the sendfile() system'
122 @echo ' call.'
123 @echo ' splice - Linux (2.6.17 and above) version which uses the new '
124 @echo ' splice() system call. Requires glibc 2.5 or higher.'
125 @echo ' This is the recommended choice for Linux if you satisfy'
126 @echo ' the requisites.'
127 @echo ' hasefroch - Hasefroch tuned implementation using TransmitFile() and'
128 @echo ' file mapping as a fallback. Requires WinSock 2.2'
129 @echo ''
130 @echo 'For example, to select the mmap RETR implementation, the compilation'
131 @echo 'command line can be:'
132 @echo ''
133 @echo ' make RETR=mmap'
134 @echo ''
135 @echo 'Finally, to enable custom optimization flags for the release binary,'
136 @echo 'define the ARCH make variable. For example:'
137 @echo ''
138 @echo ' make "ARCH=-march=pentium-m -mfpmath=sse" all'
139 @echo ''