Command line arguments with make.
Nov 12, 2013 at 6:58pm UTC
I have to input a file name on the command line for the make and I do not understand how to do this. I've tried looking it up but got confused with something like.
make arugment abd="abc"
$(abc)
I am really confused and would greatly appreciate some help thank you.
MAKE COMMAND : make postfix
FILE : data3-1.txt
Now I was told how to change the make file to put the file in it but I do not want to.
MAKE FILE
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
#============================================================================
# stack class makefile
#===========================================================================
CPP = g++
CPP_FLAGS = -g -Wall -W -Wunused -Wuninitialized -Wshadow
INCLUDE_OPT = -iquote . -iquote ../string
# Names of your test files - add them in as you build them.
# Names must start with "test_"
MYTESTS = test_default_ctor test_pop_push
#-------------------------------------------------------------------------------
#Location of string - change if your folder is called something else
# or make blank if you have a copy in the same folder as stack.
#
STRING_DIR = ../string/
#===========================================================================
msg:
@echo 'Targets for compiling test programs:'
@echo ' tests'
@echo ' clean'
@echo ' postfix'
@echo ' assembler'
#===========================================================================
# Compile string.o from Project 2.
string.o: ${STRING_DIR}string.hpp ${STRING_DIR}string.cpp
${CPP} ${CPP_FLAGS} ${INCLUDE_OPT} -c ${STRING_DIR}string.cpp
#===========================================================================
# No compile for stack is needed - it is a template.
#===========================================================================
# Compile test programs
#----------------------------------------------------------------------------
test_%: string.o test_%.o
${CPP} ${CPP_FLAGS} string.o test_$*.o -o test_$*
test_%.o: ${STRING_DIR}string.hpp stack.hpp test_%.cpp
${CPP} ${CPP_FLAGS} ${INCLUDE_OPT} -c test_$*.cpp
#===========================================================================
# Run all of your tests
#
# You will need to ADD your other below:
# For example: ./test_plus
#
tests: stack.hpp ${STRING_DIR}string.hpp ${MYTESTS}
./test_default_ctor
./test_pop_push
#===========================================================================
# Compile postfix
postfix.o: postfix.cpp ${STRING_DIR}string.hpp stack.hpp
${CPP} ${CPP_FLAGS} ${INCLUDE_OPT} -c postfix.cpp
postfix: postfix.o string.o
${CPP} ${CPP_FLAGS} postfix.o string.o -o postfix
#===========================================================================
# Compile assembler
assembler.o: assembler.cpp ${STRING_DIR}string.hpp stack.hpp
${CPP} ${CPP_FLAGS} ${INCLUDE_OPT} -c assembler.cpp
assembler: assembler.o string.o
${CPP} ${CPP_FLAGS} string.o assembler.o -o assembler
#============================================================================
clean:
rm -f *.o
rm -f postfix
rm -f assembler
rm -f $(MYTESTS)
Topic archived. No new replies allowed.