-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
54 lines (45 loc) · 1.19 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
TARGET = goniometer
CC = gcc
CFLAGS = -std=c99 -Wall -Wno-parentheses -I.
LINKER = gcc -o
LFLAGS = -Wall -I. -lm
# simple conditionals for Linux and MinGW (gcc under windows)
uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
# Linux. Tested
ifeq ($(uname_S),Linux)
LFLAGS += -pthread
endif
# MinGW under Windows. Untested
ifneq (,$(findstring MINGW,$(uname_S)))
LFLAGS += -lws2_32
endif
# Cygwin under Windows. Untested
ifneq (,$(findstring CYGWIN,$(uname_S)))
LFLAGS += -lws2_32
endif
# Mac OSX. Untested
ifeq ($(uname_S),Darwin)
LFLAGS += -pthread
endif
# change these to set the proper directories where each files shoould be
SRCDIR = src
OBJDIR = obj
BINDIR = bin
SOURCES := $(wildcard $(SRCDIR)/*.c)
INCLUDES := $(wildcard $(SRCDIR)/*.h)
OBJECTS := $(SOURCES:$(SRCDIR)/%.c=$(OBJDIR)/%.o)
rm = rm -f
$(BINDIR)/$(TARGET): $(OBJECTS)
@$(LINKER) $@ $(OBJECTS) $(LFLAGS)
@echo "Linking complete!"
$(OBJECTS): $(OBJDIR)/%.o : $(SRCDIR)/%.c
@$(CC) -c $< -o $@ $(CFLAGS)
@echo "Compiled "$<" successfully!"
.PHONEY: clean
clean:
@$(rm) $(OBJECTS)
@echo "Cleanup complete!"
.PHONEY: remove
remove: clean
@$(rm) $(BINDIR)/$(TARGET)
@echo "Executable removed!"