-
Notifications
You must be signed in to change notification settings - Fork 2
/
makefile
95 lines (78 loc) · 3.24 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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# makefile for Encryption testing on crypto branch! See the github:
# https://github.com/rlcaust/Fund-O-C
# Author: Albert Ferguson
################################################################################
# Defining make macros:
#
# wildcard function from make, searches through
# current directory for files matching *.c
#
# SRC:.c=.o is a pattern naming all *.c files found
# to *.o files
#
# $@ is target & $^ is dependency(s)
################################################################################
# primary link target and source file
LINK_TARGET = main.out
LINK_SRC = $(LINK_TARGET:.out=.c)
# lib directory macros
STATIC_LIBS = libs
STATIC_CRYPTO = $(STATIC_LIBS)/Crypto
STATIC_RAINDROPS = $(STATIC_LIBS)/PrintRaindrops
STATIC_UTIL = $(STATIC_LIBS)/Util
STATIC_COMPRESSION = $(STATIC_LIBS)/Compression
# src and target macros
CRYPTO_SRC = $(wildcard $(STATIC_CRYPTO)/*.c)
CRYPTO_TARGET = libCrypto.a
RAINDROPS_SRC = $(wildcard $(STATIC_RAINDROPS)/*.c)
RAINDROPS_TARGET = libRaindrops.a
UTIL_SRC = $(wildcard $(STATIC_UTIL)/*.c)
UTIL_TARGET = libUtil.a
COMPRESSION_SRC = $(wildcard $(STATIC_COMPRESSION)/*.c)
COMPRESSION_TARGET = libCompression.a
# object files
OBJS = $(LINK_SRC:.c=.o)
# clean targets, any object and/or compiled libs
CLEAN_OBJS = $(wildcard *.o)
CLEAN_LIBS = $(CRYPTO_TARGET) $(RAINDROPS_TARGET) $(UTIL_TARGET) $(COMPRESSION_TARGET)
# compile flags
LIBFLAGS = ar -rcs
CCFLAGS = gcc -g -Wall -Werror -ansi
################################################################################
# Compile all (default make command)
################################################################################
.PHONY : all
all : $(LINK_TARGET)
@echo $(OSFLAG)
$(LINK_TARGET) : libraries
$(CCFLAGS) -o $@ $(LINK_SRC) $(CRYPTO_TARGET) $(UTIL_TARGET) $(RAINDROPS_TARGET) $(COMPRESSION_TARGET)
@echo ============== All done! ========================
################################################################################
# Compile libraries (static),
# compile each of the three libraries required
################################################################################
libraries : $(UTIL_SRC:.c=.o) $(CRYPTO_SRC:.c=.o) $(RAINDROPS_SRC:.c=.o) $(COMPRESSION_SRC:.c=.o)
$(LIBFLAGS) $(UTIL_TARGET) $(UTIL_SRC:.c=.o)
$(LIBFLAGS) $(CRYPTO_TARGET) $(CRYPTO_SRC:.c=.o)
$(LIBFLAGS) $(RAINDROPS_TARGET) $(RAINDROPS_SRC:.c=.o)
$(LIBFLAGS) $(COMPRESSION_TARGET) $(COMPRESSION_SRC:.c=.o)
@echo ============== Libraries compilled! =============
$(UTIL_SRC:.c=.o) : $(STATIC_UTIL)
$(CCFLAGS) -c $(wildcard $^/*.c) -o $@
$(CRYPTO_SRC:.c=.o) : $(STATIC_CRYPTO)
$(CCFLAGS) -c $(wildcard $^/*.c) -o $@
$(RAINDROPS_SRC:.c=.o) : $(STATIC_RAINDROPS)
$(CCFLAGS) -c $(wildcard $^/*.c) -o $@
$(COMPRESSION_SRC:.c=.o) : $(STATIC_COMPRESSION)
$(CCFLAGS) -c $(wildcard $^/*.c) -o $@
################################################################################
# Clean directory
################################################################################
.PHONY : clean
clean :
rm -f $(CLEAN_OBJS) $(LINK_TARGET) $(STATIC_LIB_TARGET)
rm -f $(wildcard $(STATIC_CRYPTO)/*.o)
rm -f $(wildcard $(STATIC_RAINDROPS)/*.o)
rm -f $(wildcard $(STATIC_UTIL)/*.o)
rm -f $(wildcard $(STATIC_COMPRESSION)/*.o)
@echo ============== Clean all complete! ==============