-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
96 lines (78 loc) · 2.96 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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
# To build for Linux:
# make OS=linux
#
# To build for Windows x86:
# make OS=windows-x86
#
# To build for Windows x86_64:
# make OS=windows-x86_64
ifndef $(OS)
OS=linux
endif
ifndef $(DEBUG)
DEBUG=false
endif
CWD = $(shell pwd)
ifeq ($(DEBUG), true)
CFLAGS = -std=c99 -Wall -O0 -g -I /usr/local/include -I extern/include/xtd-1.0.0/ -I extern/include/collections-1.0.0/
else
CFLAGS = -std=c99 -Wall -D_DEFAULT_SOURCE -O2 -I /usr/local/include -I extern/include/xtd-1.0.0/ -I extern/include/collections-1.0.0/
endif
ifeq ($(OS),linux)
BIN_NAME = timezoner
CC = gcc
HOST=
LDFLAGS = extern/lib/libxtd.a extern/lib/libcollections.a -L /usr/local/lib -L extern/lib/ -L extern/libcollections/lib/
endif
ifeq ($(OS),windows-x86)
BIN_NAME = timezoner-x86.exe
CC=i686-w64-mingw32-gcc
HOST=i686-w64-mingw32
LDFLAGS = extern/lib/libxtd.a extern/lib/libcollections.a -L /usr/local/lib -L extern/lib/ -L extern/libcollections/lib/
endif
ifeq ($(OS),windows-x86_64)
BIN_NAME = timezoner-x64.exe
CC=x86_64-w64-mingw32-gcc
HOST=x86_64-w64-mingw32
CFLAGS += -D_POSIX -mwindows
#LDFLAGS = extern/lib/libxtd.dll.a extern/lib/libcollections.dll.a /usr/x86_64-w64-mingw32/lib/libmsvcrt.a -L/usr/local/lib -Lextern/lib/ -Lextern/libcollections/lib/ -L/usr/x86_64-w64-mingw32/lib/ -lmingw32 -lmsvcrt
LDFLAGS = extern/lib/libxtd.a extern/lib/libcollections.a -L/usr/local/lib -Lextern/lib/ -Lextern/libcollections/lib/ -L/usr/x86_64-w64-mingw32/lib/ -lmingw32 -lmsvcrt
endif
SOURCES = src/main.c
all: extern/libxtd extern/libcollections bin/$(BIN_NAME)
bin/$(BIN_NAME): $(SOURCES:.c=.o)
@mkdir -p bin
@echo "Linking: $^"
@$(CC) $(CFLAGS) -o bin/$(BIN_NAME) $^ $(LDFLAGS)
@echo "Created $@"
src/%.o: src/%.c
@echo "Compiling: $<"
@$(CC) $(CFLAGS) -c $< -o $@
#################################################
# Dependencies #
#################################################
extern/libxtd:
@mkdir -p extern/libxtd/
@git clone https://github.com/manvscode/libxtd.git extern/libxtd/
@cd extern/libxtd && autoreconf -fi && ./configure --libdir=$(CWD)/extern/lib/ --includedir=$(CWD)/extern/include/ --host=$(HOST) && make && make install
extern/libcollections:
@mkdir -p extern/libcollections/
@git clone https://github.com/manvscode/libcollections.git extern/libcollections/
@cd extern/libcollections && autoreconf -fi && ./configure --libdir=$(CWD)/extern/lib/ --includedir=$(CWD)/extern/include/ --host=$(HOST) && make && make install
#################################################
# Cleaning #
#################################################
clean_extern:
@rm -rf extern
clean:
@rm -rf src/*.o
@rm -rf bin
#################################################
# Installing #
#################################################
install:
ifeq ("$(INSTALL_PATH)","")
$(error INSTALL_PATH is not set.)
endif
@echo "Installing ${CWD}/bin/${BIN_NAME} to ${INSTALL_PATH}"
@cp bin/$(BIN_NAME) $(INSTALL_PATH)/$(BIN_NAME)