install-exec-hook No rule to make target - c

I've a C project developed in Eclipse with Autotools, and everything compiled and worked well. That's the "original" Makefile.am
bin_PROGRAMS = MyProgram_#PACKAGE_VERSION#
MyProgram_#PACKAGE_VERSION#_SOURCES = \
MyProgram.c
include_HEADERS =
MyProgram_#PACKAGE_VERSION#_CFLAGS = -Wall \
-I$(top_srcdir)/src/include \
-I$(top_srcdir) \
-I$(prefix)/include
MyProgram_#PACKAGE_VERSION#_LDFLAGS = \
-L$(prefix)/lib \
-lLibrary1\
-lLibrary2\
-lLibraryN
AM_CFLAGS = #MyProgram_#PACKAGE_VERSION#_CFLAGS#
AM_LDFLAGS = #MyProgram_#PACKAGE_VERSION#_LIBS#
CLEANFILES = *~
Problems started when I would like to create a symlink to my binary at installation time.
Googling I've found that best way to do it is to add install-exec-hook rule to my Makefile.am, and fundamentally I've add this lines of code to the Makefile, as explained here https://www.gnu.org/software/automake/manual/html_node/Extending.html#Extending
install-exec-hook: \
ln -s $(DESTDIR)$(bindir)/MyProgram_#PACKAGE_VERSION# \
$(DESTDIR)$(bindir)/MyProgram
But when I run Make Targets -> Build -> install from Eclipse I get the error: No rule to make target "ln" needed by "install-exec-hook"
I've tried making things easier, just to test if I'm missing something, and so I've written
install-exec-hook: echo "TEST"
But I still got the same error. Spent few days looking for this problem on the web, but nothing helped me.
Hope anyone can do it, many thanks
Andrea

Related

Matlab mex without xcode, but with standalone command line tools

I want to compile mex files without installing xcode, using only Command Line Tools (from apple developer center).
Apple Command Line Tools install the compiler and adds standard libraries and headers to the system in a package much smaller than xcode (which is several GBs).
Running mex on linux is possible - I see no reason why matlab mex should require the huge SDKs required for macos. A long evening of trial and error and hacking configuration files hasn't helped. Does anyone have a minimal working example of how to compile a mex file outside matlab, or a simple way to use mex without having xcode installed?
Best Regards, Magnus
Well, I have another option here:
Edit the files under /Applications/MATLAB_R2016b.app/bin/maci64/mexopts (probably there should be 3.xml file, all needs the same modification).
Locate the <XCODE_AGREED_VERSION> portion, comment the whole xml tag, e.g. wrap them with <!-- and --> like this:
<!--XCODE_AGREED_VERSION>
<and diagnostic="Xcode is installed, but its license has not been accepted. Run Xcode and accept its license agreement." >
<or>
<cmdReturns name="defaults read com.apple.dt.Xcode IDEXcodeVersionForAgreedToGMLicense"/>
<cmdReturns name="defaults read /Library/Preferences/com.apple.dt.Xcode IDEXcodeVersionForAgreedToGMLicense"/>
</or>
<cmdReturns name="
agreed=$$
if echo $agreed | grep -E '[\.\"]' >/dev/null; then
lhs=`expr "$agreed" : '\([0-9]*\)[\.].*'`
rhs=`expr "$agreed" : '[0-9]*[\.]\(.*\)$'`
if echo $rhs | grep -E '[\."]' >/dev/null; then
rhs=`expr "$rhs" : '\([0-9]*\)[\.].*'`
fi
if [ $lhs -gt 4 ] || ( [ $lhs -eq 4 ] && [ $rhs -ge 3 ] ); then
echo $agreed
else
exit 1
fi
fi" />
</and>
</XCODE_AGREED_VERSION -->
Some notes:
These files are read only by default, you need to issue sudo chmod
644 * in that directory
after comment out all necessary files, issue this command in matlab:
mex -setup C++
Then you are done
After spending more time, I wound up learning more stuff and answering my own question. I'll post my solution here if anyone else needs it in the future.
Make sure the cord is connected to your computer and that MATLAB is installed, and also install the command line tools from apple. Then call the following makefile to compile arrayProduct.c (comes with matlab) from the terminal as follows:
make mex=arrayProduct
Put this makefile code in the same folder in a file called makefile(edit to your own needs if you have to):
all:
clang -c\
-DMX_COMPAT_32 \
-DMATLAB_MEX_FILE \
-I"/Applications/MATLAB_R2016b.app/extern/include" \
-I"/Applications/MATLAB_R2016b.app/simulink/include" \
-fno-common \
-arch x86_64 \
-fexceptions \
-O2 \
-fwrapv \
-DNDEBUG \
"/Applications/MATLAB_R2016b.app/extern/version/c_mexapi_version.c" \
$(mex).c
clang \
-Wl,-twolevel_namespace \
-undefined error \
-arch x86_64 \
-bundle \
-Wl,-exported_symbols_list,"/Applications/MATLAB_R2016b.app/extern/lib/maci64/mexFunction.map" \
$(mex).o \
c_mexapi_version.o \
-O \
-Wl,-exported_symbols_list,"/Applications/MATLAB_R2016b.app/extern/lib/maci64/c_exportsmexfileversion.map" \
-L"/Applications/MATLAB_R2016b.app/bin/maci64" \
-lmx \
-lmex \
-lmat \
-lc++ \
-o $(mex).mexmaci64
The above makefile is a bare minimum working example, you should edit it to comply with your requirements.
Edit:
Option 2
You can make MATLAB understand how to use the Command Line Tools by editing the xml file containing the compiler options instead. Open the file located at
/User/username/Library/Application Support/MathWorks/MATLAB/R2016b/mex_C_maci64.xml
Remove all compiler and linker options related to ISYSROOT. This will make the compiler search for header files in /usr/include etc instead of in the SDK-folder in XCode.
I fully understand you and I'm a big advocate of non-using the enormous Xcode. From my saver here, run the following to trick mex into seeing an accepted license (no sudo needed).
Here I use the current version 13.0 at the time of writing, to be adapted.
defaults write com.apple.dt.Xcode IDEXcodeVersionForAgreedToGMLicense 13.0

