-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
66 lines (49 loc) · 2.16 KB
/
makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
CC = gcc
basic = -Wall
ifdef DEBUG
debug = $(basic) -D DEBUG
else
debug = $(basic)
endif
ifdef GDB
FLAGS = $(debug) -ggdb
else
FLAGS = $(debug)
endif
$(info FLAGS set to: $(FLAGS))
all: tftp_server tftp_client
help:
@echo ""
@echo "Usage: make [flag settings] <--> [target]"
@echo "flag settings:"
@echo "DEBUG set to any value (e.g. 'DEBUG=1') for verbose executables"
@echo "GDB set to any value for attaching debugging info for gdb"
@echo ""
@echo "target:"
@echo "all: tftp_server and tftp_client"
@echo "tftp_server: TFTP server"
@echo "tftp_client: TFTP client"
@echo "clean: remove objects and executables"
#%_test: test/%_test.c
# $(CC) $(FLAGS) $< -o testbin/$@ > log/[email protected] 2> log/[email protected]
objects = obj/pack_message.o obj/tftp_send.o obj/tftp_recv.o obj/tftp_message_alloc.o obj/tftp_request_exchange_buffer.o obj/tftp_display.o
tftp_server : $(objects) obj/tftp_server.o obj/safeprintf.o obj/safe_tftp_display.o
if [ ! -e bin/ ] ; then mkdir bin ; fi
$(CC) $(FLAGS) -lpthread obj/tftp_server.o $(objects) obj/safe_tftp_display.o obj/safeprintf.o -o bin/$@
obj/tftp_server.o : tftp_server.c headers/tftp_display.h headers/pack_message.h headers/tftp_message_alloc.h headers/tftp_constants.h headers/tftp_messages.h headers/tftp_recv.h headers/tftp_send.h headers/tftp_request_exchange_buffer.h headers/safeprintf.h headers/safe_tftp_display.h
$(CC) $(FLAGS) -c tftp_server.c -o $@
tftp_client : $(objects) obj/tftp_client.o
if [ ! -e bin/ ] ; then mkdir bin ; fi
$(CC) $(FLAGS) obj/tftp_client.o $(objects) -o bin/$@
obj/tftp_client.o : tftp_client.c headers/pack_message.h headers/tftp_message_alloc.h headers/tftp_constants.h headers/tftp_messages.h headers/tftp_recv.h headers/tftp_send.h headers/tftp_request_exchange_buffer.h headers/tftp_display.h
$(CC) $(FLAGS) -c tftp_client.c -o $@
#obj/safe_tftp_display.o: lib/safe_tftp_display.c headers/tftp_display.h
# if [ ! -e obj/ ] ; then mkdir obj ; fi
# $(CC) $(FLAGS) -c lib/safe_tftp_display.c -o $@
obj/%.o : lib/%.c
if [ ! -e obj/ ] ; then mkdir obj ; fi
$(CC) $(FLAGS) -c $< -o $@
.PHONY: clean
clean:
if [ -e obj/ ] ; then rm -r obj ; fi
if [ -e bin/ ] ; then rm -r bin ; fi