-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
58 lines (43 loc) · 1.28 KB
/
Makefile
File metadata and controls
58 lines (43 loc) · 1.28 KB
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
# Sorry for this terrible Makefile. Just started learning Make...
# Compiler options
CC=gcc
CFLAGS=-c -w
LDFLAGS=
# Directories
PROJ=cStream/
SRC=src/
BIN=bin/
OBJ=obj/
INCLUDE=include/
HEADERS_TO_COPY=$(SRC)cStream.h $(SRC)stream.h $(SRC)serialize.h $(SRC)types.h
all: install
install: create_directories create_libs create_executable copy_headers
@echo "cStream installed."
@echo "Include: $(PROJ)$(INCLUDE)"
@echo "Lib: $(PROJ)$(BIN)libcStream"
@echo "Test: $(PROJ)$(BIN)test"
create_executable: test
@echo "Created test executable."
create_libs: libcStream.a
@echo "Created libraries."
test: test.o libcStream.a
gcc -o $(BIN)test $(OBJ)test.o $(BIN)libcStream.a -lm
libcStream.a : stream.o serialize.o
ar rcs $(BIN)libcStream.a $(OBJ)stream.o $(OBJ)serialize.o
test.o: $(SRC)test.c
gcc $(CFLAGS) $(SRC)test.c -o $(OBJ)test.o
stream.o : $(SRC)stream.c $(SRC)stream.h
gcc $(CFLAGS) $(SRC)stream.c -o $(OBJ)stream.o
serialize.o: $(SRC)serialize.c $(SRC)serialize.h
gcc $(CFLAGS) $(SRC)serialize.c -o $(OBJ)serialize.o
create_directories:
@mkdir -p $(OBJ)
@mkdir -p $(BIN)
@mkdir -p $(INCLUDE)
@echo "Created directories."
copy_headers:
@cp -f $(HEADERS_TO_COPY) $(INCLUDE)
@echo "Include directory made."
clean:
rm -r -f $(BIN) $(OBJ) $(INCLUDE)
@echo "Cleaned repository."