Skip to content

Commit aa4847d

Browse files
committed
added ubuntu dependency installations to many makefiles
1 parent 01a1893 commit aa4847d

File tree

19 files changed

+142
-107
lines changed

19 files changed

+142
-107
lines changed

c/cpp.cpp

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -44,27 +44,32 @@ for the rest, go to c.c
4444
4545
#headers
4646
47-
stdlib headers don't have the .h extension
47+
stdlib headers that are not c stdlib headers don't have the .h extension
4848
49-
when writting new libs, you use the extension ``.h`` or ``.hpp``
49+
with `g++` those get linked to automatically
5050
51-
with ``g++`` those get linked to automatically
51+
when writting new libs, you can use either `.h` or `.hpp` as extensions.
5252
5353
the main c++ lib on linux is the GNU Standard C++ Library vX
5454
55-
- std bin is located at: ``/usr/lib/i386-linux-gnu/libstdc++.so.X``. Try ``locate libstdc++``.
56-
- std headers are located at: ``/usr/include/c++/4.X/``. Try ``locate /iostream``.
55+
- std bin is located at: `/usr/lib/i386-linux-gnu/libstdc++.so.X`. Try `locate libstdc++`.
56+
- std headers are located at: `/usr/include/c++/4.X/`. Try `locate /iostream`.
5757
58-
Note: c++ std headers have no ``.h`` extension, just like when included.
58+
Note: c++ std headers have no `.h` extension, just like when included.
5959
60-
- the ubuntu package is called ``libstdc++6.X``. ``dpkg -l | grep libstd``
60+
- the ubuntu package is called `libstdc++6.X`. `dpkg -l | grep libstd`
6161
6262
#c stdlin can be accessed
6363
64-
math vs cmath, X vs cX
64+
c++ is a backwards compatible extension of c, therefore it must provide all the c headers with the exact same semantincs.
6565
66-
cX puts things in std:: namespace. *always* use it.
67-
X.h puts *all* in the global namespace. *never* use it.
66+
However, it also provides a cNAME version to every NAME.h, ex: `math.h` vs `cmath`.
67+
68+
The difference is the following:
69+
70+
- cX puts things in std:: namespace. *always* use it on new code, since this reduces the probability of a name conflicts, and is the standard c++ way of doing things.
71+
72+
- X.h puts *all* in the global namespace, it is exactly the same as the c headers. *never* use it in the code.
6873
6974
- returning references
7075
http://stackoverflow.com/questions/795674/which-are-the-implications-of-return-a-value-as-constant-reference-and-constant?rq=1
@@ -857,11 +862,11 @@ void printCallStack()
857862
858863
difficulty:
859864
860-
- there is no ``Iterator`` interface that iterates over anything in the stdlib
865+
- there is no `Iterator` interface that iterates over anything in the stdlib
861866
for performance reasons.
862867
863-
By iterable understand somtehing that has an ``::iterator``,
864-
a ``begin()`` and an ``end()`` methods, like stl containers
868+
By iterable understand somtehing that has an `::iterator`,
869+
a `begin()` and an `end()` methods, like stl containers
865870
*/
866871
class VisibleInnerIterable
867872
{
@@ -953,7 +958,7 @@ void printCallStack()
953958
//BAD
954959
//compiles, but is useless to give a default,
955960
//since when calling, caller is *forced* to give a value for j
956-
//or wil get ``call is ambiguous`` compile time error
961+
//or wil get `call is ambiguous` compile time error
957962
//because compiler cannot decide between
958963
//here the default arg can be usefull for a call of type float float
959964

@@ -1047,11 +1052,11 @@ void printCallStack()
10471052
//NOTE
10481053
//without this, compilation error
10491054
//for me, blows max template recursion depth of 1024
1050-
//this can be reset with ``-ftemplate-depth``
1055+
//this can be reset with `-ftemplate-depth`
10511056

10521057

10531058
//namespaces
1054-
//- *never* use ``using namespace X`` on a header file
1059+
//- *never* use `using namespace X` on a header file
10551060

10561061
//namespace 2D{}
10571062
//ERROR
@@ -1824,7 +1829,7 @@ int main(int argc, char** argv)
18241829
//Class c();
18251830
//c.i = 1;
18261831
//ERROR
1827-
//declares *FUNCTION* called ``c()`` that returns ``Class``
1832+
//declares *FUNCTION* called `c()` that returns `Class`
18281833
//functions inside functions like this are a gcc extension
18291834
}
18301835
}

