Question 1 (1 point)
Select all of the following statements that are true:
Question 1 options:
Software developed within Microsoft Visual Studio is almost always reusable in NetBeans or Eclipse without the need to respecify compiler options, library search paths, and the link order of build products. | |
The make install command coppies built programs and libraries and documentation to correct file system locations. This usually means that the program’s binary will be copied to a directory on your PATH, the program’s manual page will be copied to a directory on your MANPATH, and any other files it depends on will be safely stored in the appropriate place. Since the install step is also defined in the Makefile, where the software is installed can change based on options passed to the configure script, or things the configure script discovered about your system. | |
Once configure has done its job, you can invoke make to build the software. This runs a series of tasks defined in a Makefile to build the finished program from its source code. | |
Eclipse, NetBeans, IntelliJ/Android Studio, Microsoft Visual Studio, xCode, Idle, etc. are Integrated Development Environments (IDEs) that integrate some or all of the following tools: syntax aware text editors, indexed and searchable documentation, compilers or interpreters, debuggers, documentation generators, and profilers. | |
Two teams are using different IDEs can usually share source code and other resources without frequent need to reintegrate software into each IDE’s build system. | |
A configure script is responsible for getting ready to build the software on a specific system. It makes sure all of the dependencies such as compilers and libraries for the rest of the build and install process are available. | |
IDE’s such as NetBeans and Eclipse do not use Makefiles and rely exclusively on other techniques for coordinating software build processes. | |
Many Open Source software projects use makefiles as part of the process for compiling/building the software on users’ computers. The typical commands to build Open Source projects are ./configure; make; sudo make install. |
Question 2 (1 point)
Read Using make and writing Makefiles[https://www.cs.swarthmore.edu/~newhall/unixhelp/howto_makefiles.html] and then select all of the following statements that are true.
You have already used make. In Lab03, you downloaded the source code for the TCL language interpreter. You compiled and installed TCL using the commands: ./configure; make; sudo make install.
The make program is itself an interpreter. It reads files (scripts) called makefiles written in the make language. By interpreting makefiles, make automatically determines which parts of a large multi-step sequence of operations need to be performed. For example, to make a Java .jar file, the various .java files needed must be compiled into .class files and then added to the .jar file. Suppose only a few .java files have been edited since the last time the .jar file was created. There’s no need to recompile every .java file. Only the modified ones need to be recompiled. Makefiles specify the rules for when operations like compiling are needed and when they are not. Make can also support distributed software build systems that simultaneously process/compile files using multiple processors and processor cores.
Integrated Development Environments (IDEs)
Many software developers use Integrated Development Environments (IDEs) such as Eclipse, NetBeans, IntelliJ/Android Studio, Microsoft Visual Studio, xCode, Idle, etc. Most IDEs integrate syntax aware text editors, indexed and searchable documentation, compilers or interpreters, debuggers, documentation generators, profilers, and more. IDEs integrate most of the tools used by professional software developers into one overarching tool – one ring to bind them all.
Given such well-known IDEs, why should a software developer consider alternative approaches such as command line scripts including make? The following are a few reasons:
1) IDE’s usually store “projects” or configuration information in IDE specific files. What happens if two teams are using different IDEs, and the teams have a need to share source code and other resources? Does each team need to integrate the other team’s code into an IDE? What happens when the source code is inevitably modified – do both teams have to reintegrate the other team’s code? What happens if the source code is open-source and intended to be by many other teams – does every reuse of the code require reintegration into each team’s preferred IDE?
2) What happens if the software being built is intended to run on a computer system that does not have a suitable IDE? For example, suppose you want to reuse software developed in Microsoft Visual Studio on a Linux system? What happens if you are developing C++ code in NetBeans but you want to compile and execute the C++ on a computer that doesn’t have support for Java? NetBeans is written in Java and requires Java to run, but many small computers including popular ones like iPhones don’t have an “official” Java runtime. (update ref: Oracle Gets Java Running on iOS Devices) Your c++ code can be compiled for and run on iPhone, but your IDE can’t.
3) Most IDEs use make or similar tools within the IDEs implementation. For example, NetBeans and Eclipse both use makefiles in certain cases. Even for Java, they use Ant which is an almost functionally equivalent Java native replacement for make. As a professional software developer, you should know and understand how your tools work. Microsoft Visual Studio uses Microsoft’s own mostly inferior NMake replacement for Make.
4) What if you need to build a gigantic software system with hundreds of thousands of files? You need a distributed build system that enables use of many processor cores simultaneously. Some IDE’s support distributed build systems, and they use make to implement such systems.
Building Open Source
Open Source software projects usually support use of the software on many different kinds of computers. If Open Source software developers use a particular IDE, they make it inconvenient and error prone to reuse their code on a wide variety of systems including systems that do not have the particular IDE available. Most Open Source software is built using the commands, ./configure; make; sudo make install.
The following is excerpted from https://robots.thoughtbot.com/the-magic-behind-configure-make-make-install
- Configure the software
The configure script is responsible for getting ready to build the software on your specific system. It makes sure all of the dependencies for the rest of the build and install process are available, and finds out whatever it needs to know to use those dependencies.
Unix programs are often written in C, so we’ll usually need a C compiler to build them. In these cases the configure script will establish that your system does indeed have a C compiler, and find out what it’s called and where to find it.
- Build the software
Once configure has done its job, we can invoke make to build the software. This runs a series of tasks defined in a Makefile to build the finished program from its source code.
The [software source code] you download usually doesn’t include a finished Makefile. Instead it comes with a template called Makefile.in and the configure script produces a customized Makefile specific to your system.
- Install the software
Now that the software is built and ready to run, the files can be copied to their final destinations. The make install command will copy the built program, and its libraries and documentation, to the correct locations.
This usually means that the program’s binary will be copied to a directory on your PATH, the program’s manual page will be copied to a directory on your MANPATH, and any other files it depends on will be safely stored in the appropriate place.
Since the install step is also defined in the Makefile, where the software is installed can change based on options passed to the configure script, or things the configure script discovered about your system.
Depending on where the software is being installed, you might need escalated permissions for this step so you can copy files to system directories. Using sudo will often do the trick.
Question 2 options:
CMake, is a cross platform build system. Among other things, cmakewill generate makefiles for you. It is particularly useful for large projects, for builds that use lots of libraries, and for dealing with platform-specific compilation issues. It automatically generates (often hard to read and debug) makefiles for different platforms. For small projects, writing makefiles by hand is likely easier. | |
Ant is a Java native alternative to make. Ant performs a role within large Java project build systems that is similar to the role of make within every other kind of project build system. Ant uses eXtensible Markup Language (XML) to define build rules and dependencies. In contrast, make uses its own language to define build rules and dependencies. | |
make is a tool to simplify building program executables from many modules. make reads in rules (specified as a list of target entries) from a user created Makefile. make will only re-build things that need to be re-built (object or executables that depend on files that have been modified since the last time the objects or executables were built). | |
makedepend cannot automatically generate dependencies for complex projects or for projects that require multiple build steps. | |
A Makefile typically starts with some variable definitions which are then followed by a set of target entries for building specific targets (typically .o & executable files in C and C++, and .class files in Java) or executing a set of command associated with a target label. | |
Makefiles cannot be used to build software written in Java or software that uses a mix of languages such as Java with Java Native Interface (JNI) access to software written in C. |
Question 3 (1 point)
Select all of the following statements that are true.
Question 3 options:
The language understood by make applies different meanings to different kinds of white space. For example, a TAB character is interpreted differently than an equivalent number of SPACE characters under certain circumstances. | |
If you have read the first few sections of http://www.gnu.org/software/make/manual/make.html, you have learned the following: (read carefully to make sure) A simple makefile consists of “rules” with the following shape: target … : prerequisites … recipe … … A target is usually the name of a file that is generated by a program; examples of targets are executable or object files. A target can also be the name of an action to carry out, such as ‘clean’ (see Phony Targets). A prerequisite is a file that is used as input to create the target. A target often depends on several files. A recipe is an action that make carries out. A recipe may have more than one command, either on the same line or each on its own line. Please note:you need to put a tab character at the beginning of every recipe line! This is an obscurity that catches the unwary. If you prefer to prefix your recipes with a character other than tab, you can set the .RECIPEPREFIX variable to an alternate character (see Special Variables). Usually a recipe is in a rule with prerequisites and serves to create a target file if any of the prerequisites change. However, the rule that specifies a recipe for the target need not have prerequisites. For example, the rule containing the delete command associated with the target ‘clean’ does not have prerequisites. A rule, then, explains how and when to remake certain files which are the targets of the particular rule. make carries out the recipe on the prerequisites to create or update the target. A rule can also explain how and when to carry out an action. See Writing Rules. A makefile may contain other text besides rules, but a simple makefile need only contain rules. Rules may look somewhat more complicated than shown in this template, but all fit the pattern more or less. | |
Wikipedia explains CMake as follows: CMake is cross-platform free and open-source software for managing the build process of software using a compiler-independent method. It is designed to support directory hierarchies and applications that depend on multiple libraries. CMake cannot be used with native build environments such as make, Apple’s Xcode, and Microsoft Visual Studio. CMake has minimal dependencies, requiring only a C++compiler on its own build system. | |
By default, make interprets a file named Makefile or makefile in the current directory. With GNU Make, if you want to use a nonstandard name for your makefile, you can specify the makefile name with the -f or –fileoption. The arguments -f name or –file=name tell make to read the file name as the makefile. If you use more than one -f or –fileoption, you can specify several makefiles. All the makefiles are effectively concatenated in the order specified. The default makefile names makefile and Makefile are not checked automatically if you specify -f or –file. | |
When you give the command (execute the program): make make reads the makefile in the current directory and begins by processing the first rule. However, make verifies that each dependency for the first rule is up to date. If not, dependencies will be built first using appropriate rules for each dependency. As a result, executing make may apply many rules other than the first rule. |
Question 4 (1 point)
In Linux (your own VM or thor), Get Java Builder & Factory example from https://github.com/oxyc/java-builder-factory-example
In a shell, use the make command to build Java Builder & Factory example
Examine the Makefile that comes with Java Builder & Factory example. Copy and paste the two line “package:” rule from Makefile into the answer field for this question.
Question 4 options:
Question 5 (2 points)
In you Linux (Ubuntu/Lubuntu) VM or on OS X if you have OS X, execute the following commands in a shell:
git clone https://github.com/fogleman/Craft.git
cd Craft
cmake .
make
./craft
Note for OS X: If you use OS X, you may need to install CMake first, and you may need to install brew (http://brew.sh) to get CMake. You can find instructions at https://github.com/fogleman/Craft:
brew install cmake
Note for Linux: If you use Linux, you may need to install several programs and libraries.
You can find instructions at https://github.com/fogleman/Craft:
sudo apt-get update
sudo apt-get install cmake libglew-dev xorg-dev libcurl4-openssl-dev
sudo apt-get build-dep glfw
sudo apt-get install git
Note: If sudo apt-get build-dep glfw doesn’t work, try sudo apt-get install libglfw-dev
To answer this question, examine the Makefile generated when you executed cmake as part of building the Craft source code. (See instructions at the very top of this question text) Find the following comment (without the quotes) in Makefile: “# The main clean target“. Copy and paste the two line make rule right after that comment into the answer filed for this question.
Final Note: In my Lubuntu VM, the ./craft program runs very slowly. I assume the problem is poor device drivers or poor integration of the VM’s graphics into the host platform. If you would like to see the ./craft program execute in all of its glory, try building it in the Linux available on lab machines as a dual boot option. Alternatively, you can download an already built Windows executable from http://www.michaelfogleman.com/craft/.