Skip to content

Commit 6c65d56

Browse files
committed
Remove submodule
1 parent a5717ab commit 6c65d56

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+2023
-1563
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

.gitignore

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Final output files: executables, .so, .a
2+
_build/
3+
4+
# Cmake style generated files
5+
build/
6+
7+
# Executable generated on current directory.
8+
main
9+
10+
# Compiled Object files
11+
*.slo
12+
*.lo
13+
*.out
14+
*.o
15+
16+
# Compiled Dynamic libraries
17+
*.so
18+
*.dylib
19+
20+
# Compiled Static libraries
21+
*.lai
22+
*.la
23+
*.a
24+
25+
# Temporary files
26+
*.tmp
27+
28+
core
29+
core.*
30+
31+
.vagrant
32+
33+
# Python tests runners.
34+
*.pyc

.gitmodules

Lines changed: 0 additions & 3 deletions
This file was deleted.

Makefile_many

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ FFLAGS ?= -std=f2003 -Wall -pedantic-errors -march=native $(FFLAGS_EXTRA)
2222
IN_DIR ?= ./
2323
IN_EXTS ?= .c .cpp .f
2424
# Unlike in Makefile_one, there is no TMP_DIR because there are no .o files generated.
25-
OUT_DIR ?= _build/
26-
OUT_EXT ?= #.elf
25+
OUT_DIR ?= ./
26+
OUT_EXT ?= .out
27+
TMP_EXT ?= .tmp
2728

2829
# Basename without extension of file to run on run target.
2930
RUN ?= main
@@ -65,7 +66,7 @@ ifneq ($(strip $(run)),)
6566
endif
6667

6768
$(OUT_DIR)%$(OUT_EXT): $(IN_DIR)%.c
68-
$(MYCC) $(CFLAGS) $(PROFILE_DEFINE) $(PROFILE_FLAGS) $(DEBUG_DEFINE) $(DEBUG_FLAGS) $(OPTIMIZE_FLAGS) $(INCLUDE_DIRS) -o "$@" "$<" $(LIBS)
69+
$(MYCC) $(CFLAGS) $(PROFILE_DEFINE) $(PROFILE_FLAGS) $(DEBUG_DEFINE) $(DEBUG_FLAGS) $(OPTIMIZE_FLAGS) $(INCLUDE_DIRS) -o "$@" "$<" $(LIBS)
6970

7071
$(OUT_DIR)%$(OUT_EXT): $(IN_DIR)%.cpp
7172
$(MYCXX) $(MYCXXFLAGS) $(PROFILE_DEFINE) $(PROFILE_FLAGS) $(DEBUG_DEFINE) $(DEBUG_FLAGS) $(OPTIMIZE_FLAGS) $(INCLUDE_DIRS) -o "$@" "$<" $(LIBS)
@@ -98,7 +99,11 @@ set_asm_flags:
9899
$(eval DEBUG_FLAGS := -ggdb3)
99100

100101
clean:
101-
rm -rf "$(OUT_DIR)"
102+
if [ ! '$(OUT_DIR)' = './' ]; then \
103+
rm -rf '$(OUT_DIR)' ;\
104+
else \
105+
rm -f *'$(OUT_EXT)' *'$(TMP_EXT)' ;\
106+
fi
102107

103108
debug: clean set_debug_flags all
104109
cd $(OUT_DIR) && gdb "$(RUN_BNAME)"

Makefile_one

Lines changed: 0 additions & 1 deletion
This file was deleted.

Makefile_one

