makefile support for windows
Stefan Schuermans

Stefan Schuermans commited on 2017-09-24 10:46:24
Showing 1 changed files, with 14 additions and 7 deletions.

... ...
@@ -1,18 +1,25 @@
1
-TARGET := Blinker
2
-
3
-CXX := g++
4 1
 CONFIG :=
5 2
 DEFINE :=
6
-INCLUDE := -Icommon -Ilinux
3
+INCLUDE := -Icommon
7 4
 CFLAGS := -Wall -Wextra -Werror -O2
8 5
 LDFLAGS :=
9 6
 LIBS := -lBlinkenLib
7
+TARGET := Blinker
8
+ifeq ($(CROSS_WIN),1)
9
+CXX := x86_64-w64-mingw32-g++
10
+PLATFORM := windows
11
+TARGET := Blinker.exe
12
+else
13
+CXX := g++
14
+PLATFORM := linux
15
+endif
16
+INCLUDE += -I$(PLATFORM)
10 17
 
11 18
 CFGS := $(wildcard config/*.cfg.sh)
12 19
 CFGS_BASE := $(patsubst %.cfg.sh,%,$(CFGS))
13 20
 CFGS_MK := $(addsuffix .cfg.mk,$(CFGS_BASE))
14 21
 
15
-SRCS := $(wildcard common/*.cpp) $(wildcard linux/*.cpp)
22
+SRCS := $(wildcard common/*.cpp) $(wildcard $(PLATFORM)/*.cpp)
16 23
 SRCS_BASE := $(patsubst %.cpp,%,$(SRCS))
17 24
 DEPS := $(addprefix obj/,$(addsuffix .d,$(SRCS_BASE)))
18 25
 OBJS := $(addprefix obj/,$(addsuffix .o,$(SRCS_BASE)))
... ...
@@ -39,7 +46,7 @@ config.mk: $(CFGS_MK)
39 46
 	sh $< >$@
40 47
 
41 48
 obj:
42
-	mkdir $@ $@/common $@/linux
49
+	mkdir $@ $@/common $@/$(PLATFORM)
43 50
 
44 51
 obj/%.d: %.cpp Makefile config.mk | obj
45 52
 	$(CXX) $(DEFINE) $(INCLUDE) $(CFLAGS) -MM -MT $(@:.d=.o) -o $@ $<
... ...
@@ -51,7 +58,7 @@ $(TARGET): $(OBJS)
51 58
 	$(CXX) $(LDFLAGS) -o $@ $+ $(LIBS)
52 59
 
53 60
 clean:
54
-	rm -f obj $(TARGET)
61
+	rm -rf obj $(TARGET)
55 62
 
56 63
 distclean: clean
57 64
 	rm -f config.mk $(CFGS_MK)
58 65