mirror of
https://github.com/samsonjs/csc360-a1-shell.git
synced 2026-03-25 08:45:52 +00:00
Improve portability of Makefile
This commit is contained in:
parent
7f95910a9c
commit
421f3f981e
3 changed files with 24 additions and 5 deletions
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
*.o
|
||||||
|
a1
|
||||||
10
Makefile
10
Makefile
|
|
@ -1,13 +1,13 @@
|
||||||
CFLAGS = -Wall -g
|
CFLAGS = -Wall -g
|
||||||
CPPFLAGS = -I/usr/local/opt/readline/include
|
CPPFLAGS = -I$(shell ./dependency-dir)/readline/include
|
||||||
LDFLAGS = -L/usr/local/opt/readline/lib
|
LDFLAGS = -L$(shell ./dependency-dir)/readline/lib
|
||||||
|
|
||||||
OBJS = utils.o builtins.o exec.o jobs.o main.o
|
OBJS = utils.o builtins.o exec.o jobs.o main.o
|
||||||
|
|
||||||
all: a1
|
all: a1
|
||||||
|
|
||||||
a1: $(OBJS)
|
a1: $(OBJS)
|
||||||
$(CC) $(CFLAGS) -o a1 $(OBJS) $(LDFLAGS) -lreadline -lhistory -ltermcap
|
$(CC) $(CFLAGS) -o a1 $(OBJS) $(LDFLAGS) -lreadline -lhistory -ltermcap
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf $(OBJS) a1
|
rm -rf $(OBJS) a1
|
||||||
|
|
|
||||||
17
dependency-dir
Executable file
17
dependency-dir
Executable file
|
|
@ -0,0 +1,17 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
if [[ $(uname -s) = Darwin ]]; then
|
||||||
|
if command -v brew >/dev/null 2>/dev/null; then
|
||||||
|
echo $(brew --prefix)/opt
|
||||||
|
elif [[ -x /opt/homebrew/bin/brew ]]; then
|
||||||
|
echo $(/opt/homebrew/bin/brew -- prefix)/opt
|
||||||
|
elif [[ -x $HOME/homebrew/bin/brew ]]; then
|
||||||
|
echo $($HOME/homebrew/bin/brew --prefix)/opt
|
||||||
|
elif [[ -x /usr/local/bin/brew ]]; then
|
||||||
|
echo $(/usr/local/bin/brew --prefix)/opt
|
||||||
|
else
|
||||||
|
echo /usr/local
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo /usr
|
||||||
|
fi
|
||||||
Loading…
Reference in a new issue