Makefile .tar: Flatten the source files' directory structure - bash

I want to collect some source files and tar them by using Makefile. The source files are scattering as follows:
project
│
├── Makefile
│
├── folder(name is arbitrary)
│ │
│ ├── test1.txt
│ ├── test2.txt
│ .
│ .
│ .
│
├── source.cpp
│
├── source2.cpp
│
├── source.h
.
.
Now, I want to have a flattened tarball file that includes every source files just under the root directory of this tarball file when I call make in the root directory(project), like this:
myTarball.tar.gz
│
├── Makefile
│
├── source.cpp
│
├── source2.cpp
│
├── source.h
│
├── test1.txt
│
├── test2.txt
│
.
.
.
The current make file looks something like this:
FILES=$($(wildcard Makefile *.h *.hpp *.cpp test*.txt */test*.txt))
$(NAME): $(FILES)
COPYFILE_DISABLE=true tar -vczf $(NAME) $(FILES)
I'm not familiar with makefile and bash, but I try my best to play around and do some searching but found nothing. The current one can only generate something like
NAME.tar.gz
│
├── Makefile
│
├── folder
│ │
│ ├── test1.txt
│ ├── test2.txt
│ .
│ .
│ .
│
├── source.cpp
│
├── source2.cpp
│
├── source.h
.
.
with the folder structure. I think I might first copy all source files in the folder to the root directory, and delete them after tar them up. Is there a better way to do this elegantly?

Well, you can do it that way but if you're using GNU tar then it's probably simpler to just let tar do the work for you rather than copying files around to a temporary location first.
Something like this should work:
$(NAME): $(FILES)
COPYFILE_DISABLE=true tar -vczf $(NAME) --transform='s,.*/,,' $(FILES)
which will remove all directories from files inside the generated tar file. See the manual for the --transform option.

Related

Is there a way to use dot-files generated with Doxygen in Sphinx?

I am currently in a transition from Doxygen to Sphinx, as it looks much better and writing documentation feels better to me.
However, I am trying to include graphs generated by Doxygen in my Sphinx documentation, as the autodoc-extension only supports Python and the project is mostly cpp.
The project I am working on has the looks a little bit like this:
.
├── project
│   ├── doc
│   │   ├── doxygen
│   │   └── sphinx
│   │   └── foo
│   │   └── bar.rst
│   └── src
└── project_build
├── doc
│   ├── CMakeFiles
│   ├── Doxyfile.doxygen
│   ├── html
│   │   ├── doxygen
│   │   │   └── baz.dot
│   │   └── foo
│   │   └── bar.html
│   └── Makefile
└── src
The problem I am having is including the dot-file created by Doxygen inside bar.rst. From what I understand Sphinx does not permit relative import (rightly so), which would make it rather ugly for me to include baz.dot. The only way I can currently see is building the project and copying the files I need from Doxygen into the project folder. What is the best/cleanest way of doing this? Because my current solution makes the documentation very static and labor intense.
Thank you in advance,
Jakob

Exuberant Ctags 5.8 generating incomplete tags file for specific project

