-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathMakefile
More file actions
37 lines (28 loc) · 769 Bytes
/
Copy pathMakefile
File metadata and controls
37 lines (28 loc) · 769 Bytes
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
CC := gcc
ODIR := build
SDIR := source
IDIR := -Iinclude
LDIR := lib
CFLAGS := $(IDIR) -fms-extensions -std=c11 -O2 -Wall
LFLAGS := -L$(LDIR) -lws2_32
CFILES := $(wildcard $(SDIR)/*.c)
OBJS := $(patsubst $(SDIR)/%.c, build/%.o, $(wildcard $(SDIR)/*.c))
PLATFORM = $(shell uname)
ifeq ($(findstring Linux,$(PLATFORM)), Linux)
TARGET = $(shell basename $(CURDIR))
endif
ifeq ($(findstring Darwin,$(PLATFORM)), Darwin)
TARGET = $(shell basename $(CURDIR))
endif
ifeq ($(findstring MINGW,$(PLATFORM)), MINGW)
TARGET = $(shell basename $(CURDIR)).exe
endif
$(TARGET): $(ODIR) $(OBJS)
$(CC) $(ODIR)/*.o -o $(TARGET) $(CFLAGS) $(LFLAGS)
$(ODIR)/%.o: $(SDIR)/%.c
$(CC) $< -c -o $@ $(CFLAGS)
$(ODIR):
@mkdir $@
.PHONY: clean
clean:
rm -f $(TARGET) $(ODIR)/*.o