-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
106 lines (88 loc) · 2.39 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
97
98
99
100
101
102
103
104
105
106
ifeq ($(OS),Windows_NT)
detected_OS := Windows
else
detected_OS := $(shell sh -c 'uname -s 2>/dev/null || echo not')
endif
# Set the include path of GNUstep.
ifeq (,$(GNUSTEP_INCLUDE))
GNUSTEP_INCLUDE=/usr/GNUstep/System/Library/Headers
endif
# Set the library path of GNUstep.
ifeq (,$(GNUSTEP_LIB))
GNUSTEP_LIB=/usr/GNUstep/System/Library/Libraries
endif
GCC_LIB=$(shell sh -c 'dirname `gcc -print-prog-name=cc1 /dev/null`')
ifeq ($(detected_OS),Windows)
TARGET=ocEnumDemo.exe
else
TARGET=ocEnumDemo
endif
ifeq ($(detected_OS),Windows)
DYNAMIC_LIB=libocenum.dll
STATIC_LIB=libocenum.a
else
ifeq ($(detected_OS),Darwin)
DYNAMIC_LIB=libocenum.dylib
else
DYNAMIC_LIB=libocenum.so
endif
STATIC_LIB=libocenum.a
endif
OBJS=OCEnum.o
TARGET_OBJS=main.o
# Set the include path of libobjc on non-Apple platforms.
OBJC_INCLUDE := -I $(GCC_LIB)/include
.PHONY: all dynamic static clean
all: $(TARGET)
$(TARGET): $(OBJS) $(TARGET_OBJS) $(STATIC_LIB)
ifeq ($(detected_OS),Darwin)
$(CC) -o $(TARGET) $(TARGET_OBJS) $(STATIC_LIB) \
-lm -lobjc -framework Foundation
else
$(CC) -o $(TARGET) $(TARGET_OBJS) $(STATIC_LIB) \
-lm -lobjc -lgnustep-base -L $(GNUSTEP_LIB)
endif
dynamic: $(DYNAMIC_LIB)
$(DYNAMIC_LIB): $(OBJS)
$(CC) -shared -o $(DYNAMIC_LIB) $(OBJS)
static: $(STATIC_LIB)
static: $(STATIC_LIB)
$(STATIC_LIB): $(OBJS)
ifeq ($(detected_OS),Darwin)
libtool -o $(STATIC_LIB) $(OBJS)
else
$(AR) rcs -o $(STATIC_LIB) $(OBJS)
endif
%.o:%.m
ifeq ($(detected_OS),Darwin)
ifeq (,$(MAKECMDGOALS))
$(CC) -fPIC -std=c11 -c $< -o $@ $(CFLAGS) \
-fconstant-string-class=NSConstantString
else
ifeq (dynamic,$(MAKECMDGOALS))
$(CC) -fPIC -std=c11 -c $< -o $@ $(CFLAGS) \
-fconstant-string-class=NSConstantString
else
$(CC) -std=c11 -c $< -o $@ $(CFLAGS) \
-fconstant-string-class=NSConstantString
endif # make dynamic
endif # make
else
ifeq (,$(MAKECMDGOALS))
$(CC) -fPIC -std=c11 -c $< -o $@ $(CFLAGS) \
$(OBJC_INCLUDE) -I $(GNUSTEP_INCLUDE) \
-fconstant-string-class=NSConstantString
else
ifeq (dynamic,$(MAKECMDGOALS))
$(CC) -fPIC -std=c11 -c $< -o $@ $(CFLAGS) \
$(OBJC_INCLUDE) -I $(GNUSTEP_INCLUDE) \
-fconstant-string-class=NSConstantString
else
$(CC) -std=c11 -c $< -o $@ $(CFLAGS) \
$(OBJC_INCLUDE) -I $(GNUSTEP_INCLUDE) \
-fconstant-string-class=NSConstantString
endif # make dynamic
endif # make
endif # Darwin
clean:
$(RM) $(TARGET) $(DYNAMIC_LIB) $(STATIC_LIB) $(TARGET_OBJS) $(OBJS)