-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
executable file
·65 lines (54 loc) · 1.54 KB
/
Copy pathMakefile
File metadata and controls
executable file
·65 lines (54 loc) · 1.54 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
59
60
61
62
63
64
65
# Can link with 32, 64 and Mac versions of the library
#
# Usage (assume its called Makefile): make (makes all for a particular machine architecture)
#
# note - if you are moving between machine architectures you must first delete your .o files
CC = gcc
CFLAGS = -g -std=gnu99
SRCS = $(shell ls *.c 2> /dev/null | grep -v backup.c )
OBJS = $(shell ls *.c 2> /dev/null | grep -v backup.c | sed s/\.c[p]*$$/\.o/ )
HFILES = $(shell ls *.h 2> /dev/null)
FILE = 32
#use the unique library names for each architecture
ARCH = $(shell arch)
OS = $(shell uname -s)
ifeq ("$(OS)", "Linux")
ifeq ("$(ARCH)", "x86_64")
FILE = 64
endif
endif
#handle macs
ifeq ("$(OS)", "Darwin")
FILE = "Mac"
endif
ALL = backup
all: $(OBJS) $(ALL)
echo:
@echo "CFLAGS: " $(CFLAGS)
@echo "SRCS: $(SRCS)"
@echo "Objects: $(OBJS)"
@echo "HFILES: $(HFILES)"
@echo "LIBNAME: $(LIBNAME)"
%.o: %.c $(HFILES)
@echo "-------------------------------"
@echo "*** Building $@"
$(CC) -c $(CFLAGS) $< -o $@
backup: backup.o $(HFILES) $(OBJS)
@echo "-------------------------------"
@echo "*** Building $@"
$(CC) $(CFLAGS) -lpthread -o $@ backup.o $(OBJS)
@echo "-------------------------------"
# clean .o
cleano:
@echo "-------------------------------"
@echo "*** Cleaning Files..."
@echo "Deleting *.o's only"
rm -f *.o
@echo "-------------------------------"
# clean targets
clean:
@echo "-------------------------------"
@echo "*** Cleaning Files..."
@echo "Deleting *.o's and '$(FILE)' bit versions of backup"
rm -f *.o $(ALL)
@echo "-------------------------------"