Question: Makefiles: For this assignment (and every assignment after this assignment, unless otherwise indicated) you will need to use a Makefile. You should be creating a
Makefiles: For this assignment (and every assignment after this assignment, unless otherwise indicated) you will need to use a Makefile. You should be creating a standard Makefile with targets for "all" and "clean". You should also create object files for each of the modules, and they should be set up as proper dependencies so that they are only compiled when needed. Make sure to "cat" the makefile when making the script, and to include the makefile when you are submitting your code. The Assignment: For this assignment, I want you to write a simple math library. The library should include four functions - add(), subtract(), multiply() and divide(). All of the functions should take in a pair of ints, and all should returns ints except divide(), which should return a double. Write a menu that takes in a number to determine which function to call, take in the pair of numbers to pass to the function, and then call the function. Please note that all of these math functions should be in a file called myMath.c which has a corresponding myMath.h file that you include in your main program. You should test the functions from your main program where you #import "myMath.h". The programming in this assignment (the math functions themselves) are pretty simple. The focus of this assignment is to make sure that you can figure out how modules work and how makefiles work. You will be marked on both the Makefile and the ability to write the library.
Conditional compilation: To make this code more interesting, I want you to add an option via conditional compilation where, if debugging is turned on, then instead of using the math functions in the myMath.c module, you use macros instead. To achieve this, you need to write macros that take parameters for ADD, SUBTRACT, MULTIPLY, and DIVIDE. Build your code with conditional compilation so that when the -DDEBUG flag is used, then the four macros are used instead of the myMath.c functions. Modify your makefile so that it has a debug target that turns on the -DDEBUG flag. When the -DDEBUG flag is turned on, the program should print out "In debugging mode..." as a part of the menu options.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
