-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathMakefile
executable file
·60 lines (42 loc) · 1.37 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
TARGET := ws
TARGET_TYPE := dll
PLUGIN_TYPE := dll
SOURCE := ws misc plugins
TARGET_OUT := $(TARGET).$(TARGET_TYPE)
BASE := .
BUILD := $(BASE)/build
PLUGINS := $(BASE)/plugins
SHARED := $(BASE)/shared
SRC := $(BASE)/source
CC := i686-w64-mingw32-gcc
STD := c99
CFLAGS := -std=$(STD) -O3 -fdata-sections -ffunction-sections -flto -DEXPORT -Wall -shared
LDFLAGS := -lws2_32 -liphlpapi -lpsapi -static -shared -Wl,--gc-sections -Wl,--out-implib,shared/lib$(TARGET).a -s
SOURCES := $(foreach FILE,$(SOURCE),$(FILE).c)
O_SOURCE := $(foreach FILE,$(SOURCES),$(SRC)/$(FILE))
OBJ := $(foreach FILE,$(SOURCE),$(FILE).o)
O_OBJS := $(foreach FILE,$(OBJ),$(BUILD)/$(FILE))
#Confusing, I know, this is to build every plugin subdirectory
PLUGINSRC := $(wildcard $(SRC)/$(PLUGINS)/*/.)
.PHONY: $(PLUGINSRC) #Gotta run this regardless of timestamp on the folder, let the plugin Makefile handle things
all: $(BUILD) $(SHARED) $(TARGET_OUT) $(PLUGINS) $(PLUGINSRC)
plugin: $(PLUGINS) $(PLUGINSRC)
ws: $(BUILD) $(SHARED) $(TARGET_OUT)
clean:
rm -rf $(BUILD) $(SHARED) $(TARGET_OUT)
rm -rf $(PLUGINS)
$(TARGET_OUT): $(O_OBJS)
$(CC) -o $@ $(O_OBJS) $(LDFLAGS)
$(BUILD)/%.o: $(SRC)/%.c
$(CC) -c $(CFLAGS) $(SRC)/$*.c -o $@
$(SRC)/%.c: $(SRC)/%.h
#Plugins
$(PLUGINSRC):
$(MAKE) -C $@
#Make directories if necessary
$(BUILD):
mkdir $(BUILD)
$(PLUGINS):
mkdir $(PLUGINS)
$(SHARED):
mkdir $(SHARED)