Question 1 (1 point)
Select all of the following statements that are true:
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.
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
1. Configure the software
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.
2. Build the software
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.
3. 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 3 (1 point)
Select all of the following statements that are true.
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 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
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/.