Link to home
Start Free TrialLog in
Avatar of VWrestle97
VWrestle97

asked on

What does this line do in this GNU Makefile

Pulling out a snippet of code from a GNU Makefile, what exactly do these lines of code do.  Please explain line-by-line.
========================================
create_tilt_heading: Makefile $(CREATE_TILT_HEADING_DOTO)
      $(LD) -o $@ $(LDFLAGS) $(CREATE_TILT_HEADING_DOTO) $(LIBS)

Where:

CREATE_TILT_HEADING_DOTO = \
  cfar.o cmdlineopts.o dtime.o endian_utils.o fft.o file_utils.o \
  create_tilt_heading.o math_utils.o scan_params_file.o snr_sort.o

create_tilt_heading.o: create_tilt_heading.c Makefile $(DOTH) $(DOTL)
      $(CC) -c $(CFLAGS) -o $@ $<

DOTH = \
  Covmat.h Propmode.h Read_fft_data.h Readmode.h array_params.h cfar.h Rotate.h \
  cmdlineopts.h complex_divide.h complex_mult.h complex_sqrt.h complex_sum.h \
  data_types.h dtime.h endian_utils.h fft.h file_utils.h lss_file_header.h lss_file_header_legacy_defs.h \
  math_utils.h min_max.h my_printf.h params.h proc_params.h raw_ts.h \
  scan_params_file.h snr_sort.h standard.h tps.h types.h trigtbl.h

DOTL = \
  scan_params_file.l

CC           = gcc

CFLAGS       = -Wall $(ADDL_CFLAGS) -I$(TOMCRYPT)/src/headers

ADDL_CFLAGS  = -O3 -g # -std=c99 # -pg

TOMCRYPT     = /export/home/LSS_TOOLS/TOM/libtomcrypt-1.16

LD           = $(CC)

LDFLAGS      = $(CFLAGS) -L/usr/local/lib -L$(TOMCRYPT)

LIBS         = -lfl -lm -ltomcrypt
ASKER CERTIFIED SOLUTION
Avatar of Duncan Roe
Duncan Roe
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of VWrestle97
VWrestle97

ASKER

Can you please provide me more explanation on the following lines?

>> -Wall  -O3 -g -I/export/home/LSS_TOOLS/TOM/libtomcrypt-1.16/src/headers

This is as much as I understand - and please correct me if I am wrong - "-Wall -03 -g" displays all warnings at level 3 of all warnings/errors during the debuging process that is executed when Make builds the create_tilt_heading target.  If -g was removed from this command, then would that stop all warnings/errors from being displayed?  And what is the significance of the -I include statement; is that where the header files of DOTH is supposed to be stored, and the "src" folder in that path where the source files for those header files supposed to be stored for the command to find the files that need to be compiled?  And should that "export" folder be in the same folder as where my Makefile is stored?  Does all my .c files belong in the "src" folder or can it also exsist in the same folder with my Makefile?  And where should I put my .l file?

>> -L/usr/local/lib
I know that -L is to shcek symlink times, but it is not clear to me why it is needed.  Also, exactly what type of files should be stored in lib... or why does it need this command?

>> -L/export/home/LSS_TOOLS/TOM/libtomcrypt-1.16
Is this just another path that has files that the command "-Wall -03 -g" needs to compile to create the target?

>>lfl -lm -ltomcrypt
I think this has something to do with flex, but still not clear how it is used or it's purpose.  Please exlpain further.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I am trying to take someone else's code that was designed to run on Linux, and I am moving it to run on a Windows XP computer with Cygwin.  I am having trouble getting the Makefile to complete the process due to an "undeclared identifier" and I was thinking it is because the files are not in a location where the Makefile can find them.

The libtomcrypt library is supposed to build into another set of C code that uses the libtomcrypt.  Are you familiar with libtomcrypt?  

>>tells gcc to look in /export/home/LSS_TOOLS/TOM/libtomcrypt-1.16/src/headers for files mentined in #include lines (as well as the usual place /usr/include)

