Sponsored Content
Top Forums Programming Makefile cannot find separator Post 303026327 by colt on Saturday 24th of November 2018 05:25:17 PM
Old 11-24-2018
Based on the above tutorial I created this Makefile

Code:
CFLAGS=-I.
DEPS = PerformanceManager.h InputHandler.h Vec3f.h Image.h FileManager.h GeometricObjects.h TGAManager.h Plane.h Sphere.h Triangle.h Scene.h TextManager.h RayTracer.h
OBJ = PerformanceManager.o  InputHandler.o Image.o FileManager.o TGAManager.o Plane.o Scene.o TextManager.o RayTracer.o main.o

%.o: %.cpp $(DEPS)
    g++ -c -o $@ $< $(CFLAGS)

RayTracer: $(OBJ) 
    g++ -O3 -fexpensive-optimizations --fast-math -lpthread -o $@ $^ $(CFLAGS)

clean:
    rm -rf *.o

It works, but it's not using the compiler flags to speedup the code. I realisz that the problem is that the flags are in the wrong place, they should be before the .o files are created. I guess I shall put them in the CFLAGS? I read somewhere that since the CFLAGS are made to be adjusted by the end-user, it's a bad practice to set them in the Makefile. If that is the case, where should I put the compiler flags?

Besides that, I do not comprehend the purpose of "-I". The tutorial says
Quote:
The -I. is included so that gcc will look in the current directory (.) for the include file hellomake.h.
. But doesn't always gcc looks in the current directory for .h files? As far as I know, it's the double "" around a .h file that makes gcc look in the current directory for the file, if it was <>, it would look for them in the global directories like /usr/include.
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Separator in Makefile?

all: $(LIBRARY) $(EXE) $(MAKEMAKE): @rm -f $(MAKEMAKE) $(PURIFY) $(CXX) -M $(INCLUDE) $(CPPFLAGS) *.cpp > $(MAKEMAKE) $(EXE): $(OBJS) $(LIBRARY) @echo "Creating a executable " $(PURIFY) $(CC) -o $(EXE) $(OBJS) $(ALLLDFLAGS) $(LIBS) This is a snippet... (2 Replies)
Discussion started by: laila63
2 Replies

2. UNIX for Dummies Questions & Answers

Help with unix separator

can some one give me a list of unix separtor(s) if one than just the separator please thank you. (2 Replies)
Discussion started by: Black mage2021
2 Replies

3. UNIX for Advanced & Expert Users

Makefile problem - How to run module load in a Makefile

Hi, I'm trying to run the module load command in a Makefile and i'm getting the following error: make: module: command not found Why is this? Is there any way to run this command in a Makefile? NOTE: command - module load msjava/sunjdk/1.5.0 works fine outside of the Makefile (2 Replies)
Discussion started by: hernandinho
2 Replies

4. UNIX for Advanced & Expert Users

Makefile executing another Makefile first?

I have 2 libraries in 2 different directories that I build with Makefiles. library B depends on library A. If I modify a .cpp file in library A and run lib B's Makefile can I have B's makefile to automatically rebuild library A? I am now rebuilding A, followed by B... but I'd like B to... (0 Replies)
Discussion started by: wwuster
0 Replies

5. UNIX for Dummies Questions & Answers

Issues with Makefile (cannot find )

Hello guys ! Need a bit of help is compiling a code, the makefile for which was originally designed to work on a 32-bit Linux platform, for a 64-bit Linux platform. My platform is Ubuntu 10.04 LTS 64-bit. I am trying to compile a code called csim, file name csim-1.1.tar.gz. To compile this... (0 Replies)
Discussion started by: pbhat
0 Replies

6. Homework & Coursework Questions

Help with Simple Multi-Level Makefile (Extremely New at Makefile)

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Basically, the prompt is make a makefile with various sub makefiles in their respective subdirectories. All code... (1 Reply)
Discussion started by: Tatl
1 Replies

7. UNIX for Dummies Questions & Answers

