diff options
author | B Stack <bgstack15@gmail.com> | 2019-08-22 16:41:26 -0400 |
---|---|---|
committer | B Stack <bgstack15@gmail.com> | 2019-08-22 16:41:26 -0400 |
commit | 11eb7e4aa720cae5d1c47190c5805619d09bee11 (patch) | |
tree | b324b97ff81d9838c382fe19dc29c2b4cb6c291c | |
download | cpp-11eb7e4aa720cae5d1c47190c5805619d09bee11.tar.gz cpp-11eb7e4aa720cae5d1c47190c5805619d09bee11.tar.bz2 cpp-11eb7e4aa720cae5d1c47190c5805619d09bee11.zip |
initial commit
-rw-r--r-- | .gitignore | 2 | ||||
-rw-r--r-- | Makefile | 44 | ||||
-rw-r--r-- | helloworld.cpp | 12 |
3 files changed, 58 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4c61283 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +*/*.o +helloworld diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..8a2f666 --- /dev/null +++ b/Makefile @@ -0,0 +1,44 @@ +awkbin :=$(shell which awk) +cpbin :=$(shell which cp) +echobin :=$(shell which echo) +findbin :=$(shell which find) +grepbin :=$(shell which grep) +installbin :=$(shell which install) +rmbin :=$(shell which rm) +sedbin :=$(shell which sed) +sortbin :=$(shell which sort) +truebin :=$(shell which true) + +CXX = g++ + +# to get full debug symbols, add -g to both FLAGS +CXXFLAGS = -g -std=c++11 -Wall -Weffc++ -Wextra -Wsign-conversion -Werror + +# adding -s will make the linker strip the file +LDFLAGS = -g + +src = $(wildcard *.cpp) +obj = $(src:.cpp=.o) + +OUTEXE = helloworld + +all: $(OUTEXE) + +# compile +$(obj): $(src) + $(CXX) -c $(CXXFLAGS) $< + +# link +$(OUTEXE): $(obj) + $(CXX) -o $@ $^ $(LDFLAGS) + +.PHONY: clean cleanall list + +list: + @$(MAKE) -pRrq -f $(lastword $(MAKEFILE_LIST)) : 2>/dev/null | ${awkbin} -v RS= -F: '/^# File/,/^# Finished Make data base/ {if ($$1 !~ "^[#.]") {print $$1}}' | ${sortbin} | ${grepbin} -E -v -e '^[^[:alnum:]]' -e '^$@$$' -e '\.(cp*|o)' + +clean: + rm -f $(obj) + +cleanall: + rm -f $(obj) $(OUTEXE) diff --git a/helloworld.cpp b/helloworld.cpp new file mode 100644 index 0000000..8474a1e --- /dev/null +++ b/helloworld.cpp @@ -0,0 +1,12 @@ +#include <iostream> + +int return5() +{ + return 5 ; +} + +int main() { + //int x { }, y { } ; + std::cout << return5() << '\n' ; + return 0 ; +} |