Using Arch Linux and I have Ctag 5.8 installed.
My Go project has this structure:
.
├── apply
│   └── apply.go
├── calculate
│   └── calculate.go
├── coupon.sqlite3
├── Godeps
│   ├── Godeps.json
│   └── Readme
├── main.go
├── Makefile
├── models
│   ├── cupom.go
│   ├── errorMessage.go
│   └── product.go
├── ping
│   └── ping.go
├── README.md
├── routes
│   └── routes.go
├── tags
├── tests
│   ├── apply_test.go
│   ├── calculate_test.go
│   ├── config.go
│   ├── coupon.sqlite3
│   └── fixtures
│   └── calculate.go
Running the command ctags -R or ctags -R . I have a tags file generated but with this content only.
!_TAG_FILE_FORMAT 2 /extended format; --format=1 will not append ;" to lines/
!_TAG_FILE_SORTED 1 /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_PROGRAM_AUTHOR Darren Hiebert /dhiebert#users.sourceforge.net/
!_TAG_PROGRAM_NAME Exuberant Ctags //
!_TAG_PROGRAM_URL http://ctags.sourceforge.net /official site/
!_TAG_PROGRAM_VERSION 5.8 //
Running the same command on other project generate the tags file correctly.
You have Exuberant Ctags installed, which does not support Go out of the box (http://ctags.sourceforge.net/languages.html).
There are a bunch of different alternative programs or ways to add it to your existing ctags:
https://go-wise.blogspot.ca/2011/09/using-ctags-with-go.html
https://github.com/eapache/starscope
https://github.com/jstemmer/gotags
http://ctags.sourceforge.net/EXTENDING.html

Qt project include file not found

I have QtCreator project named UePOSCommClient, which is some GUI applications, which is dependent on another QtCreator project, named UePOSCommProtocol, which is implementation of communications protocol betwwen UePOSCommClient and some Server app. Here is UePOSCommClient projects directory hirerachy:
uePOSCommClient/
├── build
│   └── x64
│   ├── debug
│   │   ├── main.o
│   │   ├── Makefile
│   │   ├── moc_uemainwindow.cpp
│   │   ├── moc_uemainwindow.o
│   │   ├── uemainwindow.o
│   │   └── uePOSCommClient
│   └── release
├── main.cpp
├── uemainwindow.cpp
├── uemainwindow.h
├── uePOSCommClient.pro
└── uePOSCommClient.pro.user
and here is UePOSCommProtocol's project's directoty hirerachy:
uePOSCommProtocol/
├── build
│   └── x64
│   ├── debug
│   │   ├── libuePOSCommProtocol.so -> libuePOSCommProtocol.so.1.0.0
│   │   ├── libuePOSCommProtocol.so.1 -> libuePOSCommProtocol.so.1.0.0
│   │   ├── libuePOSCommProtocol.so.1.0 -> libuePOSCommProtocol.so.1.0.0
│   │   ├── libuePOSCommProtocol.so.1.0.0
│   │   ├── Makefile
│   │   ├── moc_uemessageheader.cpp
│   │   ├── moc_uemessageheader.o
│   │   ├── moc_uemessagerequest.cpp
│   │   ├── moc_uemessagerequest.o
│   │   ├── moc_ueposcommprotocol.cpp
│   │   ├── moc_ueposcommprotocol.o
│   │   ├── uemessageheader.o
│   │   ├── uemessagerequest.o
│   │   └── ueposcommprotocol.o
│   └── release
│   ├── libuePOSCommProtocol.so -> libuePOSCommProtocol.so.1.0.0
│   ├── libuePOSCommProtocol.so.1 -> libuePOSCommProtocol.so.1.0.0
│   ├── libuePOSCommProtocol.so.1.0 -> libuePOSCommProtocol.so.1.0.0
│   ├── libuePOSCommProtocol.so.1.0.0
│   ├── Makefile
│   ├── moc_uemessageheader.cpp
│   ├── moc_uemessageheader.o
│   ├── moc_uemessagerequest.cpp
│   ├── moc_uemessagerequest.o
│   ├── moc_ueposcommprotocol.cpp
│   ├── moc_ueposcommprotocol.o
│   ├── uemessageheader.o
│   ├── uemessagerequest.o
│   └── ueposcommprotocol.o
├── net
│   └── comm_protocol
│   ├── uemessageheader.cpp
│   ├── uemessageheader.h
│   ├── uemessagerequest.cpp
│   ├── uemessagerequest.h
│   └── ueprotocolcommands.h
├── settings
│   └── uedefaults.h
├── ueposcommprotocol.cpp
├── ueposcommprotocol_global.h
├── ueposcommprotocol.h
├── uePOSCommProtocol.pro
└── uePOSCommProtocol.pro.user
Now, all works fine, the project UePOSCommClient compiles without errors, and runs without problems. However, in UePOSCommProtocol project, I have following #include statement:
#include "../../../../../../../../../home/users/Projects/uePOSCommProtocol/settings/uedefaults.h"
which is absolute path to uedefaults.h file. I am aware this is a bad practice and therefore I've replaced upper #include with:
#include "settings/uedefaults.h"
After doing so now I get No such file or directory error:
In file included from ../../../../uePOSCommProtocol/ueposcommprotocol.h:7:0,
from ../../../uemainwindow.h:11,
from ../../../main.cpp:3:
../../../../uePOSCommProtocol/net/comm_protocol/uemessagerequest.h:9:33: fatal error: settings/uedefaults.h: No such file or directory
#include "settings/uedefaults.h"
^
compilation terminated.
make: *** [main.o] Error 1
14:43:03: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project uePOSCommClient (kit: Desktop Qt 5.6.0 GCC 64bit)
When executing step "Make"
Both projects reside in /home/user/Projects directory and why am I getting this error?
P.S.: I am using Qt 5.6.0 for Linux (64bit) with QtCreator 3.6.1 on Ubuntu Linux 14.04 LTS (64bit).

CMake and correct add shared library

I'm trying to add a shared library to my project using CMake. The library is MsgPack for C++11. I must be doing something wrong because none of the examples here compile. I get this error:
error: no match for ‘operator<<’ (operand types are
‘MsgPack::Serializer’ and ‘std::unique_ptr’)
serializer << MsgPack__Factory(Array(std::move(arrayWith3Elements)));
My guess is that it has to do with my CMake syntax. The file system tree where I keep the compiled library looks like this:
/home/I/direcytory/MsgPack/
├── include
│   ├── Container.h
│   ├── ContainerHeader.h
│   ├── Core.h
│   ├── Data.h
│   ├── Element.h
│   ├── Header.h
│   ├── MsgPack.h
│   ├── MsgPackSocket.h
│   ├── netLink.h
│   ├── Number.h
│   ├── Primitive.h
│   ├── Socket.h
│   ├── StreamManager.h
│   └── Utf8.h
├── libnetLink.a
└── libnetLink.so
In CMake I'm doing this:
cmake_minimum_required(VERSION 3.0.2)
project(MyProject)
add_library(libnetLink SHARED IMPORTED)
SET_PROPERTY(TARGET libnetLink PROPERTY IMPORTED_LOCATION /home/I/Direcytory/MsgPack/libnetLink.so)
set(SOURCE_FILES main.cpp)
include_directories("/home/I/Direcytory/MsgPack/include")
target_link_libraries(MyProject libnetLink)
CMake doesn't report any errors, but my program won't compile.
It's worth noting, the above method has worked fine for me with other libraries. That's what has me confused.

Can't install Revel (Unrecognized import path)

I'm a beginner in Go and I would like to use the Revel web framework.
I installed: Git; Mercurial and even: Bazaar and CVS.
I checked my environment variables. I set environment variable GOPATH to D:\Go and added D:\Go\bin to PATH.But I still get these errors when I go get The Revel Framework (go get github.com/revel/revel)
**
package golang.org/x/net/websocket: unrecognized import path "golang.org/x/net/websocket"
package gopkg.in/fsnotify.v1: unrecognized import path "gopkg.in/fsnotify.v1"**
For instalation of GO into your home folder you need this environment variables:
.
├── bin
├── go (GO)
└── src
├── revel.project
│   ├── app
│   │   ├── controllers
│   │   ├── models
│   │   ├── routes
│   │   ├── tmp
│   │   └── views
│   │   ├── admin
│   │   ├── App
│   │   ├── errors
│   │   └── users
│   ├── conf
│   ├── messages
│   ├── public
│   │   ├── css
│   │   │   └── administrator
│   │   ├── img
│   │   ├── js
│   │   └── uploads
│   │   └── 1
│   ├── resources
│   ├── scripts
│   ├── test-results
│   └── tests
├── code.google.com
├── github.com
│   ├── revel
│   │   ├── cmd
│   │   ├── modules
│   │   └── revel
run this in your prompt path or modify if your folders are differents.
export GOARCH=amd64
export GOPATH=~/go
export GOBIN=~/go/go/bin
export GOROOT=~/go/go
export PATH=$PATH:$GOPATH/go/bin
export GOTOOLDIR=~/go/go/pkg/tool/linux_amd64
export CC="gcc"
export GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0"
export CXX=g++
export CGO_ENABLED=1
Where ~ is the name of you personal folder in the system (Bash Gnu Linux)

Resources