Added a filesystem check on CWD implementation.
[uftps.git] / Makefile
blobb53732fdcad322ecfc91264ac964a2ed6ffbd91d
2 # User FTP Server
4 # To display this Makefile help use: make help
7 CC ?= gcc
8 CFLAGS := -O2 -Wall -pipe -fomit-frame-pointer
9 CFLAGS_DBG := -O0 -Wall -pipe -g -pg -DDEBUG
10 LDFLAGS := -Wall -pipe -Wl,-s,-O1
11 LDFLAGS_DBG := -Wall -pipe -g -pg
13 SOURCES := change_dir.c command_loop.c enable_passive.c expand_arg.c \
14 file_stats.c init_session.c list_dir.c log.c next_command.c \
15 open_data_channel.c parse_port_argument.c reply.c send_file.c uftps.c
19 # Phony targets and aliases
22 .PHONY: all debug clean distclean help
24 all : uftps
25 debug: uftps.dbg
29 # Binaries (release and debug)
32 uftps: $(SOURCES:.c=.o)
33 @echo ' Linking $@' && $(CC) $(LDFLAGS) -o $@ $^
35 uftps.dbg: $(SOURCES:.c=.dbg.o)
36 @echo ' Linking [debug] $@' && $(CC) $(LDFLAGS_DBG) -o $@ $^
40 # Pattern rules
43 %.o: %.c uftps.h
44 ifdef ARCH
45 @echo ' Compiling [tuned] $@' && $(CC) $(CFLAGS) $(ARCH) -c -o $@ $<
46 else
47 @echo ' Compiling $@' && $(CC) $(CFLAGS) -c -o $@ $<
48 endif
50 %.dbg.o: %.c uftps.h
51 @echo ' Compiling [debug] $@' && $(CC) $(CFLAGS_DBG) -c -o $@ $<
55 # Special rules
58 next_command.o : command_parser.h
59 next_command.dbg.o: command_parser.h
61 command_parser.h: command_parser.gperf
62 @echo ' Generating $@' && gperf --output-file=$@ $<
66 # Cleaning and help
69 clean:
70 @-rm -fv *.o gmon.out
72 distclean: clean
73 @-rm -fv uftps uftps.dbg command_parser.h
75 help:
76 @echo 'User targets:'
77 @echo ''
78 @echo ' all - Default target. Build the UFTPS binary.'
79 @echo ' debug - Build the UFTPS binary with debugging support.'
80 @echo ' clean - Clean object files.'
81 @echo ' distclean - Clean binaries and the command parser (clean implied).'
82 @echo ''
83 @echo 'NOTE: Enable custom optimization flags for the release binary'
84 @echo ' defining the ARCH make variable. For example:'
85 @echo ''
86 @echo ' make "ARCH=-march=pentium-m -mfpmath=sse" all'
87 @echo ''
91 # Include dependecy information if necessary
93 ifneq ($(findstring clean,$(MAKECMDGOALS)),clean)
94 ifneq ($(findstring help,$(MAKECMDGOALS)),help)
95 -include $(patsubst %.c,.%.d,$(SOURCES))
96 endif
97 endif