forked from jovanbulck/jsh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
59 lines (48 loc) · 2.32 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
JSH_INSTALL_DIR = /usr/local/bin
MANPAGE_INSTALL_DIR = /usr/local/share/man/man1
CC = gcc
CFLAGS = -g
LIBS = -lreadline
LN = $(CC) $(CFLAGS) jsh-common.o jsh.o alias.o env.o -o jsh $(LIBS)
ECHO_LIBS = echo "Linking jsh with the following libraries: $(LIBS) "
UNAME_S = $(shell uname -s)
ifeq ($(UNAME_S), Darwin)
LINK = @$(LN) -L/usr/local/lib/ # Add library folder for Mac OS X readline (installed with homebrew)
else # try to link jsh with the readline library (and curses or termcap if needed)
LINK = @(($(ECHO_LIBS)); ($(LN)) || (($(ECHO_LIBS) "lncurses"); $(LN) -lncurses) || \
(($(ECHO_LIBS) "termcap"); $(LN) -termcap) || (echo "Failed linking jsh: all known fallback libraries were tried"))
endif
all: jsh-common alias env jsh link
@echo "-------- Compiling all done --------"
jsh-common: jsh-common.c jsh-common.h
$(CC) $(CFLAGS) -c jsh-common.c -o jsh-common.o
alias: alias.c alias.h jsh-common.h
$(CC) $(CFLAGS) -c alias.c -o alias.o
env: env.c env.h
$(CC) $(CFLAGS) -c env.c -o env.o
jsh: jsh-parse.c jsh.c jsh-common.h
$(CC) $(CFLAGS) -c jsh.c -o jsh.o
link: jsh-common.o jsh.o alias.o
$(LINK)
.PHONY: install
install: all
@echo "installing jsh executable in directory $(JSH_INSTALL_DIR)..."
@test -d $(JSH_INSTALL_DIR) || (mkdir -p $(JSH_INSTALL_DIR) && echo "created directory $(JSH_INSTALL_DIR)")
@install -m 0755 jsh $(JSH_INSTALL_DIR);
@echo "installing the manpage in directory $(MANPAGE_INSTALL_DIR)..."
@test -d $(MANPAGE_INSTALL_DIR) || (mkdir -p $(MANPAGE_INSTALL_DIR) && echo "created directory $(MANPAGE_INSTALL_DIR)")
@install -m 0644 jsh.1 $(MANPAGE_INSTALL_DIR);
ifneq ($(UNAME_S), Darwin) # Man-DB update is not necessary on Mac
@echo "updating man-db..."
@mandb --quiet
endif
@echo "-------- Installation all done --------"
.PHONY: clean
clean:
@rm -f jsh-common.o alias.o jsh.o jsh
.PHONY : help
help:
@echo "The following are the valid targets for this Makefile:"
@echo "... all -- (the default if no target is provided); compiles the jo-shell to the 'jsh' binary in the current directory"
@echo "... clean -- removes all object files generated by the build process"
@echo "... install -- installs the jsh binary to $(JSH_INSTALL_DIR) and the jsh man page to $(MANPAGE_INSTALL_DIR)"