GCC Makefile-Missing Separator

Hello, I am attempting to build gcc 4.0.4 on my Mac (OS X). When I use the "make" command, it returns with something like this: Makefile:6089: *** missing separator. Stop. This means that at the given line, I must go into the file and insert a TAB before the contents of that line. I have... (1 Reply)
Discussion started by: Tyler_92
1 Replies

8. Shell Programming and Scripting

Find "*.c" and "Makefile" and then delete them with one line

find "*.c" and "Makefile" and then delete them with one line (3 Replies)
Discussion started by: yanglei_fage
3 Replies

9. Shell Programming and Scripting

Field separator

Hello All, I have a file, but I want to separate the file at a particular record with comma"," in the line Input file APPLE6SSAMSUNGS5PRICEPERPIECEDOLLAR600EACH010020340URX581949695US to Output file APPLE6S,SAMSUNGS5,PRICEPERPIECE,DOLLAR600EACH,010020340URX581949695,US This is for... (11 Replies)
Discussion started by: m6248m
11 Replies

10. Shell Programming and Scripting

Separator

Hello everybody, I'll get one more help I have a cabundle file that I need to separate into 2 parts, the first sequence and the second sequence, I thought of several things but I did not remember anything that could actually accomplish this separation and transform into 2 variables, first... (4 Replies)
Discussion started by: c0i0t3
4 Replies
gccmakedep(1)						      General Commands Manual						     gccmakedep(1)

NAME
gccmakedep - create dependencies in makefiles using 'gcc -M' SYNOPSIS
gccmakedep [ -sseparator ] [ -fmakefile ] [ -a ] [ -- options -- ] sourcefile ... DESCRIPTION
The gccmakedep program calls 'gcc -M' to output makefile rules describing the dependencies of each sourcefile, so that make(1) knows which object files must be recompiled when a dependency has changed. By default, gccmakedep places its output in the file named makefile if it exists, otherwise Makefile. An alternate makefile may be speci- fied with the -f option. It first searches the makefile for a line beginning with # DO NOT DELETE or one provided with the -s option, as a delimiter for the dependency output. If it finds it, it will delete everything following this up to the end of the makefile and put the output after this line. If it doesn't find it, the program will append the string to the makefile and place the output after that. EXAMPLE
Normally, gccmakedep will be used in a makefile target so that typing 'make depend' will bring the dependencies up to date for the make- file. For example, SRCS = file1.c file2.c ... CFLAGS = -O -DHACK -I../foobar -xyz depend: gccmakedep -- $(CFLAGS) -- $(SRCS) OPTIONS
The program will ignore any option that it does not understand, so you may use the same arguments that you would for gcc(1), including -D and -U options to define and undefine symbols and -I to set the include path. -a Append the dependencies to the file instead of replacing existing dependencies. -fmakefile Filename. This allows you to specify an alternate makefile in which gccmakedep can place its output. Specifying "-" as the file name (that is, -f-) sends the output to standard output instead of modifying an existing file. -sstring Starting string delimiter. This option permits you to specify a different string for gccmakedep to look for in the makefile. The default is "# DO NOT DELETE". -- options -- If gccmakedep encounters a double hyphen (--) in the argument list, then any unrecognized arguments following it will be silently ignored. A second double hyphen terminates this special treatment. In this way, gccmakedep can be made to safely ignore esoteric compiler arguments that might normally be found in a CFLAGS make macro (see the EXAMPLE section above). -D, -I, and -U options appearing between the pair of double hyphens are still processed normally. SEE ALSO
gcc(1), make(1), makedepend(1). AUTHOR
The version of the gccmakedep included in this X.Org Foundation release was originally written by the XFree86 Project based on code sup- plied by Hongjiu Lu. Colin Watson wrote this manual page, originally for the Debian Project, based partly on the manual page for makedepend(1). X Version 11 gccmakedep 1.0.2 gccmakedep(1)
All times are GMT -4. The time now is 03:42 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy