SlideShare a Scribd company logo
Chapter 11.
PROGRAMMING LINUX
LINUX AND OPEN SOURCE SOFTWARE
1-1
Contents
 Using programming tools
 Using GNU C Compiler (gcc)
 Project management tools: make, automake, autoconf
 Graphical DevelopmentTools
• IDEs and SDKs
• Kdevelp Client
 Using popular languages
 Java
 Javascript
 PHP
 Python
 Etc.
1-2
Using GNU C Compiler (gcc)
 “GNU is an extensive collection of free software (383
packages as of January 2022), which can be used as an
operating system or can be used in parts with other operating
systems” (Wikipedia).
 GNU cc (gcc) is the GNU project’s compiler suite. It
compiles programs written in C,C++, or Objective C.
 The gcc features
 Preprocessing
 Compilation
 Assembly
 Linking
1-3
Example: gcc
1-4
1. /*
2. * Listing 3.1
3. * hello.c – Canonical “Hello, world!” program 4 4 */
4. #include <stdio.h>
5. int main(void)
6. {
7. fprintf(stdout, “Hello, Linux programming world!n”);
8. return 0;
9. }
$ gcc hello.c -o hello
$ ./hello
Hello, Linux programming world!
Complie and run
1-5
$ gcc –E hello.c -o hello.cpp
$ gcc -x cpp-output -c hello.cpp -o hello.o
Stop compilation
after pre-procesing
See content of stdio.h and
compile to an object code
$ gcc hello.o -o hello
Link the object file
$ gcc killerapp.c helper.c -o killerapp
Use code from
other file
1-6
Project management using GNU make
 Projects composed of multiple source files typically
require long, complex compiler invocations.
 make simplifies this by storing these difficult command lines in
the Makefile
 make also minimizes rebuild times because it is smart enough to
determine which files have changed, and thus only rebuilds files
whose components have changed
 make maintains a database of dependency information for your
projects and so can verify that all of the files necessary for
building a program are available each time you start a build.
1-7
Writing Makefiles
 A makefile is a text file database containing rules that tell
make what to build and how to build it.A rule consists of
the following:
 A target, the “thing” make ultimately tries to create
 A list of one or more dependencies, usually files, required to
build the target
 A list of commands to execute in order to create the target
from the specified dependencies
 Makefile
1-8
target : dependency dependency [...]
command
command
[...]
Makefile examples
 It is the makefile for building a text editor imaginatively
named editor
1-9
1 editor : editor.o screen.o keyboard.o
2 gcc -o editor editor.o screen.o keyboard.o
3
4 editor.o : editor.c editor.h keyboard.h screen.h
5 gcc -c editor.c
6
7 screen.o : screen.c screen.h
8 gcc -c screen.c
9
10 keyboard.o : keyboard.c keyboard.h
11 gcc -c keyboard.c
12
13 clean :
14 rm editor *.o
To compile editor, you would simply type make in the directory where the makefile
exists.
Default target
Dependencies
Rules
Target
Makefile excercise
 Examine the example Makefile 1 in
1-10
https://www.cs.colby.edu/maxwell/courses/tutorials/maketutor/
Makefile: variable
 To simplify editing and maintaining makefiles, make allows
you to create and use variables.
 To obtainVARNAME’s value, enclose it in parentheses and
prefix it with a $:
1-11
VARNAME = some_text [...]
$(VARNAME)
Makefile: variable
1-12
1 OBJS = editor.o screen.o keyboard.o
2 HDRS = editor.h screen.h keyboard.h
3 editor : $(OBJS)
4 gcc -o editor $(OBJS)
5
6 editor.o : editor.c $(HDRS)
7 gcc -c editor.c
8
9 screen.o : screen.c screen.h
10 gcc -c screen.c
11
12 keyboard.o : keyboard.c keyboard.h
13 gcc -c keyboard.c
14
15 .PHONY : clean
16
17 clean :
18 rm editor $(OBJS)
Variables
Default target
Rules
PHONY to skip checking filename “clean”
Environment,Automatic, PredefinedVariables
 make allows the use of environment variables
 make reads every variable defined in its environment and
creates variables with the same name and value
 make provides a long list of predefined and automatic
variables, too.
1-13
AUTOMATIC VARIABLES
Variable Description
$@ The filename of a rule’s target
$< The name of the first dependency in a rule
$^ Space-delimited list of all the dependencies in a rule
$? Space-delimited list of all the dependencies in a rule that are newer thanthe
target
$(@D) The directory part of a target filename, if the target is in a subdirectory
$(@F) The filename part of a target filename, if the target is in a subdirectory
PREDEFINED VARIABLES
Variable Description
AR Archive-maintenance programs; default value = ar
AS Program to do assembly; default value = as
CC Program for compiling C programs; default value = cc
CPP C Preprocessor program; default value = cpp
RM Program to remove files; default value = “rm -f”
ARFLAGS Flags for the archive-maintenance program; default = rv
ASFLAGS Flags for the assembler program; no default
CFLAGS Flags for the C compiler; no default
CPPFLAGS Flags for the C preprocessor; no default
LDFLAGS Flags for the linker (ld); no default
1-14
Excercise
 Examine the example Makefile 2 in
1-15
https://www.cs.colby.edu/maxwell/courses/tutorials/maketutor/
Implicit Rules
 make comes with a comprehensive set of implicit, or
predefined, rules
1-16
1 OBJS = editor.o screen.o keyboard.o
2 editor : $(OBJS)
3 cc -o editor $(OBJS)
4
5 .PHONY : clean
6
7 clean :
8 rm editor $(OBJS)
the makefile lacks
rules for building
targets
(dependencies)
make will look for C source files named editor.c, screen.c, and keyboard.c,
compile them to object files (editor.o, screen.o, and keyboard.o), and finally,
build the default editor target.
Pattern Rules
 Pattern rules look like normal rules, except that the
