title: passing optional arguments to a makefile
body: <p>I have a program and i have this make file and im trying to run my program with this makefile, and it compiles well the problem is when i run the program i what to run it like this <code>./user -n tejo.tecnico.ulisboa.pt -p 58011</code> with this <code>-n tejo.tecnico.ulisboa.pt</code> or this <code>-p 58011</code> being optional.</p>
  <p>I saw this post <a href="https://stackoverflow.com/questions/2214575/passing-arguments-to-make-run">Passing arguments to &quot;make run&quot;</a> and im not understanding what im doing wrong in the make run command</p>
  <p>So can anyone tell me whats wrong in my makefile?</p>
  <p>btw im fairly new at making makefiles and using the command line.</p>
  <p>Program:</p>
  <pre><code># Makefile
  CC   = g++
  LD   = g++
  
  AUXLIB = auxiliar_code/aux_functions.h
  SOCKETLIB = socket_operations/socket_functs.h
  COMMANDSLIB = commands/commands.h
  
  .PHONY: all clean run
  
  all: client
  
  client: socket_operations/socket.o auxiliar_code/aux.o commands/commands.o commands/client.o main.o
      $(LD) -o user socket_operations/socket.o auxiliar_code/aux.o commands/commands.o commands/client.o main.o
  
  auxiliar_code/aux.o: auxiliar_code/aux_functions.cpp $(AUXLIB) client_constants.h
      $(CC) -o auxiliar_code/aux.o -c auxiliar_code/aux_functions.cpp
  
  commands/client.o: commands/Client.cpp $(COMMANDSLIB) $(SOCKETLIB) $(AUXLIB) client_constants.h
      $(CC) -o commands/client.o -c commands/Client.cpp
  
  commands/commands.o: commands/commands.cpp $(COMMANDSLIB) $(SOCKETLIB) $(AUXLIB) client_constants.h
      $(CC) -o commands/commands.o -c commands/commands.cpp
  
  socket_operations/socket.o: socket_operations/socket_functs.cpp $(SOCKETLIB) $(AUXLIB) client_constants.h
      $(CC) -o socket_operations/socket.o -c socket_operations/socket_functs.cpp
  
  main.o: main.cpp $(COMMANDSLIB) $(AUXLIB) client_constants.h
      $(CC) $(CFLAGS) -o main.o -c main.cpp
  
  clean:
      @echo Cleaning files generated
      rm -f auxiliar_code/*.o commands/*.o socket_operations/*.o *.o user
  
  run: user
      @echo ./user $(filter-out $@,$(MAKECMDGOALS))
  %:
      @:
  </code></pre>