forked from programming-nu/nu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
120 lines (98 loc) · 2.67 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
107
108
109
110
111
112
113
114
115
116
117
118
119
#
# This Makefile is used to bootstrap Nu.
# Use it to build "mininush", a simpler and statically-linked
# version of nush, the Nu shell.
#
SYSTEM = $(shell uname)
PREFIX ?= /usr/local
ifeq ($(SYSTEM), Darwin)
ifeq ($(shell test -e /usr/lib/libffi.dylib && echo yes), yes)
# Use the libffi that ships with OS X.
FFI_LIB = -L/usr/lib -lffi
FFI_INCLUDE = -I/usr/include/ffi
LEOPARD_CFLAGS = -DLEOPARD_OBJC2
else
# Use the libffi that is distributed with Nu.
FFI_LIB = -L./libffi -lffi
FFI_INCLUDE = -I./libffi/include
LEOPARD_CFLAGS =
endif
ifeq ($(shell test -e /Developer/SDKs/MacOSX10.7.sdk && echo yes), yes)
# not a typo, we deliberatly stay back on the 10.6 SDK for now.
LION_CFLAGS = -DLION -isysroot /Developer/SDKs/MacOSX10.6.sdk
else
LION_CFLAGS =
endif
else # GNUstep
FFI_LIB=-lffi
FFI_INCLUDE=
endif
INCLUDES = $(FFI_INCLUDE) -I./include
ifeq ($(SYSTEM), Darwin)
ifeq ($(shell test -d $(PREFIX)/include && echo yes), yes)
INCLUDES += -I$(PREFIX)/include
endif
FRAMEWORKS = -framework Cocoa
LIBS = -lobjc -lreadline
ifeq ($(shell test -d $(PREFIX)/lib && echo yes), yes)
LIBDIRS += -L$(PREFIX)/lib
endif
else
FRAMEWORKS =
LIBS = -lm -lpcre -lreadline -lgnustep-base
LIBDIRS =
endif
C_FILES = $(wildcard objc/*.c) $(wildcard pcre/*.c)
OBJC_FILES = $(wildcard objc/*.m) $(wildcard main/*.m)
GCC_FILES = $(OBJC_FILES) $(C_FILES)
GCC_OBJS = $(patsubst %.m, %.o, $(OBJC_FILES)) $(patsubst %.c, %.o, $(C_FILES))
CC = gcc
CFLAGS = -g -Wall -DMININUSH -std=gnu99
MFLAGS = -fobjc-exceptions
# required to compile bundled PCRE source
CFLAGS += -DHAVE_CONFIG_H
ifeq ($(SYSTEM), Darwin)
#CC = /Developer/usr/bin/llvm-gcc-4.2
CFLAGS += -DMACOSX -DDARWIN $(LEOPARD_CFLAGS) $(LION_CFLAGS) -Ipcre
else
# CFLAGS += -DLINUX
# MFLAGS += -fconstant-string-class=NSConstantString
MFLAGS += $(shell gnustep-config --objc-flags)
endif
ifeq ($(SYSTEM), Linux)
CFLAGS += -DLINUX
endif
ifeq ($(SYSTEM), FreeBSD)
CFLAGS += -DFREEBSD
endif
# OpenSolaris "uname" kernel is "SunOS"
ifeq ($(SYSTEM), SunOS)
CFLAGS += -DOPENSOLARIS
LIBS += -lcurses
endif
LDFLAGS += $(FRAMEWORKS)
LDFLAGS += $(LIBS)
LDFLAGS += $(LIBDIRS)
LDFLAGS += $(FFI_LIB)
ifeq ($(SYSTEM), Darwin)
else
LDFLAGS += $(shell gnustep-config --base-libs)
LDFLAGS += -lobjc
ifneq ($(SYSTEM), SunOS)
LDFLAGS += -Wl,--rpath -Wl,/usr/local/lib
endif
endif
all: mininush
%.o: %.m
$(CC) $(CFLAGS) $(MFLAGS) $(INCLUDES) -c $< -o $@
%.o: %.c
$(CC) $(CFLAGS) $(INCLUDES) -c $< -o $@
.PHONY: mininush
mininush: $(GCC_OBJS)
$(CC) $(GCC_OBJS) $(CFLAGS) -o mininush $(LDFLAGS)
.PHONY: clean
clean:
rm -f objc/*.o main/*.o pcre/*.o
.PHONY: clobber
clobber: clean
rm -f mininush