c/makefile

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ CC ?= gcc
55
CXX ?= g++
66
CFLAGS ?= -Wall -std=c99 -pedantic-errors -Wno-unused-variable -Wno-unused-but-set-variable
77
CXXFLAGS ?= -pthread -Wall -std=c++0x -pedantic-errors -Wno-unused-variable -Wno-unused-but-set-variable
8-
LIBS ?=
8+
9+
#m is required by certain standrad math libraries
10+
LIBS ?= -lm
911

1012
#fortran
1113
FF ?= gfortran
@@ -85,8 +87,8 @@ clean:
8587
rm -rf "$(OUT_DIR)"
8688

8789
install-deps-ubuntu:
88-
sudo apt-get install g++
89-
sudo apt-get install gfortran
90+
sudo apt-get install -y g++
91+
sudo apt-get install -y gfortran
9092

9193
$(OUT_DIR)%$(OUT_EXT): $(IN_DIR)%.c
9294
$(CC) $(DEFINES) $(PROFILE_DEFINE) $(PROFILE_FLAGS) $(DEBUG_DEFINE) $(DEBUG_FLAGS) $(OPTIMIZE_FLAGS) $(CFLAGS) -o "$@" "$<" $(LIBS)

gsl/makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ AUXS:=$(addprefix $(AUX_DIR),$(AUXS_NODIR))
2222
OUT_BNAME:=$(OUT_NAME)$(OUT_EXT)
2323
OUT:=$(OUT_DIR)$(OUT_BNAME)
2424

25-
.PHONY: all mkdir clean assembler debug set_debug_flags profile set_profile_flags help install_ubuntu_deps
25+
.PHONY: all mkdir clean assembler debug set_debug_flags profile set_profile_flags help install-deps-ubuntu
2626

2727
all: mkdir $(OUT)
2828

@@ -42,7 +42,7 @@ mkdir:
4242
clean:
4343
rm -rf $(AUX_DIR) $(OUT_DIR)
4444

45-
install_ubuntu_deps:
46-
sudo aptitude install -y libgsl0-dev gsl-doc-info
45+
install-deps-ubuntu:
46+
sudo apt-get install -y libgsl0-dev gsl-doc-info
4747
#if you will use plplot:
4848
sudo aptitude install -y libplplot-dev plplot11-driver-xwin

gtk/makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ OPTIMIZE_FLAGS?=-O3
4848
OPTIMIZE_FLAGS?=
4949
#dont opt for educative purposes
5050

51-
.PHONY: all mkdir clean profile set_profile_flags ubuntu_deps
51+
.PHONY: all mkdir clean profile set_profile_flags install-deps-ubuntu
5252

5353
all: mkdir $(C_OUTS) $(CPP_OUTS)
5454

@@ -82,8 +82,8 @@ mkdir:
8282
clean:
8383
rm -rf "$(OUT_DIR)"
8484

85-
ubuntu_deps:
86-
sudo aptitude install -y libgtk-3-dev
85+
install-deps-ubuntu:
86+
sudo apt-get install -y libgtk-3-dev
8787

8888
$(OUT_DIR)%$(OUT_EXT): $(IN_DIR)%.c
8989
$(CC) $(DEFINES) $(PROFILE_DEFINE) $(PROFILE_FLAGS) $(DEBUG_DEFINE) $(DEBUG_FLAGS) $(OPTIMIZE_FLAGS) $(CFLAGS) -o "$@" "$<" $(LIBS)

lapack/c.c

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,5 @@ int main(void)
114114
assert_eqd( b2[0], c2[0], err );
115115
assert_eqd( b2[1], c2[1], err );
116116

117-
fputs( "\nALL ASSERTS PASSED\n", stderr );
118117
return EXIT_SUCCESS;
119118
}

lapack/f.f

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,5 @@ program main
179179

180180
!#
181181

182-
write(*,*) 'ALL ASSERTS PASSED'
183-
184182
stop
185183
end

lapack/makefile

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ FFLAGS ?= -Wall -march=native -std=f95 -pedantic-errors
1818
#paths
1919
IN_DIR ?= ./
2020
OUT_DIR ?= _out/
21-
OUT_EXT ?= .out
21+
OUT_EXT ?=
2222

2323
#run
2424
RUN ?= c #basename without extension of file to run
@@ -51,15 +51,16 @@ INS_NODIR:=$(notdir $(INS))
5151
OUTS_NODIR:=$(patsubst %$(EXT),%$(OUT_EXT),$(INS_NODIR))
5252
F_OUTS:=$(addprefix $(OUT_DIR),$(OUTS_NODIR))
5353

54-
.PHONY: all mkdir clean install ubuntu_install_deps
54+
.PHONY: all mkdir clean install install-deps-ubuntu
5555

