Like Tree1Likes
  • 1 Post By manasij7479

Regular expressions with a makefile

This is a discussion on Regular expressions with a makefile within the C++ Programming forums, part of the General Programming Boards category; My project is built using a make file. I have been using make files for a while but have yet ...

  1. #1
    Registered User
    Join Date
    Jul 2011
    Posts
    22

    Regular expressions with a makefile

    My project is built using a make file. I have been using make files for a while but have yet to get into the fun parts of a make file, such as regular expressions for all the files/objects. I apologize in advance for all the programmers that are grinding their teeth over my post. You see, I have used an IDE such as Eclipse to do all my compiling & linking for me most of the time, but this time I am using a makefile. I have found a way to automatically find the *.cpp files, but the part that really boggles me is the multifolder part. My project is based on folders within folders, all the way down. (not quite that extensive, but you get the point) I have folders that go down 3 levels.

    My current make file configuration is:

    Code:
    CC = g++
    CFLAGS = -Wall
    PROG = game
    COMPILE = $(CC) $(CFLAGS) -c
    OBJFILES := $(patsubst %.cpp,%.o,$(wildcard *.cpp))
    
    ifeq ($(shell uname),Darwin)
    	LIBS = -framework OpenGL -framework GLUT
    else
    	LIBS = -lglut
    endif
    
    all: $(PROG)
    
    $(PROG): $(OBJFILES)
    	$(CC) -o $(PROG) $(OBJFILES) $(LIBS)
    
    %.o: %.cpp
    	$(COMPILE) -o $@ $<
    
    clean:
    	rm -f $(PROG)
    	rm -f *.o
    And while I am at it, I might as well ask this question: do I include the .hpp files in the make file. I'm not really sure what a hpp file is in the first place. It sounds to me like a contradiction of terms personally, but it is part of the "glm" library I will soon use.

    As always, thank you for all your help.

  2. #2
    Registered User manasij7479's Avatar
    Join Date
    Feb 2011
    Location
    Kolkata@India
    Posts
    2,490
    do I include the .hpp files in the make file
    Generally not.

    Not sure about the rest.
    jakebird451 likes this.
    Manasij Mukherjee | gcc-4.8.2 @Arch Linux
    Slow and Steady wins the race... if and only if :
    1.None of the other participants are fast and steady.
    2.The fast and unsteady suddenly falls asleep while running !



  3. #3
    Registered User
    Join Date
    Jul 2011
    Posts
    22
    For the moment, I am using the code below as my makefile. I am not sure this makes the regex gods happy, but for the moment this will have to do as I am working on juggling my other issues.

    My temporary make file:
    Code:
    CC = g++
    CFLAGS = -Wall
    PROG = game
    
    SRCS := $(patsubst %.cpp,%.o,$(wildcard *.cpp))
    SRCS += $(patsubst %.cpp,%.o,$(wildcard */*.cpp))
    SRCS += $(patsubst %.cpp,%.o,$(wildcard */*/*.cpp))
    SRCS += $(patsubst %.cpp,%.o,$(wildcard */*/*/*.cpp))
    
    COMPILE = $(CC) $(CFLAGS) -c
    
    ifeq ($(shell uname),Darwin)
    	LIBS = -framework OpenGL -framework GLUT -framework CoreFoundation
    else
    	LIBS = -lglut
    endif
    
    #LIBS += Lib/libSOIL.a
    
    all: $(PROG)
    
    $(PROG):	$(SRCS)
    	$(CC) $(CFLAGS) -lboost_filesystem -lboost_system -o $(PROG) $(SRCS) $(LIBS)
    
    clean:
    	rm -f $(PROG)
    	rm -f *.o
    	rm -f */*.o
    	rm -f */*/*.o
    	rm -f */*/*/*.o
    
    %.o: %.cpp
    	$(COMPILE) -o $@ $<
    FIXED: This makefile is not done because I have yet to fully get the SOIL (Simple OpenGL Image Library) library to work. Since this is a C++ form and not the Game Programming forum, I will stop here.

    Don't get me wrong, I am STILL looking for a better way to improve my make file to appease the regex gods. Thanks again!
    Last edited by jakebird451; 09-05-2011 at 09:21 PM. Reason: fixed the SOIL library problem

  4. #4
    Registered User
    Join Date
    Jul 2011
    Posts
    22
    Great, well I got g++ to work, but I cannot get Xcode to compile the project now. It should be just a simple fix, but it has been frustrating me. My errors are as follows:

    with "#include <boost/filesystem.hpp>" file not found. And I obviously installed boost since I got it working on the g++ compiler. I cannot remember my entire strategy for installing boost in my frustration to get it to work, but I installed it using MacPorts as well as my custom shell script as shown below.

    I also included the libBoost_filesystem.dylib as well as libBoost_system.dylib just to make sure.

    Code:
    #!/bin/bash/
    
    #BOOST INSTALL
    clear
    echo "### INSTALLING -> BOOST ###"
    echo "---This part will take a while, and needs user participation"
    
    cd ~/Downloads/
    #see if the file is there to begin with, if it is skip the download part
    if [ ! -d "boost_1_47_0" ]; then
    	echo "---A web browser will open up a website for you to download a"
    	echo "zip containing BOOST."
    	echo "---Please let it download to ~/Downloads/"
    	echo "---When the download has finished come back to this terminal for"
    	echo "---	further instructions."
    	echo "---Please press the enter button to commence..."
    	read
    	open "http://prdownloads.sourceforge.net/boost/boost_1_47_0.tar.gz"
    	echo "---Press the enter key when the download is"
    	echo "---	finished and when you are ready to proceed"
    	#wait for the user
    	read
    	#see if the file is there
    	if [ -f "boost_1_47_0.tar.gz" ]; then
    		echo "---Got the file, now continuing"
    	else
    		echo "---Could not find the file!"
    		exit
    	fi
    	tar -zxvf "boost_1_47_0.tar.gz"
    else
    	echo "---You already have the tar.gz archive unzipped. Skipping the download"
    fi
    cd "boost_1_47_0"
    echo "---I also need to use your password to install the library"
    sudo chmod u+x bootstrap.sh
    sudo chmod u+x ./tools/build/v2/engine/build.sh
    echo "---Thank you"
    echo "---This will take a while..."
    sudo ./bootstrap.sh
    #echo "---THIS WILL ALSO TAKE A LOOOOONG TIME..."
    #sudo ./b2
    echo "---ALMOST THERE..."
    sudo ./bjam architecture=combined
    
    echo "---DONE WITH INSTALLING BOOST!"
    echo "...press enter to continue on with your life..."
    read
    clear
    #END BOOST INSTALL
    Hopefully I am over thinking this problem.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Help please: regular expressions in C++
    By reivaj7999 in forum C++ Programming
    Replies: 3
    Last Post: 08-24-2005, 01:11 AM
  2. Regular expressions
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 9
    Last Post: 01-23-2005, 08:36 PM
  3. Regular Expressions
    By Korn1699 in forum C# Programming
    Replies: 4
    Last Post: 01-11-2005, 11:50 PM
  4. Regular Expressions
    By stormbringer in forum Windows Programming
    Replies: 3
    Last Post: 03-27-2003, 08:35 AM
  5. Regular Expressions again
    By Inquirer in forum C++ Programming
    Replies: 2
    Last Post: 04-19-2002, 10:03 PM

Tags for this Thread


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21