target contains exactly one character (%) that matches
any nonempty string.
1-17
%.o : %.c
tells make to build any object file somename.o from a source file somename.c.
%.o : %.c
$(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
It defines a rule that makes any file x.o from x.c.
This rule uses the automatic variables $< and $@ to substitute the names of the
first dependency and the target each time the rule is applied. The variables
$(CC), $(CFLAGS), and $(CPPFLAGS)
Excercise
 Examine the example Makefile 3 & Makefile 4 in
1-18
https://www.cs.colby.edu/maxwell/courses/tutorials/maketutor/
Useful Makefile Targets
 make
1-19
• clean
• install
• uninstall
• dist
• test
• archive
• bugreport
# a sample makefile for a skeleton program
CC= gcc
INS= install
INSDIR = /usr/local/bin
LIBDIR= -L/usr/X11R6/lib
LIBS= -lXm -lSM -lICE -lXt -lX11
SRC= skel.c
OBJS= skel.o
PROG= skel
skel: ${OBJS}
${CC} -o ${PROG} ${SRC} ${LIBDIR} ${LIBS}
install: ${PROG}
${INS} -g root -o root ${PROG} ${INSDIR}
Excercise
 Examine the example Makefile 5 in
1-20
https://www.cs.colby.edu/maxwell/courses/tutorials/maketutor/
GNU Automake
 The primary goal of Automake is to generate ‘Makefile’ in
compliant with the GNU Makefile Standards.
 A secondary goal for Automake is that it work well with
other free software, and, specifically, GNU tools.
 Automake helps the maintainer with five large tasks, and
countless minor ones.The basic functional areas are:
• Build
• Check
• Clean
• Install and uninstall
• Distribution
1-21
Building configure.in (or configure.ac)
 The configure script ‘configure.in’ 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.
 A configure script ‘configure.in’ examines your system,
and uses the information it finds to convert
a Makefile.in template into a Makefile
 To run the configure script
1-22
./configure
Building configure.in (or configure.ac)
1-23
AC_INIT (package, version, bug-report-address)
AC_OUTPUT([file...[,extra_cmds[,init_cmds]]])
Invoke before any test
Invoke after any test
unique_file_in_source_dir is a file present in the source code directory. The call to
AC_INIT creates shell code in the generated configure script that looks for
unique_file_in_source_dir to make sure that it is in the correct directory.
AC_OUTPUT creates the output files, such as Makefiles and other (optional) output
files
file is a space separated list of output files.
Configure.in
Structuring the file Configure.ac
1-24
AC_INIT
Tests for programs
Tests for libraries
Tests for header files
Tests for typedefs
Tests for structures
Tests for compiler behavior
Tests for library functions
Tests for system services
AC_OUTPUT
Configure.in
Tests for Programs
1-25
Tests for Library Functions
1-26
Tests for Header Files
1-27
Tests for Structures
1-28
Tests for typedefs
1-29
Tests of Compiler Behavior
1-30
Tests for System Services
1-31
Using the autoconf
 This program builds an executable shell script named
configure (from configure.in) that, when executed,
automatically examines and tailors a client’s build from
source according to software resources, or dependencies
(such as programming tools, libraries, and associated
utilities) that are installed on the target host (your Linux
system).
1-32
Example
1-33
#include <stdio.h>
int
main(int argc, char* argv[])
{
printf("Hello worldn");
return 0;
}
AC_INIT([helloworld], [0.1], [george@thoughtbot.com])
AM_INIT_AUTOMAKE
AC_PROG_CC
AC_CONFIG_FILES([Makefile])
AC_OUTPUT
AUTOMAKE_OPTIONS = foreign
bin_PROGRAMS = helloworld
helloworld_SOURCES = main.c
Helloworld.c Configure.in
Makefile.am
aclocal #generate m4 env
autoconf #generate configure
automake –add-missing
configure
Makefile.in
./configure # Generate Makefile from Makefile.in
make # Use Makefile to build the program
make install # Use Makefile to install the program
Graphical DevelopmentTools
 Ubuntu has a number of graphical prototyping and
development environments available
 integrated development environment (IDE)
• Eclipse
• NetBeans
• Visual Studio Code
• Oracle JDeveloper
 software development kit (SDK)
• Android development SDK
 the KDevelop Client (for Developing in KDE)
 The Glade Client (for Developing in GNOME)
1-34
Exercise
 Download and install Eclipse IDE for C/C++ (or Java, PHP, etc.)
 Check for Java installed: java –version
• Sudo apt install default-jre
 Check OS type (64/32bit): uname -a
 Download Eclipse C/C++ tarball file from
https://www.eclipse.org/downloads/eclipse-packages/
 Extract and install
• tar –xf <tarball file.gz>
 Run Eclipse: ./eclipse
 Set PATH to run from $HOME directory
• PATH = $PATH:$HOME/<install directory>
1-35
Note: to permanently set PATH env, edit file $HOME/.profile
Eclipse
1-36
Using Java on Linux
 Most Java development occurs in an IDE
 Eclipse (www.eclipse.org)
 NetBeans (www.netbeans.org)
1-37
Using JavaScript
 To use JavaScript on Ubuntu, you write programs in your
favorite text editor. Nothing special is needed.
 Put the script somewhere and open it with your web
browser.
 Information is often passed using JavaScript Object
Notation, or JSON
 JavaScript has spawned tons of extensions and
development kits, such as Node.js and JSP.
1-38
Using JavaScript
 Node.js
 Node.js is a popular JavaScript framework used for developing
server side applications.
1-39
sudo apt-get install nodejs
sudo apt-get install npm
sudo ln –s /usr/bin/nodejs /usr/bin/node
Console.log(“This is Ubuntu Node.js”)
~$ node hello.js Hello.js
Using Python
 Most versions of Linux and UNIX, including macOS, come
with Python preinstalled
1-40
matthew@seymour:~$ python
Python 3.6.4 (default, Dec27 2017, 13:02:49)
[GCC 7.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information
Using PHP
 Installation Apache
 Installation mySQL
 Installation PHP
1-41
sudo apt install php libapache2-mod-php
sudo apt install php-cli
sudo apt install php-cgi
sudo apt install php-mysql
sudo apt install apache2
sudo apt install mysql-server
sudo apt install mysql-server

More Related Content

PDF
Introduction to GNU Make Programming Language
PPTX
PPTX
Makefile for python projects
PPTX
Introduction to Makefile
PDF
OS_Compilation_Makefile_kt4jerb34834343553
PPT
Autoconf&Automake
ODP
Introduction To Makefile
ODP
Basic Make
Introduction to GNU Make Programming Language
Makefile for python projects
Introduction to Makefile
OS_Compilation_Makefile_kt4jerb34834343553
Autoconf&Automake
Introduction To Makefile
Basic Make

Similar to LOSS_C11- Programming Linux 20221006.pdf (20)

PDF
Compiler design notes phases of compiler
PDF
Makefile Martial Arts - Chapter 1. The morning of creation
PDF
Gnubs pres-foss-cdac-sem
PDF
Gnubs-pres-foss-cdac-sem
PDF
makefiles tutorial
PPT
Introduction to Makefile
PPTX
Autotools pratical training
PPT
Ch3 gnu make
PDF
Makefile
ODP
Makefiles Bioinfo
PDF
Programming in Linux Environment
PDF
Linux intro 5 extra: makefiles
PDF
Don't Fear the Autotools
PDF
CMake Tutorial
PDF
Course 102: Lecture 12: Basic Text Handling
PDF
Linux intro 4 awk + makefile
PDF
LONI_MakeTutorial_Spring2012.pdf
PDF
cmake.pdf
PPT
Linux operating system by Quontra Solutions
PPT
PowerPoint_merge.ppt on unix programming
Compiler design notes phases of compiler
Makefile Martial Arts - Chapter 1. The morning of creation
Gnubs pres-foss-cdac-sem
Gnubs-pres-foss-cdac-sem
makefiles tutorial
Introduction to Makefile
Autotools pratical training
Ch3 gnu make
Makefile
Makefiles Bioinfo
Programming in Linux Environment
Linux intro 5 extra: makefiles
Don't Fear the Autotools
CMake Tutorial
Course 102: Lecture 12: Basic Text Handling
Linux intro 4 awk + makefile
LONI_MakeTutorial_Spring2012.pdf
cmake.pdf
Linux operating system by Quontra Solutions
PowerPoint_merge.ppt on unix programming
Ad

Recently uploaded (20)

PPTX
Lesson notes of climatology university.
PDF
Abdominal Access Techniques with Prof. Dr. R K Mishra
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PPTX
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
PPTX
Orientation - ARALprogram of Deped to the Parents.pptx
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
01-Introduction-to-Information-Management.pdf
PDF
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PDF
Yogi Goddess Pres Conference Studio Updates
PPTX
Cell Types and Its function , kingdom of life
PDF
A systematic review of self-coping strategies used by university students to ...
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
Computing-Curriculum for Schools in Ghana
PDF
Classroom Observation Tools for Teachers
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Lesson notes of climatology university.
Abdominal Access Techniques with Prof. Dr. R K Mishra
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
school management -TNTEU- B.Ed., Semester II Unit 1.pptx
Orientation - ARALprogram of Deped to the Parents.pptx
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
2.FourierTransform-ShortQuestionswithAnswers.pdf
FourierSeries-QuestionsWithAnswers(Part-A).pdf
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
01-Introduction-to-Information-Management.pdf
3rd Neelam Sanjeevareddy Memorial Lecture.pdf
Supply Chain Operations Speaking Notes -ICLT Program
Yogi Goddess Pres Conference Studio Updates
Cell Types and Its function , kingdom of life
A systematic review of self-coping strategies used by university students to ...
Module 4: Burden of Disease Tutorial Slides S2 2025
Computing-Curriculum for Schools in Ghana
Classroom Observation Tools for Teachers
Final Presentation General Medicine 03-08-2024.pptx
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
Ad

LOSS_C11- Programming Linux 20221006.pdf

  • 1. Chapter 11. PROGRAMMING LINUX LINUX AND OPEN SOURCE SOFTWARE 1-1
  • 2. Contents  Using programming tools  Using GNU C Compiler (gcc)  Project management tools: make, automake, autoconf  Graphical DevelopmentTools • IDEs and SDKs • Kdevelp Client  Using popular languages  Java  Javascript  PHP  Python  Etc. 1-2
  • 3. Using GNU C Compiler (gcc)  “GNU is an extensive collection of free software (383 packages as of January 2022), which can be used as an operating system or can be used in parts with other operating systems” (Wikipedia).  GNU cc (gcc) is the GNU project’s compiler suite. It compiles programs written in C,C++, or Objective C.  The gcc features  Preprocessing  Compilation  Assembly  Linking 1-3
  • 4. Example: gcc 1-4 1. /* 2. * Listing 3.1 3. * hello.c – Canonical “Hello, world!” program 4 4 */ 4. #include <stdio.h> 5. int main(void) 6. { 7. fprintf(stdout, “Hello, Linux programming world!n”); 8. return 0; 9. } $ gcc hello.c -o hello $ ./hello Hello, Linux programming world! Complie and run
  • 5. 1-5 $ gcc –E hello.c -o hello.cpp $ gcc -x cpp-output -c hello.cpp -o hello.o Stop compilation after pre-procesing See content of stdio.h and compile to an object code $ gcc hello.o -o hello Link the object file $ gcc killerapp.c helper.c -o killerapp Use code from other file
  • 6. 1-6
  • 7. Project management using GNU make  Projects composed of multiple source files typically require long, complex compiler invocations.  make simplifies this by storing these difficult command lines in the Makefile  make also minimizes rebuild times because it is smart enough to determine which files have changed, and thus only rebuilds files whose components have changed  make maintains a database of dependency information for your projects and so can verify that all of the files necessary for building a program are available each time you start a build. 1-7
  • 8. Writing Makefiles  A makefile is a text file database containing rules that tell make what to build and how to build it.A rule consists of the following:  A target, the “thing” make ultimately tries to create  A list of one or more dependencies, usually files, required to build the target  A list of commands to execute in order to create the target from the specified dependencies  Makefile 1-8 target : dependency dependency [...] command command [...]
  • 9. Makefile examples  It is the makefile for building a text editor imaginatively named editor 1-9 1 editor : editor.o screen.o keyboard.o 2 gcc -o editor editor.o screen.o keyboard.o 3 4 editor.o : editor.c editor.h keyboard.h screen.h 5 gcc -c editor.c 6 7 screen.o : screen.c screen.h 8 gcc -c screen.c 9 10 keyboard.o : keyboard.c keyboard.h 11 gcc -c keyboard.c 12 13 clean : 14 rm editor *.o To compile editor, you would simply type make in the directory where the makefile exists. Default target Dependencies Rules Target
  • 10. Makefile excercise  Examine the example Makefile 1 in 1-10 https://www.cs.colby.edu/maxwell/courses/tutorials/maketutor/
  • 11. Makefile: variable  To simplify editing and maintaining makefiles, make allows you to create and use variables.  To obtainVARNAME’s value, enclose it in parentheses and prefix it with a $: 1-11 VARNAME = some_text [...] $(VARNAME)
  • 12. Makefile: variable 1-12 1 OBJS = editor.o screen.o keyboard.o 2 HDRS = editor.h screen.h keyboard.h 3 editor : $(OBJS) 4 gcc -o editor $(OBJS) 5 6 editor.o : editor.c $(HDRS) 7 gcc -c editor.c 8 9 screen.o : screen.c screen.h 10 gcc -c screen.c 11 12 keyboard.o : keyboard.c keyboard.h 13 gcc -c keyboard.c 14 15 .PHONY : clean 16 17 clean : 18 rm editor $(OBJS) Variables Default target Rules PHONY to skip checking filename “clean”
  • 13. Environment,Automatic, PredefinedVariables  make allows the use of environment variables  make reads every variable defined in its environment and creates variables with the same name and value  make provides a long list of predefined and automatic variables, too. 1-13 AUTOMATIC VARIABLES Variable Description $@ The filename of a rule’s target $< The name of the first dependency in a rule $^ Space-delimited list of all the dependencies in a rule $? Space-delimited list of all the dependencies in a rule that are newer thanthe target $(@D) The directory part of a target filename, if the target is in a subdirectory $(@F) The filename part of a target filename, if the target is in a subdirectory
  • 14. PREDEFINED VARIABLES Variable Description AR Archive-maintenance programs; default value = ar AS Program to do assembly; default value = as CC Program for compiling C programs; default value = cc CPP C Preprocessor program; default value = cpp RM Program to remove files; default value = “rm -f” ARFLAGS Flags for the archive-maintenance program; default = rv ASFLAGS Flags for the assembler program; no default CFLAGS Flags for the C compiler; no default CPPFLAGS Flags for the C preprocessor; no default LDFLAGS Flags for the linker (ld); no default 1-14
  • 15. Excercise  Examine the example Makefile 2 in 1-15 https://www.cs.colby.edu/maxwell/courses/tutorials/maketutor/
  • 16. Implicit Rules  make comes with a comprehensive set of implicit, or predefined, rules 1-16 1 OBJS = editor.o screen.o keyboard.o 2 editor : $(OBJS) 3 cc -o editor $(OBJS) 4 5 .PHONY : clean 6 7 clean : 8 rm editor $(OBJS) the makefile lacks rules for building targets (dependencies) make will look for C source files named editor.c, screen.c, and keyboard.c, compile them to object files (editor.o, screen.o, and keyboard.o), and finally, build the default editor target.
  • 17. Pattern Rules  Pattern rules look like normal rules, except that the target contains exactly one character (%) that matches any nonempty string. 1-17 %.o : %.c tells make to build any object file somename.o from a source file somename.c. %.o : %.c $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@ It defines a rule that makes any file x.o from x.c. This rule uses the automatic variables $< and $@ to substitute the names of the first dependency and the target each time the rule is applied. The variables $(CC), $(CFLAGS), and $(CPPFLAGS)
  • 18. Excercise  Examine the example Makefile 3 & Makefile 4 in 1-18 https://www.cs.colby.edu/maxwell/courses/tutorials/maketutor/
  • 19. Useful Makefile Targets  make 1-19 • clean • install • uninstall • dist • test • archive • bugreport # a sample makefile for a skeleton program CC= gcc INS= install INSDIR = /usr/local/bin LIBDIR= -L/usr/X11R6/lib LIBS= -lXm -lSM -lICE -lXt -lX11 SRC= skel.c OBJS= skel.o PROG= skel skel: ${OBJS} ${CC} -o ${PROG} ${SRC} ${LIBDIR} ${LIBS} install: ${PROG} ${INS} -g root -o root ${PROG} ${INSDIR}
  • 20. Excercise  Examine the example Makefile 5 in 1-20 https://www.cs.colby.edu/maxwell/courses/tutorials/maketutor/
  • 21. GNU Automake  The primary goal of Automake is to generate ‘Makefile’ in compliant with the GNU Makefile Standards.  A secondary goal for Automake is that it work well with other free software, and, specifically, GNU tools.  Automake helps the maintainer with five large tasks, and countless minor ones.The basic functional areas are: • Build • Check • Clean • Install and uninstall • Distribution 1-21
  • 22. Building configure.in (or configure.ac)  The configure script ‘configure.in’ 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.  A configure script ‘configure.in’ examines your system, and uses the information it finds to convert a Makefile.in template into a Makefile  To run the configure script 1-22 ./configure
  • 23. Building configure.in (or configure.ac) 1-23 AC_INIT (package, version, bug-report-address) AC_OUTPUT([file...[,extra_cmds[,init_cmds]]]) Invoke before any test Invoke after any test unique_file_in_source_dir is a file present in the source code directory. The call to AC_INIT creates shell code in the generated configure script that looks for unique_file_in_source_dir to make sure that it is in the correct directory. AC_OUTPUT creates the output files, such as Makefiles and other (optional) output files file is a space separated list of output files. Configure.in
  • 24. Structuring the file Configure.ac 1-24 AC_INIT Tests for programs Tests for libraries Tests for header files Tests for typedefs Tests for structures Tests for compiler behavior Tests for library functions Tests for system services AC_OUTPUT Configure.in
  • 26. Tests for Library Functions 1-26
  • 27. Tests for Header Files 1-27
  • 30. Tests of Compiler Behavior 1-30
  • 31. Tests for System Services 1-31
  • 32. Using the autoconf  This program builds an executable shell script named configure (from configure.in) that, when executed, automatically examines and tailors a client’s build from source according to software resources, or dependencies (such as programming tools, libraries, and associated utilities) that are installed on the target host (your Linux system). 1-32
  • 33. Example 1-33 #include <stdio.h> int main(int argc, char* argv[]) { printf("Hello worldn"); return 0; } AC_INIT([helloworld], [0.1], [[email protected]]) AM_INIT_AUTOMAKE AC_PROG_CC AC_CONFIG_FILES([Makefile]) AC_OUTPUT AUTOMAKE_OPTIONS = foreign bin_PROGRAMS = helloworld helloworld_SOURCES = main.c Helloworld.c Configure.in Makefile.am aclocal #generate m4 env autoconf #generate configure automake –add-missing configure Makefile.in ./configure # Generate Makefile from Makefile.in make # Use Makefile to build the program make install # Use Makefile to install the program
  • 34. Graphical DevelopmentTools  Ubuntu has a number of graphical prototyping and development environments available  integrated development environment (IDE) • Eclipse • NetBeans • Visual Studio Code • Oracle JDeveloper  software development kit (SDK) • Android development SDK  the KDevelop Client (for Developing in KDE)  The Glade Client (for Developing in GNOME) 1-34
  • 35. Exercise  Download and install Eclipse IDE for C/C++ (or Java, PHP, etc.)  Check for Java installed: java –version • Sudo apt install default-jre  Check OS type (64/32bit): uname -a  Download Eclipse C/C++ tarball file from https://www.eclipse.org/downloads/eclipse-packages/  Extract and install • tar –xf <tarball file.gz>  Run Eclipse: ./eclipse  Set PATH to run from $HOME directory • PATH = $PATH:$HOME/<install directory> 1-35 Note: to permanently set PATH env, edit file $HOME/.profile
  • 37. Using Java on Linux  Most Java development occurs in an IDE  Eclipse (www.eclipse.org)  NetBeans (www.netbeans.org) 1-37
  • 38. Using JavaScript  To use JavaScript on Ubuntu, you write programs in your favorite text editor. Nothing special is needed.  Put the script somewhere and open it with your web browser.  Information is often passed using JavaScript Object Notation, or JSON  JavaScript has spawned tons of extensions and development kits, such as Node.js and JSP. 1-38
  • 39. Using JavaScript  Node.js  Node.js is a popular JavaScript framework used for developing server side applications. 1-39 sudo apt-get install nodejs sudo apt-get install npm sudo ln –s /usr/bin/nodejs /usr/bin/node Console.log(“This is Ubuntu Node.js”) ~$ node hello.js Hello.js
  • 40. Using Python  Most versions of Linux and UNIX, including macOS, come with Python preinstalled 1-40 matthew@seymour:~$ python Python 3.6.4 (default, Dec27 2017, 13:02:49) [GCC 7.2.0] on linux Type "help", "copyright", "credits" or "license" for more information
  • 41. Using PHP  Installation Apache  Installation mySQL  Installation PHP 1-41 sudo apt install php libapache2-mod-php sudo apt install php-cli sudo apt install php-cgi sudo apt install php-mysql sudo apt install apache2 sudo apt install mysql-server sudo apt install mysql-server