5656
all: mkdir $(C_OUTS) $(CPP_OUTS) $(F_OUTS)
5757

58-
ubuntu_install_deps:
58+
install-deps-ubuntu:
59+
sudo apt-get install -y gfortran
5960
#blas c/fotran and lapack fortran:
60-
sudo aptitude install -y liblapack-dev
61+
sudo apt-get install -y liblapack-dev
6162
#lapack c via lapacke:
62-
sudo aptitude install -y liblapacke-dev
63+
sudo apt-get install -y liblapacke-dev
6364

6465
mkdir:
6566
mkdir -p "$(OUT_DIR)"
@@ -74,7 +75,7 @@ $(OUT_DIR)%$(OUT_EXT): $(IN_DIR)%.f
7475
$(FF) $(OPTIMIZE_FLAGS) $(FFLAGS) -o "$@" "$<" $(FFLIBS)
7576

7677
run: all
77-
( cd $(OUT_DIR) && ./$(RUN_BNAME) ) #run from out dir
78+
cd $(OUT_DIR) && ./$(RUN_BNAME)
7879

7980
assembler: mkdir $(IN_DIR)$(ASSEMBLER_BASENAME)
8081
$(eval OPTIMIZE_FLAGS := -O0)

lapack/readme.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
1-
blas lapack
1+
Automatic dependencies installation may be available for your system in a make target of type:
2+
`make install-deps-XXX`, for example, `make install-deps-ubuntu`.
3+
4+
#intro
25

36
- linear algebra packages
47
- de-facto standards
58
- non-parallel
6-
- originally written in fortran.
7-
- there are also c interfaces available.
9+
- originally written in fortran
10+
- there are also c interfaces available
11+
12+
it might be a good idea to understand how to interface fortran with c
13+
before trying the c interfaces
14+
15+
#install
16+
817

9-
it might be a good idea to understand how to interface fortran with c
10-
before trying the c interfaces.
1118

1219
#related projects
1320

ode/makefile

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,41 @@
11
#compiles all files in current dir into a single output file
22

3-
CC=g++
4-
LIBS=-lglut -lGLU -lGL -lode
5-
INCLUDE_DIRS=-I/usr/include/GL
3+
CC := g++
4+
LIBS := -lode
65

7-
IN_EXT=.cpp
8-
IN_DIR=./
9-
AUX_DIR=_aux/
10-
AUX_EXT=.o
11-
OUT_DIR=_out/
12-
OUT_EXT=
6+
IN_EXT := .cpp
7+
IN_DIR := ./
8+
AUX_DIR :=_aux/
9+
AUX_EXT := .o
10+
OUT_DIR := _out/
11+
OUT_EXT :=
1312

1413
INS=$(wildcard $(IN_DIR)*$(IN_EXT))
1514
INS_NODIR:=$(notdir $(INS))
1615
AUXS_NODIR:=$(patsubst %$(IN_EXT),%$(AUX_EXT),$(INS_NODIR))
1716
AUXS=$(addprefix $(AUX_DIR),$(AUXS_NODIR))
1817
OUT=$(OUT_DIR)cheat$(OUT_EXT)
1918

20-
.PHONY: all clean mkdir run
19+
.PHONY: all clean install-deps-ubuntu mkdir run
2120

2221
all: mkdir $(OUT)
2322

24-
run: all
25-
$(OUT)
26-
2723
$(OUT): $(AUXS)
2824
$(CC) $^ -o "$@" $(LIBS)
2925

3026
$(AUX_DIR)%$(AUX_EXT): $(IN_DIR)%$(IN_EXT)
31-
$(CC) $(INCLUDE_DIRS) -c "$<" -o "$@"
27+
$(CC) -c "$<" -o "$@"
28+
29+
clean:
30+
rm -rf $(AUX_DIR) $(OUT_DIR)
31+
32+
install-deps-ubuntu:
33+
sudo apt-get install -y g++
34+
sudo apt-get install -y libode-dev
3235

3336
mkdir:
3437
mkdir -p "$(AUX_DIR)"
3538
mkdir -p "$(OUT_DIR)"
3639

37-
clean:
38-
rm -rf $(AUX_DIR) $(OUT_DIR)
40+
run: all
41+
$(OUT)

opencv/cheat.cpp renamed to opencv/main.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ int main( int argc, char** argv )
1010
string infile = "sky.jpg";
1111
string outfile = "_out/sky2.jpg";
1212
double d;
13-
int i,i2, nRows, nCols, channels;
13+
int i2, nRows, nCols, channels;
1414
Mat I, I1, I2, I3, I4, I5;
1515

1616
//create

0 commit comments

Comments
 (0)