Lines changed: 128 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
# `make help` for documentation.
2+
3+
-include Makefile_params
4+
5+
DEBUG_DEFINE ?=
6+
DEBUG_FLAGS ?=
7+
# For -DDEBUG and -DPROFILE, used dedicated DEFINES, as these must be modified
8+
# separatedly for certain targets.
9+
DEFINES ?= #-DPOSIX
10+
# Extension of the input to be compiled.
11+
IN_EXT ?= .cpp
12+
# Directory where compilation input files (e.g. `.c` or `.cpp`) are found.
13+
IN_DIR ?= ./
14+
# Fortran compiler.
15+
FF ?= gfortran
16+
INCLUDE_DIRS ?= #-L/usr/include/GL
17+
LIBS ?= #-lglut -lGLU -lGL
18+
MYCC ?= gcc
19+
MYCFLAGS ?= -std=c11 -Wall -pedantic-errors -march=native $(CFLAGS_EXTRA)
20+
MYCXX ?= g++
21+
MYCXXFLAGS ?= -std=c++11 -Wall -pedantic-errors -march=native $(CXXFLAGS_EXTRA)
22+
# Should be turned on for production.
23+
# For development leave off to compile faster and produce more predictable assembly code.
24+
OPTIMIZE_FLAGS ?= #-O3
25+
# Directory where compiled outputs will be put.
26+
OUT_DIR ?= ./
27+
OUT_BASENAME_NOEXT ?= main
28+
OUT_EXT ?=
29+
RUN ?= $(OUT_BASENAME_NOEXT)
30+
# If this file or directory exists, it will be symlinked into the same directory
31+
# from which the executable will be run. This way, the executable can suppose this is in the current directory.
32+
RUN_INPUT ?= input
33+
PROFILE_DEFINE ?=
34+
PROFILE_FLAGS ?=
35+
PREDEF ?= #-DDEBUG -DPROFILE -DWINDOWS
36+
# Passed as command line args to bin on run.
37+
RUN_ARGS ?= #0 1
38+
TMP_DIR ?= _build/
39+
TMP_EXT ?= .o
40+
41+
INS := $(wildcard $(IN_DIR)*$(IN_EXT))
42+
INS_NODIR := $(notdir $(INS))
43+
TMPS_NODIR := $(INS_NODIR:$(IN_EXT)=$(TMP_EXT))
44+
TMPS := $(addprefix $(TMP_DIR),$(TMPS_NODIR))
45+
OUT_BASENAME := $(OUT_BASENAME_NOEXT)$(OUT_EXT)
46+
OUT := $(OUT_DIR)$(OUT_BASENAME)
47+
48+
.PHONY: all all-post assembler clean debug set_debug_flags help mkdir profile set_profile_flags test
49+
50+
all: mkdir $(OUT)
51+
@#TODO ignore errors if not present
52+
@if [ -e "$(RUN_INPUT)" ] && [ ! -e "$(OUT_DIR)$(RUN_INPUT)" ]; then ln -s ../$(RUN_INPUT) "$(OUT_DIR)$(RUN_INPUT)"; fi
53+
@-$(MAKE) all-post
54+
55+
$(OUT): $(TMPS)
56+
$(MYCXX) $(PROFILE_FLAGS) $^ -o "$@" $(LIBS)
57+
58+
$(TMP_DIR)%$(TMP_EXT): $(IN_DIR)%.c
59+
$(MYCC) $(DEFINES) $(DEBUG_DEFINE) $(DEBUG_FLAGS) $(PROFILE_DEFINE) $(PROFILE_FLAGS) $(OPTIMIZE_FLAGS) $(PREDEF) $(INCLUDE_DIRS) $(MYCFLAGS) -c "$<" -o "$@"
60+
61+
$(TMP_DIR)%$(TMP_EXT): $(IN_DIR)%.cpp
62+
$(MYCXX) $(DEFINES) $(DEBUG_DEFINE) $(DEBUG_FLAGS) $(PROFILE_DEFINE) $(PROFILE_FLAGS) $(OPTIMIZE_FLAGS) $(PREDEF) $(INCLUDE_DIRS) $(MYCXXFLAGS) -c "$<" -o "$@"
63+
64+
$(TMP_DIR)%$(TMP_EXT): $(IN_DIR)%.f
65+
$(FF) $(DEFINES) $(DEBUG_DEFINE) $(DEBUG_FLAGS) $(PROFILE_DEFINE) $(PROFILE_FLAGS) $(OPTIMIZE_FLAGS) $(PREDEF) $(INCLUDE_DIRS) $(CFLAGS) -c "$<" -o "$@"
66+
67+
asm: mkdir
68+
$(eval OPTIMIZE_FLAGS := -O0)
69+
$(MYCC) $(PROFILE_DEFINE) $(PROFILE_FLAGS) $(DEBUG_DEFINE) $(DEBUG_FLAGS) $(OPTIMIZE_FLAGS) $(CFLAGS) -fverbose-asm -Wa,-adhln "$(IN_DIR)$(RUN)$(IN_EXT)" $(LIBS) -o $(TMP_DIR)asm$(TMP_EXT)
70+
71+
clean:
72+
rm -rf "$(TMP_DIR)" "$(OUT)"
73+
74+
debug: clean set_debug_flags all
75+
gdb $(OUT)
76+
77+
mkdir:
78+
mkdir -p "$(TMP_DIR)" "$(OUT_DIR)"
79+
80+
profile: clean set_profile_flags all run
81+
mv -f gmon.out "$(OUT_DIR)"
82+
gprof -b $(OUT) "$(OUT_DIR)"gmon.out | tee "$(OUT).profile_out" | less
83+
84+
set_debug_flags:
85+
$(eval DEBUG_FLAGS := -ggdb3)
86+
$(eval DEBUG_DEFINE := -DDEBUG)
87+
$(eval OPTIMIZE_FLAGS := -O0)
88+
89+
set_profile_flags:
90+
$(eval PROFILE_FLAGS := -p -pg)
91+
$(eval PROFILE_DEFINE := -DPROFILE)
92+
#$(eval OPTIMIZE_FLAGS := )
93+
94+
run: all
95+
@echo
96+
cd $(OUT_DIR) && ./$(OUT_BASENAME) $(RUN_ARGS)
97+
98+
test: all
99+
@echo
100+
if [ -x test ]; then ./test $(OUT_DIR) $(OUT_BASENAME); else $(MAKE) run && echo 'All tests passed.'; fi
101+
102+
-include Makefile_targets
103+
104+
help:
105+
@echo 'Compile all files with extension IN_EXT in directory IN_DIR into or into a single output file.'
106+
@echo ''
107+
@echo 'IN_EXT can be either of: `.cpp`, `.c` or `.f`. The compiler is chosen accordingly.'
108+
@echo ''
109+
@echo '# Most useful invocations'
110+
@echo ''
111+
@echo 'Build:'
112+
@echo ''
113+
@echo ' make'
114+
@echo ''
115+
@echo 'Build and run output:'
116+
@echo ''
117+
@echo ' make run'
118+
@echo ''
119+
@echo '# Targets'
120+
@echo ''
121+
@echo 'all ................. Build all.'
122+
@echo 'asm [RUN=name] ...... BROKEN Print generated assembly code for the file with given basename without extension.'
123+
@echo 'clean ............... Clean built files.'
124+
@echo 'debug ............... Run with `gdb`.'
125+
@echo 'help ................ Print help to stdout.'
126+
@echo 'profile ............. Run with `gprof`.'
127+
@echo 'run ................. Run a file with the given basename or the default not given.'
128+
@echo 'test ................ If `test` exists, run `./test <output-directory> <output-basename>`. Else check exit status == 0.'