Does this mean that as long as all the header files of "DOTH" (or all the projects .C files that have include <xxxx.h> and include "xxxx.h" in the code) are stored in /usr/include, then I don't need to store them in /export/home/LSS_TOOLS/TOM/libtomcrypt-1.16/src/headers anymore?  The header files that need to be included in these locations, are they only limited to the files associated with the target or should I put all of the projects header files in the specified location?

What about the DOTL = scan_params_file.l; where is this file supposed to go?



SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>>the *exact* error message you are getting (some lines of output before and after would help too)

==============================================
$ make
gcc -c -Wall -O3 -g  -I/export/home/TOOLS/TOM/libtomcrypt-1.16/src/headers -
o scan_params_file.o scan_params_file.c
scan_params_file.l: In function `range_check':
scan_params_file.l:212: warning: int format, uint32_t arg (arg 4)
scan_params_file.l:212: warning: int format, uint32_t arg (arg 4)
scan_params_file.l: In function `scan_params_file':
.
.
.
scan_params_file.l:900: error: `MAXINT' undeclared (first use in this function)
scan_params_file.l:900: error: (Each undeclared identifier is reported only once

scan_params_file.l:900: error: for each function it appears in.)
scan_params_file.l:908: warning: int format, uint32_t arg (arg 4)
scan_params_file.l:908: warning: int format, uint32_t arg (arg 4)
scan_params_file.l:919: warning: int format, uint32_t arg (arg 4)
scan_params_file.l:919: warning: int format, uint32_t arg (arg 6)
.
.
.
scan_params_file.l:2232: warning: int format, uint32_t arg (arg 4)
scan_params_file.l:2232: warning: int format, long int arg (arg 7)
scan_params_file.l:2244: warning: int format, uint32_t arg (arg 4)
scan_params_file.l:2244: warning: int format, uint32_t arg (arg 4)
.
.
.
scan_params_file.l:2302: warning: unsigned int format, uint32_t arg (arg 3)
scan_params_file.l:2302: warning: unsigned int format, uint32_t arg (arg 4)
scan_params_file.l:2302: warning: unsigned int format, uint32_t arg (arg 3)
scan_params_file.l:2302: warning: unsigned int format, uint32_t arg (arg 4)
scan_params_file.l:2305: warning: int format, uint32_t arg (arg 4)
scan_params_file.l:2305: warning: int format, uint32_t arg (arg 4)
scan_params_file.l:2308: warning: int format, uint32_t arg (arg 4)
scan_params_file.l:2308: warning: int format, uint32_t arg (arg 6)
.
.
.
scan_params_file.l: At top level:
scan_params_file.c:6925: warning: 'yyunput' defined but not used
make: *** [scan_params_file.o] Error 1
==================================================================

>> the output from "make --version" on your system

$ make -version
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i686-pc-cygwin


>> and if possible also on the system where the Makefile ran OK.

Sorry, I don't have access to that computer

>> have a configure script? Did you run it under Cygwin?

What do you mean by "configure script"?  This program ran under Linux but I don't know if it ever ran on Cygwin; but I am currently trying to run it on a Windows XP computer with Cygwin installed.  

If you copied the package from Linux, did you run "make distclean" first?

$ make distclean
make: *** No rule to make target `distclean'.  Stop.

$ make clean
rm -f *.[o]

After the "make clean", running make still gives me the same error.

I am trying to build a package that takes in data from an external Hard-drive and decrypts the data so it can be analyzed on Matlab.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I added the include lines into scan_params_file.l just as you recommended as shown below but didn't work, why?  

So I then replace INT_MAX and now it works, but now I am getting another error when I run "make"; it looks like the error occurs when the make gets to the sub-target "make create_tile_heading".  Why am I getting this error if "TOMCRYPT = /export/home/TOOLS/TOM/libtomcrypt-1.16" is declared in my Makefile and the path exists on my computer?