Beginner in writing makefile; checking my Makefile

I am trying to understand how to write my own makefile for small project, so I have a few questions
my project consists of src directory that contains main.c, file1.c, file2.c, header1.h, and finally header2.h these files use some library from non standard library that I have created and non standard header file, the library directory is located in usr/lib/pr__lib and the header directory is located in usr/include/lib
so I should create two makefile.am one will be located in src directory and the other one will be in root directory of the project the makefile.am of the src directory is as shown below:
program_NAME := PRDSL
bin_PROGRAMS = PRDSL_AutoProject
program_INCLUDE_DIRS := /usr/bin/PR__bin
program_LIBRARY_DIRS := /usr/lib/PR__lib
CFLAGS += $(foreach includedir,$(program_INCLUDE_DIRS),-I$(includedir))
program_LIBRARIES := \
libprdependency \
libprdynarray_pic \
libprhistogram_pic \
libprlistofarrays \
libprlistofarrays_pic \
libprmalloc \
libvreo_wrapper_library
AM_LDFLAGS += $(foreach librarydir,$(program_LIBRARY_DIRS),-L$(librarydir))
AM_LDFLAGS += $(foreach library,$(program_LIBRARIES),-l$(library))
PRDSL_AutoProject_SOURCES = \
main.c \
file1.c \
file2.c
depend :
makedepend --$(CFLAGS) --$(PRDSL_AutoProject_SOURCES)
all: $(program_NAME)
2nd makefile.am at the root directory is as shown below:
SUBDIRS = src
PRDSL_AutoProjectdocdir = ${prefix}/doc/PRDSL_AutoProject
PRDSL_AutoProjectdoc_DATA = \
README\
COPYING\
AUTHORS\
ChangeLog\
INSTALL\
NEWS
INTLTOOL_FILES = intltool-extract.in \
intltool-merge.in \
intltool-update.in
EXTRA_DIST = $(PRDSL_AutoProjectdoc_DATA) \
$(INTLTOOL_FILES)
DISTCLEANFILES = intltool-extract \
intltool-merge \
intltool-update \
po/.intltool-merge-cache
# Remove doc directory on uninstall
uninstall-local:
-rm -r $(PRDSL_AutoProjectdocdir)
but I get the below errors and warnings while I was running automake command:
src/Makefile.am:20: error: 'program_LIBRARIES' is used but 'programdir' is undefined
src/Makefile.am:18: warning: 'CFLAGS' is a user variable, you should not override it;
src/Makefile.am:18: use 'AM_CFLAGS' instead
src/Makefile.am:43: error: AM_LDFLAGS must be set with '=' before using '+='
could any one review it and help me?
For src/Makefile.am:43: error: AM_LDFLAGS must be set with '=' before using '+=' see my answer to your previous question.
Yes, the following lines are telling you to use AM_CFLAGS instead of CFLAGS because, as the error indicates, CFLAGS is a user-specified value and you should leave it alone.
src/Makefile.am:18: warning: 'CFLAGS' is a user variable, you should not override it;
src/Makefile.am:18: use 'AM_CFLAGS' instead
I believe, though I am far from certain, that the reason you are getting src/Makefile.am:20: error: 'program_LIBRARIES' is used but 'programdir' is undefined is because you are using a variable program_LIBRARIES that the autotools believe is a variable they should be using but that you are not using in that way and are instead using in the loop which sets the value for AM_LDFLAGS. As such, and assuming I am correct, if you rename that to not follow the autotool variable naming scheme I believe that error will go away.