README.md

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,10 @@ Relies on [C++ boilerplate](https://github.com/cirosantilli/cpp-boilerplate) to
2121
1. [C++](cpp/)
2222
1. [C vs C++](c-vs-cpp.md)
2323
1. [Style guides](style-guides.md)
24-
1. Multi-file
25-
1. [static](static.c)
26-
1. [extern](extern.c)
27-
1. Cross-language
28-
1. [C from C++](c-from-cpp/)
29-
1. [C++ from C](cpp-from-c/)
30-
1. [Fortran from C](fortran-from-c/)
24+
1. Cross-language
25+
1. [C from C++](c-from-cpp/)
26+
1. [C++ from C](cpp-from-c/)
27+
1. [Fortran from C](fortran-from-c/)
3128
1. [GDB](gdb/)
3229
1. [Boost](boost/)
3330
1. [CMake](cmake.md)
@@ -46,4 +43,5 @@ Relies on [C++ boilerplate](https://github.com/cirosantilli/cpp-boilerplate) to
4643
1. [OpenCV](opencv/)
4744
1. [PLplot](plplot/)
4845
1. [CONTRIBUTING](CONTRIBUTING.md)
46+
1. [TODO](TODO.md)
4947
1. [Bibliography](bibliography.md)

TODO.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# TODO
2+
3+
- factor out all the makefiles
4+
5+
## Cheat on interesting libraries
6+
7+
C++ has many major interesting non standard libs.
8+
9+
### unit testing
10+
11+
Google unit test framework: <http://code.google.com/p/googletest/>
12+
13+
### Linear algebra
14+
15+
#### eigen
16+
17+
<http://eigen.tuxfamily.org/index.php?title=Main_Page>
18+
19+
#### blitz++
20+
21+
<http://blitz.sourceforge.net/>
22+
23+
#### armadillo
24+
25+
<http://arma.sourceforge.net/>
26+
27+
### tokamak
28+
29+
Rigid body physical engine.

Vagrantfile

Lines changed: 0 additions & 1 deletion
This file was deleted.

Vagrantfile

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# -*- mode: ruby -*-
2+
# vi: set ft=ruby :
3+
4+
# Minimalistic template containing with the most important settings.
5+
6+
# WARNING: if you use more than one CPU on the guest
7+
# enable hardware virtualization from your BIOS
8+
cpus = '1'
9+
memory = '512'
10+
11+
# WARNING: if you are going to run a 64 bit guest inside a 32 bit host
12+
# you must enable hardware virtualization from your BIOS
13+
begin
14+
Box = 'precise32'
15+
BoxUrl = 'http://files.vagrantup.com/precise32.box'
16+
hostname = 'cpp'
17+
end
18+
19+
Vagrant.configure("2") do |config|
20+
config.vm.box = box
21+
config.vm.box_url = box_url
22+
config.vm.hostname = hostname
23+
config.vm.network :forwarded_port, guest: 4000, host: 4000
24+
config.vm.provider "virtualbox" do |v|
25+
v.customize [
26+
'modifyvm', :id,
27+
'--cpus', cpus,
28+
'--memory', memory,
29+
'--name', hostname + '_vagrant'
30+
]
31+
if cpus.to_i > 1
32+
v.customize ['modifyvm', :id, '--ioapic', 'on']
33+
end
34+
end
35+
config.vm.provision :shell, path: 'configure'
36+
config.vm.provision :shell, privileged: false, inline: 'echo cd "/vagrant" >> ~/.bashrc'
37+
end

Vagrantfile_params.rb

Lines changed: 0 additions & 4 deletions
This file was deleted.

boilerplate

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)