-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
67 lines (53 loc) · 1.6 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
# Detect system OS.
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
# Set the encoding of the CGI script.
ifneq (,$(CGI_ENCODING))
ENCODING=-DOCGI_ENCODING=$(CGI_ENCODING)
endif
GCC_LIB=$(shell sh -c 'dirname `gcc -print-prog-name=cc1 /dev/null`')
# Set the file name of target CGI script.
ifeq (,$(CGI_PROGRAM))
ifeq ($(detected_OS),Windows)
CGI_PROGRAM=index.exe
else
CGI_PROGRAM=index.cgi
endif
endif
OBJS=NSArray+RawArray.o NSNumber+OCGIFormResultType.o NSNumber+OCGIEnvironmentResultType.o \
OCGIEnvironmentVariable.o OCGIHeader.o OCGICookie.o OCGIForm.o OCGIFile.o OCGISanitizer.o \
OCGIMain.o
# Set the include path of libobjc on non-Apple platforms.
OBJC_INCLUDE := -I $(GCC_LIB)/include
.PHONY: all clean
all: cgi
cgi: cgic.o $(OBJS)
ifeq ($(detected_OS),Darwin)
$(CC) -o $(CGI_PROGRAM) cgic.o $(OBJS) -lobjc -framework Foundation
else
$(CC) -o $(CGI_PROGRAM) cgic.o $(OBJS) -lobjc -lgnustep-base -L $(GNUSTEP_LIB)
endif
%.o:%.c
$(CC) -std=c89 -c $< -o $@ $(CFLAGS)
%.o:%.m
ifeq ($(detected_OS),Darwin)
$(CC) -std=c11 -c $< -o $@ $(CFLAGS) $(ENCODING) \
-fconstant-string-class=NSConstantString
else
$(CC) -std=c11 -c $< -o $@ $(CFLAGS) $(ENCODING) \
$(OBJC_INCLUDE) -I $(GNUSTEP_INCLUDE) \
-fconstant-string-class=NSConstantString
endif
clean:
$(RM) $(CGI_PROGRAM) cgic.o $(OBJS)