Recursive makefile No rule to make target `all'. Stop

The project is about a root directory that contains a src directory. I created two makefiles, one at the top directory and the other at the src directory. Here is the makefile of the src directory:
## Process this file with automake to produce Makefile.in
## Created by Netbeans
AM_CPPFLAGS = \
-DPACKAGE_LOCALE_DIR=\""$(localedir)"\" \
-DPACKAGE_SRC_DIR=\""$(srcdir)"\" \
-DPACKAGE_DATA_DIR=\""$(pkgdatadir)"\"
bin_PROGRAMS = scratchautotool
program_INCLUDE_DIRS := /usr/bin/PR__bin
program_LIBRARY_DIRS := /usr/lib/PR__lib
CFLAGS += $(foreach includedir,$(program_INCLUDE_DIRS),-I$(includedir))
AM_LDFLAGS += $(foreach librarydir,$(program_LIBRARY_DIRS),-L$(librarydir))
scratchautotool_SOURCES = \
main.c \
Task.c \
SeedVP.c
depend :
makedepend --$(CFLAGS) --$(scratchautotool_SOURCES)
The makefile of the root directory is shown below:
## Process this file with automake to produce Makefile.in
## Created by Netbeans
SUBDIRS = src
scratchautotooldocdir = ${prefix}/doc/scratchautotool
scratchautotooldoc_DATA = \
README\
COPYING\
AUTHORS\
ChangeLog\
INSTALL\
NEWS
INTLTOOL_FILES = intltool-extract.in \
intltool-merge.in \
intltool-update.in
EXTRA_DIST = $(scratchautotooldoc_DATA) \
$(INTLTOOL_FILES)
DISTCLEANFILES = intltool-extract \
intltool-merge \
intltool-update \
po/.intltool-merge-cache
# Remove doc directory on uninstall
uninstall-local:
-rm -r $(scratchautotooldocdir)
but while I was invoking make from the terminal it gave me the following error:
Making all in src
make[2]: Entering directory `../src'
make[2]: *** No rule to make target `all'. Stop.
make[2]: Leaving directory `../src'
The error is pretty clear: it is expecting to find the target all, and isn't. I'm assuming you called make without specifying a target; the default is (surprise!) all.
I want to share the solution for my question with any one who will encounter the same issue, I have modified the makefile as shown below:
all: scratchautotool
depend :
makedepend $(CFLAGS) $(scratchautotool_SOURCES)
but this also gave the same error, so I've searched and I've found that the makedepend didn't exist so I had to install xutils-dev package(which includes the program makedepend) using the below command:
sudo apt-get install xutils-dev
but this command solves the above mentioned issue only! but the makefile now has a new issue :)

Dovecot plugin deleted_to_trash misses lib.h, make fails

