Added more logging messages.
[uftps.git] / Makefile
blob9ab11fdf25ef7e6b85a8a0a23e4996aff3189ab3
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 client_port.c command_loop.c file_stats.c \
14 init_session.c list_dir.c log.c misc.c next_command.c send_file.c \
15 session_globals.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
42 %.o: %.c
43 ifdef ARCH
44 @echo ' Compiling [tuned] $@' && $(CC) $(CFLAGS) $(ARCH) -c -o $@ $<
45 else
46 @echo ' Compiling $@' && $(CC) $(CFLAGS) -c -o $@ $<
47 endif
49 %.dbg.o: %.c
50 @echo ' Compiling [debug] $@' && $(CC) $(CFLAGS_DBG) -c -o $@ $<
52 .%.d: %.c
53 @echo ' Dependencies $<' && $(CC) -MM $< \
54 | awk -F: '{printf "$(<:.c=.o) $@:%s\n",$$2; \
55 printf "$(<:.c=.dbg.o) $@:%s\n",$$2}' >$@
59 # Special rules
61 .next_command.d: command_list.h
63 command_list.h: command_list.gperf
64 @echo ' Generating $@' && gperf --output-file=$@ $<
68 # Cleaning and help
71 clean:
72 @-rm -fv *.o gmon.out
74 distclean: clean
75 @-rm -fv .*.d uftps uftps.exe uftps.dbg command_list.h
77 help:
78 @echo 'User targets:'
79 @echo ''
80 @echo ' all - Default target. Build the GNU/Linux binary.'
81 @echo ' debug - Build the GNU/Linux binary with debugging support.'
82 @echo ' clean - Clean object files.'
83 @echo ' distclean - Clean binaries and DFA header (clean implied).'
84 @echo ''
85 @echo 'NOTE: Enable custom optimization flags for the UNIX binary'
86 @echo ' defining the ARCH make variable. For example:'
87 @echo ''
88 @echo ' make "ARCH=-march=pentium-m -mfpmath=sse" all'
89 @echo ''
93 # Include dependecy information if necessary
95 ifneq ($(findstring clean,$(MAKECMDGOALS)),clean)
96 ifneq ($(findstring help,$(MAKECMDGOALS)),help)
97 -include $(patsubst %.c,.%.d,$(SOURCES))
98 endif
99 endif