mikeizbicki / ucr-cs100

open source software construction course
Other
485 stars 407 forks source link

makefile and creating bin #81

Closed willccoates closed 10 years ago

willccoates commented 10 years ago

i tried adding the code

all: bin rshell bin: [! -d bin] && mkdir bin

and i got the error

[! -d bin] && mkdir bin /bin/sh: 1: [!: not found make: *\ [bin] Error 127

could anyone explain what i need to fix

mikeizbicki commented 10 years ago

you need a tab after the bin, so:

all: bin rshell
bin:
    [! -d bin] && mkdir bin
willccoates commented 10 years ago

yea i have that in my Makefile

katherinegallaher commented 10 years ago

I had to put a dollar sign before the bin in the brackets like [ ! -d $bin ] && mkdir bin

willccoates commented 10 years ago

i just tried it and i still got the same error :/

katherinegallaher commented 10 years ago

maybe you need a space between the bracket and the exclamation point ?

willccoates commented 10 years ago

ahh idk whats wrong with it lol

katherinegallaher commented 10 years ago

lol well if it helps mine looks like this, idk what could be wrong though :

all: bin rshell ls

bin: [ ! -d $bin ] && mkdir bin

examplestudent commented 10 years ago

Please paste the exact contents of the file here. Put it inside of three backticks so that github displays it as code. Lookup "github flavored markdown" if you need a tutorial on how to do this. Also, put the exact error message you get when you run make. I mean EVERYTHING, including the command prompt and the stuff you type in.

On Mon, Aug 18, 2014 at 8:04 PM, william coates notifications@github.com wrote:

ahh idk whats wrong with it lol

Reply to this email directly or view it on GitHub https://github.com/mikeizbicki/ucr-cs100/issues/81#issuecomment-52585090 .

willccoates commented 10 years ago
  1 all: bin rshell
  2 bin:
  3     [ ! -d bin] && mkdir bin
  4 rshell:
  5     g++ -Wall -Werror -ansi -pedantic src/main.cpp -o ./bin/rshell
  6 ls:
  7     g++ -Wall -Werror -ansi -pedantic src/ls.cpp -o ./bin/ls
  8 cp:
  9     g++ -Wall -Werror -ansi -pedantic src/cp.cpp -o ./bin/cp
william@william-Inspiron-N5110:~/cs100/hw12/rshell$ make
[ ! -d bin] && mkdir bin
/bin/sh: 1: [: missing ]
make: *** [bin] Error 2
william@william-Inspiron-N5110:~/cs100/hw12/rshell$ 
mikeizbicki commented 10 years ago

You need a space between bin and ]. The [ executable expects its last parameter to be ], but it's last parameter in your version is bin].

willccoates commented 10 years ago

that worked! thank you