I'm trying to install the Dovecot plugin deleted_to_trash. However, I need to update the configuration file, according to the readme, but I don't know what to fill in for DOVECOT_INC_PATH.
The directory that the author put, /usr/include/dovecot, doesn't exist.
If I try to make without changing anything, I get:
me#cs:/my-path/dtt# make
cc \
-fPIC -shared -Wall \
-I/usr/include/dovecot \
-I/usr/include/dovecot/src \
-I/usr/include/dovecot/src/lib \
-I/usr/include/dovecot/src/lib-storage \
-I/usr/include/dovecot/src/lib-mail \
-I/usr/include/dovecot/src/lib-imap \
-I/usr/include/dovecot/src/lib-index \
-DHAVE_CONFIG_H \
src/deleted-to-trash-plugin.c -o lib_deleted_to_trash_plugin.so
In file included from src/deleted-to-trash-plugin.c:4:0:
src/deleted-to-trash-plugin.h:4:17: fatal error: lib.h: No such file or directory
compilation terminated.
make: *** [lib_deleted_to_trash_plugin.so] Error 1
I tried to find the missing lib.h, but nothing useful:
me#cs:/my-path/dtt# find / -name "lib.h"
/usr/src/linux-headers-3.8.0-19-generic/include/config/rtc/lib.h
/usr/src/linux-headers-3.8.0-19-generic/include/config/iio/adis/lib.h
/usr/src/linux-headers-3.8.0-19-generic/include/config/snd/opl3/lib.h
/usr/src/linux-headers-3.8.0-19-generic/include/config/snd/firewire/lib.h
/usr/src/linux-headers-3.8.0-19-generic/include/config/snd/oxygen/lib.h
/usr/src/linux-headers-3.8.0-19-generic/include/config/snd/vx/lib.h
/usr/src/linux-headers-3.8.0-19-generic/include/config/ceph/lib.h
/usr/src/linux-headers-3.8.0-19-generic/include/config/x86/speedstep/lib.h
/usr/src/linux-headers-3.8.0-19-generic/include/config/rt2800/lib.h
/usr/src/linux-headers-3.8.0-19-generic/include/config/rt2x00/lib.h
/usr/src/linux-headers-3.8.0-35-generic/include/config/rtc/lib.h
/usr/src/linux-headers-3.8.0-35-generic/include/config/iio/adis/lib.h
/usr/src/linux-headers-3.8.0-35-generic/include/config/snd/opl3/lib.h
/usr/src/linux-headers-3.8.0-35-generic/include/config/snd/firewire/lib.h
/usr/src/linux-headers-3.8.0-35-generic/include/config/snd/oxygen/lib.h
/usr/src/linux-headers-3.8.0-35-generic/include/config/snd/vx/lib.h
/usr/src/linux-headers-3.8.0-35-generic/include/config/ceph/lib.h
/usr/src/linux-headers-3.8.0-35-generic/include/config/x86/speedstep/lib.h
/usr/src/linux-headers-3.8.0-35-generic/include/config/rt2800/lib.h
/usr/src/linux-headers-3.8.0-35-generic/include/config/rt2x00/lib.h
How can I find out the value I need for DOVECOT_INC_PATH?
I think you want to compile dovecot from source.
And I can find lib.h in dovecot-2.2.13.tar.gz from below url.
http://www.dovecot.org/releases/2.2/dovecot-2.2.13.tar.gz
If you installed dovecot as package, how about to install more dovecot related packages as like dovecot-dev or dovecot-source? I think you can find it.
If you can't resolve the problem, please copy lib.h file from sources tarball file to /usr/include/dovecot/src/lib.

Complex Makefile with Python and Shared Libraries

I have next to no experience in Makefiles, and I'm trying to learn - and I understand most of it. But, I have a directory structure like this:
/src/
/mysql/
mp_mysql.h
mp_mysql.c
/sqlite/
mp_sqlite.h
mp_sqlite.c
/lib/
mysql.so
sqlite.so
And I'm trying to write a makefile that compiles the files in /src/mysql into /lib/mysql.so and do the same for sqlite. I could probably get it if someone helped me along! Thanks!
P.S. The project is a Python project, and I'm writing a special adapter in C for MySQL. All of the resources I've found online I can't get to work and/or work to make one big executable.
First, write a Makefile for each directory and define a DIR_BUILD variable, which can be overridden when calling make.
Then, write a project Makefile which runs each of the child Makefiles.
For example,
DIR_BUILD = '.'
mysql.so: mp_mysql.c mp_mysql.h
gcc $< -o $(DIR_BUILD)/$#
and, for the parent Makefile:
SUBDIRS = `find . -mindepth 1 -maxdepth 1 -type d`
all:
for d in $(SUBDIRS); \
do \
$(MAKE) --directory=$$d DIR_BUILD=../lib; \
done
No guarentees, let me know how it goes!

Resources