gcc -o create_tilt_heading -Wall -O3 -g  -I/export/home/TOOLS/TOM/libtomcryp
t-1.16/src/headers -L/usr/local/lib -L/export/home/TOOLS/TOM/libtomcrypt-1.1
6 cfar.o cmdlineopts.o dtime.o endian_utils.o fft.o file_utils.o create_tilt_hea
ding.o math_utils.o scan_params_file.o snr_sort.o -lfl -lm -ltomcrypt
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld: cannot find
 -ltomcrypt
collect2: ld returned 1 exit status
make: *** [create_tilt_heading] Error 1
==========================================
%{

/* RCS patterns
 *   $Id: $
 *   $Revision: $
 */

#include <sys/types.h>
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

/* added to fix MAXINT undeclared error */
#include <ldap.h>
#include <usb.h>

.
.
.
%}
=======================================
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
$ ldconfig -p|grep tomcrypt
bash: ldconfig: command not found

Can you please tell me more about the compiled package?  I think I may need more help with this.
I installed all packages that Cygwin offers using their Setup.exe version 2.573.2.2 and selected from one of their downloading URL sites.  I couldn't find a linker.  I don't think Cygwin offers the command for "ldconfig".  

So, which way is the hard way?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ok, I did a "make" for libtomcrypt-1.17 as you specified and made 1.16 1o 1.17 change in my Makefile, But still getting the same error when I "make" my Makefile.  Why wouldn't it create libtomcrypt.a in /lib?
==================================
scan_params_file.l: At top level:
scan_params_file.c:6827: warning: 'yyunput' defined but not used
gcc -c -Wall -O3 -g  -I/export/home/TOOLS/TOM/libtomcrypt-1.17/src/headers -
o snr_sort.o snr_sort.c
gcc -o create_tilt_heading -Wall -O3 -g  -I/export/home/TOOLS/TOM/libtomcryp
t-1.17/src/headers -L/usr/local/lib -L/export/home/TOOLS/TOM/libtomcrypt-1.1
7 cfar.o cmdlineopts.o dtime.o endian_utils.o fft.o file_utils.o create_tilt_hea
ding.o math_utils.o scan_params_file.o snr_sort.o -lfl -lm -ltomcrypt
/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld: cannot find
 -ltomcrypt
collect2: ld returned 1 exit status
make: *** [create_tilt_heading] Error 1
===================================
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
These are the results:

paez@fc498817526740e /home/morestuff/tools/lss17/export/home/tools/tom
$ ls -ltr -al
total 3440
-rwx------+ 1 paez None 1919172 Sep 11 15:05 libtomcrypt-1.16.tgz
drwx------+ 7 paez None       0 Jan 22 17:38 libtomcrypt-1.16
-rwx------+ 1 paez None 1599215 Jan 29 09:12 crypt-1.17.tar.bz2
drwx------+ 7 paez None       0 Jan 29 09:40 libtomcrypt-1.17
drwx------+ 3 paez None       0 Jan 29 09:49 ..
drwx------+ 4 paez None       0 Jan 29 09:49 .

paez@fc498817526740e /home/morestuff/tools/lss17/export/home/ltools/tom
$ ls Ma* ma*
ls: cannot access Ma*: No such file or directory
ls: cannot access ma*: No such file or directory

>>see if you can make a .a in libtomcrypt-1.16 (change your Makefile back if you can).

I also tried to make "libtomcrypt-1.16" and then make on my project, but no .a file was found in /lib
Just in case you wanted to know for the more generic path:
=======================================
paez@fc498817526740e /home/morestuff/tools/lss17
$ ls Ma* ma*
Makefile            main_beamforming_3d.c  main_mfp_th_az_file.c   math_utils.h
Makefile_new        main_mfp_bft.c         main_mfp_th_az_file2.c  math_utils.o
Makefile_old        main_mfp_bft_th.c      main_mfp_th_xyz.c
main_beamforming.c  main_mfp_th_adr.c      math_utils.c
=======================================
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks for the help.  I got the program working.  I was actually waiting for a response from the  EE community because I would like to give everyone more points than splitting just 500 pts.  I want to wait another day to hear back from them.  If I don't, I guess I will just have to split the 500pts.
Thank you for the help!  I wish I could give more but I was told that is against the rules.